onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danielman...@apache.org
Subject svn commit: r1418140 [6/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...
Date Fri, 07 Dec 2012 00:11:37 GMT
Added: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/features/WebServletBindingFeature.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/features/WebServletBindingFeature.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/features/WebServletBindingFeature.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/features/WebServletBindingFeature.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,80 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.enterprise.features;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.inject.Singleton;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+
+import org.apache.onami.autobind.install.BindingStage;
+import org.apache.onami.autobind.scanner.features.BindingScannerFeature;
+
+import com.google.inject.servlet.ServletModule;
+
+
+@Singleton
+public class WebServletBindingFeature extends BindingScannerFeature {
+	private static Logger LOGGER = Logger.getLogger(WebServletBindingFeature.class.getName());
+	
+	@Override
+	public BindingStage accept(Class<Object> annotatedClass, Map<String, Annotation> annotations) {
+		if (annotations.containsKey(WebServlet.class.getName())) {
+			return BindingStage.BINDING;
+		}
+		return BindingStage.IGNORE;
+	}
+
+	@Override
+	public void process(final Class<Object> annotatedClass,
+			final Map<String, Annotation> annotations) {
+		final WebServlet annotation = (WebServlet) annotations.get(WebServlet.class.getName());
+		
+		String[] patterns = annotation.value();
+		final String value;
+		final String[] values;
+		if(patterns.length > 0){
+			final PropertiesResolver resolver = new PropertiesResolver(patterns[0]);
+			resolver.setInjector(injector);
+			value = resolver.get();
+			if(patterns.length > 1){
+				values = new String[patterns.length-1];
+				
+				for(int i=1;i<patterns.length;i++){
+					final PropertiesResolver patternResolver = new PropertiesResolver(patterns[i]);
+					patternResolver.setInjector(injector);
+					values[i-1] = patternResolver.get();
+				}				
+			}else{
+				values = null;
+			}
+		}else{
+			// failure
+			LOGGER.info("Ignoring Servlet \""+annotatedClass+"\", because no Values for URLs were specified.");
+			return;
+		}
+
+		_binder.install(new ServletModule(){
+			@Override
+			protected void configureServlets() {
+				serve(value).with(annotatedClass.asSubclass(HttpServlet.class));
+			}
+		});
+	}
+}

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Alternatives.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Alternatives.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Alternatives.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Alternatives.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,37 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.enterprise.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Alternatives {
+    @XmlElement(name = "class", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected List<String> classes;
+
+    public List<String> getClasses() {
+        if (classes == null) {
+        	classes = new ArrayList<String>();
+        }
+        return this.classes;
+    }
+}

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Beans.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Beans.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Beans.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Beans.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,66 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.enterprise.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "beans", namespace = "http://java.sun.com/xml/ns/javaee")
+public class Beans {
+	@XmlElement(name="interceptors", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected Interceptors interceptors;
+    @XmlElement(name="decorators", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected Decorators decorators;
+    @XmlElement(name="alternatives", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected Alternatives alternatives;
+
+    public Interceptors getInterceptors() {
+    	if(interceptors == null){
+    		interceptors = new Interceptors();
+    	}
+        return interceptors;
+    }
+
+    public void setInterceptors(Interceptors value) {
+        this.interceptors = value;
+    }
+
+    public Decorators getDecorators() {
+    	if(decorators == null){
+    		decorators = new Decorators();
+    	}
+        return decorators;
+    }
+
+    public void setDecorators(Decorators value) {
+        this.decorators = value;
+    }
+
+    
+    public Alternatives getAlternatives() {
+    	if(alternatives == null){
+    		alternatives = new Alternatives();
+    	}
+        return alternatives;
+    }
+
+    public void setAlternatives(Alternatives value) {
+        this.alternatives = value;
+    }
+}

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Decorators.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Decorators.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Decorators.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Decorators.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.enterprise.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Decorators {
+    @XmlElement(name = "class", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected List<String> classes;
+
+    public List<String> getClasses() {
+        if (classes == null) {
+            classes = new ArrayList<String>();
+        }
+        return this.classes;
+    }
+}

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Interceptors.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Interceptors.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Interceptors.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/main/java/org/apache/onami/autobind/enterprise/model/Interceptors.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.enterprise.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Interceptors {
+    @XmlElement(name = "class", namespace = "http://java.sun.com/xml/ns/javaee")
+    protected List<String> classes;
+
+    public List<String> getClasses() {
+        if (classes == null) {
+        	classes = new ArrayList<String>();
+        }
+        return this.classes;
+    }
+
+}

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/AllTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/AllTests.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/AllTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,24 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.tests.enterprise;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( { EnterpriseTests.class })
+public class AllTests {
+}

Added: incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/EnterpriseTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/EnterpriseTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/EnterpriseTests.java (added)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/test/java/org/apache/onami/autobind/integrations/tests/enterprise/EnterpriseTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,146 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.tests.enterprise;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.enterprise.inject.Alternative;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.To;
+import org.apache.onami.autobind.annotations.To.Type;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.enterprise.BeansXMLFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class EnterpriseTests {
+	@Test
+	public void createDynamicModule() {
+		Injector injector = Guice.createInjector(StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(EnterpriseTests.class)));
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void testWithWrongPackage() {
+		Injector injector = Guice.createInjector(StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create("java", false)));
+		assertNotNull(injector);
+
+		try {
+			SecondTestInterface testInstance = injector.getInstance(SecondTestInterface.class);
+			fail("The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+					+ (testInstance == null));
+		} catch (ConfigurationException e) {
+			// ok
+		}
+	}
+
+	@Test
+	public void createTestInterface() {
+		Injector injector = Guice.createInjector(StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(EnterpriseTests.class)));
+		assertNotNull(injector);
+
+		try {
+			TestInterface testInstance = injector.getInstance(TestInterface.class);
+			fail("Instance implements TestInterface, but was not bound to. Instance may be null? "
+					+ (testInstance == null));
+		} catch (ConfigurationException e) {
+			// ok
+		}
+	}
+
+	@Test
+	public void createSecondTestInterface() {
+		Injector injector = Guice.createInjector(StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(EnterpriseTests.class)));
+		assertNotNull(injector);
+
+		SecondTestInterface sameInstance = injector.getInstance(SecondTestInterface.class);
+		assertNotNull(sameInstance);
+		assertTrue(sameInstance.fireEvent().equals(TestInterfaceImplementation.EVENT));
+		assertTrue(sameInstance instanceof TestInterfaceImplementation);
+		assertTrue(sameInstance instanceof TestInterface);
+	}
+	
+	@Test
+	public void cdiTest() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(EnterpriseTests.class), PackageFilter.create(BeansXMLFeature.class));
+		startup.addFeature(BeansXMLFeature.class);
+		
+		Injector injector = Guice.createInjector(startup);
+		
+		assertNotNull(injector);
+
+		SecondTestInterface sameInstance = injector.getInstance(SecondTestInterface.class);
+		assertNotNull(sameInstance);
+		assertTrue(sameInstance.fireEvent().equals(AlternativeImplementation.EVENT));
+		assertTrue(sameInstance instanceof AlternativeImplementation);
+		assertTrue(sameInstance instanceof TestInterface);
+	}
+
+	public static interface TestInterface {
+		String sayHello();
+	}
+
+	public static interface SecondTestInterface {
+		String fireEvent();
+	}
+
+	@Bind(to = @To(value=Type.CUSTOM, customs={SecondTestInterface.class}))
+	public static class TestInterfaceImplementation implements TestInterface, SecondTestInterface {
+		public static final String TEST = "test";
+		public static final String EVENT = "event";
+
+		@Override
+		public String sayHello() {
+			return TEST;
+		}
+
+		@Override
+		public String fireEvent() {
+			return EVENT;
+		}
+	}
+	
+	@Alternative
+	@Bind(to = @To(value=Type.CUSTOM, customs={SecondTestInterface.class}))
+	public static class AlternativeImplementation implements TestInterface, SecondTestInterface {
+		public static final String TEST = "alternative_test";
+		public static final String EVENT = "alternative_event";
+
+		@Override
+		public String sayHello() {
+			return TEST;
+		}
+
+		@Override
+		public String fireEvent() {
+			return EVENT;
+		}
+	}
+}

Modified: incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/META-INF/beans.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/META-INF/beans.xml (original)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/META-INF/beans.xml Fri Dec  7 00:11:06 2012
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee beans_1_0.xsd ">
 	<alternatives>
-		<class>de.devsurf.injection.guice.integrations.tests.enterprise.EnterpriseTests$AlternativeImplementation</class>
+		<class>org.apache.onami.autobind.integrations.tests.enterprise.EnterpriseTests$AlternativeImplementation</class>
 	</alternatives>
 </beans>

Modified: incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/beans.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/beans.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/beans.xml (original)
+++ incubator/onami/trunk/autobind/integrations/enterprise/src/test/resources/beans.xml Fri Dec  7 00:11:06 2012
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee beans_1_0.xsd ">
 	<alternatives>
-		<class>de.devsurf.injection.guice.integrations.tests.enterprise.EnterpriseTests$AlternativeImplementation</class>
+		<class>org.apache.onami.autobind.integrations.tests.enterprise.EnterpriseTests$AlternativeImplementation</class>
 	</alternatives>
 </beans>

Propchange: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/AutomaticGuiceManager.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/AutomaticGuiceManager.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/AutomaticGuiceManager.java (added)
+++ incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/AutomaticGuiceManager.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,67 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.metro;
+
+import javax.xml.ws.WebServiceContext;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.sun.istack.NotNull;
+import com.sun.xml.ws.api.message.Packet;
+import com.sun.xml.ws.api.server.ResourceInjector;
+import com.sun.xml.ws.api.server.WSEndpoint;
+import com.sun.xml.ws.api.server.WSWebServiceContext;
+import com.sun.xml.ws.server.AbstractMultiInstanceResolver;
+
+public class AutomaticGuiceManager<T> extends AbstractMultiInstanceResolver<T> {
+	private static Module startup;
+	protected static Injector injector;
+	protected ResourceInjector resourceInjector;
+	protected WSWebServiceContext webServiceContext;
+
+	public AutomaticGuiceManager(@NotNull final Class<T> clazz) throws IllegalAccessException,
+			InstantiationException {
+		super(clazz);
+	}
+
+	@Override
+	public T resolve(@NotNull final Packet packet) {
+		final T instance = injector.getInstance(this.clazz);
+		resourceInjector.inject(this.webServiceContext, instance);
+		return instance;
+	}
+
+	@SuppressWarnings("rawtypes")
+	@Override
+	public synchronized void start(WSWebServiceContext wsc, WSEndpoint endpoint) {
+		resourceInjector = getResourceInjector(endpoint);
+		webServiceContext = wsc;
+		if(injector == null){
+			injector = Guice.createInjector(startup, new AbstractModule() {
+				@Override
+				protected void configure() {
+					bind(WebServiceContext.class).toInstance(webServiceContext);
+				}
+			});
+		}
+	}
+	
+	public static void inject(Module startup){
+		AutomaticGuiceManager.startup = startup;
+	}
+}

Added: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceContextListener.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceContextListener.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceContextListener.java (added)
+++ incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceContextListener.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.metro;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import com.google.inject.Module;
+import com.sun.xml.ws.transport.http.servlet.WSServletContextListener;
+
+public abstract class GuiceContextListener implements ServletContextListener{
+	private WSServletContextListener delegate = new WSServletContextListener();
+
+	public void attributeAdded(ServletContextAttributeEvent event) {
+		delegate.attributeAdded(event);
+	}
+
+	public void attributeRemoved(ServletContextAttributeEvent event) {
+		delegate.attributeRemoved(event);
+	}
+
+	public void attributeReplaced(ServletContextAttributeEvent event) {
+		delegate.attributeReplaced(event);
+	}
+
+	public void contextDestroyed(ServletContextEvent event) {
+		delegate.contextDestroyed(event);
+	}
+
+	public void contextInitialized(ServletContextEvent event) {
+		AutomaticGuiceManager.inject(getModule());
+		delegate.contextInitialized(event);
+	}
+
+	public boolean equals(Object obj) {
+		return delegate.equals(obj);
+	}
+
+	public int hashCode() {
+		return delegate.hashCode();
+	}
+
+	public String toString() {
+		return delegate.toString();
+	}
+	
+	protected abstract Module getModule();
+}

Added: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManaged.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManaged.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManaged.java (added)
+++ incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManaged.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,35 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.metro;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
+
+import com.sun.xml.ws.api.server.InstanceResolverAnnotation;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+@Documented
+@WebServiceFeatureAnnotation(id = GuiceManagedFeature.ID, bean = GuiceManagedFeature.class)
+@InstanceResolverAnnotation(AutomaticGuiceManager.class)
+public @interface GuiceManaged {
+}

Added: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManagedFeature.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManagedFeature.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManagedFeature.java (added)
+++ incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/GuiceManagedFeature.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.metro;
+
+import javax.xml.ws.WebServiceFeature;
+
+import com.sun.xml.ws.api.FeatureConstructor;
+
+/**
+ * @author Daniel Manzke
+ */
+public class GuiceManagedFeature extends WebServiceFeature {
+	public static final String ID = "automatic.managed.feature";
+
+	@FeatureConstructor
+	public GuiceManagedFeature() {
+		this.enabled = true;
+	}
+
+	public String getID() {
+		return ID;
+	}
+}

Added: incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/InjectorProvider.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/InjectorProvider.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/InjectorProvider.java (added)
+++ incubator/onami/trunk/autobind/integrations/metro/src/main/java/org/apache/onami/autobind/integrations/metro/InjectorProvider.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,23 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.integrations.metro;
+
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+public interface InjectorProvider extends Provider<Injector>{
+
+}

Modified: incubator/onami/trunk/autobind/integrations/metro/src/test/resources/jndi.properties
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/metro/src/test/resources/jndi.properties?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/integrations/metro/src/test/resources/jndi.properties (original)
+++ incubator/onami/trunk/autobind/integrations/metro/src/test/resources/jndi.properties Fri Dec  7 00:11:06 2012
@@ -1,3 +1,2 @@
-java.naming.factory.initial = de.devsurf.injection.guice.integrations.guicyfruit.jndi.GuicyInitialContextFactory
-guice.classpath.scanner = de.devsurf.injection.guice.scanner.asm.ASMClasspathScanner
-guice.classpath.packages =de.devsurf.injection.guice.integrations.test.guicyfruit.jndi;de.devsurf.injection.guice.integrations.guicyfruit
\ No newline at end of file
+guice.classpath.scanner=org.apache.onami.autobind.scanner.asm.ASMClasspathScanner
+guice.classpath.packages=org.apache.onami.autobind.integrations.test
\ No newline at end of file

Modified: incubator/onami/trunk/autobind/integrations/pom.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/integrations/pom.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/integrations/pom.xml (original)
+++ incubator/onami/trunk/autobind/integrations/pom.xml Fri Dec  7 00:11:06 2012
@@ -32,10 +32,10 @@
   <packaging>pom</packaging>
 
   <modules>
-    <!--
-    TODO UPGRADE ROCOTO TO CURRENT VERSION
     <module>commons.configurations</module>
-    <module>enterprise</module>                -->
+    <!-- PropertiesResolver is not available anymore
+    <module>enterprise</module>
+    -->               
     <module>metro</module>
   </modules>
 

Modified: incubator/onami/trunk/autobind/scanner/asm/pom.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/pom.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/pom.xml (original)
+++ incubator/onami/trunk/autobind/scanner/asm/pom.xml Fri Dec  7 00:11:06 2012
@@ -35,6 +35,13 @@
       <artifactId>onami-autobind-core</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.onami.autobind</groupId>
+      <artifactId>onami-autobind-configuration</artifactId>
+      <version>${project.version}</version>
+      <type>jar</type>
+      <!--scope>test</scope-->
+    </dependency>
   </dependencies>
 
   <!-- build>

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/ASMClasspathScanner.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/ASMClasspathScanner.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/ASMClasspathScanner.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/ASMClasspathScanner.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,431 @@
+package org.apache.onami.autobind.scanner.asm;
+
+/*
+ * 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.Runtime.getRuntime;
+import static java.lang.String.format;
+import static java.lang.System.getProperty;
+import static java.util.Collections.synchronizedSet;
+import static java.util.concurrent.Executors.newFixedThreadPool;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+import static java.util.logging.Level.WARNING;
+import static java.util.logging.Logger.getLogger;
+import static java.util.regex.Pattern.compile;
+import static org.apache.onami.autobind.scanner.asm.AnnotationCollector.ASM_FLAGS;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.onami.autobind.scanner.ClasspathScanner;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.features.ScannerFeature;
+import org.objectweb.asm.ClassReader;
+
+/**
+ * This Implementation only uses the ASM-API to read all recognized classes. It
+ * doesn't depend on any further 3rd-Party libraries.
+ */
+public class ASMClasspathScanner
+    implements ClasspathScanner
+{
+
+    private static final String LINE_SEPARATOR = getProperty( "line.separator" );
+
+    private final Logger _logger = getLogger( getClass().getName() );
+
+    @Inject
+    @Named( "classpath" )
+    private URL[] classPath;
+
+    private List<Pattern> patterns = new ArrayList<Pattern>();
+
+    private final Set<String> visited;
+
+    private final BlockingQueue<AnnotationCollector> collectors;
+
+    @Inject
+    public ASMClasspathScanner( Set<ScannerFeature> listeners, @Named( "packages" ) PackageFilter... filter )
+    {
+        int cores = getRuntime().availableProcessors();
+        this.collectors = new ArrayBlockingQueue<AnnotationCollector>( cores );
+
+        for ( int i = 0; i < cores; i++ )
+        {
+            try
+            {
+                collectors.put( new AnnotationCollector() );
+            }
+            catch ( InterruptedException e )
+            {
+                // ignore
+            }
+        }
+        for ( PackageFilter p : filter )
+        {
+            includePackage( p );
+        }
+
+        for ( ScannerFeature listener : listeners )
+        {
+            addFeature( listener );
+        }
+        visited = synchronizedSet( new HashSet<String>() );
+    }
+
+    @Override
+    public void addFeature( ScannerFeature feature )
+    {
+        for ( AnnotationCollector collector : collectors )
+        {
+            collector.addScannerFeature( feature );
+        }
+    }
+
+    @Override
+    public void removeFeature( ScannerFeature feature )
+    {
+        for ( AnnotationCollector collector : collectors )
+        {
+            collector.addScannerFeature( feature );
+        }
+    }
+
+    @Override
+    public List<ScannerFeature> getFeatures()
+    {
+        List<ScannerFeature> features;
+        try
+        {
+            AnnotationCollector collector = collectors.take();
+            features = collector.getScannerFeatures();
+            collectors.put( collector );
+        }
+        catch ( InterruptedException e )
+        {
+            // ignore
+            features = Collections.emptyList();
+        }
+        return features;
+    }
+
+    @Override
+    public void includePackage( final PackageFilter filter )
+    {
+        String packageName = filter.getPackage();
+        String pattern = ".*" + packageName.replace( ".", "/" );
+
+        if ( filter.deep() )
+        {
+            pattern = pattern + "/(?:\\w|/)*([A-Z](?:\\w|\\$)+)\\.class$";
+        }
+        else
+        {
+            pattern = pattern + "/([A-Z](?:\\w|\\$)+)\\.class$";
+        }
+
+        if ( _logger.isLoggable( FINE ) )
+        {
+            _logger.fine( format( "Including Package for scanning: %s generating Pattern: %s", packageName,  pattern ) );
+        }
+        patterns.add( compile( pattern ) );
+    }
+
+    @Override
+    public void excludePackage( final PackageFilter filter )
+    {
+        // TODO Could use Predicate of Google
+    }
+
+    public void scan()
+        throws IOException
+    {
+        ExecutorService pool = newFixedThreadPool( getRuntime().availableProcessors() );
+
+        if ( _logger.isLoggable( INFO ) )
+        {
+            StringBuilder builder = new StringBuilder();
+            builder.append( "Using Root-Path for Classpath scanning:" ).append( LINE_SEPARATOR );
+            for ( URL url : classPath )
+            {
+                builder.append( url.toString() ).append( LINE_SEPARATOR );
+            }
+            _logger.log( INFO, builder.toString() );
+        }
+
+        List<Future<?>> futures = new ArrayList<Future<?>>();
+        for ( final URL url : classPath )
+        {
+            Future<?> task = pool.submit( new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        if ( url.toString().startsWith( "jar:" ) )
+                        {
+                            visitJar( url );
+                            return;
+                        }
+                        URI uri;
+                        File entry;
+                        try
+                        {
+                            uri = url.toURI();
+                            entry = new File( uri );
+                            if ( !entry.exists() )
+                            {
+                                if ( _logger.isLoggable( FINE ) )
+                                {
+                                    _logger.log( FINE, format( "Skipping Entry %s, because it doesn't exists.", entry ) );
+                                }
+                                return;
+                            }
+                        }
+                        catch ( URISyntaxException e )
+                        {
+                            // ignore
+                            _logger.log( WARNING, format( "Using invalid URL for Classpath Scanning: %s", url ), e );
+                            return;
+                        }
+                        catch ( Throwable e )
+                        {
+                            // ignore
+                            _logger.log( SEVERE, format( "Using invalid URL for Classpath Scanning: ", url ), e );
+                            return;
+                        }
+
+                        if ( entry.isDirectory() )
+                        {
+                            visitFolder( entry );
+                        }
+                        else
+                        {
+                            String path = uri.toString();
+                            if ( matches( path ) )
+                            {
+                                if ( !visited.contains( entry.getAbsolutePath() ) )
+                                {
+                                    visitClass( new FileInputStream( entry ) );
+                                    visited.add( entry.getAbsolutePath() );
+                                }
+                            }
+                            else if ( path.endsWith( ".jar" ) )
+                            {
+                                visitJar( entry );
+                            }
+                        }
+                    }
+                    catch ( FileNotFoundException e )
+                    {
+                        if ( _logger.isLoggable( FINE ) )
+                        {
+                            _logger.log( FINE, format( "Skipping Entry %s, because it doesn't exists.", url ), e );
+                        }
+                    }
+                    catch ( IOException e )
+                    {
+                        if ( _logger.isLoggable( FINE ) )
+                        {
+                            _logger.log( FINE, format( "Skipping Entry %s, because it couldn't be scanned.", url ),  e );
+                        }
+                    }
+                    catch ( Throwable e )
+                    {
+                        _logger.log( WARNING, format( "Skipping Entry %s, because it couldn't be scanned.", url ),  e );
+                    }
+                }
+            } );
+            futures.add( task );
+        }
+        for ( Future<?> future : futures )
+        {
+            try
+            {
+                future.get();
+            }
+            catch ( InterruptedException e )
+            {
+                throw new RuntimeException( e );
+            }
+            catch ( ExecutionException e )
+            {
+                _logger.log( SEVERE, e.getMessage(), e );
+            }
+        }
+        pool.shutdown();
+        destroy();
+    }
+
+    public void destroy()
+    {
+        classPath = null;
+        collectors.clear();
+        patterns.clear();
+        patterns = null;
+        visited.clear();
+    }
+
+    private void visitFolder( File folder )
+        throws IOException
+    {
+        if ( _logger.isLoggable( FINE ) )
+        {
+            _logger.log( FINE, format( "Scanning Folder: %s...", folder.getAbsolutePath() ) );
+        }
+
+        File[] files = folder.listFiles();
+        for ( File file : files )
+        {
+            if ( file.isDirectory() )
+            {
+                visitFolder( file );
+            }
+            else
+            {
+                String path = file.toURI().toString();
+                if ( matches( path ) )
+                {
+                    if ( !visited.contains( file.getAbsolutePath() ) )
+                    {
+                        visitClass( new FileInputStream( file ) );
+                        visited.add( file.getAbsolutePath() );
+                    }
+                }
+                else if ( path.endsWith( ".jar" ) )
+                {
+                    visitJar( file );
+                }
+            }
+        }
+    }
+
+    private void visitJar( URL url )
+        throws IOException
+    {
+        if ( _logger.isLoggable( FINE ) )
+        {
+            _logger.log( FINE, format( "Scanning JAR-File: %s", url ) );
+        }
+
+        JarURLConnection conn = (JarURLConnection) url.openConnection();
+        _visitJar( conn.getJarFile() );
+    }
+
+    private void visitJar( File file )
+        throws IOException
+    {
+        if ( _logger.isLoggable( FINE ) )
+        {
+            _logger.log( FINE, format( "Scanning JAR-File: %s", file.getAbsolutePath() ) );
+        }
+
+        JarFile jarFile = new JarFile( file );
+        _visitJar( jarFile );
+    }
+
+    private void _visitJar( JarFile jarFile )
+        throws IOException
+    {
+        Enumeration<JarEntry> jarEntries = jarFile.entries();
+        for ( JarEntry jarEntry = null; jarEntries.hasMoreElements(); )
+        {
+            jarEntry = jarEntries.nextElement();
+            String name = jarEntry.getName();
+
+            if ( !jarEntry.isDirectory() && matches( name ) )
+            {
+                if ( !visited.contains( name ) )
+                {
+                    visitClass( jarFile.getInputStream( jarEntry ) );
+                    visited.add( name );
+                }
+            }
+        }
+    }
+
+    private void visitClass( InputStream in )
+        throws IOException
+    {
+        ClassReader reader = new ClassReader( new BufferedInputStream( in ) );
+        try
+        {
+            AnnotationCollector collector = collectors.take();
+            reader.accept( collector, ASM_FLAGS );
+            collectors.put( collector );
+        }
+        catch ( InterruptedException e )
+        {
+            // ignore
+        }
+    }
+
+    private boolean matches( String name )
+    {
+        boolean returned = false;
+        try
+        {
+            for ( Pattern pattern : patterns )
+            {
+                if ( pattern.matcher( name ).matches() )
+                {
+                    return ( returned = true );
+                }
+            }
+            return returned;
+        }
+        finally
+        {
+            if ( _logger.isLoggable( Level.FINE ) )
+            {
+                _logger.log( FINE, format( "%s.matches(..) - \"%s\" -> %s",
+                                           getClass().getSimpleName(), name, returned ) );
+            }
+        }
+    }
+
+}

Added: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/AnnotationCollector.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/AnnotationCollector.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/AnnotationCollector.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/AnnotationCollector.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,156 @@
+package org.apache.onami.autobind.scanner.asm;
+
+/*
+ * 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.util.Collections.unmodifiableList;
+import static java.util.logging.Level.WARNING;
+import static java.util.logging.Logger.getLogger;
+import static org.objectweb.asm.ClassReader.SKIP_CODE;
+import static org.objectweb.asm.ClassReader.SKIP_DEBUG;
+import static org.objectweb.asm.ClassReader.SKIP_FRAMES;
+import static org.objectweb.asm.Opcodes.ASM4;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.onami.autobind.scanner.features.ScannerFeature;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassVisitor;
+
+/**
+ * Visitor implementation to collect field annotation information from class.
+ */
+final class AnnotationCollector
+    extends ClassVisitor
+{
+
+    public static final int ASM_FLAGS = SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES;
+
+    private final Logger _logger = getLogger( getClass().getName() );
+
+    private String _name;
+
+    private Class<?> _class;
+
+    private boolean _ignore;
+
+    private final Map<String, Annotation> _annotations;
+
+    private final List<ScannerFeature> _features;
+
+    public AnnotationCollector()
+    {
+        super( ASM4 );
+        _features = new LinkedList<ScannerFeature>();
+        _annotations = new HashMap<String, Annotation>();
+    }
+
+    public void addScannerFeature( ScannerFeature listener )
+    {
+        _features.add( listener );
+    }
+
+    public void removerScannerFeature( ScannerFeature listener )
+    {
+        _features.remove( listener );
+    }
+
+    public List<ScannerFeature> getScannerFeatures()
+    {
+        return unmodifiableList( _features );
+    }
+
+    public void destroy()
+    {
+        _annotations.clear();
+        _class = null;
+        _features.clear();
+    }
+
+    @Override
+    public void visit( int version, int access, String name, String signature, String superName, String[] interfaces )
+    {
+        _name = name.replace( '/', '.' );
+        for ( String interf : interfaces )
+        {
+            if ( interf.equals( "java/lang/annotation/Annotation" ) )
+            {
+                _ignore = true;
+                return;
+            }
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public AnnotationVisitor visitAnnotation( String sig, boolean visible )
+    {
+        if ( _ignore )
+        {
+            return null;
+        }
+        String annotationClassStr = sig.replace( '/', '.' ).substring( 1, sig.length() - 1 );
+        if ( _class == null )
+        {
+            try
+            {
+                _class = Thread.currentThread().getContextClassLoader().loadClass( _name );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                _logger.log( WARNING, "Failure while visitAnnotation. Class could not be loaded.", e );
+                return null;
+            }
+        }
+        try
+        {
+            Class<Annotation> annotationClass =
+                (Class<Annotation>) getClass().getClassLoader().loadClass( annotationClassStr );
+            Annotation annotation = _class.getAnnotation( annotationClass );
+            _annotations.put( annotationClassStr, annotation );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            e.printStackTrace();
+            _logger.log( WARNING, "Failure while visitAnnotation. Class could not be loaded.", e );
+        }
+
+        return null;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public void visitEnd()
+    {
+        if ( !_ignore && _annotations.size() > 0 && !_annotations.containsKey( "javax.enterprise.inject.Alternative" ) )
+        {
+            for ( ScannerFeature listener : _features )
+            {
+                listener.found( (Class<Object>) _class, _annotations );
+            }
+        }
+        _name = null;
+        _class = null;
+        _ignore = false;
+        _annotations.clear();
+    }
+
+}

Added: incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/package-info.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/package-info.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/package-info.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/main/java/org/apache/onami/autobind/scanner/asm/package-info.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,22 @@
+/**
+ * This package includes all annotations which are used to
+ * annotating class like it would be written with the Guice ESL.
+ */
+package org.apache.onami.autobind.scanner.asm;
+
+/*
+ * 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/scanner/asm/src/test/java/org/apache/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/AllTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/AllTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/AllTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,46 @@
+
+/*
+ * 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.
+ */
+package org.apache.onami.autobind.scanner.asm.tests;
+
+import org.apache.onami.autobind.scanner.asm.tests.autobind.AutobindTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.bind.InterfaceAutobindTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.duplicate.DuplicateAutobindTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.filter.PackageFilterTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.multiple.MultibindTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.names.NamedAutobindTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.only.ImplementationOnlyTests;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.provider.ProviderTest;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.startconfig.StartConfigProviderTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith( Suite.class )
+@Suite.SuiteClasses( { AutobindTests.class,
+                       InterfaceAutobindTests.class,
+                       //DuplicateAutobindTests.class,
+                       NamedAutobindTests.class,
+                       MultibindTests.class,
+                       ImplementationOnlyTests.class,
+                       PackageFilterTests.class,
+                       StartConfigProviderTest.class,
+                       ProviderTest.class } )
+public class AllTests
+{
+}

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/AutobindTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/AutobindTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/AutobindTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/AutobindTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,150 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind;
+
+/*
+ * 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 org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class AutobindTests
+{
+
+    @Test
+    public void createDynamicModule()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( AutobindTests.class, false ) ) );
+        assertNotNull( injector );
+    }
+
+    @Test
+    public void testWithWrongPackage()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java", false ) ) );
+        assertNotNull( injector );
+
+        TestInterface testInstance;
+        try
+        {
+            testInstance = injector.getInstance( TestInterface.class );
+            fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+                + ( testInstance == null ) );
+        }
+        catch ( ConfigurationException e )
+        {
+            // ok
+        }
+    }
+
+    @Test
+    public void createTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( AutobindTests.class, false ) ) );
+        assertNotNull( injector );
+
+        TestInterface testInstance = injector.getInstance( TestInterface.class );
+        assertNotNull( testInstance );
+        assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+        assertTrue( testInstance instanceof TestInterfaceImplementation );
+        assertTrue( testInstance instanceof SecondTestInterface );
+    }
+
+    @Test
+    public void createSecondTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( AutobindTests.class, false ) ) );
+        assertNotNull( injector );
+
+        SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+        assertNotNull( sameInstance );
+        assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+        assertTrue( sameInstance instanceof TestInterfaceImplementation );
+        assertTrue( sameInstance instanceof TestInterface );
+    }
+
+    @Test
+    public void createAllInterfaces()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( AutobindTests.class, false ) ) );
+        assertNotNull( injector );
+
+        TestInterface testInstance = injector.getInstance( TestInterface.class );
+        assertNotNull( testInstance );
+        assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+        assertTrue( testInstance instanceof TestInterfaceImplementation );
+        assertTrue( testInstance instanceof SecondTestInterface );
+
+        SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+        assertNotNull( sameInstance );
+        assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+        assertTrue( sameInstance instanceof TestInterfaceImplementation );
+        assertTrue( testInstance instanceof TestInterface );
+    }
+
+    public static interface TestInterface
+    {
+        String sayHello();
+    }
+
+    public static interface SecondTestInterface
+    {
+        String fireEvent();
+    }
+
+    @Bind
+    public static class TestInterfaceImplementation
+        implements TestInterface, SecondTestInterface
+    {
+        public static final String TEST = "test";
+
+        public static final String EVENT = "event";
+
+        @Override
+        public String sayHello()
+        {
+            return TEST;
+        }
+
+        @Override
+        public String fireEvent()
+        {
+            return EVENT;
+        }
+    }
+
+}

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/bind/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/bind/InterfaceAutobindTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/bind/InterfaceAutobindTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/bind/InterfaceAutobindTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/bind/InterfaceAutobindTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,135 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.bind;
+
+/*
+ * 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 org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.To;
+import org.apache.onami.autobind.annotations.To.Type;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class InterfaceAutobindTests
+{
+
+    @Test
+    public void createDynamicModule()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( InterfaceAutobindTests.class ) ) );
+        assertNotNull( injector );
+    }
+
+    @Test
+    public void testWithWrongPackage()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java", false ) ) );
+        assertNotNull( injector );
+
+        try
+        {
+            SecondTestInterface testInstance = injector.getInstance( SecondTestInterface.class );
+            fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+                + ( testInstance == null ) );
+        }
+        catch ( ConfigurationException e )
+        {
+            // ok
+        }
+    }
+
+    @Test
+    public void createTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( InterfaceAutobindTests.class ) ) );
+        assertNotNull( injector );
+
+        try
+        {
+            TestInterface testInstance = injector.getInstance( TestInterface.class );
+            fail( "Instance implements TestInterface, but was not bound to. Instance may be null? "
+                + ( testInstance == null ) );
+        }
+        catch ( ConfigurationException e )
+        {
+            // ok
+        }
+    }
+
+    @Test
+    public void createSecondTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( InterfaceAutobindTests.class ) ) );
+        assertNotNull( injector );
+
+        SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+        assertNotNull( sameInstance );
+        assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+        assertTrue( sameInstance instanceof TestInterfaceImplementation );
+        assertTrue( sameInstance instanceof TestInterface );
+    }
+
+    public static interface TestInterface
+    {
+        String sayHello();
+    }
+
+    public static interface SecondTestInterface
+    {
+        String fireEvent();
+    }
+
+    @Bind( to = @To( value = Type.CUSTOM, customs = { SecondTestInterface.class } ) )
+    public static class TestInterfaceImplementation
+        implements TestInterface, SecondTestInterface
+    {
+        public static final String TEST = "test";
+
+        public static final String EVENT = "event";
+
+        @Override
+        public String sayHello()
+        {
+            return TEST;
+        }
+
+        @Override
+        public String fireEvent()
+        {
+            return EVENT;
+        }
+    }
+
+}

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/duplicate/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/duplicate/DuplicateAutobindTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/duplicate/DuplicateAutobindTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/duplicate/DuplicateAutobindTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/duplicate/DuplicateAutobindTests.java Fri Dec  7 00:11:06 2012
@@ -0,0 +1,155 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.duplicate;
+
+/*
+ * 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 org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.To;
+import org.apache.onami.autobind.annotations.To.Type;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class DuplicateAutobindTests
+{
+
+    @Test
+    public void createDynamicModule()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( DuplicateAutobindTests.class ) ) );
+        assertNotNull( injector );
+    }
+
+    @Test
+    public void testWithWrongPackage()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+        assertNotNull( injector );
+
+        try
+        {
+            SecondTestInterface testInstance = injector.getInstance( SecondTestInterface.class );
+            fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+                + ( testInstance == null ) );
+        }
+        catch ( ConfigurationException e )
+        {
+            // ok
+        }
+    }
+
+    @Test
+    public void createTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( DuplicateAutobindTests.class ) ) );
+        assertNotNull( injector );
+
+        try
+        {
+            TestInterface testInstance = injector.getInstance( TestInterface.class );
+            fail( "Instance implements TestInterface, but was not bound to. Instance may be null? "
+                + ( testInstance == null ) );
+        }
+        catch ( ConfigurationException e )
+        {
+            // ok
+        }
+    }
+
+    @Test
+    public void createSecondTestInterface()
+    {
+        Injector injector =
+            Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+                                                        PackageFilter.create( DuplicateAutobindTests.class ) ) );
+        assertNotNull( injector );
+
+        SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+        assertNotNull( sameInstance );
+        assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+        assertTrue( sameInstance instanceof TestInterface );
+    }
+
+    public static interface TestInterface
+    {
+        String sayHello();
+    }
+
+    public static interface SecondTestInterface
+    {
+        String fireEvent();
+    }
+
+    @Bind( to = @To( value = Type.CUSTOM, customs = { SecondTestInterface.class } ) )
+    public static class TestInterfaceImplementation
+        implements TestInterface, SecondTestInterface
+    {
+        public static final String TEST = "test";
+
+        public static final String EVENT = "event";
+
+        @Override
+        public String sayHello()
+        {
+            return TEST;
+        }
+
+        @Override
+        public String fireEvent()
+        {
+            return EVENT;
+        }
+    }
+
+    @Bind( to = @To( value = Type.CUSTOM, customs = { SecondTestInterface.class } ) )
+    public static class SecondInterfaceImplementation
+        implements TestInterface, SecondTestInterface
+    {
+        public static final String TEST = "test";
+
+        public static final String EVENT = "event";
+
+        @Override
+        public String sayHello()
+        {
+            return TEST;
+        }
+
+        @Override
+        public String fireEvent()
+        {
+            return EVENT;
+        }
+    }
+
+}

Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/
------------------------------------------------------------------------------
    bugtraq:number = true



Mime
View raw message