pool.setName( poolMetaData.getName() );
pool.setDeferUntilRequested( poolMetaData.isDeferUntilRequested() );
RestartableRubyRuntimePool restartablePool = new RestartableRubyRuntimePool( pool );
RubyRuntimeFactoryPoolService service = new RubyRuntimeFactoryPoolService( restartablePool );
ServiceName name = CoreServices.runtimePoolName( unit, pool.getName() );
phaseContext.getServiceTarget().addService( name, service )
.addDependency( CoreServices.runtimeFactoryName( unit ), RubyRuntimeFactory.class, service.getRubyRuntimeFactoryInjector() )
.addDependency( CoreServices.appNamespaceContextSelector( unit ), NamespaceContextSelector.class, service.getNamespaceContextSelectorInjector() )
.install();
unit.addToAttachmentList( DeploymentNotifier.SERVICES_ATTACHMENT_KEY, name );
ServiceName startName = CoreServices.runtimeStartPoolName( unit, pool.getName() );
phaseContext.getServiceTarget().addService( startName, new RubyRuntimePoolStartService( pool ) )
.addDependency( name )
.setInitialMode( Mode.PASSIVE )
.install();
String mbeanName = ObjectNameFactory.create( "torquebox.pools", new Hashtable<String, String>() {
{
put( "app", rubyAppMetaData.getApplicationName() );
put( "name", poolMetaData.getName() );
}
} ).toString();
ServiceName mbeanServiceName = name.append( "mbean" );
MBeanRegistrationService<BasicRubyRuntimePoolMBean> mbeanService = new MBeanRegistrationService<BasicRubyRuntimePoolMBean>( mbeanName, mbeanServiceName );
phaseContext.getServiceTarget().addService( mbeanServiceName, mbeanService )
.addDependency( DependencyType.OPTIONAL, MBeanServerService.SERVICE_NAME, MBeanServer.class, mbeanService.getMBeanServerInjector() )
.addDependency( name, BasicRubyRuntimePoolMBean.class, mbeanService.getValueInjector() )
.setInitialMode( Mode.PASSIVE )
.install();
} else {
DefaultRubyRuntimePool pool = new DefaultRubyRuntimePool();
pool.setName( poolMetaData.getName() );
pool.setMinimumInstances( poolMetaData.getMinimumSize() );
pool.setMaximumInstances( poolMetaData.getMaximumSize() );
pool.setDeferUntilRequested( poolMetaData.isDeferUntilRequested() );
RestartableRubyRuntimePool restartablePool = new RestartableRubyRuntimePool( pool );
RubyRuntimeFactoryPoolService service = new RubyRuntimeFactoryPoolService( restartablePool );
ServiceName name = CoreServices.runtimePoolName( unit, pool.getName() );
phaseContext.getServiceTarget().addService( name, service )
.addDependency( CoreServices.runtimeFactoryName( unit ), RubyRuntimeFactory.class, service.getRubyRuntimeFactoryInjector() )
.addDependency( CoreServices.appNamespaceContextSelector( unit ), NamespaceContextSelector.class, service.getNamespaceContextSelectorInjector() )
.install();
unit.addToAttachmentList( DeploymentNotifier.SERVICES_ATTACHMENT_KEY, name );
phaseContext.getServiceTarget().addService( name.append( "START" ), new RubyRuntimePoolStartService( pool ) )