You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by da...@apache.org on 2012/12/07 01:11:37 UTC
svn commit: r1418140 [3/8] - in /incubator/onami/trunk/autobind:
aop/src/main/java/org/apache/ aop/src/main/java/org/nnsoft/
aop/src/test/java/org/apache/ aop/src/test/java/org/apache/onami/
aop/src/test/java/org/nnsoft/ configuration/src/main/java/org...
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/BindingScannerFeature.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/BindingScannerFeature.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/BindingScannerFeature.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/BindingScannerFeature.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,336 @@
+package org.apache.onami.autobind.scanner.features;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static java.lang.String.format;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Logger.getLogger;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+
+import org.apache.onami.autobind.install.BindingStage;
+import org.apache.onami.autobind.install.BindingTracer;
+import org.apache.onami.autobind.install.InstallationContext;
+import org.apache.onami.autobind.install.InstallationContext.StageableRequest;
+import org.apache.onami.autobind.install.bindjob.BindingJob;
+import org.apache.onami.autobind.install.bindjob.ConstantBindingJob;
+import org.apache.onami.autobind.install.bindjob.ImplementationBindingJob;
+import org.apache.onami.autobind.install.bindjob.InstanceBindingJob;
+import org.apache.onami.autobind.install.bindjob.InterfaceBindingJob;
+import org.apache.onami.autobind.install.bindjob.ProviderBindingJob;
+import org.apache.onami.autobind.scanner.ScannerModule;
+import org.apache.onami.autobind.utils.VariableResolver;
+
+import com.google.inject.Binder;
+import com.google.inject.Injector;
+import com.google.inject.binder.AnnotatedBindingBuilder;
+import com.google.inject.binder.LinkedBindingBuilder;
+import com.google.inject.binder.ScopedBindingBuilder;
+import com.google.inject.util.Providers;
+
+/**
+ * Default Implementation for Annotation Listeners, which should stay informed
+ * abbout found annotated classes. Due the fact, that we need the Binder of the
+ * Child Injector, it will be set at runtime by the {@link ScannerModule}.
+ */
+public abstract class BindingScannerFeature
+ implements ScannerFeature
+{
+
+ private final Logger _logger = getLogger( getClass().getName() );
+
+ protected Set<String> others = new HashSet<String>();
+
+ protected Set<String> qualifiers = new HashSet<String>();
+
+ protected Binder _binder;
+
+ @Inject
+ protected Injector injector;
+
+ @Inject
+ protected BindingTracer tracer;
+
+ @Inject
+ protected VariableResolver resolver;
+
+ protected InstallationContext context;
+
+ public void setBinder( Binder binder )
+ {
+ _binder = binder;
+ }
+
+ @Inject
+ public void configure( InstallationContext context )
+ {
+ this.context = context;
+ }
+
+ @Override
+ public void found( final Class<Object> annotatedClass, final Map<String, Annotation> annotations )
+ {
+ final BindingStage stage = accept( annotatedClass, annotations );
+ if ( stage != BindingStage.IGNORE )
+ {
+ context.add( new StageableRequest()
+ {
+ private Class<Object> _annotatedClass = annotatedClass;
+
+ private Map<String, Annotation> _annotations = new HashMap<String, Annotation>( annotations );
+
+ @Override
+ public Void call()
+ throws Exception
+ {
+ process( _annotatedClass, _annotations );
+ return null;
+ }
+
+ @Override
+ public BindingStage getExecutionStage()
+ {
+ return stage;
+ }
+ } );
+ }
+ }
+
+ public abstract BindingStage accept( Class<Object> annotatedClass, Map<String, Annotation> annotations );
+
+ public abstract void process( Class<Object> annotatedClass, Map<String, Annotation> annotations );
+
+ protected <T, V extends T> void bindProvider( final Provider<V> provider, Class<T> interf, Annotation annotation,
+ Class<? extends Annotation> scope )
+ {
+ BindingJob job = new ProviderBindingJob( scope, provider.getClass(), annotation, interf.getName() );
+ if ( !tracer.contains( job ) )
+ {
+ LinkedBindingBuilder<T> builder;
+ synchronized ( _binder )
+ {
+ builder = _binder.bind( interf );
+ if ( annotation != null )
+ {
+ builder = ( (AnnotatedBindingBuilder<T>) builder ).annotatedWith( annotation );
+ }
+ ScopedBindingBuilder scopedBuilder = builder.toProvider( Providers.guicify( provider ) );
+ if ( scope != null )
+ {
+ scopedBuilder.in( scope );
+ }
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+ protected <T, V extends T> void bindProvider( final Class<? extends Provider<V>> provider, Class<T> interf,
+ Annotation annotation, Class<? extends Annotation> scope )
+ {
+ BindingJob job = new ProviderBindingJob( scope, provider, annotation, interf.getName() );
+ if ( !tracer.contains( job ) )
+ {
+ LinkedBindingBuilder<T> builder;
+ synchronized ( _binder )
+ {
+ builder = _binder.bind( interf );
+ if ( annotation != null )
+ {
+ builder = ( (AnnotatedBindingBuilder<T>) builder ).annotatedWith( annotation );
+ }
+ ScopedBindingBuilder scopedBuilder = builder.toProvider( provider );
+ if ( scope != null )
+ {
+ scopedBuilder.in( scope );
+ }
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+ protected <T, V extends T> void bindInstance( V implementation, Class<T> interf, Annotation annotation,
+ Class<? extends Annotation> scope )
+ {
+ BindingJob job =
+ new InstanceBindingJob( scope, annotation, implementation.getClass().getName(), interf.getName() );
+
+ if ( !tracer.contains( job ) )
+ {
+ LinkedBindingBuilder<T> builder;
+ synchronized ( _binder )
+ {
+ builder = _binder.bind( interf );
+ if ( annotation != null )
+ {
+ builder = ( (AnnotatedBindingBuilder<T>) builder ).annotatedWith( annotation );
+ }
+ builder.toInstance( implementation );
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+ protected void bindConstant( String value, Annotation annotation )
+ {
+ BindingJob job = new ConstantBindingJob( annotation, value.getClass().getName() );
+ if ( !tracer.contains( job ) )
+ {
+ synchronized ( _binder )
+ {
+ _binder.bindConstant().annotatedWith( annotation ).to( value );
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+ protected <T, V extends T> void bind( Class<V> implementationClass, Class<T> interf, Annotation annotation,
+ Class<? extends Annotation> scope )
+ {
+ BindingJob job = new InterfaceBindingJob( scope, annotation, implementationClass.getName(), interf.getName() );
+
+ if ( !tracer.contains( job ) )
+ {
+ LinkedBindingBuilder<T> builder;
+ synchronized ( _binder )
+ {
+ builder = _binder.bind( interf );
+ if ( annotation != null )
+ {
+ builder = ( (AnnotatedBindingBuilder<T>) builder ).annotatedWith( annotation );
+ }
+ ScopedBindingBuilder scopedBindingBuilder = builder.to( implementationClass );
+ if ( scope != null )
+ {
+ scopedBindingBuilder.in( scope );
+ }
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+ protected <T> void bind( Class<T> implementationClass, Annotation annotation, Class<? extends Annotation> scope )
+ {
+ BindingJob job = new ImplementationBindingJob( scope, annotation, implementationClass.getName() );
+
+ if ( !tracer.contains( job ) )
+ {
+ LinkedBindingBuilder<T> builder;
+ synchronized ( _binder )
+ {
+ builder = _binder.bind( implementationClass );
+ if ( annotation != null )
+ {
+ builder = ( (AnnotatedBindingBuilder<T>) builder ).annotatedWith( annotation );
+ }
+ if ( scope != null )
+ {
+ builder.in( scope );
+ }
+ }
+ tracer.add( job );
+ }
+ else
+ {
+ String message = format( "Ignoring BindingJob \"%s\", because it was already bound.", job );
+
+ if ( _logger.isLoggable( FINE ) )
+ {
+ _logger.log( FINE, message, new Exception( message ) );
+ }
+ else if ( _logger.isLoggable( INFO ) )
+ {
+ _logger.log( INFO, message );
+ }
+ }
+ }
+
+}
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/MultiBindingScannerFeature.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/MultiBindingScannerFeature.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/MultiBindingScannerFeature.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/MultiBindingScannerFeature.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,90 @@
+package org.apache.onami.autobind.scanner.features;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static com.google.inject.multibindings.Multibinder.newSetBinder;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.onami.autobind.scanner.ScannerModule;
+
+import com.google.inject.binder.ScopedBindingBuilder;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * Default Implementation for Annotation Listeners, which should stay informed
+ * abbout found annotated classes. Due the fact, that we need the Binder of the
+ * Child Injector, it will be set at runtime by the {@link ScannerModule}.
+ */
+public abstract class MultiBindingScannerFeature
+ extends BindingScannerFeature
+{
+
+ protected <T, V extends T> void bindInstance( V impl, Class<T> interf, Annotation annotation,
+ Class<? extends Annotation> scope )
+ {
+ Multibinder<T> builder;
+ synchronized ( _binder )
+ {
+ if ( annotation != null )
+ {
+ builder = newSetBinder( _binder, interf, annotation );
+ }
+ else
+ {
+ builder = newSetBinder( _binder, interf );
+ }
+
+ builder.addBinding().toInstance( impl );
+ }
+ }
+
+ protected void bindConstant( String value, Annotation annotation )
+ {
+ Multibinder<String> builder;
+ synchronized ( _binder )
+ {
+ builder = newSetBinder( _binder, String.class, annotation );
+ builder.addBinding().toInstance( value );
+ }
+ }
+
+ protected <T, V extends T> void bind( Class<V> impl, Class<T> interf, Annotation annotation,
+ Class<? extends Annotation> scope )
+ {
+ Multibinder<T> builder;
+ synchronized ( _binder )
+ {
+ if ( annotation != null )
+ {
+ builder = newSetBinder( _binder, interf, annotation );
+ }
+ else
+ {
+ builder = newSetBinder( _binder, interf );
+ }
+
+ ScopedBindingBuilder scopedBindingBuilder = builder.addBinding().to( impl );
+ if ( scope != null )
+ {
+ scopedBindingBuilder.in( scope );
+ }
+ }
+ }
+
+}
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/ScannerFeature.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/ScannerFeature.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/ScannerFeature.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/ScannerFeature.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,36 @@
+package org.apache.onami.autobind.scanner.features;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+/**
+ * This Interface is used, if you want get informed, for Classes with
+ * Annotations. This is used for creating Classes for the automatic Module
+ * installation or the automatic Bean binding.
+ *
+ * You will get the Class for the annotated one and a Proxy of the attached
+ * Annotations.
+ */
+public interface ScannerFeature
+{
+
+ void found( Class<Object> annotatedClass, Map<String, Annotation> annotations );
+
+}
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/package-info.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/package-info.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/package-info.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/features/package-info.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,21 @@
+/**
+ * TODO fill me.
+ */
+package org.apache.onami.autobind.scanner.features;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/package-info.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/package-info.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/package-info.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/scanner/package-info.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,21 @@
+/**
+ * TODO fill me.
+ */
+package org.apache.onami.autobind.scanner;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
Propchange: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/utils/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/utils/VariableResolver.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/utils/VariableResolver.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/utils/VariableResolver.java (added)
+++ incubator/onami/trunk/autobind/core/src/main/java/org/apache/onami/autobind/utils/VariableResolver.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,108 @@
+package org.apache.onami.autobind.utils;
+
+import java.util.StringTokenizer;
+
+import javax.inject.Inject;
+
+import org.apache.onami.autobind.jsr330.Names;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+
+
+public class VariableResolver {
+
+ /**
+ * The symbol that indicates a variable begin.
+ */
+ private static final String VAR_BEGIN = "$";
+
+ /**
+ * The symbol that separates the key name to the default value.
+ */
+ private static final String PIPE_SEPARATOR = "|";
+
+ private static final String KEY_PREFIX = "${";
+
+ /**
+ * The Injector instance used to resolve variables.
+ */
+ @Inject
+ private Injector injector;
+
+ public String resolve(final String pattern) {
+ StringBuilder buffer = new StringBuilder();
+
+ int prev = 0;
+ int pos;
+ while ((pos = pattern.indexOf(VAR_BEGIN, prev)) >= 0) {
+ if (pos > 0) {
+ buffer.append(pattern.substring(prev, pos));
+ }
+ if (pos == pattern.length() - 1) {
+ buffer.append(VAR_BEGIN);
+ prev = pos + 1;
+ } else if (pattern.charAt(pos + 1) != '{') {
+ if (pattern.charAt(pos + 1) == '$') {
+ buffer.append(VAR_BEGIN);
+ prev = pos + 2;
+ } else {
+ buffer.append(pattern.substring(pos, pos + 2));
+ prev = pos + 2;
+ }
+ } else {
+ int endName = pattern.indexOf('}', pos);
+ if (endName < 0) {
+ throw new IllegalArgumentException("Syntax error in property: " + pattern);
+ }
+ StringTokenizer keyTokenizer = new StringTokenizer(pattern.substring(pos + 2, endName), PIPE_SEPARATOR);
+ String key = keyTokenizer.nextToken().trim();
+ String defaultValue = null;
+ if (keyTokenizer.hasMoreTokens()) {
+ defaultValue = keyTokenizer.nextToken().trim();
+ }
+
+ try {
+ buffer.append(injector.getInstance(Key.get(String.class, Names.named(key))));
+ } catch (Throwable e) {
+ if (defaultValue != null) {
+ buffer.append(defaultValue);
+ } else {
+ buffer.append(KEY_PREFIX).append(key).append('}');
+ }
+ }
+
+ prev = endName + 1;
+ }
+ }
+ if (prev < pattern.length()) {
+ buffer.append(pattern.substring(prev));
+ }
+
+ return buffer.toString();
+ }
+
+ public static void main(String[] args) {
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bindConstant().annotatedWith(Names.named("variable.1")).to("feuer");
+ bindConstant().annotatedWith(Names.named("variable.2")).to("frei");
+ bindConstant().annotatedWith(Names.named("config.soap.protocol")).to("ftp");
+ bindConstant().annotatedWith(Names.named("config.soap.ip")).to("1.1.1.1");
+ bindConstant().annotatedWith(Names.named("config.soap.port")).to("9999");
+ bindConstant().annotatedWith(Names.named("config.soap.app")).to("dynmaic");
+ bindConstant().annotatedWith(Names.named("config.soap.client")).to("/henkel");
+ bindConstant().annotatedWith(Names.named("config.soap.stage")).to("test");
+ }
+ });
+
+ VariableResolver resolver = injector.getInstance(VariableResolver.class);
+ System.out.println(resolver.resolve("${variable.1} ${variable.2}"));
+ System.out.println(resolver.resolve("\"${variable.3| }\""));
+ System.out.println(resolver.resolve("${config.soap.protocol|http}://${config.soap.ip|127.0.0.1}:${config.soap.port|12400}/${config.soap.app|configuration}${config.soap.client| }/soap/optional.xml?stage=${config.soap.stage|default}"));
+ }
+
+}
Modified: incubator/onami/trunk/autobind/examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/pom.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/examples/pom.xml (original)
+++ incubator/onami/trunk/autobind/examples/pom.xml Fri Dec 7 00:11:06 2012
@@ -60,11 +60,11 @@
<version>1.6</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.apache.onami.autobind.integrations</groupId>
<artifactId>onami-integrations-enterprise</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency-->
</dependencies>
<build>
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/MethodCallingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/MethodCallingInterceptor.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/MethodCallingInterceptor.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/MethodCallingInterceptor.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,77 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop;
+
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.interceptor.Interceptor;
+
+import org.aopalliance.intercept.MethodInvocation;
+
+import com.google.inject.matcher.Matcher;
+import com.google.inject.matcher.Matchers;
+
+/**
+ * Interceptor Example which monitors all Methods and logs their Signatures.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Interceptor
+public class MethodCallingInterceptor {
+ private Logger _logger = Logger.getLogger(MethodCallingInterceptor.class.getName());
+
+ @Invoke
+ public Object invoke(MethodInvocation invocation) throws Throwable {
+ Object destination = invocation.getThis();
+ StringBuilder logMessageBuilder = new StringBuilder(250);
+
+ logMessageBuilder.append("Invoking Method \"");
+ logMessageBuilder.append(invocation.getMethod().getName());
+ logMessageBuilder.append("\" on ");
+ logMessageBuilder.append(destination.getClass().getName());
+ logMessageBuilder.append(" with Arguments: ");
+
+ Class<?>[] types = invocation.getMethod().getParameterTypes();
+ Object[] parameters = invocation.getArguments();
+
+ for (int i = 0; i < types.length; i++) {
+ Object parameter = parameters[i];
+ Class<?> type = types[i];
+
+ logMessageBuilder.append(" \"");
+ logMessageBuilder.append(type.getSimpleName());
+ logMessageBuilder.append("\": ");
+ logMessageBuilder.append(parameter);
+ }
+ _logger.log(Level.SEVERE, logMessageBuilder.toString());
+
+ return invocation.proceed();
+ }
+
+ @ClassMatcher
+ public Matcher<? super Class<?>> getClassMatcher() {
+ return Matchers.any();
+ }
+
+ @MethodMatcher
+ public Matcher<? super Method> getMethodMatcher() {
+ return Matchers.annotatedWith(Intercept.class);
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedInheritedMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedInheritedMethodInterceptor.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedInheritedMethodInterceptor.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedInheritedMethodInterceptor.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.Interceptor;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.onami.autobind.aop.ClassMatcher;
+import org.apache.onami.autobind.aop.Intercept;
+import org.apache.onami.autobind.aop.MethodMatcher;
+
+import com.google.inject.matcher.Matcher;
+import com.google.inject.matcher.Matchers;
+
+
+@Interceptor
+public class AnnotatedInheritedMethodInterceptor implements MethodInterceptor {
+
+ @Override
+ public Object invoke(MethodInvocation invocation) throws Throwable {
+ System.out.println(AnnotatedInheritedMethodInterceptor.class.getSimpleName()
+ + " - Trying to invoke: " + invocation.getMethod().getName());
+ return invocation.proceed();
+ }
+
+ @ClassMatcher
+ public Matcher<? super Class<?>> getClassMatcher() {
+ return Matchers.any();
+ }
+
+ @MethodMatcher
+ public Matcher<? super Method> getMethodMatcher() {
+ return Matchers.annotatedWith(Intercept.class);
+ }
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedMethodInterceptor.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedMethodInterceptor.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/AnnotatedMethodInterceptor.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.Interceptor;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.onami.autobind.aop.ClassMatcher;
+import org.apache.onami.autobind.aop.Intercept;
+import org.apache.onami.autobind.aop.Invoke;
+import org.apache.onami.autobind.aop.MethodMatcher;
+
+import com.google.inject.matcher.Matcher;
+import com.google.inject.matcher.Matchers;
+
+
+@Interceptor
+public class AnnotatedMethodInterceptor {
+
+ @Invoke
+ public Object invoke(MethodInvocation invocation) throws Throwable {
+ System.out.println(AnnotatedMethodInterceptor.class.getSimpleName()
+ + " - Trying to invoke: " + invocation.getMethod().getName());
+ return invocation.proceed();
+ }
+
+ @ClassMatcher
+ public Matcher<? super Class<?>> getClassMatcher() {
+ return Matchers.any();
+ }
+
+ @MethodMatcher
+ public Matcher<? super Method> getMethodMatcher() {
+ return Matchers.annotatedWith(Intercept.class);
+ }
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/Example.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/Example.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/Example.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/Example.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+/**
+ * Interface which is used to bind an implementation too.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public interface Example {
+ String sayHello();
+
+ String convert(String message, boolean enabled, int times);
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleApp.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleApp.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleApp.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleApp.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,64 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import java.io.IOException;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.aop.feature.InterceptorFeature;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.example.starter.ExampleApplication;
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.ScannerModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+/**
+ * Example Application, which creates a new Injector with the help of the
+ * provided {@link StartupModule}. It passes the {@link ASMClasspathScanner}
+ * class for the {@link ClasspathScanner} and the packages (de.devsurf) which
+ * should be scanned. The {@link StartupModule} binds these parameter, so we are
+ * able to create and inject our {@link ScannerModule}. This Module uses the
+ * {@link ClasspathScanner} to explore the Classpath and scans for Annotations.
+ *
+ * All recognized Classes annotated with {@link GuiceModule} are installed in
+ * the child injector and with {@link Bind} are automatically bound.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Bind(multiple = true)
+public class ExampleApp implements ExampleApplication {
+ @Override
+ public void run() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class, PackageFilter.create(ExampleApp.class), PackageFilter.create("de.devsurf.injection.guice.aop"));
+ startup.addFeature(InterceptorFeature.class);
+ Injector injector = Guice.createInjector(startup);
+
+ Example example = injector.getInstance(Example.class);
+ System.out.println(example.sayHello());
+ System.out.println(example.convert("good bye! ", true, 3));
+ }
+
+ public static void main(String[] args) throws IOException {
+ new ExampleApp().run();
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleImpl.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleImpl.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleImpl.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/ExampleImpl.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,51 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.aop.Intercept;
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+
+/**
+ * This class implements the Example interface and uses the {@link Bind}-
+ * Annotation, so it will be recognized by the {@link ClasspathScanner}. In this
+ * Example the {@link ASMClasspathScanner} is used.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Bind
+public class ExampleImpl implements Example {
+ @Override
+ @Intercept
+ public String sayHello() {
+ return "yeahhh!!!";
+ }
+
+ @Override
+ @Intercept
+ public String convert(String message, boolean enabled, int times) {
+ if (enabled) {
+ String part = message;
+ for (int i = 0; i < times; i++) {
+ message += part;
+ }
+ }
+ return message;
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InheritedMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InheritedMethodInterceptor.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InheritedMethodInterceptor.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InheritedMethodInterceptor.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.Interceptor;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.onami.autobind.aop.ClassMatcher;
+import org.apache.onami.autobind.aop.GuiceMethodInterceptor;
+import org.apache.onami.autobind.aop.Intercept;
+import org.apache.onami.autobind.aop.MethodMatcher;
+
+import com.google.inject.matcher.Matcher;
+import com.google.inject.matcher.Matchers;
+
+
+@Interceptor
+public class InheritedMethodInterceptor extends GuiceMethodInterceptor {
+
+ @Override
+ public Object invoke(MethodInvocation invocation) throws Throwable {
+ System.out.println(InheritedMethodInterceptor.class.getSimpleName()
+ + " - Trying to invoke: " + invocation.getMethod().getName());
+ return invocation.proceed();
+ }
+
+ @Override
+ @ClassMatcher
+ public Matcher<? super Class<?>> getClassMatcher() {
+ return Matchers.any();
+ }
+
+ @Override
+ @MethodMatcher
+ public Matcher<? super Method> getMethodMatcher() {
+ return Matchers.annotatedWith(Intercept.class);
+ }
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InvalidMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InvalidMethodInterceptor.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InvalidMethodInterceptor.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/aop/example/interceptor/InvalidMethodInterceptor.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.aop.example.interceptor;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.Interceptor;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.onami.autobind.aop.ClassMatcher;
+import org.apache.onami.autobind.aop.Intercept;
+import org.apache.onami.autobind.aop.Invoke;
+import org.apache.onami.autobind.aop.MethodMatcher;
+
+import com.google.inject.matcher.Matcher;
+import com.google.inject.matcher.Matchers;
+
+
+@Interceptor
+public class InvalidMethodInterceptor {
+
+ @Invoke
+ public Object invoke(MethodInvocation invocation, Object obj) throws Throwable {
+ return invocation.proceed();
+ }
+
+ @ClassMatcher
+ public Matcher<? super Class<?>> getClassMatcher() {
+ return Matchers.any();
+ }
+
+ @MethodMatcher
+ public Matcher<? super Method> getMethodMatcher() {
+ return Matchers.annotatedWith(Intercept.class);
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/Example.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/Example.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/Example.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/Example.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.general;
+
+/**
+ * Interface which is used to bind an implementation too.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public interface Example {
+ String sayHello();
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleApp.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleApp.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleApp.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleApp.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.general;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.example.starter.ExampleApplication;
+import org.apache.onami.autobind.integrations.commons.configuration.CommonsConfigurationFeature;
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.ScannerModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+/**
+ * Example Application, which creates a new Injector with the help of the
+ * provided {@link StartupModule}. It passes the {@link ASMClasspathScanner}
+ * class for the {@link ClasspathScanner} and the packages (de.devsurf) which
+ * should be scanned. The {@link StartupModule} binds these parameter, so we are
+ * able to create and inject our {@link ScannerModule}. This Module uses the
+ * {@link ClasspathScanner} to explore the Classpath and scans for Annotations.
+ *
+ * All recognized Classes annotated with {@link GuiceModule} are installed in
+ * the child injector and with {@link Bind} are automatically bound.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Bind(multiple = true)
+public class ExampleApp implements ExampleApplication {
+ @Override
+ public void run() {
+ StartupModule startupModule = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ExampleApp.class));
+ startupModule.addFeature(CommonsConfigurationFeature.class);
+ Injector injector = Guice.createInjector(startupModule);
+
+ System.out.println(injector.getInstance(Example.class).sayHello());
+ }
+
+ public static void main(String[] args) {
+ new ExampleApp().run();
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleConfiguration.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleConfiguration.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleConfiguration.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.general;
+
+import javax.inject.Named;
+
+import org.apache.commons.configuration.plist.PropertyListConfiguration;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+
+
+@Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.plist"), to = PropertyListConfiguration.class)
+public interface ExampleConfiguration {
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleImpl.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleImpl.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleImpl.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleImpl.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.general;
+
+import javax.inject.Named;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Inject;
+
+
+/**
+ * This class implements the Example interface and is not annotated like the
+ * other Examples, due the fact, that the {@link ExampleModule} will bind it
+ * manually. In this Example the {@link ASMClasspathScanner} is used, to find
+ * the {@link ExampleModule} and automatically install it.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public class ExampleImpl implements Example {
+ @Inject
+ @Named("config")
+ private Configuration config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getString("de.devsurf.configuration.message");
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleModule.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleModule.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleModule.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/general/ExampleModule.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.general;
+
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.AbstractModule;
+
+
+/**
+ * This is a GuiceModule, which bind the {@link ExampleImpl} to the
+ * {@link Example} interface and it will be recognized by the
+ * {@link ASMClasspathScanner}, due the fact that it is annotated with the
+ * {@link GuiceModule}.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@GuiceModule
+public class ExampleModule extends AbstractModule {
+ @Override
+ protected void configure() {
+ bind(Example.class).to(ExampleImpl.class);
+ }
+}
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/Example.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/Example.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/Example.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/Example.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.plist;
+
+/**
+ * Interface which is used to bind an implementation too.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public interface Example {
+ String sayHello();
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleApp.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleApp.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleApp.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleApp.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.plist;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.example.starter.ExampleApplication;
+import org.apache.onami.autobind.integrations.commons.configuration.CommonsConfigurationFeature;
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.ScannerModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+/**
+ * Example Application, which creates a new Injector with the help of the
+ * provided {@link StartupModule}. It passes the {@link ASMClasspathScanner}
+ * class for the {@link ClasspathScanner} and the packages (de.devsurf) which
+ * should be scanned. The {@link StartupModule} binds these parameter, so we are
+ * able to create and inject our {@link ScannerModule}. This Module uses the
+ * {@link ClasspathScanner} to explore the Classpath and scans for Annotations.
+ *
+ * All recognized Classes annotated with {@link GuiceModule} are installed in
+ * the child injector and with {@link Bind} are automatically bound.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Bind(multiple = true)
+public class ExampleApp implements ExampleApplication {
+ @Override
+ public void run() {
+ StartupModule startupModule = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ExampleApp.class));
+ startupModule.addFeature(CommonsConfigurationFeature.class);
+ Injector injector = Guice.createInjector(startupModule);
+
+ System.out.println(injector.getInstance(Example.class).sayHello());
+ }
+
+ public static void main(String[] args) {
+ new ExampleApp().run();
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleConfiguration.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleConfiguration.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleConfiguration.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.plist;
+
+import javax.inject.Named;
+
+import org.apache.commons.configuration.plist.PropertyListConfiguration;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+
+
+@Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.plist"), to = PropertyListConfiguration.class)
+public interface ExampleConfiguration {
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleImpl.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleImpl.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleImpl.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleImpl.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.plist;
+
+import javax.inject.Named;
+
+import org.apache.commons.configuration.plist.PropertyListConfiguration;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Inject;
+
+
+/**
+ * This class implements the Example interface and is not annotated like the
+ * other Examples, due the fact, that the {@link ExampleModule} will bind it
+ * manually. In this Example the {@link ASMClasspathScanner} is used, to find
+ * the {@link ExampleModule} and automatically install it.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public class ExampleImpl implements Example {
+ @Inject
+ @Named("config")
+ private PropertyListConfiguration config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getString("de.devsurf.configuration.message");
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleModule.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleModule.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleModule.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/commons/plist/ExampleModule.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.commons.plist;
+
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.AbstractModule;
+
+
+/**
+ * This is a GuiceModule, which bind the {@link ExampleImpl} to the
+ * {@link Example} interface and it will be recognized by the
+ * {@link ASMClasspathScanner}, due the fact that it is annotated with the
+ * {@link GuiceModule}.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@GuiceModule
+public class ExampleModule extends AbstractModule {
+ @Override
+ protected void configure() {
+ bind(Example.class).to(ExampleImpl.class);
+ }
+}
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/Example.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/Example.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/Example.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/Example.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.dynamic;
+
+/**
+ * Interface which is used to bind an implementation too.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public interface Example {
+ String sayHello();
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleApp.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleApp.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleApp.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleApp.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.dynamic;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.example.starter.ExampleApplication;
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.ScannerModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+/**
+ * Example Application, which creates a new Injector with the help of the
+ * provided {@link StartupModule}. It passes the {@link ASMClasspathScanner}
+ * class for the {@link ClasspathScanner} and the packages (de.devsurf) which
+ * should be scanned. The {@link StartupModule} binds these parameter, so we are
+ * able to create and inject our {@link ScannerModule}. This Module uses the
+ * {@link ClasspathScanner} to explore the Classpath and scans for Annotations.
+ *
+ * All recognized Classes annotated with {@link GuiceModule} are installed in
+ * the child injector and with {@link Bind} are automatically bound.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@Bind(multiple = true)
+public class ExampleApp implements ExampleApplication {
+ @Override
+ public void run() {
+ System.setProperty("myconfig", "/configuration.properties");
+ StartupModule starter = StartupModule.create(ASMClasspathScanner.class, PackageFilter.create(ExampleApp.class
+ ));
+ starter.addFeature(ConfigurationFeature.class);
+ starter.bindSystemProperties();
+ Injector injector = Guice.createInjector(starter);
+ System.out.println(injector.getInstance(Example.class).sayHello());
+ }
+
+ public static void main(String[] args) {
+ new ExampleApp().run();
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleConfiguration.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleConfiguration.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleConfiguration.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.dynamic;
+
+import javax.inject.Named;
+
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+
+
+@Configuration(name = @Named("config"), location = @PathConfig(value = "${myconfig}"))
+public interface ExampleConfiguration {
+
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleImpl.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleImpl.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleImpl.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleImpl.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.dynamic;
+
+import java.util.Properties;
+
+import javax.inject.Named;
+
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.Inject;
+
+
+/**
+ * This class implements the Example interface and is not annotated like the
+ * other Examples, due the fact, that the {@link ExampleModule} will bind it
+ * manually. In this Example the {@link ASMClasspathScanner} is used, to find
+ * the {@link ExampleModule} and automatically install it.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public class ExampleImpl implements Example {
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+}
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleModule.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleModule.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleModule.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/dynamic/ExampleModule.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.dynamic;
+
+import org.apache.onami.autobind.annotations.GuiceModule;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+
+import com.google.inject.AbstractModule;
+
+
+/**
+ * This is a GuiceModule, which bind the {@link ExampleImpl} to the
+ * {@link Example} interface and it will be recognized by the
+ * {@link ASMClasspathScanner}, due the fact that it is annotated with the
+ * {@link GuiceModule}.
+ *
+ * @author Daniel Manzke
+ *
+ */
+@GuiceModule
+public class ExampleModule extends AbstractModule {
+ @Override
+ protected void configure() {
+ bind(Example.class).to(ExampleImpl.class);
+ }
+}
Propchange: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/general/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/general/Example.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/general/Example.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/general/Example.java (added)
+++ incubator/onami/trunk/autobind/examples/src/main/java/org/apache/onami/autobind/configuration/example/map/general/Example.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.onami.autobind.configuration.example.map.general;
+
+/**
+ * Interface which is used to bind an implementation too.
+ *
+ * @author Daniel Manzke
+ *
+ */
+public interface Example {
+ String sayHello();
+}