Jython:
from java.util import Hashtable
from javax.management import ObjectName
from javax.management.remote import JMXConnectorFactory
from javax.management.remote import JMXServiceURL
serviceURL= JMXServiceURL("t3", "yourserver", 7001, "/jndi/weblogic.management.mbeanservers.runtime")
h= Hashtable()
h.put("java.naming.security.principal", "weblogic")
h.put("java.naming.security.credentials", "weblogic")
h.put("jmx.remote.protocol.provider.pkgs", "weblogic.management.remote")
connector = JMXConnectorFactory.connect(serviceURL, h)
connection = connector.getMBeanServerConnection()
mbeanName= "com.bea:ServerRuntime=atlasadmin,Name=TimerService,ApplicationRuntime=Worklist_Console,Type=EJBTimerRuntime,EJBComponentRuntime=weblogic-timer-control.jar,StatelessEJBRuntime=TimerService"
mbeanObjName= ObjectName(mbeanName)
operationName= "activateDisabledTimers"
paramTypes = jarray.array([], Class.forName("java.lang.String"))
paramValues= jarray.array([], Class.forName("java.lang.Object"))
result=connection.invoke(mbeanObjName, operationName, paramValues, paramTypes);
print result
Java
import java.util.Hashtable;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
class Test {
public static void main(String[] args) {
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL , "weblogic");
h.put(Context.SECURITY_CREDENTIALS, "weblogic");
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
try {
JMXServiceURL serviceURL= new JMXServiceURL("t3", "yourserver", 7001, "/jndi/weblogic.management.mbeanservers.runtime");
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
MBeanServerConnection connection = connector.getMBeanServerConnection();
String mbeanName= "com.bea:ServerRuntime=atlasadmin,Name=TimerService,ApplicationRuntime=Worklist_Console,Type=EJBTimerRuntime,EJBComponentRuntime=weblogic-timer-control.jar,StatelessEJBRuntime=TimerService";
ObjectName mbeanObjName= new ObjectName(mbeanName);
String operationName= "activateDisabledTimers";
String[] paramTypes= new String[] {};
Object[] paramValues= new Object[] {};
Object result=connection.invoke(mbeanObjName, operationName, paramValues, paramTypes);
System.out.println("result="+result);
} catch (Exception exc) {
exc.printStackTrace();
}
}
}
Thursday, December 31, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment