Search in sources :

Example 6 with InvalidTargetObjectTypeException

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;
}
Also used : JMException(javax.management.JMException) NotificationSenderAware(org.activiti.management.jmx.annotations.NotificationSenderAware) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean)

Example 7 with InvalidTargetObjectTypeException

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);
}
Also used : JMException(javax.management.JMException) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean)

Example 8 with InvalidTargetObjectTypeException

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);
                }
            }
        }
    }
}
Also used : ModelMBeanAssembler(org.apache.cxf.management.jmx.export.runtime.ModelMBeanAssembler) JMException(javax.management.JMException) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) MBeanServer(javax.management.MBeanServer) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ObjectName(javax.management.ObjectName)

Example 9 with InvalidTargetObjectTypeException

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;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ObjectName(javax.management.ObjectName) LinkedHashMap(java.util.LinkedHashMap) MBeanException(javax.management.MBeanException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Aggregations

InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)9 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)6 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)6 JMException (javax.management.JMException)5 MBeanException (javax.management.MBeanException)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ObjectName (javax.management.ObjectName)2 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 FileLogger (mx4j.log.FileLogger)2 Logger (mx4j.log.Logger)2 MBeanLogger (mx4j.log.MBeanLogger)2 ManagedInstance (org.apache.camel.api.management.ManagedInstance)2 NotificationSenderAware (org.apache.camel.api.management.NotificationSenderAware)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 MBeanServer (javax.management.MBeanServer)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ModelMBean (javax.management.modelmbean.ModelMBean)1 ModelMBeanInfoSupport (javax.management.modelmbean.ModelMBeanInfoSupport)1 NotificationSenderAware (org.activiti.management.jmx.annotations.NotificationSenderAware)1