javax.management.modelmbean.InvalidTargetObjectTypeException Java Examples

The following examples show how to use javax.management.modelmbean.InvalidTargetObjectTypeException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private Object resolveTargetObject(Descriptor descriptor) throws MBeanException
{
   Logger logger = getLogger();
   Object target = descriptor.getFieldValue("targetObject");
   if (logger.isEnabledFor(Logger.TRACE)) logger.trace("targetObject is: " + target);
   if (target == null)
   {
      target = getManagedResource();
   }
   else
   {
      String targetObjectType = (String)descriptor.getFieldValue("targetObjectType");
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("targetObjectType is: " + targetObjectType);
      if (targetObjectType == null)
      {
         // Not defined, assume object reference
         targetObjectType = OBJECT_RESOURCE_TYPE;
      }

      if (!isResourceTypeSupported(targetObjectType)) throw new MBeanException(new InvalidTargetObjectTypeException(targetObjectType));
   }
   return target;
}
 
Example #2
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private Object resolveTargetObject(Descriptor descriptor) throws MBeanException
{
   Logger logger = getLogger();
   Object target = descriptor.getFieldValue("targetObject");
   if (logger.isEnabledFor(Logger.TRACE)) logger.trace("targetObject is: " + target);
   if (target == null)
   {
      target = getManagedResource();
   }
   else
   {
      String targetObjectType = (String)descriptor.getFieldValue("targetObjectType");
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("targetObjectType is: " + targetObjectType);
      if (targetObjectType == null)
      {
         // Not defined, assume object reference
         targetObjectType = OBJECT_RESOURCE_TYPE;
      }

      if (!isResourceTypeSupported(targetObjectType)) throw new MBeanException(new InvalidTargetObjectTypeException(targetObjectType));
   }
   return target;
}
 
Example #3
Source File: InstrumentationManagerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #4
Source File: BaseCatalinaMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected T doGetManagedResource() throws MBeanException {
    try {
        @SuppressWarnings("unchecked")
        T resource = (T) getManagedResource();
        return resource;
    } catch (InstanceNotFoundException | RuntimeOperationsException |
            InvalidTargetObjectTypeException e) {
        throw new MBeanException(e);
    }
}
 
Example #5
Source File: RMEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
                }
            }
        }
    }
}
 
Example #6
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setManagedResource(Object resource, String resourceType) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
{
   if (resource == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_MANAGED_RESOURCE_CANNOT_BE_NULL.toLocalizedString()));
   if (!isResourceTypeSupported(resourceType)) throw new InvalidTargetObjectTypeException(resourceType);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Setting managed resource to be: " + resource);
   m_managedResource = resource;
}
 
Example #7
Source File: DefaultManagementMBeanAssembler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ModelMBean assemble(Object obj, ObjectName name) throws JMException {
    ModelMBeanInfo mbi = null;

    // use the default provided mbean which has been annotated with JMX annotations
    LOGGER.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;
}
 
Example #8
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setManagedResource(Object resource, String resourceType) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
{
   if (resource == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_MANAGED_RESOURCE_CANNOT_BE_NULL.toLocalizedString()));
   if (!isResourceTypeSupported(resourceType)) throw new InvalidTargetObjectTypeException(resourceType);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Setting managed resource to be: " + resource);
   m_managedResource = resource;
}
 
Example #9
Source File: SpringModelMBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Sets managed resource to expose and stores its {@link ClassLoader}.
 */
@Override
public void setManagedResource(Object managedResource, String managedResourceType)
		throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException {

	this.managedResourceClassLoader = managedResource.getClass().getClassLoader();
	super.setManagedResource(managedResource, managedResourceType);
}
 
Example #10
Source File: SpringModelMBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets managed resource to expose and stores its {@link ClassLoader}.
 */
@Override
public void setManagedResource(Object managedResource, String managedResourceType)
		throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException {

	this.managedResourceClassLoader = managedResource.getClass().getClassLoader();
	super.setManagedResource(managedResource, managedResourceType);
}
 
Example #11
Source File: DefaultManagementMBeanAssembler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: SpringModelMBean.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Sets managed resource to expose and stores its {@link ClassLoader}.
 */
@Override
public void setManagedResource(Object managedResource, String managedResourceType)
		throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException {

	this.managedResourceClassLoader = managedResource.getClass().getClassLoader();
	super.setManagedResource(managedResource, managedResourceType);
}
 
Example #13
Source File: SpringModelMBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Sets managed resource to expose and stores its {@link ClassLoader}.
 */
@Override
public void setManagedResource(Object managedResource, String managedResourceType)
		throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException {

	this.managedResourceClassLoader = managedResource.getClass().getClassLoader();
	super.setManagedResource(managedResource, managedResourceType);
}
 
Example #14
Source File: JmxBuilderModelMBean.java    From groovy with Apache License 2.0 4 votes vote down vote up
public JmxBuilderModelMBean(Object objectRef) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException {
    super.setManagedResource(objectRef, "ObjectReference");
}
 
Example #15
Source File: TestModelMBean.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException,
        InstanceNotFoundException, InvalidTargetObjectTypeException {
}
 
Example #16
Source File: BaseModelMBean.java    From tomcatsrc with Apache License 2.0 3 votes vote down vote up
/**
 * Get the instance handle of the object against which we execute
 * all methods in this ModelMBean management interface.
 *
 * @exception InstanceNotFoundException if the managed resource object
 *  cannot be found
 * @exception InvalidTargetObjectTypeException if the managed resource
 *  object is of the wrong type
 * @exception MBeanException if the initializer of the object throws
 *  an exception
 * @exception RuntimeOperationsException if the managed resource or the
 *  resource type is <code>null</code> or invalid
 */
public Object getManagedResource()
    throws InstanceNotFoundException, InvalidTargetObjectTypeException,
    MBeanException, RuntimeOperationsException {

    if (resource == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Managed resource is null"),
             "Managed resource is null");

    return resource;

}
 
Example #17
Source File: BaseModelMBean.java    From Tomcat7.0.67 with Apache License 2.0 3 votes vote down vote up
/**
 * Get the instance handle of the object against which we execute
 * all methods in this ModelMBean management interface.
 *
 * @exception InstanceNotFoundException if the managed resource object
 *  cannot be found
 * @exception InvalidTargetObjectTypeException if the managed resource
 *  object is of the wrong type
 * @exception MBeanException if the initializer of the object throws
 *  an exception
 * @exception RuntimeOperationsException if the managed resource or the
 *  resource type is <code>null</code> or invalid
 */
public Object getManagedResource()
    throws InstanceNotFoundException, InvalidTargetObjectTypeException,
    MBeanException, RuntimeOperationsException {

    if (resource == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Managed resource is null"),
             "Managed resource is null");

    return resource;

}
 
Example #18
Source File: BaseModelMBean.java    From Tomcat8-Source-Read with MIT License 3 votes vote down vote up
/**
 * Get the instance handle of the object against which we execute
 * all methods in this ModelMBean management interface.
 *
 * @return the backend managed object
 * @exception InstanceNotFoundException if the managed resource object
 *  cannot be found
 * @exception InvalidTargetObjectTypeException if the managed resource
 *  object is of the wrong type
 * @exception MBeanException if the initializer of the object throws
 *  an exception
 * @exception RuntimeOperationsException if the managed resource or the
 *  resource type is <code>null</code> or invalid
 */
public Object getManagedResource()
    throws InstanceNotFoundException, InvalidTargetObjectTypeException,
    MBeanException, RuntimeOperationsException {

    if (resource == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Managed resource is null"),
             "Managed resource is null");

    return resource;

}