use of javax.management.modelmbean.InvalidTargetObjectTypeException in project Activiti by Activiti.
the class DefaultManagementMBeanAssembler method assemble.
public ModelMBean assemble(Object obj, ObjectName name) throws JMException {
ModelMBeanInfo mbi = null;
// use the default provided mbean which has been annotated with JMX
// annotations
LOG.trace("Assembling MBeanInfo for: {} from @ManagedResource object: {}", name, obj);
mbi = assembler.getMBeanInfo(obj, null, name.toString());
if (mbi == null) {
return null;
}
RequiredModelMBean mbean = new RequiredModelMBean(mbi);
try {
mbean.setManagedResource(obj, "ObjectReference");
} catch (InvalidTargetObjectTypeException e) {
throw new JMException(e.getMessage());
}
// Allows the managed object to send notifications
if (obj instanceof NotificationSenderAware) {
((NotificationSenderAware) obj).setNotificationSender(new NotificationSenderAdapter(mbean));
}
return mbean;
}
use of javax.management.modelmbean.InvalidTargetObjectTypeException in project cxf by apache.
the class InstrumentationManagerImpl method register.
private void register(Object obj, ObjectName name, ModelMBeanInfo mbi, boolean forceRegistration) throws JMException {
RequiredModelMBean rtMBean = (RequiredModelMBean) mbs.instantiate("javax.management.modelmbean.RequiredModelMBean");
rtMBean.setModelMBeanInfo(mbi);
try {
rtMBean.setManagedResource(obj, "ObjectReference");
} catch (InvalidTargetObjectTypeException itotex) {
throw new JMException(itotex.getMessage());
}
registerMBeanWithServer(rtMBean, persist(name), forceRegistration);
}
use of javax.management.modelmbean.InvalidTargetObjectTypeException in project cxf by apache.
the class RMEndpoint method initialise.
void initialise(RMConfiguration config, Conduit c, EndpointReferenceType r, org.apache.cxf.transport.Destination d, Message message) {
configuration = config;
conduit = c;
replyTo = r;
createServices();
createEndpoints(d);
setPolicies(message);
if (manager != null && manager.getBus() != null) {
managedEndpoint = new ManagedRMEndpoint(this);
instrumentationManager = manager.getBus().getExtension(InstrumentationManager.class);
if (instrumentationManager != null) {
ModelMBeanAssembler assembler = new ModelMBeanAssembler();
ModelMBeanInfo mbi = assembler.getModelMbeanInfo(managedEndpoint.getClass());
MBeanServer mbs = instrumentationManager.getMBeanServer();
if (mbs == null) {
LOG.log(Level.WARNING, "MBeanServer not available.");
} else {
try {
RequiredModelMBean rtMBean = (RequiredModelMBean) mbs.instantiate("javax.management.modelmbean.RequiredModelMBean");
rtMBean.setModelMBeanInfo(mbi);
try {
rtMBean.setManagedResource(managedEndpoint, "ObjectReference");
} catch (InvalidTargetObjectTypeException itotex) {
throw new JMException(itotex.getMessage());
}
ObjectName name = managedEndpoint.getObjectName();
instrumentationManager.register(rtMBean, name);
modelMBean = rtMBean;
} catch (JMException jmex) {
LOG.log(Level.WARNING, "Registering ManagedRMEndpoint failed.", jmex);
}
}
}
}
}
use of javax.management.modelmbean.InvalidTargetObjectTypeException in project kernel by exoplatform.
the class JMXManagementProvider method manage.
public Object manage(ManagedResource context) {
if (context == null) {
throw new IllegalArgumentException("The context cannot be null");
}
ExoModelMBean mbean = null;
try {
ExoMBeanInfoBuilder infoBuilder = new ExoMBeanInfoBuilder(context.getMetaData());
ModelMBeanInfo info = infoBuilder.build();
mbean = new ExoModelMBean(context, context.getResource(), info);
} catch (IllegalArgumentException e) {
LOG.warn("Could not create the ExoModelMBean for the class " + context.getResource() == null ? null : context.getResource().getClass(), e);
} catch (RuntimeOperationsException e) {
LOG.warn("Could not create the ExoModelMBean for the class " + context.getResource() == null ? null : context.getResource().getClass(), e);
} catch (InstanceNotFoundException e) {
LOG.warn("Could not create the ExoModelMBean for the class " + context.getResource() == null ? null : context.getResource().getClass(), e);
} catch (MBeanException e) {
LOG.warn("Could not create the ExoModelMBean for the class " + context.getResource() == null ? null : context.getResource().getClass(), e);
} catch (InvalidTargetObjectTypeException e) {
LOG.warn("Could not create the ExoModelMBean for the class " + context.getResource() == null ? null : context.getResource().getClass(), e);
}
//
if (mbean != null) {
ObjectName on = null;
PropertiesInfo oni = PropertiesInfo.resolve(context.getResource().getClass(), NameTemplate.class);
if (oni != null) {
try {
Map<String, String> foo = oni.resolve(context.getResource());
on = JMX.createObjectName("exo", foo);
} catch (MalformedObjectNameException e) {
LOG.warn("Could not create the ObjectName for the class " + context.getResource().getClass(), e);
}
}
if (on != null) {
// Merge with the container hierarchy context
try {
Map<String, String> props = new LinkedHashMap<String, String>();
// Merge scoping properties
List<MBeanScopingData> list = context.getScopingData(MBeanScopingData.class);
// Read in revert order because wee received list of parents in upward order
for (int i = list.size(); i > 0; i--) {
MBeanScopingData scopingData = list.get(i - 1);
props.putAll(scopingData);
}
// and a Hashtable<String, String> with Java 6.
for (Object o : on.getKeyPropertyList().entrySet()) {
Map.Entry entry = (Map.Entry) o;
String key = (String) entry.getKey();
String value = (String) entry.getValue();
props.put(key, value);
}
//
on = JMX.createObjectName(on.getDomain(), props);
//
attemptToRegister(on, mbean);
//
return on;
} catch (MalformedObjectNameException e) {
LOG.warn("Could not register the MBean for the class " + context.getResource().getClass(), e);
}
}
}
//
return null;
}
Aggregations