javax.management.JMX.isMXBeanInterface()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中javax.management.JMX.isMXBeanInterface()方法的一些代码示例,展示了JMX.isMXBeanInterface()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMX.isMXBeanInterface()方法的具体详情如下:
包路径:javax.management.JMX
类名称:JMX
方法名:isMXBeanInterface

JMX.isMXBeanInterface介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the Java 6 MXBean interface exists for the given class, if any
 * (that is, an interface whose name ends with "MXBean" and/or
 * carries an appropriate MXBean annotation).
 * @param clazz the class to check
 * @return whether there is an MXBean interface for the given class
 */
@Nullable
public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  if (clazz == null || clazz.getSuperclass() == null) {
    return null;
  }
  Class<?>[] implementedInterfaces = clazz.getInterfaces();
  for (Class<?> iface : implementedInterfaces) {
    if (JMX.isMXBeanInterface(iface)) {
      return iface;
    }
  }
  return getMXBeanInterface(clazz.getSuperclass());
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Return the Java 6 MXBean interface exists for the given class, if any
 * (that is, an interface whose name ends with "MXBean" and/or
 * carries an appropriate MXBean annotation).
 * @param clazz the class to check
 * @return whether there is an MXBean interface for the given class
 */
@Nullable
public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  if (clazz == null || clazz.getSuperclass() == null) {
    return null;
  }
  Class<?>[] implementedInterfaces = clazz.getInterfaces();
  for (Class<?> iface : implementedInterfaces) {
    if (JMX.isMXBeanInterface(iface)) {
      return iface;
    }
  }
  return getMXBeanInterface(clazz.getSuperclass());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Ensures that an {@code MBeanServerConnection} is configured and attempts
 * to detect a local connection if one is not supplied.
 */
public void prepare() {
  synchronized (this.preparationMonitor) {
    if (this.server != null) {
      this.serverToUse = this.server;
    }
    else {
      this.serverToUse = null;
      this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
    }
    this.invocationHandler = null;
    if (this.useStrictCasing) {
      Assert.state(this.objectName != null, "No ObjectName set");
      // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
      this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
          (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
    }
    else {
      // Non-strict casing can only be achieved through custom invocation handling.
      // Only partial MXBean support available!
      retrieveMBeanInfo(this.serverToUse);
    }
  }
}
/**

代码示例来源:origin: apache/geode

/**
 *
 * @param member member to which this MBean belongs
 * @param monitoringRegion corresponding MonitoringRegion
 * @param objectName ObjectName of the MBean
 * @param interfaceClass on which interface the proxy to be exposed
 */
public static Object newProxyInstance(DistributedMember member,
  Region<String, Object> monitoringRegion, ObjectName objectName,
  FederationComponent federationComponent, Class interfaceClass)
  throws ClassNotFoundException, IntrospectionException {
 boolean isMXBean = JMX.isMXBeanInterface(interfaceClass);
 boolean notificationBroadcaster = federationComponent.isNotificationEmitter();
 InvocationHandler handler =
   new MBeanProxyInvocationHandler(member, objectName, monitoringRegion, isMXBean);
 Class[] interfaces;
 if (notificationBroadcaster) {
  interfaces =
    new Class[] {interfaceClass, ProxyInterface.class, NotificationBroadCasterProxy.class};
 } else {
  interfaces = new Class[] {interfaceClass, ProxyInterface.class};
 }
 Object proxy = Proxy.newProxyInstance(MBeanProxyInvocationHandler.class.getClassLoader(),
   interfaces, handler);
 return interfaceClass.cast(proxy);
}

代码示例来源:origin: apache/geode

@Override
public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
 if (DistributedSystemMXBean.class.equals(mbeanInterface)
   && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  return mbeanInterface.cast(getDistributedSystemMXBean());
 } else if (JMX.isMXBeanInterface(mbeanInterface)) {
  return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 } else {
  return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 }
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Ensures that an {@code MBeanServerConnection} is configured and attempts
 * to detect a local connection if one is not supplied.
 */
public void prepare() {
  synchronized (this.preparationMonitor) {
    if (this.server != null) {
      this.serverToUse = this.server;
    }
    else {
      this.serverToUse = null;
      this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
    }
    this.invocationHandler = null;
    if (this.useStrictCasing) {
      Assert.state(this.objectName != null, "No ObjectName set");
      // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
      this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
          (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
    }
    else {
      // Non-strict casing can only be achieved through custom invocation handling.
      // Only partial MXBean support available!
      retrieveMBeanInfo(this.serverToUse);
    }
  }
}
/**

代码示例来源:origin: apache/geode

/**
 * @return the open type converter for a given type
 */
private static OpenTypeConverter makeConverter(Type objType) throws OpenDataException {
 if (objType instanceof GenericArrayType) {
  Type componentType = ((GenericArrayType) objType).getGenericComponentType();
  return makeArrayOrCollectionConverter(objType, componentType);
 } else if (objType instanceof Class) {
  Class objClass = (Class<?>) objType;
  if (objClass.isEnum()) {
   return makeEnumConverter(objClass);
  } else if (objClass.isArray()) {
   Type componentType = objClass.getComponentType();
   return makeArrayOrCollectionConverter(objClass, componentType);
  } else if (JMX.isMXBeanInterface(objClass)) {
   throw openDataException("Cannot obtain array class",
     new ManagementException(" MXBean as an Return Type is not supported"));
  } else {
   return makeCompositeConverter(objClass);
  }
 } else if (objType instanceof ParameterizedType) {
  return makeParameterizedConverter((ParameterizedType) objType);
 } else
  throw new OpenDataException("Cannot map type: " + objType);
}

代码示例来源:origin: apache/geode

} else {
 this.managerMemberObjectName = this.distributedSystemMXBeanProxy.getMemberObjectName();
 if (this.managerMemberObjectName == null || !JMX.isMXBeanInterface(MemberMXBean.class)) {
  logger.info("MemberMXBean with ObjectName " + this.managerMemberObjectName
    + " is not present on member with endpoints : " + endpoints);

代码示例来源:origin: org.marketcetera/core

/**
 * Returns true if the supplied object implements an
 * interface that is an MXBean interface or a DynamicMBean interface.
 *
 * @param inObject the object instance that needs to be tested
 *
 * @return if the object is an MXBean.
 */
private static boolean isMXBean(Object inObject) {
  for (Class<?> c = inObject.getClass();
     !Object.class.equals(c);
     c = c.getSuperclass()) {
    for(Class<?> intf: c.getInterfaces()) {
      if(JMX.isMXBeanInterface(intf) ||
          DynamicMBean.class.equals(intf)) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata-core

/**
 * Instance where the MBean interface is implemented by another object.
 * 
 * @param <T>
 *            Compiler check that <code>mbeanImplementation</code>
 *            implements <code>mbeanInterface</code>
 * @param mbeanImplementation
 *            The implementation of the MBean implementing the
 *            <code>mbeanInterface</code>
 * @param mbeanInterface
 *            The interface of the MBean
 * @throws NotCompliantMBeanException
 *             If <code>mbeanImplementation</code> is not a JMX compliant
 *             MBean
 */
public <T> AnnotatedStandardMBean(T mbeanImplementation, Class<T> mbeanInterface) throws NotCompliantMBeanException {
  super(mbeanImplementation, mbeanInterface, JMX.isMXBeanInterface(mbeanInterface));
  this.mbeanImplementation = mbeanImplementation;
  this.mBeanRegistration = mbeanImplementation instanceof MBeanRegistration ? (MBeanRegistration) mbeanImplementation
      : NullMBeanRegistration.INSTANCE;
  this.beanInfoCache = new MBeanInfoCache(mbeanInterface);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Return the Java 6 MXBean interface exists for the given class, if any
 * (that is, an interface whose name ends with "MXBean" and/or
 * carries an appropriate MXBean annotation).
 * @param clazz the class to check
 * @return whether there is an MXBean interface for the given class
 */
@Nullable
public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  if (clazz == null || clazz.getSuperclass() == null) {
    return null;
  }
  Class<?>[] implementedInterfaces = clazz.getInterfaces();
  for (Class<?> iface : implementedInterfaces) {
    if (JMX.isMXBeanInterface(iface)) {
      return iface;
    }
  }
  return getMXBeanInterface(clazz.getSuperclass());
}

代码示例来源:origin: org.apache.geode/gemfire-core

public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
 if (DistributedSystemMXBean.class.equals(mbeanInterface)
  && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  return mbeanInterface.cast(getDistributedSystemMXBean());
 }
 else if (JMX.isMXBeanInterface(mbeanInterface)) {
  return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 }
 else {
  return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 }
}

代码示例来源:origin: io.snappydata/gemfire-core

public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
 if (DistributedSystemMXBean.class.equals(mbeanInterface)
  && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  return mbeanInterface.cast(getDistributedSystemMXBean());
 }
 else if (JMX.isMXBeanInterface(mbeanInterface)) {
  return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 }
 else {
  return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
 }
}

代码示例来源:origin: io.snappydata/gemfire-core

Class interfaceClass) throws ClassNotFoundException,
 IntrospectionException {
boolean isMXBean = JMX.isMXBeanInterface(interfaceClass);
boolean notificationBroadcaster = ((FederationComponent) monitoringRegion
  .get(objectName.toString())).isNotificationEmitter();

代码示例来源:origin: org.apache.geode/gemfire-core

Class interfaceClass) throws ClassNotFoundException,
 IntrospectionException {
boolean isMXBean = JMX.isMXBeanInterface(interfaceClass);
boolean notificationBroadcaster = ((FederationComponent) monitoringRegion
  .get(objectName.toString())).isNotificationEmitter();

代码示例来源:origin: apache/servicemix-bundles

/**
 * Ensures that an {@code MBeanServerConnection} is configured and attempts
 * to detect a local connection if one is not supplied.
 */
public void prepare() {
  synchronized (this.preparationMonitor) {
    if (this.server != null) {
      this.serverToUse = this.server;
    }
    else {
      this.serverToUse = null;
      this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
    }
    this.invocationHandler = null;
    if (this.useStrictCasing) {
      Assert.state(this.objectName != null, "No ObjectName set");
      // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
      this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
          (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
    }
    else {
      // Non-strict casing can only be achieved through custom invocation handling.
      // Only partial MXBean support available!
      retrieveMBeanInfo(this.serverToUse);
    }
  }
}
/**

代码示例来源:origin: org.apache.geode/gemfire-core

this.distributedSystemMXBeanProxy = JMX.newMXBeanProxy(mbsc, MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
if (this.distributedSystemMXBeanProxy == null || !JMX.isMXBeanInterface(DistributedSystemMXBean.class)) {
 LogWrapper.getInstance().info("DistributedSystemMXBean is not present on member with endpoints : "+this.endpoints);
 connector.close();
 if (this.managerMemberObjectName == null || !JMX.isMXBeanInterface(MemberMXBean.class)) {
  LogWrapper.getInstance().info("MemberMXBean with ObjectName "+this.managerMemberObjectName+" is not present on member with endpoints : "+endpoints);
  this.connector.close();

代码示例来源:origin: io.snappydata/gemfire-core

this.distributedSystemMXBeanProxy = JMX.newMXBeanProxy(mbsc, MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
if (this.distributedSystemMXBeanProxy == null || !JMX.isMXBeanInterface(DistributedSystemMXBean.class)) {
 LogWrapper.getInstance().info("DistributedSystemMXBean is not present on member with endpoints : "+this.endpoints);
 connector.close();
 if (this.managerMemberObjectName == null || !JMX.isMXBeanInterface(MemberMXBean.class)) {
  LogWrapper.getInstance().info("MemberMXBean with ObjectName "+this.managerMemberObjectName+" is not present on member with endpoints : "+endpoints);
  this.connector.close();

代码示例来源:origin: org.apache.geode/gemfire-core

Type componentType = objClass.getComponentType();
 return makeArrayOrCollectionConverter(objClass, componentType);
} else if (JMX.isMXBeanInterface(objClass)) {
 throw openDataException("Cannot obtain array class",
   new ManagementException(

相关文章

微信公众号

最新文章

更多