diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java b/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java index d6823b78c1..70d401be5e 100644 --- a/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java +++ b/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java @@ -38,12 +38,9 @@ package sonia.scm.plugin; import com.google.inject.Binder; import com.google.inject.Module; -import sonia.scm.plugin.ext.ExtensionProcessor; - //~--- JDK imports ------------------------------------------------------------ import java.util.Collection; -import java.util.Set; /** * diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotatedClass.java b/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotatedClass.java deleted file mode 100644 index 36deb8098d..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotatedClass.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Objects; - -//~--- JDK imports ------------------------------------------------------------ - -import java.lang.annotation.Annotation; - -/** - * Represents a annotated class, collected by a {@link AnnotationCollector}. - * - * @author Sebastian Sdorra - * @since 1.26 - * - * @param - */ -public class AnnotatedClass -{ - - /** - * Constructs a new annotated class. - * - * - * @param annotation found annotation - * @param annotatedClass annotated class - */ - public AnnotatedClass(T annotation, Class annotatedClass) - { - this.annotation = annotation; - this.annotatedClass = annotatedClass; - } - - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ - @Override - @SuppressWarnings("unchecked") - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final AnnotatedClass other = (AnnotatedClass) obj; - - return Objects.equal(annotation, other.annotation) - && Objects.equal(annotatedClass, other.annotatedClass); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(annotation, annotatedClass); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return Objects.toStringHelper(this) - .add("annotation", annotation) - .add("annotatedClass", annotatedClass) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Returns the annotated class. - * - * - * @return annotated class - */ - public Class getAnnotatedClass() - { - return annotatedClass; - } - - /** - * Returns the annotation. - * - * - * @return annotation - */ - public T getAnnotation() - { - return annotation; - } - - //~--- fields --------------------------------------------------------------- - - /** annotated class */ - private Class annotatedClass; - - /** annotation */ - private T annotation; -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationCollector.java b/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationCollector.java deleted file mode 100644 index f8423cd252..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationCollector.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - -package sonia.scm.plugin.ext; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.collect.Sets; - -//~--- JDK imports ------------------------------------------------------------ - -import java.lang.annotation.Annotation; - -import java.util.Set; - -/** - * Collects all annotated classes found by a {@link AnnotationScanner}. - * - * @author Sebastian Sdorra - * @since 1.26 - * - * @param - */ -public class AnnotationCollector - implements AnnotationProcessor -{ - - /** - * Creates a new annotation collector. - * - * - * @param annotation found annotation - * @param annotatedClass annotated class - */ - @Override - public void processAnnotation(T annotation, Class annotatedClass) - { - annotatedClasses.add(new AnnotatedClass(annotation, annotatedClass)); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Returns the annotated classes. - * - * - * @return set of annotated classes - */ - public Set> getAnnotatedClasses() - { - return annotatedClasses; - } - - //~--- fields --------------------------------------------------------------- - - /** set of annotated classes */ - private Set> annotatedClasses = Sets.newHashSet(); -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationProcessor.java b/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationProcessor.java deleted file mode 100644 index 67f5f193e6..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationProcessor.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.lang.annotation.Annotation; - -/** - * Processor for annotated classes found by a {@link AnnotationScanner}. - * - * @author Sebastian Sdorra - * @since 1.26 - * - * @param - */ -public interface AnnotationProcessor -{ - - /** - * Process annotated class. - * - * - * @param annotation found annotation - * @param annotatedClass annotated class - */ - public void processAnnotation(T annotation, Class annotatedClass); -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScanner.java b/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScanner.java deleted file mode 100644 index 555b493c94..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScanner.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import java.lang.annotation.Annotation; - -/** - * The annotation scanner is able to scan archives and directories for - * annotated classes. Each annotated class can be processed with a - * {@link AnnotationProcessor}. - * - * @author Sebastian Sdorra - * @since 1.26 - */ -public interface AnnotationScanner -{ - - /** - * Adds a {@link AnnotationProcessor} for the given annotation. - * - * - * @param annotationClass class of the annotation - * @param processor processor - * @param annotation type - */ - public void addProcessor(Class annotationClass, - AnnotationProcessor processor); - - /** - * Scans the given archive for annotations. - * - * - * @param archive archive input stream - * - * @throws IOException - */ - public void scanArchive(InputStream archive) throws IOException; - - /** - * Scans a directory for annotated classes. - * - * - * @param directory directory to scan - * - * @throws IOException - */ - public void scanDirectory(File directory) throws IOException; -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScannerFactory.java b/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScannerFactory.java deleted file mode 100644 index aa07b5c000..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/AnnotationScannerFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Collection; - -/** - * Factory class for {@link AnnotationScanner}. - * - * @author Sebastian Sdorra - * @since 1.26 - */ -public interface AnnotationScannerFactory -{ - - /** - * Returns a new {@link AnnotationScanner} for the given class loader - * and packages. - * - * - * - * @param classLoader class loader - * @param packages packages to scann - * - * @return new annotation scanner - */ - public AnnotationScanner create(ClassLoader classLoader, - Collection packages); -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/DefaultExtensionScanner.java b/scm-core/src/main/java/sonia/scm/plugin/ext/DefaultExtensionScanner.java deleted file mode 100644 index 12668011eb..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/DefaultExtensionScanner.java +++ /dev/null @@ -1,333 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.util.IOUtil; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import java.util.Collection; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - -/** - * - * @author Sebastian Sdorra - * @since 1.6 - */ -public class DefaultExtensionScanner - implements ExtensionScanner, DirectoryExtensionScanner -{ - - /** the logger for DefaultExtensionScanner */ - private static final Logger logger = - LoggerFactory.getLogger(DefaultExtensionScanner.class); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param inputStream - * @param packages - * - * @throws IOException - */ - @Override - public void processExtensions(ClassLoader classLoader, - Collection extensionObjects, - InputStream inputStream, - Collection packages) - throws IOException - { - JarInputStream input = null; - - try - { - input = new JarInputStream(inputStream); - - JarEntry entry = input.getNextJarEntry(); - - while (entry != null) - { - if (!entry.isDirectory()) - { - processEntry(classLoader, extensionObjects, packages, entry); - } - - entry = input.getNextJarEntry(); - } - } - finally - { - IOUtil.close(input); - } - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param directory - * @param packages - * - * @throws IOException - */ - @Override - public void processExtensions(ClassLoader classLoader, - Collection extensionObjects, - File directory, Collection packages) - throws IOException - { - String basePath = directory.getAbsolutePath(); - - if (directory.exists() && directory.isDirectory()) - { - processDirectory(classLoader, extensionObjects, directory, packages, - basePath); - } - else - { - logger.error("directory is required"); - } - } - - /** - * Method description - * - * - * @param classLoader - * @param name - * - * @return - */ - private Class createClass(ClassLoader classLoader, String name) - { - Class clazz = null; - - try - { - clazz = classLoader.loadClass(name); - } - catch (Exception ex) - { - logger.error("could not class ".concat(name), ex); - } - - return clazz; - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param name - */ - private void processClass(ClassLoader classLoader, - Collection extensionObjects, - Collection packages, String name) - { - if (isManagedClass(packages, name)) - { - Class managedClass = createClass(classLoader, name); - - if (managedClass != null) - { - processManagedClass(extensionObjects, managedClass); - } - } - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param basePath - * @param file - */ - private void processClassFile(ClassLoader classLoader, - Collection extensionObjects, - Collection packages, String basePath, - File file) - { - String name = file.getAbsolutePath().substring(basePath.length()); - - if (name.startsWith("/")) - { - name = name.substring(1); - } - - name = getClassName(name); - processClass(classLoader, extensionObjects, packages, name); - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param directory - * @param packages - * @param basePath - */ - private void processDirectory(ClassLoader classLoader, - Collection extensionObjects, - File directory, Collection packages, - String basePath) - { - File[] children = directory.listFiles(); - - for (File child : children) - { - if (child.isDirectory()) - { - processDirectory(classLoader, extensionObjects, child, packages, - basePath); - } - else if (child.getName().endsWith(".class")) - { - processClassFile(classLoader, extensionObjects, packages, basePath, - child); - } - } - } - - /** - * Method description - * - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param entry - */ - private void processEntry(ClassLoader classLoader, - Collection extensionObjects, - Collection packages, JarEntry entry) - { - String name = entry.getName(); - - if (name.endsWith(".class")) - { - name = getClassName(name); - processClass(classLoader, extensionObjects, packages, name); - } - } - - /** - * Method description - * - * - * @param extensionObjects - * @param managedClass - */ - private void processManagedClass( - Collection extensionObjects, Class managedClass) - { - Extension extension = managedClass.getAnnotation(Extension.class); - - if (extension != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("found extension class {}", managedClass.getName()); - } - - extensionObjects.add(new ExtensionObject(extension, managedClass)); - } - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param name - * - * @return - */ - private String getClassName(String name) - { - return name.replaceAll("/", ".").substring(0, name.length() - 6); - } - - /** - * Method description - * - * - * @param packages - * @param name - * - * @return - */ - private boolean isManagedClass(Collection packages, String name) - { - boolean result = false; - - for (String pkg : packages) - { - if (name.startsWith(pkg)) - { - result = true; - - break; - } - } - - return result; - } -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/DirectoryExtensionScanner.java b/scm-core/src/main/java/sonia/scm/plugin/ext/DirectoryExtensionScanner.java deleted file mode 100644 index 9cfe4f7647..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/DirectoryExtensionScanner.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.IOException; - -import java.util.Collection; - -/** - * - * @author Sebastian Sdorra - * @since 1.6 - */ -public interface DirectoryExtensionScanner -{ - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param directory - * @param packages - * - * @throws IOException - */ - public void processExtensions(ClassLoader classLoader, - Collection extensionObjects, - File directory, Collection packages) - throws IOException; -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionObject.java b/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionObject.java deleted file mode 100644 index 6493cac33e..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionObject.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -/** - * - * @author Sebastian Sdorra - */ -public class ExtensionObject -{ - - /** - * Constructs ... - * - * - * @param extension - * @param extensionClass - */ - public ExtensionObject(Extension extension, Class extensionClass) - { - this.extension = extension; - this.extensionClass = extensionClass; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public Extension getExtension() - { - return extension; - } - - /** - * Method description - * - * - * @return - */ - public Class getExtensionClass() - { - return extensionClass; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Extension extension; - - /** Field description */ - private Class extensionClass; -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionProcessor.java b/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionProcessor.java deleted file mode 100644 index c52e9002ba..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionProcessor.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -/** - * - * @author Sebastian Sdorra - */ -public interface ExtensionProcessor -{ - - /** - * Method description - * - * - * @param extension - * @param extensionClass - */ - public void processExtension(Extension extension, Class extensionClass); -} diff --git a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionScanner.java b/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionScanner.java deleted file mode 100644 index de99db626f..0000000000 --- a/scm-core/src/main/java/sonia/scm/plugin/ext/ExtensionScanner.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.IOException; -import java.io.InputStream; - -import java.util.Collection; - -/** - * - * @author Sebastian Sdorra - */ -public interface ExtensionScanner -{ - - /** - * Method description - * - * - * - * @param classLoader - * @param extensionObjects - * @param input - * @param packagess - * - * @throws IOException - */ - public void processExtensions(ClassLoader classLoader, - Collection extensionObjects, - InputStream input, Collection packagess) - throws IOException; -} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginLoader.java index 1a36bf0387..4f79162558 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginLoader.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginLoader.java @@ -46,7 +46,6 @@ import com.google.inject.Module; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sonia.scm.plugin.ext.ExtensionBinder; import sonia.scm.util.ClassLoaders; //~--- JDK imports ------------------------------------------------------------ diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ext/ExtensionBinder.java b/scm-webapp/src/main/java/sonia/scm/plugin/ExtensionBinder.java similarity index 99% rename from scm-webapp/src/main/java/sonia/scm/plugin/ext/ExtensionBinder.java rename to scm-webapp/src/main/java/sonia/scm/plugin/ExtensionBinder.java index 29777832c3..42b3751759 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/ext/ExtensionBinder.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/ExtensionBinder.java @@ -31,7 +31,7 @@ -package sonia.scm.plugin.ext; +package sonia.scm.plugin; //~--- non-JDK imports -------------------------------------------------------- diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScanner.java b/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScanner.java deleted file mode 100644 index ac504bfcae..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScanner.java +++ /dev/null @@ -1,394 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.util.IOUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import java.lang.annotation.Annotation; - -import java.util.Collection; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultAnnotationScanner implements AnnotationScanner -{ - - /** - * the logger for DefaultAnnotationScanner - */ - private static final Logger logger = - LoggerFactory.getLogger(DefaultAnnotationScanner.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param classLoader - * @param packages - */ - public DefaultAnnotationScanner(ClassLoader classLoader, - Collection packages) - { - this.classLoader = classLoader; - this.packages = packages; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param annotationClass - * @param processor - * @param - */ - @Override - public void addProcessor(Class annotationClass, - AnnotationProcessor processor) - { - processors.put(annotationClass, processor); - } - - /** - * Method description - * - * - * @param archive - * - * @throws IOException - */ - @Override - public void scanArchive(InputStream archive) throws IOException - { - JarInputStream input = null; - - try - { - input = new JarInputStream(archive); - - JarEntry entry = input.getNextJarEntry(); - - while (entry != null) - { - if (!entry.isDirectory()) - { - processEntry(entry); - } - - entry = input.getNextJarEntry(); - } - } - finally - { - IOUtil.close(input); - } - } - - /** - * Method description - * - * - * @param directory - */ - @Override - public void scanDirectory(File directory) - { - Preconditions.checkArgument(directory.isDirectory(), - "file must be a directory"); - - String basePath = directory.getAbsolutePath(); - - processDirectory(basePath, directory); - } - - /** - * Method description - * - * - * @param classLoader - * @param name - * - * @return - */ - private Class createClass(String name) - { - Class clazz = null; - - try - { - clazz = classLoader.loadClass(name); - } - catch (Exception ex) - { - logger.error("could not class ".concat(name), ex); - } - - return clazz; - } - - /** - * Method description - * - * - * - * @param annotationClass - * @param annotation - * @param managedClass - */ - @SuppressWarnings("unchecked") - private void processAnnotation(Class annotationClass, - Annotation annotation, Class managedClass) - { - logger.trace("process annotation {} on class {}", annotationClass, - managedClass); - - Collection aps = processors.get(annotationClass); - - if (Util.isNotEmpty(aps)) - { - for (AnnotationProcessor ap : aps) - { - if (logger.isDebugEnabled()) - { - logger.debug("call processor {} with {} and {}", ap.getClass(), - annotation, managedClass); - } - - ap.processAnnotation(annotation, managedClass); - } - } - else if (logger.isTraceEnabled()) - { - logger.trace("no processor found for annotation {}", - annotation.getClass()); - } - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param name - */ - private void processClass(String name) - { - if (isManagedClass(packages, name)) - { - Class managedClass = createClass(name); - - if (managedClass != null) - { - processManagedClass(managedClass); - } - } - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param basePath - * @param file - */ - private void processClassFile(String basePath, File file) - { - String name = file.getAbsolutePath().substring(basePath.length()); - - if (name.startsWith("/")) - { - name = name.substring(1); - } - - name = getClassName(name); - processClass(name); - } - - /** - * Method description - * - * - * @param classLoader - * @param extensionObjects - * @param directory - * @param packages - * @param basePath - */ - private void processDirectory(String basePath, File directory) - { - File[] children = directory.listFiles(); - - for (File child : children) - { - if (child.isDirectory()) - { - processDirectory(basePath, child); - } - else if (child.getName().endsWith(".class")) - { - processClassFile(basePath, child); - } - } - } - - /** - * Method description - * - * - * - * @param classLoader - * @param extensionObjects - * @param packages - * @param entry - */ - private void processEntry(JarEntry entry) - { - String name = entry.getName(); - - if (name.endsWith(".class")) - { - name = getClassName(name); - processClass(name); - } - } - - /** - * Method description - * - * - * @param extensionObjects - * @param managedClass - */ - @SuppressWarnings("unchecked") - private void processManagedClass(Class managedClass) - { - logger.trace("check managed class {} for annotations", managedClass); - - for (Class annotationClass : processors.keySet()) - { - Annotation annotation = managedClass.getAnnotation(annotationClass); - - if (annotation != null) - { - processAnnotation(annotationClass, annotation, managedClass); - } - else if (logger.isTraceEnabled()) - { - logger.trace("annotation {} not found at {}", annotationClass, - managedClass); - } - } - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param name - * - * @return - */ - private String getClassName(String name) - { - return name.replaceAll("/", ".").substring(0, name.length() - 6); - } - - /** - * Method description - * - * - * @param packages - * @param name - * - * @return - */ - private boolean isManagedClass(Collection packages, String name) - { - boolean result = false; - - for (String pkg : packages) - { - if (name.startsWith(pkg)) - { - result = true; - - break; - } - } - - return result; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private ClassLoader classLoader; - - /** Field description */ - private Collection packages; - - /** Field description */ - private Multimap processors = - HashMultimap.create(); -} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScannerFactory.java b/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScannerFactory.java deleted file mode 100644 index 8c21059bae..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/plugin/ext/DefaultAnnotationScannerFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - -package sonia.scm.plugin.ext; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Collection; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultAnnotationScannerFactory implements AnnotationScannerFactory -{ - - /** - * Method description - * - * - * @param classLoader - * @param packages - * - * @return - */ - @Override - public AnnotationScanner create(ClassLoader classLoader, - Collection packages) - { - return new DefaultAnnotationScanner(classLoader, packages); - } -} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ext/Extensions.java b/scm-webapp/src/main/java/sonia/scm/plugin/ext/Extensions.java deleted file mode 100644 index 06d298e27a..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/plugin/ext/Extensions.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2010, 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 SCM-Manager; 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://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.plugin.ext; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.ExtensionPoint; - -//~--- JDK imports ------------------------------------------------------------ - -import java.lang.annotation.Annotation; - -/** - * - * @author Sebastian Sdorra - */ -public final class Extensions -{ - - /** - * Constructs ... - * - */ - private Extensions() {} - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public static Extension createExtension() - { - return new Extension() - { - - @Override - public Class annotationType() - { - return Extension.class; - } - }; - } - - /** - * Method description - * - * - * @param multi - * - * @return - */ - public static ExtensionPoint createExtensionPoint(final boolean multi) - { - return new ExtensionPoint() - { - - @Override - public boolean multi() - { - return multi; - } - - @Override - public Class annotationType() - { - return ExtensionPoint.class; - } - }; - } -}