Discussion:
wat is WebSphere Java management API equivalent for wsadmin's AdminTask ??
(too old to reply)
v***@in.ibm.com
2009-06-05 06:49:36 UTC
Permalink
I tried to use the java management APIs of the websphere application server to complete some administration tasks. one of the tasks was to create a service integration bus. In JACL/Jython we used the wasadmin operation

+$AdminTask createSIBus $busName+

In trying to convert this piece to a java function using the websphere java management APIs, i tried the below two methods which did not work. *i want to know which class/package is the WebSphere Java Management API substitute for wsadmin's AdminTask.*

h4. Method 1
In this method i used the AdminOperations Mbean to invoke the createSIBus operation. I tried it eventhough I was aware that AdminOperations MBean doesnt support that operation. As expected it failed :)
{code}
javax.management.ObjectName on = new javax.management.ObjectName
("*:*,type=AdminOperations,process=server1");

Set objectNameSet= adminClient.queryNames(on, null);

if(objectNameSet != null) {
Iterator i = objectNameSet.iterator();
while (i.hasNext()) {
System.out.println("in here");
on = (ObjectName)i.next();
System.out.println(on);
}
}

String signature[] = new String[]{"java.lang.String","java.lang.String"};
Object params[] = new Object[] {busName, busDesc};

adminClient.invoke(on, "createSIBus", params, signature);
{code}

h4. Method 2

This was a more hopeful try by using Node object. This again was a failure. I also tried using server object and failed too.
{code}
ObjectName parent = configService.resolve(session, "Node="+"rfidic-5Node02")[0];
String signature[] = new String[]{"java.lang.String","java.lang.String"};
Object params[] = new Object[] {busName, busDesc};

adminClient.invoke(parent, "createSIBus", params, signature);
{code}
SJC
2009-06-05 15:53:22 UTC
Permalink
h4. wsadmin to Java package mapping

Start with

AdminTask = com.ibm.websphere.management.cmdframework
AdminConfig = com.ibm.websphere.management.configservice
AdminApp = com.ibm.websphere.management.application
AdminControl = com.ibm.websphere.management and javax.management (JMX)

h4. Creating an SIBus in Java

public static void createBus(Session session, String cellName, String busName) throws Exception{

CommandMgr commandMgr = CommandMgr.getCommandMgr();
AdminCommand cmd = commandMgr.createCommand("createSIBus");
cmd.setConfigSession(session);

cmd.setParameter("bus", busName);
cmd.setParameter("description", description);

cmd.execute();

CommandResult result = cmd.getCommandResult();
if (!result.isSuccessful())
throw new AdminException(result.getException());

}
v***@in.ibm.com
2009-06-12 05:48:20 UTC
Permalink
thanks SJC for your post...it helped me a lot...
r***@gmail.com
2009-06-12 13:14:35 UTC
Permalink
Hi SJC,

I'm an Intermediate scripter, where I can write very small scripts using JACL..Now I want to step ahead and want to learn some advanced scripting..Could you please tell me the resources where I can start some advanced scripting using JMX api's...like the one you have written for creating the SIB...


Thanks in advance,

Kris

Loading...