Class AbstractRspModule

java.lang.Object
com.google.inject.AbstractModule
com._1c.g5.wiring.AbstractServiceAwareModule
com.e1c.langtool.v8.dt.xtext.AbstractRspModule
All Implemented Interfaces:
com.google.inject.Module

public abstract class AbstractRspModule extends AbstractServiceAwareModule
Abstract Guice module with helper methods to bind services from OSGi service registry and Xtext resource service provider registry by language resource extension.

Clients may extend this class, implement AbstractServiceAwareModule.doConfigure(), and call the inherited methods with extended DSL, that allows to bind toService(...). Example of usage:

 public class MyModule extends AbstractRspModule
 {
     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"));

         // bind service from Resource Service provider registry by resource file extension name
         bindToRspService(IScopeProvider, "dslext");
     }
 }
 
See Also:
  • Constructor Details

    • AbstractRspModule

      public AbstractRspModule(org.osgi.framework.BundleContext context)
      Constructor of AbstractRspModule.
      Parameters:
      context - the parent bundle context, cannot be null
    • AbstractRspModule

      public AbstractRspModule(org.eclipse.core.runtime.Plugin bundle)
      Parameters:
      bundle - the parent bundle, cannot be null
  • Method Details

    • bindToRspService

      protected <T> com.google.inject.binder.ScopedBindingBuilder bindToRspService(Class<T> clazz, String fileExt)
      Bind service to RSP service.
      Type Parameters:
      T - the generic type of the service, cannot be null
      Parameters:
      clazz - the class object of the service to obtain form RSP registry, cannot be null
      fileExt - the language file extension of the Xtext resource, cannot be null
      Throws:
      IllegalStateException - if cannot find RSP for given language file extension or if serivce not found in RSP
      See Also:
      • Binder.bind(Class)