LayerBean layerBean = new LayerBean( layer, layerDescriptor );
ObjectName objectName = new ObjectName( "Qi4j:application=" + application.name() + ",layer=" + layer
.name() );
names.push( objectName );
RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, layerDescriptor.name(), LayerBean.class
.getName() ).
attribute( "uses", "Layer usages", String.class.getName(), "Other layers that this layer uses", "getUses", null )
.
operation( "restart", "Restart layer", String.class.getName(), MBeanOperationInfo.ACTION_INFO )
.
newModelMBean();
mbean.setManagedResource( layerBean, "ObjectReference" );
server.registerMBean( mbean, objectName );
mbeans.add( objectName );
}
else if( visited instanceof ModuleDescriptor )
{
ModuleDescriptor moduleDescriptor = (ModuleDescriptor) visited;
module = application.findModule( layer.name(), moduleDescriptor.name() );
ObjectName objectName = new ObjectName( names.peek()
.toString() + ",module=" + moduleDescriptor.name() );
names.push( objectName );
RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, moduleDescriptor.name(), moduleDescriptor
.getClass()
.getName() ).
attribute( "name", "Module name", String.class.getName(), "Name of module", "name", null ).
newModelMBean();
mbean.setManagedResource( moduleDescriptor, "ObjectReference" );
server.registerMBean( mbean, objectName );
mbeans.add( objectName );
}
else if( visited instanceof ServiceDescriptor )
{
ServiceDescriptor serviceDescriptor = (ServiceDescriptor) visited;
ObjectName objectName = new ObjectName( names.peek()
.toString() + ",class=Service,service=" + serviceDescriptor
.identity() );
RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, serviceDescriptor.identity(), ServiceBean.class
.getName() ).
attribute( "Id", "Service id", String.class.getName(), "Id of service", "getId", null ).
attribute( "Visibility", "Service visibility", String.class.getName(), "Visibility of service", "getVisibility", null )
.
attribute( "Type", "Service type", String.class.getName(), "Type of service", "getType", null )
.
attribute( "Active", "Service is active", Boolean.class.getName(), "Service is active", "isActive", null )
.
attribute( "Available", "Service is available", Boolean.class.getName(), "Service is available", "isAvailable", null )
.
operation( "restart", "Restart service", String.class.getName(), ModelMBeanOperationInfo.ACTION_INFO )
.
newModelMBean();
mbean.setManagedResource( new ServiceBean( serviceDescriptor, module ), "ObjectReference" );
server.registerMBean( mbean, objectName );
mbeans.add( objectName );
}
else if( visited instanceof ImportedServiceDescriptor )
{
ImportedServiceDescriptor importedServiceDescriptor = (ImportedServiceDescriptor) visited;
ObjectName objectName = new ObjectName( names.peek()
.toString() + ",class=Imported service,importedservice=" + importedServiceDescriptor
.identity() );
RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, importedServiceDescriptor.identity(), ImportedServiceBean.class
.getName() ).
attribute( "Id", "Service id", String.class.getName(), "Id of service", "getId", null ).
attribute( "Visibility", "Service visibility", String.class.getName(), "Visibility of service", "getVisibility", null )
.
attribute( "Type", "Service type", String.class.getName(), "Type of imported service", "getType", null )
.
newModelMBean();
mbean.setManagedResource( new ImportedServiceBean( importedServiceDescriptor ), "ObjectReference" );
server.registerMBean( mbean, objectName );
mbeans.add( objectName );
}