Skip to main content

Manipulating Oracle Gateway Entity Store with gateway SDK

Oracle Enterprise Gateway (OEG) is built in gateway product from company Vordel to simplify and secure SOA deployments. OEG replaces Oracle web service manager functionality for SOA development. In real life, most of all time we have a lot of services to registered in OWSM or in OEG. Even more, it was not possible to migrate registered services from one node to another on OWSM. When we got plan to migrate from OWSM to OEG, our main aim was to register web services automatically through API. I was very happy, when found OEG provides some SDK to working with registry. Here is the first attempt to working with OEG SDK. We will use maven to build our project. OEG entity store consolidate all the entities and objects uses in the repository, for example all the registered services and policies. Through Entity store you can add, update and delete any entity. In OTN you can find one tutorial to develop a custom policy through OEG SDK. OEG also provide entity explorer to working with entity store, %OEG_HOME%\Win32\bin\esexplorer.bat First we will install all the necessary libraries on maven local repository.
set OEG_HOME=c:/OEG/gateway/system

call mvn install:install-file -DgroupId=com.vordel -DartifactId=client -Dversion=1.0 -Dfile=%OEG_HOME%/lib/client.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=com.vordel -DartifactId=common -Dversion=1.0 -Dfile=%OEG_HOME%/lib/common.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=com.vordel -DartifactId=entityStore -Dversion=1.0 -Dfile=%OEG_HOME%/lib/entityStore.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.axis -DartifactId=axis -Dversion=1.0 -Dfile=%OEG_HOME%/lib/modules/axis.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=commons-discovery -Dversion=0.2 -Dfile=%OEG_HOME%/lib/modules/commons-discovery-0.2.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=commons-logging -Dversion=1.0.4 -Dfile=%OEG_HOME%/lib/modules/commons-logging-1.0.4.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=javax.xml.rpc -DartifactId=jaxrpc -Dversion=1.0 -Dfile=%OEG_HOME%/lib/modules/jaxrpc.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=javax.wsdl -DartifactId=javax.wsdl_api -Dversion=1.6.2 -Dfile=%OEG_HOME%/lib/plugins/javax.wsdl_api_1.6.2.jar -Dpackaging=jar -DgeneratePom=true
rem add also Win32\lib\vjni.lib in your classpath
After running the above script, we will got all the libraries on our maven local repository. For working correctly, we also have to add vjni.dll file on our classpath. For windows we can do it through PATH variable, for linux platform we can use LD_LIBRARY_PATH. Next we have to create a maven project and add all the dependencies on it as follows:
<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>client</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>common</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>entityStore</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.axis</groupId>
      <artifactId>axis</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-discovery</artifactId>
      <version>0.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.0.4</version>
    </dependency>
    <dependency>
      <groupId>javax.xml.rpc</groupId>
      <artifactId>jaxrpc</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>javax.wsdl</groupId>
      <artifactId>javax.wsdl_api</artifactId>
      <version>1.6.2</version>
    </dependency>
  </dependencies>
Now we are ready to write some code and manipulate with OEG entity store. Here is our some pseudo code to manipulate entity.
public class EntityStoreFactory {
    private EntityStoreFactory(){};
 
    public static EntityStore getEntityStore(final String URL, final String userName, final String password) throws EntityStoreException{
        com.vordel.es.EntityStoreFactory efs = com.vordel.es.EntityStoreFactory.getInstance();
        efs.registerForURL(URL, com.vordel.es.provider.soap.client.SOAPStore.class, new ArrayList<string>(2){{add(userName); add(password);}});
        return efs.getEntityStoreForURL(URL);
    }
}
For testing purpose we are using SOAP provider to connect, but it's possible to use another type of provide such as LDAP, DB e.t.c. You can find the configuration file for the entity store factory in the following place %OEG_HOME%\gateway\system\conf\esproviders.xml .Even you can initialize provider as follows^
efs.initializeProviders(new FileInputStream("%OEG_HOME%\\enterprisegateway\\system\\conf\\esproviders.xml"));
through getEntityStore we can get the entityStore and ready to manipulate entity.
public class AddEntity {
    private static Properties props = new Properties();
    static{
        props.put("javax.xml.rpc.security.auth.username","admin");
        props.put("javax.xml.rpc.security.auth.password","changeme");
    }

    public static void main(String[] args) {
        final String url = "http://localhost:8090/configuration/policies";

        System.out.println("Test Vordel ES api");
        EntityStore es = null;
        try {
            es = EntityStoreFactory.getEntityStore(url,"admin","changeme");
            es.connect(url, props);
            // test connection
            ESPK rootESPK =  es.getRootPK();
            System.out.println("Root:"+ rootESPK.toString());
            /** Get the example webservice entity for simplicity, assume we have one web service registered **/
            // get the web services
            ESPK espkBRs = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1668"); // added through service manager http://www.webservicex.net/stockquote.asmx?WSDL
            com.vordel.es.Entity entBrs = es.getEntity(espkBRs);
            // add test entity
            ESPK parentPK = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:147");
            com.vordel.es.Entity newEntity = new com.vordel.es.Entity(entBrs.getType()); // webservice type
            // add more fields
            // add parent key
            newEntity.setStringField("name", "testby-api");
            Value primaryWsdlValue = new Value();
            newEntity.setReferenceField("primaryWSDL", new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1670"));

            ESPK newAddEspk = es.addEntity(parentPK, newEntity);
            System.out.println("NewEspk:"+ newAddEspk);
            // add more element on it - ex wsdl
            EntityType wsdlEType = new EntityTypeImpl(es, "");
            com.vordel.es.Entity wsdlEntity = new com.vordel.es.Entity(wsdlEType);
            wsdlEntity.setStringField("uri", "http://localhost:9000/StockQuote?WSDL");
            wsdlEntity.setStringField("wsdl", "http://localhost:9000/StockQuote?WSDL");
            es.addEntity(newAddEspk, wsdlEntity);
            // add Generated circuits
            // get Circuite container for example
            ESPK parentCircuiteCPK = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1655");
            com.vordel.es.Entity newCCType = new com.vordel.es.Entity(es.getEntity(parentCircuiteCPK).getType()); // Contained type
            ESPK newCCForTest = es.addEntity(parentCircuiteCPK, newCCType);
            // add filter circuit
        } catch (EntityStoreException e) {
            e.printStackTrace();
        } finally {
            if(es!=null){
                try {
                    es.disconnect();
                } catch (EntityStoreException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Now we can use entity explorer to check our newly created web service entity.
Our newly created web service is not fully configured yet, we have to add circuit policy on it. Next post will describe how to add circuit policy briefly. Happy coding))

Comments

Popular posts from this blog

8 things every developer should know about the Apache Ignite caching

Any technology, no matter how advanced it is, will not be able to solve your problems if you implement it improperly. Caching, precisely when it comes to the use of a distributed caching, can only accelerate your application with the proper use and configurations of it. From this point of view, Apache Ignite is no different, and there are a few steps to consider before using it in the production environment. In this article, we describe various technics that can help you to plan and adequately use of Apache Ignite as cutting-edge caching technology. Do proper capacity planning before using Ignite cluster. Do paperwork for understanding the size of the cache, number of CPUs or how many JVMs will be required. Let’s assume that you are using Hibernate as an ORM in 10 application servers and wish to use Ignite as an L2 cache. Calculate the total memory usages and the number of Ignite nodes you have to need for maintaining your SLA. An incorrect number of the Ignite nodes can become a b...

Analyse with ANT - a sonar way

After the Javaone conference in Moscow, i have found some free hours to play with Sonar . Here is a quick steps to start analyzing with ANT projects. Sonar provides Analyze with ANT document to play around with ANT, i have just modify some parts. Here is it. 1) Download the Sonar Ant Task and put it in your ${ANT_HOME}/lib directory 2) Modify your ANT build.xml as follows: <?xml version = '1.0' encoding = 'windows-1251'?> <project name="abc" default="build" basedir="."> <!-- Define the Sonar task if this hasn't been done in a common script --> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath path="E:\java\ant\1.8\apache-ant-1.8.0\lib" /> </taskdef> <!-- Out-of-the-box those parameters are optional --> <property name="sonar.jdbc.url" value="jdbc:oracle:thin:@xyz/sirius.xyz" /> <property na...

Quick start with In memory Data Grid, Apache Ignite

UP1: For complete quick start guide, see also the sample chapter of the book "High performance in-memory computing with Apache Ignite" here . Even you can find the sample examples from the GitHub repository . IMDG or In memory data grid is not an in-memory relational database, an NoSQL database or a relational database. It is a different breed of software datastore. The data model is distributed across many servers in a single location or across multiple locations. This distribution is known as a data fabric. This distributed model is known as a ‘shared nothing’ architecture. IMDG has following characteristics: All servers can be active in each site. All data is stored in the RAM of the servers. Servers can be added or removed non-disruptively, to increase the amount of RAM available. The data model is non-relational and is object-based.  Distributed applications written on the platform independent language. The data fabric is resilient, allowing non-disruptive au...