|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -18,19 +18,20 @@ package org.springframework.context.annotation; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import javax.management.MBeanServer; |
|
|
|
import javax.management.MBeanServer; |
|
|
|
|
|
|
|
import javax.naming.NamingException; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.beans.factory.BeanFactoryAware; |
|
|
|
import org.springframework.beans.factory.BeanFactoryAware; |
|
|
|
import org.springframework.beans.factory.FactoryBean; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
|
import org.springframework.context.EnvironmentAware; |
|
|
|
import org.springframework.context.EnvironmentAware; |
|
|
|
import org.springframework.core.annotation.AnnotationAttributes; |
|
|
|
import org.springframework.core.annotation.AnnotationAttributes; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
|
|
|
|
import org.springframework.jmx.MBeanServerNotFoundException; |
|
|
|
import org.springframework.jmx.export.annotation.AnnotationMBeanExporter; |
|
|
|
import org.springframework.jmx.export.annotation.AnnotationMBeanExporter; |
|
|
|
import org.springframework.jmx.support.RegistrationPolicy; |
|
|
|
import org.springframework.jmx.support.RegistrationPolicy; |
|
|
|
import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean; |
|
|
|
import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean; |
|
|
|
import org.springframework.jndi.JndiObjectFactoryBean; |
|
|
|
import org.springframework.jndi.JndiLocatorDelegate; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
@ -119,21 +120,26 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static enum SpecificPlatform { |
|
|
|
public static enum SpecificPlatform { |
|
|
|
|
|
|
|
|
|
|
|
WEBLOGIC("weblogic.management.Helper") { |
|
|
|
WEBLOGIC("weblogic.management.Helper") { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public FactoryBean<?> getMBeanServerFactory() { |
|
|
|
public MBeanServer getMBeanServer() { |
|
|
|
JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); |
|
|
|
try { |
|
|
|
factory.setJndiName("java:comp/env/jmx/runtime"); |
|
|
|
return new JndiLocatorDelegate().lookup("java:comp/env/jmx/runtime", MBeanServer.class); |
|
|
|
return factory; |
|
|
|
} |
|
|
|
|
|
|
|
catch (NamingException ex) { |
|
|
|
|
|
|
|
throw new MBeanServerNotFoundException("Failed to retrieve WebLogic MBeanServer from JNDI", ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
WEBSPHERE("com.ibm.websphere.management.AdminServiceFactory") { |
|
|
|
WEBSPHERE("com.ibm.websphere.management.AdminServiceFactory") { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public FactoryBean<MBeanServer> getMBeanServerFactory() { |
|
|
|
public MBeanServer getMBeanServer() { |
|
|
|
return new WebSphereMBeanServerFactoryBean(); |
|
|
|
WebSphereMBeanServerFactoryBean fb = new WebSphereMBeanServerFactoryBean(); |
|
|
|
|
|
|
|
fb.afterPropertiesSet(); |
|
|
|
|
|
|
|
return fb.getObject(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -143,19 +149,7 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, |
|
|
|
this.identifyingClass = identifyingClass; |
|
|
|
this.identifyingClass = identifyingClass; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MBeanServer getMBeanServer() { |
|
|
|
public abstract MBeanServer getMBeanServer(); |
|
|
|
Object server; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
server = getMBeanServerFactory().getObject(); |
|
|
|
|
|
|
|
Assert.isInstanceOf(MBeanServer.class, server); |
|
|
|
|
|
|
|
return (MBeanServer) server; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) { |
|
|
|
|
|
|
|
throw new IllegalStateException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract FactoryBean<?> getMBeanServerFactory(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static SpecificPlatform get() { |
|
|
|
public static SpecificPlatform get() { |
|
|
|
ClassLoader classLoader = MBeanExportConfiguration.class.getClassLoader(); |
|
|
|
ClassLoader classLoader = MBeanExportConfiguration.class.getClassLoader(); |
|
|
|
|