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

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

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

JMX.isMXBeanInterface介绍

暂无

代码示例

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

  1. /**
  2. * Return the Java 6 MXBean interface exists for the given class, if any
  3. * (that is, an interface whose name ends with "MXBean" and/or
  4. * carries an appropriate MXBean annotation).
  5. * @param clazz the class to check
  6. * @return whether there is an MXBean interface for the given class
  7. */
  8. @Nullable
  9. public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  10. if (clazz == null || clazz.getSuperclass() == null) {
  11. return null;
  12. }
  13. Class<?>[] implementedInterfaces = clazz.getInterfaces();
  14. for (Class<?> iface : implementedInterfaces) {
  15. if (JMX.isMXBeanInterface(iface)) {
  16. return iface;
  17. }
  18. }
  19. return getMXBeanInterface(clazz.getSuperclass());
  20. }

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

  1. /**
  2. * Return the Java 6 MXBean interface exists for the given class, if any
  3. * (that is, an interface whose name ends with "MXBean" and/or
  4. * carries an appropriate MXBean annotation).
  5. * @param clazz the class to check
  6. * @return whether there is an MXBean interface for the given class
  7. */
  8. @Nullable
  9. public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  10. if (clazz == null || clazz.getSuperclass() == null) {
  11. return null;
  12. }
  13. Class<?>[] implementedInterfaces = clazz.getInterfaces();
  14. for (Class<?> iface : implementedInterfaces) {
  15. if (JMX.isMXBeanInterface(iface)) {
  16. return iface;
  17. }
  18. }
  19. return getMXBeanInterface(clazz.getSuperclass());
  20. }

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

  1. /**
  2. * Ensures that an {@code MBeanServerConnection} is configured and attempts
  3. * to detect a local connection if one is not supplied.
  4. */
  5. public void prepare() {
  6. synchronized (this.preparationMonitor) {
  7. if (this.server != null) {
  8. this.serverToUse = this.server;
  9. }
  10. else {
  11. this.serverToUse = null;
  12. this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
  13. }
  14. this.invocationHandler = null;
  15. if (this.useStrictCasing) {
  16. Assert.state(this.objectName != null, "No ObjectName set");
  17. // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
  18. this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
  19. (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
  20. }
  21. else {
  22. // Non-strict casing can only be achieved through custom invocation handling.
  23. // Only partial MXBean support available!
  24. retrieveMBeanInfo(this.serverToUse);
  25. }
  26. }
  27. }
  28. /**

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

  1. /**
  2. *
  3. * @param member member to which this MBean belongs
  4. * @param monitoringRegion corresponding MonitoringRegion
  5. * @param objectName ObjectName of the MBean
  6. * @param interfaceClass on which interface the proxy to be exposed
  7. */
  8. public static Object newProxyInstance(DistributedMember member,
  9. Region<String, Object> monitoringRegion, ObjectName objectName,
  10. FederationComponent federationComponent, Class interfaceClass)
  11. throws ClassNotFoundException, IntrospectionException {
  12. boolean isMXBean = JMX.isMXBeanInterface(interfaceClass);
  13. boolean notificationBroadcaster = federationComponent.isNotificationEmitter();
  14. InvocationHandler handler =
  15. new MBeanProxyInvocationHandler(member, objectName, monitoringRegion, isMXBean);
  16. Class[] interfaces;
  17. if (notificationBroadcaster) {
  18. interfaces =
  19. new Class[] {interfaceClass, ProxyInterface.class, NotificationBroadCasterProxy.class};
  20. } else {
  21. interfaces = new Class[] {interfaceClass, ProxyInterface.class};
  22. }
  23. Object proxy = Proxy.newProxyInstance(MBeanProxyInvocationHandler.class.getClassLoader(),
  24. interfaces, handler);
  25. return interfaceClass.cast(proxy);
  26. }

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

  1. @Override
  2. public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
  3. if (DistributedSystemMXBean.class.equals(mbeanInterface)
  4. && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  5. return mbeanInterface.cast(getDistributedSystemMXBean());
  6. } else if (JMX.isMXBeanInterface(mbeanInterface)) {
  7. return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  8. } else {
  9. return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  10. }
  11. }

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

  1. /**
  2. * Ensures that an {@code MBeanServerConnection} is configured and attempts
  3. * to detect a local connection if one is not supplied.
  4. */
  5. public void prepare() {
  6. synchronized (this.preparationMonitor) {
  7. if (this.server != null) {
  8. this.serverToUse = this.server;
  9. }
  10. else {
  11. this.serverToUse = null;
  12. this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
  13. }
  14. this.invocationHandler = null;
  15. if (this.useStrictCasing) {
  16. Assert.state(this.objectName != null, "No ObjectName set");
  17. // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
  18. this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
  19. (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
  20. }
  21. else {
  22. // Non-strict casing can only be achieved through custom invocation handling.
  23. // Only partial MXBean support available!
  24. retrieveMBeanInfo(this.serverToUse);
  25. }
  26. }
  27. }
  28. /**

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

  1. /**
  2. * @return the open type converter for a given type
  3. */
  4. private static OpenTypeConverter makeConverter(Type objType) throws OpenDataException {
  5. if (objType instanceof GenericArrayType) {
  6. Type componentType = ((GenericArrayType) objType).getGenericComponentType();
  7. return makeArrayOrCollectionConverter(objType, componentType);
  8. } else if (objType instanceof Class) {
  9. Class objClass = (Class<?>) objType;
  10. if (objClass.isEnum()) {
  11. return makeEnumConverter(objClass);
  12. } else if (objClass.isArray()) {
  13. Type componentType = objClass.getComponentType();
  14. return makeArrayOrCollectionConverter(objClass, componentType);
  15. } else if (JMX.isMXBeanInterface(objClass)) {
  16. throw openDataException("Cannot obtain array class",
  17. new ManagementException(" MXBean as an Return Type is not supported"));
  18. } else {
  19. return makeCompositeConverter(objClass);
  20. }
  21. } else if (objType instanceof ParameterizedType) {
  22. return makeParameterizedConverter((ParameterizedType) objType);
  23. } else
  24. throw new OpenDataException("Cannot map type: " + objType);
  25. }

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

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

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

  1. /**
  2. * Returns true if the supplied object implements an
  3. * interface that is an MXBean interface or a DynamicMBean interface.
  4. *
  5. * @param inObject the object instance that needs to be tested
  6. *
  7. * @return if the object is an MXBean.
  8. */
  9. private static boolean isMXBean(Object inObject) {
  10. for (Class<?> c = inObject.getClass();
  11. !Object.class.equals(c);
  12. c = c.getSuperclass()) {
  13. for(Class<?> intf: c.getInterfaces()) {
  14. if(JMX.isMXBeanInterface(intf) ||
  15. DynamicMBean.class.equals(intf)) {
  16. return true;
  17. }
  18. }
  19. }
  20. return false;
  21. }

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

  1. /**
  2. * Instance where the MBean interface is implemented by another object.
  3. *
  4. * @param <T>
  5. * Compiler check that <code>mbeanImplementation</code>
  6. * implements <code>mbeanInterface</code>
  7. * @param mbeanImplementation
  8. * The implementation of the MBean implementing the
  9. * <code>mbeanInterface</code>
  10. * @param mbeanInterface
  11. * The interface of the MBean
  12. * @throws NotCompliantMBeanException
  13. * If <code>mbeanImplementation</code> is not a JMX compliant
  14. * MBean
  15. */
  16. public <T> AnnotatedStandardMBean(T mbeanImplementation, Class<T> mbeanInterface) throws NotCompliantMBeanException {
  17. super(mbeanImplementation, mbeanInterface, JMX.isMXBeanInterface(mbeanInterface));
  18. this.mbeanImplementation = mbeanImplementation;
  19. this.mBeanRegistration = mbeanImplementation instanceof MBeanRegistration ? (MBeanRegistration) mbeanImplementation
  20. : NullMBeanRegistration.INSTANCE;
  21. this.beanInfoCache = new MBeanInfoCache(mbeanInterface);
  22. }

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

  1. /**
  2. * Return the Java 6 MXBean interface exists for the given class, if any
  3. * (that is, an interface whose name ends with "MXBean" and/or
  4. * carries an appropriate MXBean annotation).
  5. * @param clazz the class to check
  6. * @return whether there is an MXBean interface for the given class
  7. */
  8. @Nullable
  9. public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
  10. if (clazz == null || clazz.getSuperclass() == null) {
  11. return null;
  12. }
  13. Class<?>[] implementedInterfaces = clazz.getInterfaces();
  14. for (Class<?> iface : implementedInterfaces) {
  15. if (JMX.isMXBeanInterface(iface)) {
  16. return iface;
  17. }
  18. }
  19. return getMXBeanInterface(clazz.getSuperclass());
  20. }

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

  1. public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
  2. if (DistributedSystemMXBean.class.equals(mbeanInterface)
  3. && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  4. return mbeanInterface.cast(getDistributedSystemMXBean());
  5. }
  6. else if (JMX.isMXBeanInterface(mbeanInterface)) {
  7. return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  8. }
  9. else {
  10. return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  11. }
  12. }

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

  1. public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) {
  2. if (DistributedSystemMXBean.class.equals(mbeanInterface)
  3. && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) {
  4. return mbeanInterface.cast(getDistributedSystemMXBean());
  5. }
  6. else if (JMX.isMXBeanInterface(mbeanInterface)) {
  7. return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  8. }
  9. else {
  10. return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface);
  11. }
  12. }

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

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

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

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

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

  1. /**
  2. * Ensures that an {@code MBeanServerConnection} is configured and attempts
  3. * to detect a local connection if one is not supplied.
  4. */
  5. public void prepare() {
  6. synchronized (this.preparationMonitor) {
  7. if (this.server != null) {
  8. this.serverToUse = this.server;
  9. }
  10. else {
  11. this.serverToUse = null;
  12. this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
  13. }
  14. this.invocationHandler = null;
  15. if (this.useStrictCasing) {
  16. Assert.state(this.objectName != null, "No ObjectName set");
  17. // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
  18. this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
  19. (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
  20. }
  21. else {
  22. // Non-strict casing can only be achieved through custom invocation handling.
  23. // Only partial MXBean support available!
  24. retrieveMBeanInfo(this.serverToUse);
  25. }
  26. }
  27. }
  28. /**

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

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

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

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

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

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

相关文章