Added:
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicProvider.java
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/Internal.java
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/OSGiConfigurator.java
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/ServiceRegistryImpl.java
/trunk/dependency-shot-dynamic/src/main/resources/META-INF
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.BindingsProvider
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.ConfigurationHandler
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.CustomScopeHandler
Deleted:
/trunk/dependency-shot-dynamic/src/main/resources/META-INF.services/cx.ath.mancel01.dependencyshot.spi.CustomScopeHandler
Modified:
/trunk/dependency-shot-dynamic/pom.xml
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicProxy.java
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicScope.java
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/ServiceRegistry.java
/trunk/dependency-shot-dynamic/src/test/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicTest.java
/trunk/dependency-shot-lifecycle/src/main/java/cx/ath/mancel01/dependencyshot/lifecycle/ManagedBeanHandler.java
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicProvider.java
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009-2010 Mathieu ANCELIN.
+ *
+ * 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.
+ * under the License.
+ */
+
+package cx.ath.mancel01.dependencyshot.dynamic;
+
+import cx.ath.mancel01.dependencyshot.graph.Binding;
+import cx.ath.mancel01.dependencyshot.graph.BindingBuilder;
+import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
+import cx.ath.mancel01.dependencyshot.spi.BindingsProvider;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ *
+ * @author Mathieu ANCELIN
+ */
+public class DynamicProvider extends BindingsProvider {
+
+ @Override
+ public Collection<Binding> getProvidedBindings(InjectorImpl injector) {
+
+ ArrayList<Binding> bindings = new ArrayList<Binding>();
+
+ bindings.add(BindingBuilder
+ .prepareBindingThat()
+ .bind(ServiceRegistry.class)
+ .annotatedWith(Internal.class)
+ .to(ServiceRegistryImpl.class)
+ .build());
+ bindings.add(BindingBuilder
+ .prepareBindingThat()
+ .bind(ServiceRegistry.class)
+ .annotatedWith(OSGi.class)
+ .to(OSGiServiceRegistryImpl.class)
+ .build());
+
+ return bindings;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/Internal.java
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009-2010 Mathieu ANCELIN.
+ *
+ * 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.
+ * under the License.
+ */
+
+package cx.ath.mancel01.dependencyshot.dynamic;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author Mathieu ANCELIN
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Qualifier
+public @interface Internal {
+
+}
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/OSGiConfigurator.java
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2009-2010 Mathieu ANCELIN.
+ *
+ * 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.
+ * under the License.
+ */
+package cx.ath.mancel01.dependencyshot.dynamic;
+
+import cx.ath.mancel01.dependencyshot.DependencyShot;
+import cx.ath.mancel01.dependencyshot.api.Stage;
+import cx.ath.mancel01.dependencyshot.graph.Binder;
+import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
+import cx.ath.mancel01.dependencyshot.spi.ConfigurationHandler;
+import javax.inject.Inject;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Mathieu ANCELIN
+ */
+public class OSGiConfigurator extends ConfigurationHandler {
+
+ private BundleContext context;
+ private Binder binder;
+
+ @Inject @OSGi
+ private ServiceRegistry registry;
+
+ @Override
+ public InjectorImpl getInjector(Stage stage) {
+ InjectorImpl injector = null;
+ if (context == null) {
+ throw new IllegalStateException("You must set the current
bundle context.");
+ }
+ if (binder == null) {
+ // TODO :
+ injector = DependencyShot.getInjector();
+ } else {
+ injector = DependencyShot.getInjector(binder);
+ }
+ injector.injectInstance(this);
+ if (registry == null) {
+ throw new IllegalStateException("Injection for bundle context
failed.");
+ }
+ ((OSGiServiceRegistryImpl) registry).setContext(context);
+ return injector;
+ }
+
+ @Override
+ public boolean isAutoEnabled() {
+ return false;
+ }
+
+ public OSGiConfigurator withBinder(Binder binder) {
+ this.binder = binder;
+ return this;
+ }
+
+ public OSGiConfigurator context(BundleContext context) {
+ this.context = context;
+ return this;
+ }
+}
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/ServiceRegistryImpl.java
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2010 mathieu.
+ *
+ * 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.
+ * under the License.
+ */
+
+package cx.ath.mancel01.dependencyshot.dynamic;
+
+import cx.ath.mancel01.dependencyshot.api.DSInjector;
+import cx.ath.mancel01.dependencyshot.api.event.EventManager;
+import cx.ath.mancel01.dependencyshot.event.EventManagerImpl;
+import cx.ath.mancel01.dependencyshot.exceptions.DSIllegalStateException;
+import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ *
+ * @author mathieu
+ */
+@Singleton
+public class ServiceRegistryImpl implements ServiceRegistry {
+
+ @Inject
+ private DSInjector injector;
+
+ @Inject
+ private EventManager eventManager;
+
+ private ConcurrentHashMap<Class<?>, Collection<Class<?>>> services =
+ new ConcurrentHashMap<Class<?>, Collection<Class<?>>>();
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ for (Class<?> clazz : services.keySet()) {
+ builder.append(clazz.getName());
+ ArrayList<Class<?>> classes = (ArrayList<Class<?>>)
services.get(clazz);
+ for (Class<?> service : classes) {
+ builder.append("\n => ");
+ builder.append(service.getName());
+ }
+ builder.append("\n\n");
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public void addServiceListener(Class<?> listener) {
+ ((EventManagerImpl) eventManager).registerListener(listener);
+ }
+
+ @Override
+ public void removeServiceListener(Class<?> listener) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> ServiceRegistration registerService(Class<T> clazz, Class<?
extends T> service) {
+ if(!service.isAnnotationPresent(Dynamic.class)) {
+ throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
+ }
+ services.putIfAbsent(clazz, new ArrayList<Class<?>>());
+ ArrayList<Class<?>> classes = (ArrayList<Class<?>>)
services.get(clazz);
+ if (!classes.contains(service)) {
+ synchronized(classes) {
+ classes.add(service);
+ }
+ }
+ List<Class<?>> itfs = new ArrayList<Class<?>>();
+ itfs.add(clazz);
+ return new ServiceRegistrationImpl(itfs, service);
+ }
+
+ @Override
+ public <T> ServiceRegistration registerService(Class<T> clazz, T
service) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> ServiceRegistration registerService(Class<T>[] clazzes,
Class<? extends T> service) {
+ for (Class<T> clazz : clazzes) {
+ registerService(clazz, service);
+ }
+ return new ServiceRegistrationImpl(Arrays.asList(clazzes),
service);
+ }
+
+ @Override
+ public <T> ServiceRegistration registerService(Class<T>[] clazzes, T
service) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T getService(Class<T> contract) {
+ return (T) ((InjectorImpl)injector)
+ .getUnscopedInstance(((ArrayList<Class<?>>)
services.get(contract)).get(0));
+ }
+
+ @Override
+ public <T> Iterable<T> getServices(Class<T> contract) {
+ Collection<T> objects = new ArrayList<T>();
+ for (Class<?> clazz : services.get(contract)) {
+ objects.add((T)
((InjectorImpl)injector).getUnscopedInstance(clazz));
+ }
+ return objects;
+ }
+
+ public Map<Class<?>, Collection<Class<?>>> getAvailableServices() {
+ return services;
+ }
+
+ public void swap(Class<?> to) {
+ if(!to.isAnnotationPresent(Dynamic.class)) {
+ throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
+ }
+ for (Class from : to.getInterfaces()) {
+ ArrayList<Class<?>> classes = (ArrayList<Class<?>>)
services.get(from);
+ if (classes.contains(to)) {
+ int index = classes.indexOf(to);
+ Class<?> old = classes.set(0, to);
+ classes.set(index, old);
+ } else {
+ registerServiceAndSwap(from, to);
+ }
+ }
+ }
+
+ public void registerServiceAndSwap(Class<?> from, Class<?> to) {
+ if(!to.isAnnotationPresent(Dynamic.class)) {
+ throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
+ }
+ services.putIfAbsent(from, new ArrayList<Class<?>>());
+ ArrayList<Class<?>> classes = (ArrayList<Class<?>>)
services.get(from);
+ if (!classes.contains(to)) {
+ synchronized(classes) {
+ classes.add(0, to);
+ }
+ }
+ }
+
+ public Class<?> getContract(Class<?> from) {
+ return ((ArrayList<Class<?>>) services.get(from)).get(0);
+ }
+
+ public Collection<Class<?>> multipleContractsLookup(Class<?> from) {
+ return services.get(from);
+ }
+
+ private class ServiceRegistrationImpl<T> implements
ServiceRegistration {
+
+ final List<Class<T>> classes;
+ final Class<? extends T> to;
+
+ public ServiceRegistrationImpl(List<Class<T>> classes, Class<?
extends T> to) {
+ this.classes = classes;
+ this.to = to;
+ }
+
+ @Override
+ public void unregister() {
+ for (Class from : classes) {
+ services.get(from).remove(to);
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.BindingsProvider
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,1 @@
+cx.ath.mancel01.dependencyshot.dynamic.DynamicProvider
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.ConfigurationHandler
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,1 @@
+cx.ath.mancel01.dependencyshot.dynamic.OSGiConfigurator
=======================================
--- /dev/null
+++
/trunk/dependency-shot-dynamic/src/main/resources/META-INF/services/cx.ath.mancel01.dependencyshot.spi.CustomScopeHandler
Thu Apr 7 09:13:25 2011
@@ -0,0 +1,1 @@
+cx.ath.mancel01.dependencyshot.dynamic.DynamicScope
=======================================
---
/trunk/dependency-shot-dynamic/src/main/resources/META-INF.services/cx.ath.mancel01.dependencyshot.spi.CustomScopeHandler
Thu Nov 4 10:23:53 2010
+++ /dev/null
@@ -1,1 +0,0 @@
-cx.ath.mancel01.dependencyshot.dynamic.DynamicScope
=======================================
--- /trunk/dependency-shot-dynamic/pom.xml Thu Nov 4 08:43:26 2010
+++ /trunk/dependency-shot-dynamic/pom.xml Thu Apr 7 09:13:25 2011
@@ -49,6 +49,31 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>cx.ath.mancel01</groupId>
+ <artifactId>dependency-shot-aop</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>cx.ath.mancel01</groupId>
+ <artifactId>dependency-shot-lifecycle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>cx.ath.mancel01</groupId>
+ <artifactId>dependency-shot-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.8.0.GA</version>
=======================================
---
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicProxy.java
Wed Nov 17 11:30:36 2010
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicProxy.java
Thu Apr 7 09:13:25 2011
@@ -19,6 +19,7 @@
import cx.ath.mancel01.dependencyshot.api.InjectionPoint;
import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import javassist.util.proxy.MethodFilter;
import javassist.util.proxy.MethodHandler;
@@ -27,7 +28,7 @@
*
* @author Mathieu ANCELIN
*/
-public class DynamicProxy<T> implements MethodFilter, MethodHandler {
+public class DynamicProxy<T> implements MethodFilter, MethodHandler,
InvocationHandler {
private final Class<T> from;
@@ -35,13 +36,13 @@
private final InjectorImpl injector;
- private final ServiceRegistry registry;
+ private final ServiceRegistryImpl registry;
private Object actualService;
public DynamicProxy(
Class<T> from, InjectionPoint point,
- InjectorImpl injector, ServiceRegistry registry) {
+ InjectorImpl injector, ServiceRegistryImpl registry) {
this.from = from;
this.injector= injector;
this.registry = registry;
@@ -67,7 +68,13 @@
@Override
public Object invoke(Object self, Method method, Method proceed,
Object[] args) throws Throwable {
- actualService = registry.lookup(from);
+ actualService = registry.getService(from);
+ return method.invoke(actualService, args);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
+ actualService = registry.getService(from);
return method.invoke(actualService, args);
}
}
=======================================
---
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicScope.java
Wed Nov 17 11:30:36 2010
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicScope.java
Thu Apr 7 09:13:25 2011
@@ -21,6 +21,7 @@
import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
import cx.ath.mancel01.dependencyshot.spi.CustomScopeHandler;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Proxy;
/**
*
@@ -37,8 +38,9 @@
public <T> T getScopedInstance(Class<T> interf, Class<? extends T>
clazz,
InjectionPoint point, InjectorImpl injector) {
DynamicProxy proxy = new DynamicProxy(interf, point,
- injector, injector.getInstance(ServiceRegistry.class));
- return (T) ProxyHelper.createProxy(proxy);
+ injector, injector.getInstance(ServiceRegistryImpl.class));
+ return (T) Proxy.newProxyInstance(getClass().getClassLoader(), new
Class[] {interf}, proxy);
+ //return (T) ProxyHelper.createProxy(proxy);
}
@Override
=======================================
---
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/ServiceRegistry.java
Wed Nov 17 11:30:36 2010
+++
/trunk/dependency-shot-dynamic/src/main/java/cx/ath/mancel01/dependencyshot/dynamic/ServiceRegistry.java
Thu Apr 7 09:13:25 2011
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 mathieu.
+ * Copyright 2011 mathieuancelin.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,114 +17,35 @@
package cx.ath.mancel01.dependencyshot.dynamic;
-import cx.ath.mancel01.dependencyshot.api.DSInjector;
-import cx.ath.mancel01.dependencyshot.exceptions.DSIllegalStateException;
-import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
/**
*
- * @author mathieu
+ * @author mathieuancelin
*/
-@Singleton
-public class ServiceRegistry {
-
- @Inject
- private DSInjector injector;
-
- private ConcurrentHashMap<Class<?>, ArrayList<Class<?>>> services =
- new ConcurrentHashMap<Class<?>, ArrayList<Class<?>>>();
-
- public void registerService(Class<?> from, Class<?> to) {
- if(!to.isAnnotationPresent(Dynamic.class)) {
- throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
- }
- services.putIfAbsent(from, new ArrayList<Class<?>>());
- ArrayList<Class<?>> classes = services.get(from);
- if (!classes.contains(to)) {
- synchronized(classes) {
- classes.add(to);
- }
- }
- }
-
- public void swap(Class<?> to) {
- if(!to.isAnnotationPresent(Dynamic.class)) {
- throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
- }
- for (Class from : to.getInterfaces()) {
- ArrayList<Class<?>> classes = services.get(from);
- if (classes.contains(to)) {
- int index = classes.indexOf(to);
- Class<?> old = classes.set(0, to);
- classes.set(index, old);
- } else {
- registerServiceAndSwap(from, to);
- }
- }
- }
-
- public void registerServiceAndSwap(Class<?> from, Class<?> to) {
- if(!to.isAnnotationPresent(Dynamic.class)) {
- throw new DSIllegalStateException("You can't register non
dynamic implementation for a service");
- }
- services.putIfAbsent(from, new ArrayList<Class<?>>());
- ArrayList<Class<?>> classes = services.get(from);
- if (!classes.contains(to)) {
- synchronized(classes) {
- classes.add(0, to);
- }
- }
- }
-
- public void unregisterService(Class<?> to) {
- for (Class from : to.getInterfaces()) {
- services.get(from).remove(to);
- }
- }
-
- public Class<?> getContract(Class<?> from) {
- return services.get(from).get(0);
- }
-
- public Object lookup(Class<?> from) {
- return
((InjectorImpl)injector).getUnscopedInstance(services.get(from).get(0));
- }
-
- public Collection<Object> multipleLookup(Class<?> from) {
- Collection<Object> objects = new ArrayList<Object>();
- for (Class<?> clazz : services.get(from)) {
-
objects.add(((InjectorImpl)injector).getUnscopedInstance(clazz));
- }
- return objects;
- }
-
- public Collection<Class<?>> multipleContractsLookup(Class<?> from) {
- return services.get(from);
- }
-
- public Map<Class<?>, ArrayList<Class<?>>> getServices() {
- return services;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- for (Class<?> clazz : services.keySet()) {
- builder.append(clazz.getName());
- List<Class<?>> classes = services.get(clazz);
- for (Class<?> service : classes) {
- builder.append("\n => ");
- builder.append(service.getName());
- }
- builder.append("\n\n");
- }
- return builder.toString();
+public interface ServiceRegistry {
+
+ public void addServiceListener(Class<?> listener);
+
+ public void removeServiceListener(Class<?> listener);
+
+ public <T> ServiceRegistration registerService(Class<T> clazz,
Class<? extends T> service);
+
+ public <T> ServiceRegistration registerService(Class<T> clazz, T
service);
+
+ public <T> ServiceRegistration registerService(Class<T>[] clazzes,
Class<? extends T> service);
+
+ public <T> ServiceRegistration registerService(Class<T>[] clazzes, T
service);
+
+ public <T> T getService(Class<T> contract);
+
+ public <T> Iterable<T> getServices(Class<T> contract);
+
+// public <T> boolean ungetService(T service);
+//
+// public <T> boolean ungetServices(Collection<T> services);
+//
+// public Map<Class<?>, Collection<Class<?>>> getAvailableServices();
+
+ public static interface ServiceRegistration {
+ void unregister();
}
}
=======================================
---
/trunk/dependency-shot-dynamic/src/test/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicTest.java
Wed Nov 24 14:50:03 2010
+++
/trunk/dependency-shot-dynamic/src/test/java/cx/ath/mancel01/dependencyshot/dynamic/DynamicTest.java
Thu Apr 7 09:13:25 2011
@@ -44,10 +44,10 @@
}
};
DSInjector injector = DependencyShot.getInjector(binder);
- ServiceRegistry registry =
injector.getInstance(ServiceRegistry.class);
+ ServiceRegistryImpl registry =
injector.getInstance(ServiceRegistryImpl.class);
- registry.registerService(PaymentService.class,
+ ServiceRegistry.ServiceRegistration reg =
registry.registerService(PaymentService.class,
PayPalServiceImpl.class);
registry.registerService(PaymentService.class,
CreditCardServiceImpl.class);
@@ -57,7 +57,7 @@
Assert.assertEquals(PAYPAL, service.pay(123));
- registry.unregisterService(PayPalServiceImpl.class);
+ reg.unregister();
Assert.assertEquals(CREDITCARD, service.pay(123));
registry.registerService(PaymentService.class,
=======================================
---
/trunk/dependency-shot-lifecycle/src/main/java/cx/ath/mancel01/dependencyshot/lifecycle/ManagedBeanHandler.java
Tue Feb 22 13:22:34 2011
+++
/trunk/dependency-shot-lifecycle/src/main/java/cx/ath/mancel01/dependencyshot/lifecycle/ManagedBeanHandler.java
Thu Apr 7 09:13:25 2011
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
-import javax.annotation.ManagedBean;
/**
* Handler for managedbean management.
@@ -44,7 +43,7 @@
}
public static boolean isManagedBean(Class clazz) {
- return clazz.isAnnotationPresent(ManagedBean.class);
+ return true;
}
@Override