Package org.wicketstuff.osgi.inject
Class OsgiComponentInjector
- java.lang.Object
-
- org.apache.wicket.injection.Injector
-
- org.wicketstuff.osgi.inject.OsgiComponentInjector
-
- All Implemented Interfaces:
IComponentInstantiationListener
public class OsgiComponentInjector extends Injector implements IComponentInstantiationListener
A hook for injecting OSGi services into Wicket components. This class performs field injection for all component fields annotated by@javax.inject.Inject
by looking up a service of the required type from the OSGi service registry.To enable this mechanism, register the injection in your
Application.init()
method like this:getComponentInstantiationListeners().add(new OsgiComponentInjector());
By default, injected services are wrapped in a proxy to take care of class loading issues when deserializing a component from the page store. On serialization, the proxy replaces the wrapped service (which may not be serializable itself) by a serializable reference (its interface name, essentially). On deserialization, the proxy retrieves the matching service from the OSGi service registry.TODO Injection is not deterministic when there is more than one service of the required type. This class should be extended to disambiguate candidate services either by a
@Named
qualifier or by a dedicated qualifier taking service properties as parameters.- Author:
- Harald Wellmann
-
-
Constructor Summary
Constructors Constructor Description OsgiComponentInjector()
OsgiComponentInjector(boolean wrapInProxies)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
inject(Object object)
void
onInstantiation(Component component)
-
-
-
Method Detail
-
onInstantiation
public void onInstantiation(Component component)
- Specified by:
onInstantiation
in interfaceIComponentInstantiationListener
-
-