Package com._1c.g5.wiring
Class AbstractServiceAwareModule
- java.lang.Object
-
- com.google.inject.AbstractModule
-
- com._1c.g5.wiring.AbstractServiceAwareModule
-
- All Implemented Interfaces:
com.google.inject.Module
public abstract class AbstractServiceAwareModule extends com.google.inject.AbstractModule
Abstract Guice module with helper methods to bind services from OSGi service registry.Clients may extend this class, implement
doConfigure()
, and call the inherited methods with extended DSL, that allows to bindtoService(...)
. Example of usage:public class MyModule extends AbstractServiceAwareModule { public MyModule(BundleContext context) { super(context); } @Override protected void doConfigure() { // bind plug-in internal local services bind(IInternalService.class).to(InternalService.class).in(Singleton.class); bind(IOtherInternalService.class).to(OtherInternalService.class); // bind neccessary imported OSGi services bind(IPublicService.class).toService(); bind(IPublicQualifiedService.class).annotatedWith(Names.named("MdImplementation")) .toService(IPublicQualifiedService.class, ServiceProperties.named("MdImplementation")); } }
- See Also:
AbstractModule
,ServiceProperties
-
-
Constructor Summary
Constructors Constructor Description AbstractServiceAwareModule(org.eclipse.core.runtime.Plugin bundle)
Constructor ofAbstractServiceAwareModule
.AbstractServiceAwareModule(org.osgi.framework.BundleContext context)
Constructor ofAbstractServiceAwareModule
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> IServiceAwareLinkedBindingBuilder<T>
bind(com.google.inject.Key<T> key)
protected <T> IServiceAwareAnnotatedBindingBuilder<T>
bind(com.google.inject.TypeLiteral<T> typeLiteral)
protected <T> IServiceAwareAnnotatedBindingBuilder<T>
bind(Class<T> clazz)
protected void
configure()
protected abstract void
doConfigure()
Configures aBinder
via the exposed methods.-
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bindConstant, binder, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
-
-
-
Constructor Detail
-
AbstractServiceAwareModule
public AbstractServiceAwareModule(org.eclipse.core.runtime.Plugin bundle)
Constructor ofAbstractServiceAwareModule
.- Parameters:
bundle
- the parent bundle, cannot benull
-
AbstractServiceAwareModule
public AbstractServiceAwareModule(org.osgi.framework.BundleContext context)
Constructor ofAbstractServiceAwareModule
.- Parameters:
context
- the parent bundle context, cannot benull
-
-
Method Detail
-
configure
protected void configure()
- Specified by:
configure
in classcom.google.inject.AbstractModule
-
bind
protected <T> IServiceAwareLinkedBindingBuilder<T> bind(com.google.inject.Key<T> key)
- Overrides:
bind
in classcom.google.inject.AbstractModule
-
bind
protected <T> IServiceAwareAnnotatedBindingBuilder<T> bind(com.google.inject.TypeLiteral<T> typeLiteral)
- Overrides:
bind
in classcom.google.inject.AbstractModule
-
bind
protected <T> IServiceAwareAnnotatedBindingBuilder<T> bind(Class<T> clazz)
- Overrides:
bind
in classcom.google.inject.AbstractModule
-
doConfigure
protected abstract void doConfigure()
Configures aBinder
via the exposed methods.Clienst may use methods of
AbstractModule
and extra methods ofAbstractServiceAwareModule
DSL to bind imported OSGi services.
-
-