Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.errai.as7support;
 

Author(s):
Mike Brock <cbrock@redhat.com>
Christian Sadilek <csadilek@redhat.com>
public class ErraiServiceActivator implements ServiceActivator {
  private Logger log = LoggerFactory.getLogger(ErraiServiceActivator.class);
  public void activate(ServiceActivatorContext serviceActivatorContextthrows ServiceRegistryException {
    .info("JBoss AS 7 Service Activator initialized ...");
    final ServiceName bindingServiceName = .
            .append("ErraiService");
    final BinderService binderService = new BinderService("ErraiService");
    ServiceBuilder<ManagedReferenceFactorybuilder = serviceActivatorContext.getServiceTarget()
            .addService(bindingServiceNamebinderService);
            binderService.getNamingStoreInjector());
      private volatile ErraiService service;
      private void init() {
         = Guice.createInjector(new AbstractModule() {
          public void configure() {
            bind(MessageBus.class).to(ServerMessageBusImpl.class);
            bind(ServerMessageBus.class).to(ServerMessageBusImpl.class);
            bind(ErraiService.class).to(ErraiServiceImpl.class);
            bind(ErraiServiceConfigurator.class).to(ErraiServiceConfiguratorImpl.class);
          }
        }).getInstance(ErraiService.class);
      }
      @Override
      public synchronized ManagedReference getReference() {
        if ( == null) {
          init();
        }
        return new ManagedReference() {
          @Override
          public void release() {
            .stopService();
          }
          @Override
          public Object getInstance() {
            return ;
          }
        };
      }
    });
    try {
      builder.install();
    }
    catch (DuplicateServiceException dse) {
      .info("Service already registered.");
    }
    .info("bound errai service to JNDI context: java:global/ErraiService");
  }
New to GrepCode? Check out our FAQ X