Sunday, October 30, 2011

Oracle SOA Suite – Getting the default version of the Composite


Oracle SOA Suite – Getting the default version of the Composite:

Sometimes it required to get the default version of the Composite. Below are the different approaches to get the default version of the composite in Oracle SOA Suite 11g or Oracle SOA Suite 12c

Through Ant Script:

Execute the below ant script, this will return the default version of the specified composite.
ant -f $ORACLE_HOME/bin/ant-sca-mgmt.xml getDefaultCompositeRevision -Dhost=nft-soa-vip1 -Dport=8004 -Duser=weblogic -DcompositeName=GetOpenCompositeInstances
$ORACLE_HOME – Where the SOA binary is installed.


Through EM Console:

1. Login to EM Console.
2. From the navigation pane, expand the farm and SOA folders then right click on soa-infra and then select Administration and System MBean browser.
3. Expand the folder Application Defined MBeans then oracle.soa.config then expand the Server folder. Expand CompositeLifecycleConfig folder and click on the soa-infra MBean.
4. Click on the Operations tab then click on the operation getDefaultComposite .



5. Enter the CompositeDN - partition name/composite name e.g default/Project value for that we have to get the default version and click on invoke button; this will provide the details about the default version of the composite.


Through JMX:

The below code snippet can be used to get the default version of the composite from JAVA.
Change the SOA server details and the composite details accordingly.

package getdefaultversion;

import java.util.Hashtable;
import java.util.Set;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import javax.naming.Context;

import oracle.fabric.composite.model.CompositeNameModel;

public class GetCompositeDefaultVersion {
//This method will return the default version of the specified Composite.
static MBeanServerConnection m_connection = null;

public static String getDefaultVersion() {
String jndiroot = "/jndi/";
String revision = null;

try {
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "xxxxx");
jndiProps.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");

JMXServiceURL serviceURL = new JMXServiceURL("t3","localhost",8000,jndiroot + "weblogic.management.mbeanservers.runtime");
JMXConnector m_connector =
JMXConnectorFactory.newJMXConnector(serviceURL, jndiProps);
m_connector.connect();
m_connection = m_connector.getMBeanServerConnection();
ObjectName compositeLifeCycleMBean = null;
Set queryResult =
m_connection.queryNames(new ObjectName("*:j2eeType=CompositeLifecycleConfig,*"),
null);
if (!queryResult.isEmpty()) {
compositeLifeCycleMBean =
(ObjectName)queryResult.iterator().next();
}
//CompositeDN - DomainName/CompositeName
String compositeDN = "default" + '/' + "GetDomainID";
revision =
getDefaultCompositeRevision(compositeLifeCycleMBean, compositeDN);
} catch (Exception e) {
e.printStackTrace();
}
return revision;
}

public static String getDefaultCompositeRevision(ObjectName compositeLifeCycleMBean,
String compositeDN) throws Exception {
String revision = null;
CompositeData deployedComposite =
(CompositeData)m_connection.invoke(compositeLifeCycleMBean,
"getDefaultComposite",
new Object[] { compositeDN },
new String[] { String.class.getName() });
if (deployedComposite != null) {
CompositeNameModel cm =
CompositeNameModel.parseDN((String)deployedComposite.get("DN"));
revision = cm.getRevision();
}
System.err.println("Default Revision...." + revision);
return revision;
}

public static void main(String[] args) {
getDefaultVersion();
}

}

Required Jar files -
$Oracle_Home\wlserver\server\lib\Wljmxclient.jar
$Oracle_Home\soa\soa\modules\oracle.soa.fabric_11.1.1\oracle.soa.fabric.jar

O/P - Default Revision....1.0


3 comments:

  1. Good Post Albin,I can see that you know the way to access composites from Java, I'm going to ask you a doubt, I'm finding the method to deploy/undeply composites via JMX, I've checked these API's but I only have found this MBean oracle.soa.config:Location=soa_server1,name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra with the operation removeCompositeForLabel, do you have any idea to perform this task? thanks in advance.

    ReplyDelete
  2. one of the useful link for getting the email notification in case default version of the composite is in retire state.
    http://soamagic.blogspot.de/

    ReplyDelete
  3. First of all, composite materials can expand the spectrum as far as material capabilities offered by industry. Often times, the goal of a composite material is to combine the unique advantages of two separate materials into one superior material which contains the unique advantages of each.
    1/4 inch plywood

    ReplyDelete