From 85cb34f4989d4d83b5f46eb71d17ae7ee956ce51 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 11 Sep 2010 15:03:17 +0200 Subject: [PATCH] added scm-cli and scm-server-util --- pom.xml | 2 + scm-cli/pom.xml | 18 ++ .../src/main/java/sonia/scm/cli/Argument.java | 57 +++++ .../main/java/sonia/scm/cli/CliException.java | 82 ++++++ .../java/sonia/scm/cli/CliHelpBuilder.java | 56 ++++ .../main/java/sonia/scm/cli/CliParser.java | 199 +++++++++++++++ .../sonia/scm/cli/CliRequiredException.java | 53 ++++ .../main/java/sonia/scm/cli/ConvertUtil.java | 85 ++++++ .../sonia/scm/cli/DefaultCliHelpBuilder.java | 241 ++++++++++++++++++ scm-server-util/pom.xml | 28 ++ scm-webapp/pom.xml | 41 +-- .../main/java/sonia/scm/ContextListener.java | 1 + 12 files changed, 826 insertions(+), 37 deletions(-) create mode 100644 scm-cli/pom.xml create mode 100644 scm-cli/src/main/java/sonia/scm/cli/Argument.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/CliException.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/CliHelpBuilder.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/CliParser.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/CliRequiredException.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/ConvertUtil.java create mode 100644 scm-cli/src/main/java/sonia/scm/cli/DefaultCliHelpBuilder.java create mode 100644 scm-server-util/pom.xml diff --git a/pom.xml b/pom.xml index 640dff1927..f569dd96ec 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,8 @@ scm-core + scm-cli + scm-server-util plugins scm-agent scm-webapp diff --git a/scm-cli/pom.xml b/scm-cli/pom.xml new file mode 100644 index 0000000000..bda76c86d6 --- /dev/null +++ b/scm-cli/pom.xml @@ -0,0 +1,18 @@ + + + + 4.0.0 + + + scm + sonia.scm + 1.0-SNAPSHOT + + + sonia.scm + scm-cli + 1.0-SNAPSHOT + scm-cli + + diff --git a/scm-cli/src/main/java/sonia/scm/cli/Argument.java b/scm-cli/src/main/java/sonia/scm/cli/Argument.java new file mode 100644 index 0000000000..0294882ce1 --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/Argument.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +//~--- JDK imports ------------------------------------------------------------ + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author Sebastian Sdorra + */ +@Documented +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Argument +{ + String value(); + String longName() default ""; + String description() default ""; + boolean required() default false; +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/CliException.java b/scm-cli/src/main/java/sonia/scm/cli/CliException.java new file mode 100644 index 0000000000..b3b776d052 --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/CliException.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +/** + * + * @author Sebastian Sdorra + */ +public class CliException extends Exception +{ + + /** + * Constructs ... + * + */ + public CliException() {} + + /** + * Constructs ... + * + * + * @param string + */ + public CliException(String string) + { + super(string); + } + + /** + * Constructs ... + * + * + * @param thrwbl + */ + public CliException(Throwable thrwbl) + { + super(thrwbl); + } + + /** + * Constructs ... + * + * + * @param string + * @param thrwbl + */ + public CliException(String string, Throwable thrwbl) + { + super(string, thrwbl); + } +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/CliHelpBuilder.java b/scm-cli/src/main/java/sonia/scm/cli/CliHelpBuilder.java new file mode 100644 index 0000000000..331f17cf16 --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/CliHelpBuilder.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public interface CliHelpBuilder +{ + + /** + * Method description + * + * + * @param arguments + * + * @return + */ + public String createHelp(List arguments); +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/CliParser.java b/scm-cli/src/main/java/sonia/scm/cli/CliParser.java new file mode 100644 index 0000000000..26b3196bed --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/CliParser.java @@ -0,0 +1,199 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +//~--- non-JDK imports -------------------------------------------------------- + + +//~--- JDK imports ------------------------------------------------------------ + +import java.lang.reflect.Field; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public class CliParser +{ + + /** + * Method description + * + * + * + * @param helpBuilder + * @param clazz + * + * @return + */ + public String createHelp(CliHelpBuilder helpBuilder, Class clazz) + { + Field[] fields = clazz.getDeclaredFields(); + List arguments = new ArrayList(); + + for (Field field : fields) + { + Argument argument = field.getAnnotation(Argument.class); + + if (argument != null) + { + arguments.add(argument); + } + } + + return helpBuilder.createHelp(arguments); + } + + /** + * Method description + * + * + * @param helpBuilder + * @param object + * + * @return + */ + public String createHelp(CliHelpBuilder helpBuilder, Object object) + { + return createHelp(helpBuilder, object.getClass()); + } + + /** + * Method description + * + * + * @param object + * @param arguments + * + * @throws CliException + */ + public void parse(Object object, String[] arguments) throws CliException + { + Field[] fields = object.getClass().getDeclaredFields(); + int length = arguments.length; + + for (Field field : fields) + { + Argument argument = field.getAnnotation(Argument.class); + + if (argument != null) + { + String name = "-" + argument.value(); + String longName = "--" + argument.longName(); + boolean found = false; + + for (int i = 0; i < length; i++) + { + if (arguments[i].equals(name) + || (!longName.equals("--") && arguments[i].startsWith(longName))) + { + found = true; + + if (field.getType().isAssignableFrom(Boolean.class)) + { + setArgument(object, field, Boolean.TRUE); + } + else if (arguments[i].equals(name) && (i + 1 < length)) + { + setArgument(object, field, + ConvertUtil.convertString(field.getType(), + arguments[i + 1])); + } + else if (arguments[i].startsWith(longName + "=")) + { + String value = arguments[i].substring(longName.length() + 1); + + if ((value != null) && (value.length() > 0)) + { + setArgument(object, field, + ConvertUtil.convertString(field.getType(), value)); + } + } + else + { + throw new CliException("missing parameter for " + name); + } + } + } + + if (!found && argument.required()) + { + throw new CliRequiredException(name + " is required"); + } + } + } + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Method description + * + * + * + * @param object + * @param field + * @param value + * + * @throws CliException + */ + private void setArgument(Object object, Field field, Object value) + throws CliException + { + try + { + boolean modifyAccess = false; + + if (!field.isAccessible()) + { + field.setAccessible(true); + modifyAccess = true; + } + + field.set(object, value); + + if (modifyAccess) + { + field.setAccessible(false); + } + } + catch (Exception ex) + { + throw new CliException(ex); + } + } +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/CliRequiredException.java b/scm-cli/src/main/java/sonia/scm/cli/CliRequiredException.java new file mode 100644 index 0000000000..f9032f26ce --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/CliRequiredException.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +/** + * + * @author Sebastian Sdorra + */ +public class CliRequiredException extends CliException +{ + + /** + * Constructs ... + * + * + * @param string + */ + public CliRequiredException(String string) + { + super(string); + } +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/ConvertUtil.java b/scm-cli/src/main/java/sonia/scm/cli/ConvertUtil.java new file mode 100644 index 0000000000..f16e2179db --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/ConvertUtil.java @@ -0,0 +1,85 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + + +package sonia.scm.cli; + +//~--- JDK imports ------------------------------------------------------------ + +import java.math.BigInteger; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Sebastian Sdorra + */ +public class ConvertUtil +{ + + /** Field description */ + private static final Logger logger = + Logger.getLogger(ConvertUtil.class.getName()); + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param type + * @param value + * + * @return + */ + public static Object convertString(Class type, String value) + { + Object result = null; + + try + { + if (type.isAssignableFrom(String.class)) + { + result = value; + } + else if (type.isAssignableFrom(Short.class)) + { + result = Short.parseShort(value); + } + else if (type.isAssignableFrom(Integer.class)) + { + result = Integer.parseInt(value); + } + else if (type.isAssignableFrom(Long.class)) + { + result = Long.parseLong(value); + } + else if (type.isAssignableFrom(BigInteger.class)) + { + result = new BigInteger(value); + } + else if (type.isAssignableFrom(Float.class)) + { + result = Float.parseFloat(value); + } + else if (type.isAssignableFrom(Double.class)) + { + result = Double.parseDouble(value); + } + else if (type.isAssignableFrom(Boolean.class)) + { + result = Boolean.parseBoolean(value); + } + } + catch (NumberFormatException ex) + { + logger.log(Level.FINER, null, ex); + } + + return result; + } +} diff --git a/scm-cli/src/main/java/sonia/scm/cli/DefaultCliHelpBuilder.java b/scm-cli/src/main/java/sonia/scm/cli/DefaultCliHelpBuilder.java new file mode 100644 index 0000000000..24afa5b5a8 --- /dev/null +++ b/scm-cli/src/main/java/sonia/scm/cli/DefaultCliHelpBuilder.java @@ -0,0 +1,241 @@ +/** + * Copyright (c) 2009, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of JAB; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://kenai.com/projects/jab + * + */ + + + +package sonia.scm.cli; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public class DefaultCliHelpBuilder implements CliHelpBuilder +{ + + /** + * Constructs ... + * + */ + public DefaultCliHelpBuilder() {} + + /** + * Constructs ... + * + * + * @param prefix + * @param suffix + */ + public DefaultCliHelpBuilder(String prefix, String suffix) + { + this.prefix = prefix; + this.suffix = suffix; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param arguments + * + * @return + */ + @Override + public String createHelp(List arguments) + { + String s = System.getProperty("line.separator"); + int paramLength = 20; + List list = new ArrayList(); + + if (arguments != null) + { + for (Argument argument : arguments) + { + HelpLine line = new HelpLine(); + String name = argument.value(); + String longName = argument.longName(); + String description = argument.description(); + StringBuilder result = new StringBuilder("-"); + + result.append(name); + + if (longName.length() > 0) + { + result.append(",--").append(longName); + } + + line.parameter = result.toString(); + + if (line.parameter.length() > paramLength) + { + paramLength = line.parameter.length(); + } + + if (description.length() > 0) + { + line.description = description; + } + + list.add(line); + } + } + + paramLength += 2; + Collections.sort(list); + + StringBuilder result = new StringBuilder(); + + if ((prefix != null) && (prefix.trim().length() > 0)) + { + result.append(prefix).append(s); + } + + for (HelpLine line : list) + { + int length = line.parameter.length(); + + result.append(line.parameter); + + for (int i = length; i < paramLength; i++) + { + result.append(" "); + } + + result.append(line.description).append(s); + } + + if ((suffix != null) && (suffix.trim().length() > 0)) + { + result.append(suffix).append(s); + } + + return result.toString(); + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public String getPrefix() + { + return prefix; + } + + /** + * Method description + * + * + * @return + */ + public String getSuffix() + { + return suffix; + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @param prefix + */ + public void setPrefix(String prefix) + { + this.prefix = prefix; + } + + /** + * Method description + * + * + * @param suffix + */ + public void setSuffix(String suffix) + { + this.suffix = suffix; + } + + //~--- inner classes -------------------------------------------------------- + + /** + * Class description + * + * + * @version Enter version here..., 10/03/06 + * @author Enter your name here... + */ + private static class HelpLine implements Comparable + { + + /** + * Method description + * + * + * @param o + * + * @return + */ + @Override + public int compareTo(HelpLine o) + { + return parameter.compareTo(o.parameter); + } + + //~--- fields ------------------------------------------------------------- + + /** Field description */ + private String description; + + /** Field description */ + private String parameter; + } + + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String prefix; + + /** Field description */ + private String suffix; +} diff --git a/scm-server-util/pom.xml b/scm-server-util/pom.xml new file mode 100644 index 0000000000..1b3b64087a --- /dev/null +++ b/scm-server-util/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + + scm + sonia.scm + 1.0-SNAPSHOT + + + sonia.scm.server + scm-server-util + 1.0-SNAPSHOT + scm-server-util + + + + + sonia.scm + scm-cli + 1.0-SNAPSHOT + + + + + diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 6fb715e8eb..40f7fbeb88 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -24,7 +24,7 @@ 2.5 provided - + sonia.scm scm-core @@ -64,13 +64,13 @@ com.google.inject guice - 2.0 + ${guice.version} com.google.inject.extensions guice-servlet - 2.0 + ${guice.version} @@ -92,41 +92,8 @@ 1.4-ea06 + 2.0 - - - - - endorsed - - - sun.boot.class.path - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - ${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path} - - - - - javax - javaee-endorsed-api - 6.0 - - - - - - - - diff --git a/scm-webapp/src/main/java/sonia/scm/ContextListener.java b/scm-webapp/src/main/java/sonia/scm/ContextListener.java index f09708fa9a..fafa0dd144 100644 --- a/scm-webapp/src/main/java/sonia/scm/ContextListener.java +++ b/scm-webapp/src/main/java/sonia/scm/ContextListener.java @@ -58,6 +58,7 @@ public class ContextListener extends GuiceServletContextListener protected void configureServlets() { bind(Authenticator.class).to(DemoAuthenticator.class); + bind(SCMContextProvider.class).toInstance(SCMContext.getContext()); Map params = new HashMap();