|
From: <nic...@uk...> - 2004-11-29 00:00:18
|
Hi,
With embedded JMX server in JDK1.5, it would be really nice if Java Service
Wrapper could auto-register its JMX bean (upon jdk1.5 detection).
This is especially so when using the WrapperStartStopApp and
WrapperSimpleApp integration methods.
Below is the code/config I have written to register JMX beans using the
WrapperStartStopApp integration means.
It would be much nicer if it was built into the wrapper itself - and
enabled via a wrapper.conf parameter
wrapper.jmx.enable=true
wrapper.jmx.name="wrapper:type=Java Service Wrapper Control"
Its a fantastic utility by the way. Documentation is excellent. Its
well-baked. It Just Works. ;-)
Cheers,
Nick
--------------- conf ---------------
wrapper.java.additional.2=-Dcom.sun.management.jmxremote
wrapper.java.additional.3=-Dcom.sun.management.jmxremote.port=4242
wrapper.java.additional.4=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.5=-Dcom.sun.management.jmxremote.ssl=false
wrapper.java.additional.6=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.7=-Dcom.sun.management.jmxremote.password.file=jmxremote.password
wrapper.java.additional.8=-Dwrapper.mbean.name="wrapper:type=Java Service
Wrapper Control"
--------------- code ---------------
public class WrapperStartStopWithJMXApp {
private static final String DEFAULT_WRAPPER_MBEAN_NAME =
"wrapper:type=Java Service Wrapper Control";
private static final String WRAPPER_BEAN_NAME_KEY =
"wrapper.mbean.name";
public static void main(String[] args) {
try {
Class.forName("javax.management.MBeanServer");
registerMbeans();
}
catch (ClassNotFoundException ignore) {
}
WrapperStartStopApp.main(args);
}
private static void registerMbeans() {
try {
System.out.println("JDK 1.5 detected, registering Java Service
Wrapper MBean");
WrapperManager managerBean = new WrapperManager();
ObjectName name = new ObjectName(getName());
MBeanServer server =
ManagementFactory.getPlatformMBeanServer();
server.registerMBean(managerBean, name);
}
catch (Exception e) {
System.err.println("Failed to register ServiceWrapper MBeans");
e.printStackTrace();
}
}
private static String getName() {
String name = System.getProperty(WRAPPER_BEAN_NAME_KEY);
if (name == null) {
System.out.println("Property \"" + WRAPPER_BEAN_NAME_KEY + "\"
not set. Using default : \"" + DEFAULT_WRAPPER_MBEAN_NAME + "\"");
name = DEFAULT_WRAPPER_MBEAN_NAME;
}
return name;
}
}
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
**********************************************************************************************
BNP Paribas Private Bank London Branch is authorised
by CECEI & AMF and is regulated by the Financial Services
Authority for the conduct of its investment business in the
United Kingdom.
BNP Paribas Securities Services London Branch is authorised
by CECEI & AMF and is regulated by the Financial Services
Authority for the conduct of its investment business in the
United Kingdom.
BNP Paribas Fund Services UK Limited is authorised and
regulated by the Financial Services Authority.
|