public class OsgiComponentInjector
extends org.apache.wicket.injection.Injector
implements org.apache.wicket.application.IComponentInstantiationListener
@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.
Constructor and Description |
---|
OsgiComponentInjector() |
OsgiComponentInjector(boolean wrapInProxies) |
Modifier and Type | Method and Description |
---|---|
void |
inject(Object object) |
void |
onInstantiation(org.apache.wicket.Component component) |
public OsgiComponentInjector()
public OsgiComponentInjector(boolean wrapInProxies)
public void inject(Object object)
inject
in class org.apache.wicket.injection.Injector
public void onInstantiation(org.apache.wicket.Component component)
onInstantiation
in interface org.apache.wicket.application.IComponentInstantiationListener
Copyright © 2015. All rights reserved.