Sunday, 23 December 2012

Oracle SOA Human Workflow


Oracle Workflow APIs provides three types of Task Service APIs:
1. Single Task Service:
This is used for programmatically setting the outcome of a single task. ITaskService interface exposes operations to perform actions viz. add/remove comments, withdraw or reassign tasks, etc. It internally uses the ITaskQueryService interface (discussed in next section) to fetch a specific task and then perform operations on it
2. Task Query Service
This is used for programmatically retrieving tasks, task details, etc. The ITaskQueryService interface exposes methods to fetch workflow-context from remote client object, retrieve tasks that match the specified task filter viz. task-number, task-id, etc.
3. Federated Task Service
This is used for programmatically fetching task details from multiple SOA runtime environments.
We first create an instance of TaskAuthenticationClient which can be used to get handle to the instances if ITaskQueryService and ITaskService. This class will abstract the underlying SOA APIs from the invoker classes. We will employ singleton design for this class as we want to restrict the object creation to a single instance.
We will now create a TaskServiceClient class. This class will hold the references of TaskAuthenticationClient, ITaskQueryService, ITaskService and the IWorkflowContext.
The code snippet below demonstrates the use of SOA API to
  • Fetch list of tasks based on a filter
  • Fetch task details based on task number
  • Fetch task history i.e. various versions of the task
  • Add comments to a task


For more information contact the blogger at:
piyush@piyush-agarwal.com
piyush.m.agarwal@gmail.com  

Sunday, 16 December 2012

Oracle SOA Composite Locator Client

This post throws light on the SOA Facade APIs available as part of Oracle's SOA Suite Infra Management Java API. It exposes operations for attributes viz. composites, components, services and references. All these can be programmatically managed via a powerful store of Java API which serves as an effective alternative to managing the same attributes with Oracle's Enterprise Manager (EM).

 The Locator interface exposes methods that serve as important entry point into the facade API. LocatorFactory can be used to fetch direct connection to the Locator.

Steps involved are:
  • Set the JNDI properties 
 
jndiProps = new Hashtable<String, String>();
jndiProps.put(Context.PROVIDER_URL, "jndi_server_provider");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "context_class_name");
jndiProps.put(Context.SECURITY_PRINCIPAL, "user_name");
jndiProps.put(Context.SECURITY_CREDENTIALS, "password");
 
    • Use LocatorFacotry to get instance of Locator
     
    Locator locator = LocatorFactory.createLocator(jndiProps);
     
    • Locator API can be used to retrieve various SCA artifacts viz. composites, components, references, etc. The example shown here demonstrates ‘direct binding’ which enables clients to directly invoke composite services thus bypassing the overhead of XML conversion required for web service bindings. Some of the most commonly used Locator API methods are mentioned below: 
    We first create an instance of CompositeLocatorAuthenticationClient. We will employ singleton design to avoid multiple instances creation.  

     
    public class CompositeLocatorAuthenticationClient {
     private Locator locator = null;
     private Hashtable jndiProps = null;
     private static CompositeLocatorAuthenticationClient soaAuthenticationClient; 
     
     private CompositeLocatorAuthenticationClient() {
      jndiProps = new Hashtable();
      jndiProps.put(Context.PROVIDER_URL, ""));
      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "");
      jndiProps.put(Context.SECURITY_PRINCIPAL, "");
      jndiProps.put(Context.SECURITY_CREDENTIALS, "");
      jndiProps.put("dedicated.connection", "true");
     }
    
     public static CompositeLocatorAuthenticationClient 
         getAuthenticationClient() {
      if (soaAuthenticationClient == null) {
       soaAuthenticationClient = new 
        CompositeLocatorAuthenticationClient();
      }
      return soaAuthenticationClient;
     }
    
     public Locator getLocator(Hashtable aJndiProps) throws 
        CompositeLocatorAuthenticationException {
      if (locator == null) {
       try {
        locator = LocatorFactory.createLocator(aJndiProps != null ? 
            aJndiProps : jndiProps);
       } catch (Exception exception) {
        throw new CompositeLocatorAuthenticationException("Error in 
            creating new instance for Locator", exception);
       }
      }
      return locator;
     }
    
     public Locator getLocator() throws 
         CompositeLocatorAuthenticationException {
      return getLocator(null);
     }
    }
     

    We will now create a client class that would use the above CompositeLocatorClient to communicate with the underlying SOA infrastructure. The client below demonstrates how the audit-trail for a composite instance can be fetched using SOA APIs
     
    public class CompositeLocatorClient {
    
     private CompositeLocatorAuthenticationClient 
        authenticationClient = null;
    
     public CompositeLocatorClient() {
      super();
      authenticationClient = CompositeLocatorAuthenticationClient.
          getAuthenticationClient();
     }
    
     public Object getAuditTrail(String compositeName, String instanceTitle) 
         throws CompositeLocatorClientException {
      CompositeInstanceFilter compositeInstanceFilter = 
          new CompositeInstanceFilter();
      compositeInstanceFilter.setCompositeName(compositeName);
      compositeInstanceFilter.setTitle(instanceTitle);
      return getAuditTrail(compositeInstanceFilter);
     }
    
     private Object getAuditTrail(CompositeInstanceFilter compositeInstanceFilter) 
         throws CompositeLocatorClientException {
      try {
       Locator locator = this.authenticationClient.getLocator();
       List compositeInstances = locator.
           getCompositeInstances(
           compositeInstanceFilter);
       if (compositeInstances != null && compositeInstances.size() > 0) {
        String ecid = compositeInstances.get(0).getECID();
        return locator.getAuditTrail(ecid);
       }
       return null;
      } catch (Exception exception) {
       throw new CompositeLocatorClientException(exception);
      }
     }
    }
     

    For more information contact the blogger at:
    piyush@piyush-agarwal.com
    piyush.m.agarwal@gmail.com

    Sunday, 9 December 2012

    Introduction to SOA Composite Architecture

     
    Service Component Architecture (SCA) is an Assembly Model Technology which encompasses a wide range of disparate technologies, running on different platforms, using different languages, yet working towards a common goal through environment neutrality. SCA comprises of basic artifact called Composite which internally comprises of one or more Components that contain the business functionality.
    SCA Artifacts:
    1. Composite: This is the Unit of Deployment in SCA environment and exposes functionality to the outside world as Service. These services can be accesses remotely via HTTP/HTTPS, SOAP, JCA Adapter, etc.
    2. Component: Each composite comprises of one or many components. The component holds the business functionality and is the Unit of Orchestration in SCA environment.
    3. Entry Point: Components offer their functionality as service to other components within same composite or to outside world via Entry Point.
    4. Reference: Components may depend on services by other components, this dependency is called Reference.
    5. Wire: The linkage information between services and references is represented by Wires.
    SCA represents a set of services that satisfy business functionality and is controlled or orchestrated form a single point of contact. As an example let us consider case of an Insurance Company, where each micro-functionality can be represented as a component viz. Underwriting, Policy Admin Service, Claim, etc. These components are interwoven on an SCA platform to help satisfy the all-encompassing business requirement.
    clip_image001
    SOA Composite Architecture

    SCA grosses hierarchy componentization to a whole new level. An SCA System can comprise of multiple composites, each composite contains multiple components which are implemented in Java or BPEL or PHP, etc. Thus we can say the nested model supported by SCA is arbitrarily deep and recursive. 
    SCA provides a Policy Framework to look into non-functional requirements which impacts the artifacts deployed on the SCA System throughout its lifecycle, for instance:
    • Quality Of Service (QoS)
    • Security
    • Lifecycle Management
    • Monitoring
    Vendors like IBM, Oracle employ SCA models to compose applications that follow Service Oriented Architecture (SOA) principles. These SOA Composites can be created, managed and orchestrated via respective SOA Suite interfaces.

    For more information contact the blogger at:
    piyush@piyush-agarwal.com
    piyush.m.agarwal@gmail.com