use of org.exoplatform.management.spi.ManagementProvider in project kernel by exoplatform.
the class ManageableComponentAdapterMT method register.
protected void register(Container co, Object instance) {
if (registered.compareAndSet(false, true)) {
do {
if (co instanceof ManageableContainer) {
break;
}
} while ((co = co.getSuccessor()) != null);
if (co instanceof ManageableContainer) {
ManageableContainer container = (ManageableContainer) co;
if (container.managementContext != null) {
// Register the instance against the management context
if (LOG.isDebugEnabled())
LOG.debug("==> add " + instance + " to a mbean server");
container.managementContext.register(instance);
// Register if it is a management provider
if (instance instanceof ManagementProvider) {
ManagementProvider provider = (ManagementProvider) instance;
container.addProvider(provider);
}
}
}
}
}
use of org.exoplatform.management.spi.ManagementProvider in project kernel by exoplatform.
the class ManageableComponentAdapter method register.
protected void register(Container co, Object instance) {
if (registered.compareAndSet(false, true)) {
do {
if (co instanceof ManageableContainer) {
break;
}
} while ((co = co.getSuccessor()) != null);
if (co instanceof ManageableContainer) {
ManageableContainer container = (ManageableContainer) co;
if (container.managementContext != null) {
// Register the instance against the management context
if (LOG.isDebugEnabled())
LOG.debug("==> add " + instance + " to a mbean server");
container.managementContext.register(instance);
// Register if it is a management provider
if (instance instanceof ManagementProvider) {
ManagementProvider provider = (ManagementProvider) instance;
container.addProvider(provider);
}
}
}
}
}
use of org.exoplatform.management.spi.ManagementProvider in project kernel by exoplatform.
the class ManageableContainer method registerComponentInstance.
/**
* {@inheritDoc}
*/
public <T> ComponentAdapter<T> registerComponentInstance(Object componentKey, T componentInstance) throws ContainerException {
ComponentAdapter<T> adapter = super.registerComponentInstance(componentKey, componentInstance);
if (managementContext != null) {
managementContext.register(componentInstance);
// Register if it is a management provider
if (componentInstance instanceof ManagementProvider) {
ManagementProvider provider = (ManagementProvider) componentInstance;
addProvider(provider);
}
}
return adapter;
}
use of org.exoplatform.management.spi.ManagementProvider in project kernel by exoplatform.
the class ManagementContextImpl method register.
public void register(Object o) {
Object resource = null;
// Apply managed by annotation
ManagedBy managedBy = o.getClass().getAnnotation(ManagedBy.class);
if (managedBy != null) {
try {
Class<?> managedByClass = managedBy.value();
Constructor<?> blah = managedByClass.getConstructor(o.getClass());
resource = blah.newInstance(o);
} catch (NoSuchMethodException e) {
LOG.error(e.getLocalizedMessage(), e);
} catch (InstantiationException e) {
LOG.error(e.getLocalizedMessage(), e);
} catch (IllegalAccessException e) {
LOG.error(e.getLocalizedMessage(), e);
} catch (InvocationTargetException e) {
LOG.error(e.getLocalizedMessage(), e);
}
} else {
resource = o;
}
//
if (resource != null) {
MetaDataBuilder builder = new MetaDataBuilder(resource.getClass());
if (builder.isBuildable()) {
ManagedTypeMetaData metaData = builder.build();
//
ManagementContextImpl managementContext;
if (resource instanceof Container) {
managementContext = (ManagementContextImpl) ((Container) resource).getManagementContext();
} else {
managementContext = new ManagementContextImpl(this, resource, metaData);
}
//
if (registrations.containsKey(resource)) {
LOG.debug("The component " + resource + " has already been registered");
return;
} else {
registrations.put(resource, managementContext);
}
//
ManageableContainer container = findContainer();
// Install for all the providers related
for (ManagementProvider provider : container.getProviders()) {
Object name = provider.manage(managementContext);
if (name != null) {
managementContext.managedSet.put(provider, name);
}
}
// Allow for more resource management
if (resource instanceof ManagementAware) {
((ManagementAware) resource).setContext(managementContext);
}
}
}
}
Aggregations