Thursday, December 30, 2010

Book Review: "Oracle SOA Suite 11g R1 Developer's Guide"


What's SOA

Commentators have provided multiple definitions of SOA (the acronym for Service-oriented architecture) and there is no consensus on what it really means and provides. However, a system based on a SOA is usually guided by a set of design principles for its development, maintenance, and usage:
  • Service loose coupling
  • Service reusability
  • Service discoverability
  • Service composability
  • etc
An SOA-based solution will package functionality as a suite of interoperable services that can be used within multiple separate systems from several business domains. In this article, we will review a book named Oracle SOA Suite 11g R1 Developer's Guide, in which it addresses Oracle SOA Suite (that is Oracle's SOA-based solution).

Lego Metaphor

Very often "LEGO block" analogy gets applied to SOA[4]. Conceptually, a services orientation turns your entire application portfolio into technological LEGO blocks that can be assembled in any number of configurations to meet changing business needs. But unlike a single LEGO block, which can only be used in one design at a time, a 'service' can be used by several applications at once.

Introduction of the Book

Oracle Fusion Applications (the re-implementation of Oracle's E-Business Suite, Siebel, PeopleSoft and JD Edwards Enterprise as a single) is probably the largest SOA-based application being built today and it has the Oracle SOA platform at its core.

As stated by the authors (Antony Reynolds and Matt Wright), this book is to provide developers and technical architects with a practical guide to using and applying the Oracle SOA Suite in the delivery of real world SOA-based applications.

This book holds 720 pages in its content and is the final product of multiple years' writing effort. The whole book is written to address a key question:
  • What is the best way to combine/use all of these different components (or services) to implement a real world SOA solution?
However, there isn't a single simple answer, but rather you have many choices, each with their own set of advantages and disadvantages.

Oracle SOA Suite

Out of the box, Oracle SOA Suite provides an assortment of lego pieces (or base set) that can be used to build your composite applications. This set allows you to complete a scene or setting or to enlarge existing structures as what you would discover in the Lego Land. It includes the following components, but not limited to:
  • Adapters
    • Take an existing piece of functionality and "adapt" it to the SOA world, so that it can interact with other SOA Suite components
      • Allows the SOA Suite to treat non-web service interfaces as though they have a web service interface
    • Adapters are implemented and accessed using JCA (Java Connector Architecture)
    • OOTB, SOA Suite includes the following technology adapters:
      • File adapter
      • FTP adapter
      • Database adapter
      • JMS adapter
      • MQ adapter
      • AQ adapter
      • Socket adapter
      • BAM adapter
  • BAM (Business Activity Monitoring)
    • Gives business users a real-time view into how business processes are performing
  • BPEL
    • Assembles services to build composite services and long-running business processes
    • Includes support for the BPEL 1.1 standard, with most constructs from BPEL 2.0 also being supported
    • Includes a Human Workflow component that provides support for human interaction with processes
  • CEP (Complex Event Processor)
    • Supports time-based and series-based analysis of data
  • OSB (Oracle Service Bus; formerly AquaLogic Service Bus)
    • Provides routing and transformation
    • Only executes on the Oracle WebLogic platform in the current release
  • Oracle B2B
    • Supports the management of service agreements or contracts
  • Oracle Mediator (formerly Oracle Enterprise Service Bus)
    • Provides routing and transformation
    • Executes on other non-Oracle platforms too
  • Rules Engine
    • Supports business decision-making
    • Provides a declarative mechanism for defining business rules externally to your application
Among them, BPEL, OSB and Oracle Mediator are "Lego Baseplates" which you can use to assembly large structures. These components allow multiple services to be linked to each other as part of a single managed process. They all can be used to support service orchestration in your composite application.

As shown in the diagram, but not listed on the list, there is a security component. Security is a characteristic of services, yet to implement it effectively requires a centralized policy store coupled with distributed policy enforcement at the service boundaries. In Oracle SOA Suite, Enterprise Manager serves as a policy manager for security, providing a centralized service for policy enforcement points to obtain their policies.

Not shown on the diagram, there is a component named EDN (
i.e., Event Delivery Network) which is a key new component in Oracle SOA Suite 11 g that provides a declarative way to generate and consume business events within the SOA infrastructure. EDN uses JMS to deliver events from subscribers to publishers, but the configuration of JMS queues and topics and any associated filters is hidden from users of the EDN service.

Finally, SCA (Service Component Architecture) in SOA Suite is a standard that is used to define how services in a composite application are connected. It also defines how a service may interact with other services. An SCA Assembly in SOA Suite is described in a file named composite.xml.

What This Book Has Provided

JDeveloper is the primary development tool for building composite applications and for deployment into the SOA Suite. Using it, most of the creation, testing, integration, deployment and maintenance of composite applications can be done declaratively without much coding effort.

In the first part of the book, it provides detailed descriptions of various components (except B2B and CEP) as listed in "Oracle SOA Suite" section and provides step-by-step instructions on creating sample applications using these core components.

In the second part of the book,an online auction site (oBay) is used to illustrate how to use the various components of the SOA Suite to implement a real-world SOA-based solution.

Authors of the book took you through the process of defining a high level SOA blueprint, outlining some of the objectives and considerations you should take into account when developing an SOA-based architecture. Along the way they've addressed a number of questions or issues, as well as highlighting particular areas of interest in its overall design.

Some of the issues addressed in the book are listed below:
  • How to virtualize services
  • How to create loosely-coupled services
  • How to to avoid an overly-fragmented solution
  • How to monitor and process service events
  • How to handle system and business errors
  • How to recover from system and business errors using compensation
  • How to test, integrate, deploy, and maintain the SOA solution
  • How to provide support for human interaction with processes
  • How to create processes and applications from existing services
  • How to use policies to secure and administer SOA applications
  • How to design XML schemas and service contracts for improved agility, reuse, and interoperability
  • How to implement validation within a service using XSD validation, Schematron, and Business Rules, as well as within the service
  • How to avoid clients of the service having to deal with the specifics of the services state management

Summary

To create SOA-based solutions, it needs different kinds of thinking and approaches. Therefore, we need guidance for their best practices and good design patterns. We also need a "hands on" guide to harness and apply this technology.

This book has provided both. It offers a good coverage of both SOA theories and hands-on instructions. Antony and Matt were just the right people to create such content, each having many years hands-on experience of enabling Oracle SOA Suite implementations for customers and partners, as well as a close working relationship with Oracle's SOA engineering and product management teams.

As forworded by David Schaffer, he believes that this book will help developers realize their goals with the Oracle SOA Suite, helping them increase productivity, avoid common pitfalls, and improve ROI through more scalable, agile, and re-usable implementations. I cannot agree more.

References

  1. Learning To Speak Lego
  2. Oracle SOA Suite 11g R1 Developer's Guide
  3. Service-oriented architecture
  4. Why are we building 'enterprise' SOAs with 'LEGO blocks'?
  5. Oracle SOA Suite, Business Process Management Suite, and Web Services Documentation
  6. SOA Suite Documentation (in a zip file)
  7. Oracle SOA Suite 10g Documentation
  8. Oracle SOA Suite 11g Documentation
  9. Oracle Fusion Middleware 11g Software Downloads
  10. Official Oracle SOA Suite 11g Samples
  11. Oracle® Fusion Middleware Performance and Tuning Guide 11g Release 1 (11.1.1)
  12. Automating Testing of SOA Composite Applications (Oracle SOA Suite 11.1.1.7)
  13. Oracle® Fusion Middleware Enterprise Deployment Guide for Oracle SOA Suite 11g Release 1 (11.1.1)
  14. Oracle Unveils Oracle SOA Suite 12c
  15. Typical Memory, File Descriptors, and Processes Required for an Oracle SOA Suite Enterprise Deployment (12c 12.1.3)

Saturday, December 18, 2010

How to Create Oracle ADF BC Services (2)

This article is a continued writing from the previous how-to article. Here we will demonstrate how to create an ADF BC service using Create Business Components from Tables wizard.

Step 1: Create a New Fusion Web Application (ADF)

  • Open the New Gallery wizard and choose Fusion Web Application (ADF) [File > New > General > Applications > Fusion Web Application (ADF)]
  • In the Create Fusion Web Application (ADF) wizard, specify your application name (e.g., EmployeeWS2)
    • Specify "oracle.apps" to be your Default Package name
  • Click Finish.

Step 2: Creating a Database Connection[8]

  • Open the Create Database Connection dialog [File > New > General > Connections > Database Connection] .
  • Select Application Resources if it is not selected as the Create Connection In option.
  • Enter a name for the connection, select the connection type, and enter the username and password (use scott/tiger because we're going to use EMP table in SCOTT schema)
  • Click Test Connection to confirm that you can connect.
  • Click OK if the connection was successful.

Step 3: Create Business Components from Tables

When you create an entity object from an existing table, first JDeveloper interrogates the data dictionary to infer the following information: the primary and unique key attributes, the SQL and Java data types of each attribute based on those of the underlying column, etc.
JDeveloper then creates the XML component definition file that represents its declarative settings and saves it in the directory that corresponds to the name of its package. This XML file contains the name of the table, the names and data types of each entity attribute, and the column name for each attribute.
  • In the Application Navigator, select the Model project and launch the Create Business Components from Tables wizard [File > New > Business Tier > ADF Business Components > Business Components from Tables].

  • In the Initialize Business Components Project dialog which opens before the wizard, confirm that the database connection you created is the current selection and click OK.
  • On step 1 of the Create Business Components from Tables wizard, Entity Objects, enter EMP% in Name Filter, click Query to populate the Available list.
  • Select EMP table from the Available list and shuttle it to the Selected list to create default business components based on it. Then click Next.

  • On step 2, Updatable View Objects, select business component, EmpView(Emp), from the Available list and shuttle it to the Selected list. Then click Next.

  • On step 3, Read-Only View Objects, skip it.
  • On step 4, Application Module, click Finish.
    • Each ADFbc service needs to have a backing application module. The view object instances in the application module can be published as SDOs.
  • Click Save All to save your work.

Step 4: Edit the View Object

  • In the Application Navigator, double-click EmpView in the Model project to open it in the view object editor.
  • Select the Attributes tab to display all the attributes in the EmpView view object.
  • In the attributes table, select attribute Empno and edit it. Make it a key by checking Key Attribute.

  • In the attributes table, select attribute RowID and delete it (see previous how-to article for explanation)

  • Click Save All to save your work.

Step 5: Edit the Entity Object

  • In the Application Navigator, double-click Emp entity object in the Model project to open it in the entity object editor.
  • Select the Attributes tab to display all the attributes in the Emp entity object.
  • In the attributes table, select attribute Empno and edit it. Make it a primary key by checking Primary Key.

  • In the attributes table, select attribute RowID and delete it.
  • Click Save All to save your work.

Test the Application in the Business Component Tester

  • In the Application Navigator, right-click AppModuleAM and choose Run.
  • In the Oracle Business Component Browser, double-click EmpView1.
  • Jot down the Empno (i.e., 7369) shown in the diagram. You need this information in the test step below (i.e., step 7)
  • Click '>' icon to navigate to the next record.

Step 6: Publish Application Module as Web Service

  • In the Application Navigator, double-click the AppModule.
  • In the Application Module Editor, select Service Interface tab to open the Service Interface page.
  • In the Service Interface page, select the '+' icon to enable support for service interface.
  • Use the Create Service Interface wizard to configure the options you want.
    • Click twice to skip Step 1 and 2 (we use default settings).
    • On the Service View Instances page, select EmpView1 and shuttle it over to the Selected list, and enable Create, Delete, Update, and GetByKey in the Basic Operations section. Then click Finish.
  • You should be able to see the following files are generated under AppModule ->serviceInterface:
    • AppModuleServiceImpl.java
    • AppModuleService.java
    • AppModuleService.wsdl
    • AppModuleService.xsd

Step 7: Test ADFbc Service

  • In the Application Navigator, right-click the AppModuleServiceImpl.java in the serviceInterface folder and select Run.
  • Select Target URL (i.e., http://localhost:7101/EmployeeWS2-Model-context-root/AppModuleService) in the Running:DefaultServer Log window and click on it.
  • Test ADF BC Service using HTTP Analyzer.

Possible Improvements and Other Use Cases

An application module can expose its standard CRUD methods of view objects to web service clients without requiring any custom Java code. When used without customization, your component is completely defined by its XML component definition and it will be fully functional without custom Java code or even a Java class file for the component. If you have no need to extend the built-in functionality of a component in ADF Business Components, and no need to write any custom code to handle its built-in events, you can use the component in this XML-only fashion. However, sometimes you do need to write custom methods and expose them as service methods. For example, your custom methods can:
  • Configure view object properties to query the correct data to display
  • Iterate over view object rows to return an aggregate calculation
  • Perform any kind of multistep procedural logic with one or more view objects
In the next step, we will show sayHello as our custom method for simplicity.

Customizing an Application Module with Service Methods

To add a custom service method to your application module, you must first enable a custom Java class for it. To generate a Java file for your application module class:
  1. In the Application Navigator, double-click the application module.
  2. In the overview editor, click the Java navigation tab.
  3. On the Java Classes page, click Edit Java Classes (i.e., pencil icon).
  4. In the Select Java Options dialog, select Generate Application Module Class.
  5. Click OK and click Save All button.

To add sayHello service method to Employee Service and publish it to the service interface:
  1. In the Application Navigator, double-click the AppModuleImpl.java.
  2. Add the following code snippets at the bottom of the file:
     public String sayHello(String name) {
    return "Hi " + name;
    }
  3. Click Save to save changes.
  4. In the Application Navigator, double-click the application module.
  5. In the overview editor, click the Service Interface navigation tab.
  6. On the Service Interface page, click Edit Service Interface Custom Methods (i.e. pencil icon).
  7. On the Service Custom Methods dialog, shuttle sayHello(Strig):String from the Available list to the Selected list. Click OK.
  8. Click Save All to save your work.
  9. Use Step 8 above to test it.

Creating Multiple Entity Objects and Associations

To create a single entity object, you can use Create Entity Object wizard. However, if you need to create multiple entity objects and associations from existing tables, you use the Create Business Components from Tables wizard. See Section 4 "Creating a Business Domain Layer Using Entity Objects" in [4] for more details.
The Create Business Components from Tables wizard makes it easy to quickly generate many business components at the same time. In practice, this does not mean that you should use it to immediately create entity objects for every table in your database schema just because it is possible to do so. If your application requires all of the tables, then that strategy might be appropriate. But because you can use the wizard whenever needed, you should create the entity objects for the tables that you know will be involved in the application.
Section 9.4 "Defining Nested Application Modules" in [4] describes a use case-driven design approach for your business services that can assist you in understanding which entity objects are required to support your application's business logic needs. You can always add more entity objects later as necessary.

Generic Application Template

Notice that we've created our application using Fusion Web Application (ADF) template. Two projects have been created for us: Model and ViewController. However, if you don't plan to create UI components using ViewController project, you might be better off using "Generic Application" template.

In this case, you need to select ADF Business Components from the list of available technologies in step 2 of Create Generic Application wizard and shuffle it to the right as shown below:
This will create an application with an empty project preconfgured for you to create your ADF-BC Components and ADF-BC services.
References
  1. ADF Business Components
  2. Open SOA
  3. Oracle Application Development Framework
  4. Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1)
  5. Oracle JDeveloper
  6. Service Data Objects Home
  7. Web Services Description Language (WSDL) 1.1
  8. Database Connections in JDeveloper 11
  9. Open Source sample applications for Oracle Fusion Middleware technology

How to Create Oracle ADF BC Services

Introduction
The Oracle Application Development Framework (Oracle ADF) is an end-to-end application framework that builds on Java Platform, Enterprise Edition (Java EE) standards and open-source technologies to simplify and accelerate implementing service-oriented applications.
Using Oracle JDeveloper 11g and Oracle ADF framework in tandem, you implement business services and publish them as web services using a declarative, component-based approach that allows you to focus on application-specific business logic instead of low-level application "plumbing" code. In other words, creating, testing, and deploying data-centric web services in Oracle ADF is extremely easy and requires no web services specific knowledge or coding on your part.
Oracle ADF Business Components (BC) will be the main source of data access and business logic in Fusion applications. Using it, service provider can easily develop new remotable services (i.e, ADF BC services). For each exposed view objects used in ADF BC services, we can generate standard Create, Retrieve, Update, and Delete (CRUD) methods. In addition to the standard CRUD methods, custom methods can also be selected to be included in the ADF BC service.
Oracle JDeveloper includes a variety of ways to construct ADF BC services. In this article, we will demonstrate the following approach:
  • Create schema-object-based entity object
This approach starts from creating an entity object with its supporting components (i.e., application module and view object). Then we will expose the auto-generated CRUD methods from view objects as service operations. Using this approach, JDeveloper helps you to construct business components (i.e., application module, entity object, and view object) in one shot.
Every entity object must have at least one attribute marked as a primary key. In our example, EMP table has no primary key constraint. Using our approach, Create Entity Object wizard will allow you to set any attribute as primary key.

ADF Business Components
Oracle ADF Business Components is a framework implements the Business Services layer on top of a data source in a declarative way. It provides out-of-the-box services such as transaction management, resource pooling, locking, declarative validation rules, translation, and object-relational mapping.
To use Oracle ADF BC, you use wizards in JDeveloper to create:
  • Application Module
    • An application module is a service component that UI or Web Service clients use to work with application data. It defines an updatable data model and top-level procedures and functions (called service methods) for a logical unit of work related to an end-user task. To simplify the task of implementing your services, you leverage a set of business components like entity objects and view objects.
    • You can enable a service interface on any Application Module. The service interface expose Application Modules as remotable services allowing third-party applications to find, create, update and delete business information using standard web services protocols. All of the business validation rules encapsulated in your Entity Objects are automatically enforced through this service interface as well.
    • You can use any application module both as a local component and as remotely-accessible service. This allows you to support both interactive Web user interfaces as well as programmatic Web-service clients with the same component.
  • Entity object
    • An entity object represents a row in a database table and simplifies modifying its data by handling all DML operations for you. It can encapsulate business logic for the row to ensure your business rules are consistently enforced. You associate an entity object with others to reflect relationships in the underlying tables to create a layer of business domain objects to reuse in multiple applications.
  • View object
    • A view object represents a SQL query and simplifies working with its results. You declaratively join, project, filter, sort, and aggregate entity object data into exactly the "shape" required by the end-user task at hand, including the ability to link a view object with others to create master/detail hierarchies of any complexity. When users modify business data using a view object, that component automatically collaborates with entity objects to consistently validate and save the changes.
The following diagram illustrates the relationship among application module, entity object, and view object. A view object defines a query and produces a row set of rows. View objects and entity objects collaborate to enable an updatable data model. Application module contains view objects and it provides transaction.

ADF Business Component Service
ADF BC services are remotable services, typically coarse-grained and designed to be published remotely in a loosely coupled SOA architecture. It's easy to develop business services using ADF Business Components. JDeveloper allows you to publish application modules as web services which use SDOs ( Service Data Objects) to standardize the way that data structures are passed between Java and XML. JDeveloper also generates the WSDL service description that is used by the web service client in the consuming application.
When you use remote ADF Fusion Business Service, each remote call is stateless and the remote service does not participate in the same transaction as their composing parent application module. In the majority of the cases, calls to remote services will be informational in nature and will not be effecting changes to remote objects. However, if you must use a remote service to make changes then keep these points in mind:
  • An exception thrown by the remote service will cause the local transaction to fail.
  • However, the converse is not true.
In other words, if you successfully call a remote service that results in modifying data, and then subsequently your local transaction fails for any reason, then it is the responsibility of your error handling code to perform a compensating transaction against the remote service to "undo" the previous change made.
In this article, we will demonstrate how to create ADF BC services that exposes the top-level Employee View Object. Standard data manipulation operations on the Employee View Object including the following operations:
  • createEmpVO1
  • updateEmpVO1
  • deleteEmpVO1
  • getEmpVO1

Integrated WebLogic Server (WLS)
To run JDeveloper application in a Java EE container, it must be bound to a Server Instance. Integrated WebLogic Server (Integrated WLS) comes packaged with JDeveloper. You can run your applications directly on this server without the need to deploy. The integrated WLS is sufficient to run your application to make sure it displays correctly in browsers, or for testing and debugging portions of the application. However, real end-to-end testing should be done in a standalone WebLogic Server because that is what will be used in a production environment. For simplicity, our sample application will use Integrated WLS for deployment and testing.
JDeveloper is bundled with a WLS domain (i.e., "DefaultDomain"), and "DefaultServer" is defined for it. All JDeveloper applications are bound by default to "DefaultServer." In this document, these default settings are assumed. To view the properties of "DefaultServer" Server Instance, in the Resource Palette -> IDE Connections -> Application Server -> IntegratedWebLogicServer, right click and select "Properties...".
Prerequisites
This article assumes that you are familiar with
  • ADF
  • WSDL
  • JDeveloper
  • Web Services
and have access to a running JDeveloper and a running Oracle Database with EMP table in SCOTT schema. The resources section at the end provides you with pointers to documentation and tutorials.

Create Schema-Object-Based Entity Object

Step 1: Create a New Fusion Web Application (ADF)
  • Open the New Gallery wizard and choose Fusion Web Application (ADF) [File > New > General > Applications > Fusion Web Application (ADF)]
  • In the Create Fusion Web Application (ADF) wizard, specify your application name (e.g., EmployeeWS)
  • Click Finish.

Step 2: Create the Entity Object
To create a single entity object, you can use the Create Entity Object wizard, which is available in the New Gallery:
  • In the Application Navigator, select the Model project and open Create Entity Object wizard [File > New > Business Tier > ADF Business Components > Entity Object].
    • Because this is the first component you're creating in the project, the Initialize Business Components Project dialog appears to allow you to select a database connection.
    • Edit the Connection in the Initialize Business Components Project wizard by clicking on "pencil" icon. Note that you may need to change the Connection name if it's already being used.
    • Enter scott as username and tiger as password. We're going to use EMP table in SCOTT Schema for this example.
    • Click Test Connection to confirm that you can connect.
    • Click OK if the connection was successful.
    • Click OK to close Initialize Business Components Project wizard.
  • In the "Create Entity Object - Step 1 of 6", enter "EMP" as Schema Object. Click Next.

  • Click Next to skip "Create Entity Object - Step 2 of 6".
  • In the "Create Entity Object - Step 3 of 6", make "Empno" attribute a primary key by checking "Primary Key" box. Click Next.

  • Click Next to skip "Create Entity Object - Step 4 of 6".
  • In the "Create Entity Object - Step 5 of 6", check "Generate Default View Object" box. Then, check Application Module box. Click Next.

  • Click Finish.

Step 3: Generate SDO Class
Following the guidelines specified by the Open SOA [2] collaboration, the application module's web service uses Service Data Objects [6] to standardize the way that data structures are passed between Java and XML.
View objects are published in web services as SDOs. Follow the steps below to generate SDO classes for your view objects.
  • In the Application Navigator, double-click the EmpVO.
  • In the View Object Editor, select the Java tab.
  • In the Java page, click the Edit icon in the Java Classes section. The Edit icon resembles a pencil.
  • In the "Select Java Options" wizard, check "Generate Service Data Object Class" box. Click OK.

You should be able to see the following files are generated:
  • Emp.java
  • Emp.xsd
  • EmpImpl.java
Note that this step actually is optional. If you skip and proceed directly to step 4, JDeveloper will still generate those SDO files for you.

Step 4: Publish Application Module as Web Service
You can use any application module both as a local component and as remotely-accessible service. This allows you to support both interactive Web user interfaces as well as programmatic Web-service clients with the same component.
JDeveloper creates the web service implementation wrapper and other files required to expose the application module as a web service. If you make changes to your application module's declarative service interface settings, JDeveloper automatically keeps the related web service artifacts in sync.
You publish your application module as web service:
  • In the Application Navigator, double-click the AppModuleAM.
  • In the Application Module Editor, select Service Interface to open the Service Interface page.
  • In the Service Interface page, select the '+' sign to enable support for service interface.
  • Use the Create Service Interface wizard to configure the options you want.
  • On the Service Interface page of the wizard, click Next twice to skip step 1 and 2.
  • On the Service View Instances page, select Emp1 and shuttle it over to the Selected list, and enable Create, Update, Delete, and GetByKey in the Basic Operations section. Then click Finish.

You should be able to see the following files are generated under AppModuleAM->serviceInterface
  • AppModuleAMServiceImpl.java
  • AppModuleAMService.java
  • AppModuleAMService.wsdl
  • AppModuleAMService.xsd

Step 5: Test the Application Modlue in the Oracle Business Component Browser
You can test the application module in the Oracle Business Component Browser:
  • In the Application Navigator, right-click AppModuleAM and choose Run.
  • In the Oracle Business Component Browser, double-click EmpVO1.
  • Click ">" icon to navigate to the next record.
  • Jot down Empno (e.g., "7369") for the next step.

Step 6: Test ADF BC Service
You can test your service interface without deploying it by selecting the generated web service class in the Application Navigator and choosing Run on the right-mouse menu. JDeveloper starts the embedded WebLogic Server (WLS) instance, and then provides a built-in web service testing tool where you can enter sample data for any of the service methods and verify the result returned.
  • In the Application Navigator, right-click the AppModuleServiceImpl.java in the serviceInterface folder and select Run.
  • Select Target URL (i.e., http://localhost:7101/EmployeeWS-Model-context-root/AppModuleAMService) in the Running: DefaultServer Log view and click on it.
  • Test ADF BC Service using HTTP Analyzer.
  • On the HTTP Analyzer page, select AppModuleServiceSoapHttpPort.getEmp1 from the operation's pull-down list.
  • Enter a valid empno (e.g., "7369") and send the request.
References
  1. ADF Business Components
  2. Open SOA
  3. Oracle Application Development Framework
  4. Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1)
  5. Oracle JDeveloper
  6. Service Data Objects Home
  7. Web Services Description Language (WSDL) 1.1
  8. How to Create Oracle ADF BC Services (2)
  9. Open Source sample applications for Oracle Fusion Middleware technology

Saturday, December 11, 2010

Using Remote Debugging in JDeveloper 11g

The debuggee is the application being debugged which can be running on either a local or remote machine. Doing remote debugging, it means that you can use the debugger to debug code that has already been deployed on a remote machine or running in a different VM instance.

JDeveloper IDE supports both local debugging and remote debugging. For local debugging, JDeveloper automatically launches the debuggee and then attaches the debugger to that program. In remote debugging, you must manually launch debuggee. If you're remote debugging a JSP or a servlet, you must manually start a browser to invoke your JSP or servlet. Once the debuggee is launched and the JDeveloper debugger is attached to it, remote debugging is very similar to local debugging.

Usually, the debugger attaches to the debuggee. It is also possible that the debugger listens and the debuggee attaches to the debugger. In this article, we will show you how to set up and use a Jdeveloper to do remote debugging of applications deployed to WebLogic server (WLS).

Configuring the Remote WLS

To debug an application deployed to the WLS, you first make sure that WLS server is running using the following extra Java options:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=@{debug.port}

When WLS starts, it opens up @{debug.port} (e.g., 4000) and default port is 8453.

Configuring the JDeveloper

Assume you have deployed your application to the remote WLS server. Now let's setup JDeveloper to do the remote debugging. Follow the steps below:
  1. Open the JDeveloper
  2. Go to Tools -> Preferences -> Debugger -> Breakpoints -> Choose Global (Radio box)

    By selecting Global, it means that breakpoints set next are active whenever you are debugging, regardless of what project you are using.

  3. Open the source codes. Set the break points as needed
  4. Right click your project and select Project Properties -> Run/Debug/Profile
  5. Select Default Run Configurations and Edit it
  6. Click on Remote Debugging and Profiling check box in Launch Settings option
  7. Go to Debugger -> Remote Options. Update the following properties:
    • Protocol = Attach to JPDA
    • Host = Host of the Remote server
    • Port = Debug Port number (eg: 4000)
    For remote debugging, you must choose which protocol to use before you start your remote debugging session. We select "Attach to JPDA" because you will be using Java Platform Debugger Architecture (JPDA) and you would like the debugger to attach to the debug process.
  8. Right click on your project -> Click on Start Remote Debugger
  9. A dialog will pop up and make sure your configurations are correct
  10. Activate your application deployed on the remote WLS server via some mechanisms. This should trigger the break points that you have set in JDeveloper.
Java Platform Debugger Architecture (JPDA)

JPDA stands for Java Platform Debugger Architecture. It’s a multi-layered debugging architecture which enables a tool developer such as Oracle JDeveloper to easily and effectively develop a debugger application which will run across platforms, virtual machine (VM) implementations and JDK versions. For more information, see the references.

Summary

You can use JDeveloper IDE to remote debug Java programs, JSPs, servlets, or distributed applications. For debugging Web pages such as JSPs or servlets, you can also use its HTTP Analyzer.


References
  1. JPDA Tutorial by Preetam
  2. Handy JDeveloper utility: the Http Analyzer
  3. Oracle JDeveloper Downloads
  4. Oracle Weblogic Documentation Library
  5. Running and Debugging Java Programs
  6. Remote Debugging with OC4J

Thursday, November 25, 2010

Book Review: Web 2.0 Solutions with Oracle WebCenter 11g


This article reviews a book named Web 2.0 Solutions with Oracle WebCenter 11g authored by Plinio Arbizu and Ashok Aggarwal with the help of Amit Gupta and Sukanta K. Hazra.

Web 2.0 takes advantage the web platform to build applications that offer communication, collaboration, knowledge sharing, social networking while Enterprise 2.0 promotes the productivity of organizations by using the new technology platform offered by Web 2.0. The scope of Enterprise 2.0 is not restricted to the organization itself, but also includes its partners and customers.

How we can implement a solution that supports the guidelines suggested by Enterprise 2.0 and Web 2.0? The Oracle answer is called Oracle WebCenter Suite.

In this book, it teaches you how to create custom WebCenter applications using Oracle WebCenter Suite with its hands-on practical tutorial.

What's Oracle WebCenter

In a nutshell, Oracle WebCenter provides design time and runtime tools for building enterprise portals, transactional websites, and social networking sites. Different WebCenter terms mean different products and services it provide. See below for clarification:

WebCenter Services – A set of pre-built business components (Blogs, Wikis, Discussions, Search, etc) that developers can utilize to build applications. These are essentially out of the box portlets.
WebCenter Spaces
– The homegrown out of the box Oracle portal product.

WebCenter Framework – A set of ADF components and APIs that let developers tap into the Oracle product stack.
WebCenter Suite 11g
- Oracle owns 3 portal products: WCI (Plumtree->BEA acquisition), BEA Portal (BEA acquisition), and WebCenter (Oracle Organic product). WebCenter Suite is the blanket license you can buy to acquire all three of these portal products.

WebCenter 11g
- The term used for collectively referring to Oracle WebCenter Spaces, WebCenter Services, and WebCenter Framework.


What's in the Book

Oracle WebCenter provides a rich set of Web 2.0 features and Enterprise 2.0 capabilities. It is the platform that provides the integration of the following services:
  • Wiki and Blog Services
  • Content Management Service
  • Discussion Forums Service
  • Search Service
  • Tags and Links Services
To simplify its configuration and deployment, Oracle has provided pre-bluilt solutions such as existing WebCenter task flows, an out-of-box Portal application, and many other building blocks which requires little development efforts. However, it still requires you some knowledge of how to assemly different components together and in which order. To fill in that gap, this cookbook comes in handy. It provides you detailed step-by-step instructions, guidance, tips and best practices.

For example, it
  • Provides you the tip on increasing the number of processes to be used by Database
  • Describes each building blocks and instructs you to build them from bottom up
  • Guides you to run Repository Creation Utility (RCU) and install the WebLogic Server before you install WebCenter
  • Helps you create simple WebCenter applications to demonstrate the tools, development methodology, and deployment of custom WebCenter applications
  • Helps you create a HelloWorld web service, which is used by a HelloWorld portlet producer; the portlet producer is then consumed by a HelloWorld WebCenter application
  • Helps you develop page templates and add data-access features to your WebCenter applications
  • Demonstrates simple ways to incorporate different collaboration tools or services into your custom WebCenter applications
  • Shows you how to configure ADF Security and set the ADF policy on the pages created
  • Makes clear how to configure, personalize and create content and combine it with external information using Oracle WebCenter Spaces
  • Touches upon Oracle Composer and Oracle Metadata Service
Read More

With the aid of this book, you can acquire the experience of setting up Oracle WebCenter design-time and runtime environments, developing Custom WebCenter applications with JDeveloper IDE using ADF and JSF, working on an out-of-box Portal Application named WebCenter Spaces, creating site contents using WebCenter Spaces, etc. However, this is just a beginning.

You can follow up on resources listed in the references section. For example, as a WebCenter Developer, you would like to read its Developer's Guide; to polish your ADF skills, you would like follow up on Fusion Middleware Developer's Guide.

Finally, you can also deep dive into Fusion Order Demo for WebCenter, which demonstrates common use cases in Fusion Middleware applications, including the integration between different components of the Fusion technology stack (ADF, BPEL, and WebCenter).

References

  1. Developing Applications on Oracle® WebLogic Server 10g Release 3 (10.3)
  2. Oracle® Fusion Middleware Tutorial for Oracle WebCenter Developers 11g Release 1 (11.1.1)
  3. Oracle JDeveloper and ADF Documentation (11.1.1.3.0)
  4. Oracle WebCenter Developer's Guide
  5. Oracle Fusion Order Demo Application for WebCenter
  6. Time For Enterprise 2.0 To Get Enterprisey by Sandy Kemsley
  7. Web 2.0 Solutions with Oracle WebCenter 11g
  8. Oracle® Fusion Middleware Repository Creation Utility User's Guide 11g Release 1 (11.1.1)

Thursday, October 14, 2010

Oracle Text (11g)

What's Oracle Text

Oracle Text is a powerful search technology built into Oracle11g Standard and Enterprise Editions. Oracle Text uses standard SQL to index, search, and analyze text stored in structured form inside Oracle database, or in unstructured form in either local file system, or on the Web.

The Text index is in the database – no separate data or index storage required. Text queries are executed in the Oracle process – no separate query processing. The Oracle optimizer is aware of the Text index, so it can choose the best execution plan for any query – gives the best performance for ad hoc queries involving Text and structured criteria.

Oracle Text search functionality includes:

  • Boolean operators (AND, OR, NOT, NEAR etc)
  • Exact phrase match
  • Section searching
  • Fuzzy (words that are spelled similarly)
  • Stemming (search for mice and find mouse)
  • Wildcard
  • Thesaurus (synonyms)
  • Stopwords
  • Case sensitivity
  • Search scoring proximity (Searches for words near one another)
  • Results ranking
  • Keyword highlighting.

The advanced features of Oracle Text include:

  • Search for a document by theme
  • Get the themes of a document
  • Get the gist of a document
  • Get the theme gist of a document
  • Extend the knowledge base to include terms from a particular industry
  • Extend the knowledge base to make new associations between terms

Finally, Oracle Text also provides:

  • Classification
  • Clustering
  • Query refinement

SQL API

Oracle Text’s SQL API makes it simple and intuitive for application developers and DBA’s to create and maintain Text indexes and execute Text searches.

Create a Text index

To create an Oracle Text index, simply use the CREATE INDEX command. Forn example:

CREATE INDEX description_idx ON product_information(product_description) INDEXTYPE IS CTXSYS.CONTEXT; 


Execute Text Searches

Now you can search for information about all products where “monitor” is near “high resolution” in the product description:

SELECT score(1),  product_id,  product_name FROM product_information WHERE CONTAINS(product_description, 'monitorNEARhighresolution', 1) > 0 ORDERBY score(1) DESC; 


Maintain a Text index

As with any full-text retrieval index, changes to the underlying data are applied to the index in batch. To synchronize the text index “index_one” using 2 megabytes of memory, use:

exec ctx_ddl.sync_index(‘index_one’,’2M’);  


The synchronize can be done periodically (every 5 minutes, every hour, etc.) or immediately. Note that the catalog indextype - designed specifically for the short pieces of text typically found in eBusiness catalogs – needs no synchronization. The catalog index is always up-to-date.

Simple Management

Oracle Text management can be done using the Oracle Enterprise Manager.

Creating Indices

Oracle Text provides different index types that are suitable for different purposes. There are four Text index types:
  1. Standard index type (context)
  2. Catalog index type (ctxcat)
  3. Classification index type (ctxrule)
  4. XPath index type (ctxxpath)

Different indexing approaches will be covered in more details in later section.

You create a text index as a type of extensible index to Oracle Database using standard SQL. This means that an Oracle Text index operates like an Oracle Database index. It has a name by which it is referenced and can be manipulated with standard SQL statements.

The benefits of a creating an Oracle Text index include fast response time for text queries with the CONTAINS, CATSEARCH, and MATCHES Oracle Text operators. These operators query the CONTEXT, CTXCAT, and CTXRULE index types respectively.

Oracle Text Indexing Process

The Oracle Text indexing process is modeled after a pipeline, where data items retrieved from a data store pass through a series of transformations before their keywords are added to the index. The indexing process is split into multiple phases, which is configurable by the application developer.

The indexing process includes the following phases:

  • Data Retrieval: Data is simply fetched from a data store, for example, a Web page, database large object, or local file system, and passed as a stream of data to the next phase.
  • Filtering: The filters are responsible for converting data in different file formats to plain text. The other components in the indexing pipeline only process plain text data and don't know about file formats such as Microsoft Word or Excel.
  • Sectioning: The sectioner adds metadata about the structure of the original data item.
  • Lexing: A stream of characters is split into words based on the language of the item.
  • Indexing: In this final phase, the keywords are added to the actual index.

Index Types

CONTEXT Index

CONTEXT index enables users to search document collections, such as Web sites, digital libraries, or document warehouses. The collection is typically static with no significant change in content after the initial indexing run. Documents can be of any size and of different formats, such as HTML, PDF, or Microsoft Word. These documents are stored in a document table.

To query this index, the application uses the SQL CONTAINS operator in the WHERE clause of a SELECT statement.

CTXCAT index

CONTEXT index enables users to search catalog information which consists of inventory type information, such as that of an online book store or auction site. The stored information consists of text information, such as book titles, and related structured information, such as price. The information is usually updated regularly to keep the online catalog up to date with the inventory.

To query this index, the application uses the CATSEARCH operator in the WHERE clause of a SELECT statement. Queries are usually a combination of a text component and a structured component. Results are almost always sorted by a structured component, such as date or price. Good response time is always an important factor with this type of query application.

CTXRULE index

CONTEXT index enables users to classify an incoming stream or a set of documents by comparing to a pre-defined set of rules. When a document matches one or more rules, the application performs some action.

For example, assume there is an incoming stream of news articles. You can define a rule to represent the category of Finance. The rule is essentially one or more queries that select document about the subject of Finance. When a document arrives about a Wall Street earnings forecast and satisfies the rules for this category, the application takes an action, such as tagging the document as Finance or e-mailing one or more users.

To classify an incoming stream of text, use the MATCHES operator in the WHERE clause of a SELECT statement. Before you start, you need to create a table of rules and then create a CTXRULE index.

CTXXPATH Index

CTXXPATH index is provided for improving performance on XPath searches on XML documents. Note that this indextype will be deprecated and is only supported for backward compatibility with older releases of Oracle Database where XMLIndex is not available. If you are building a new application, Oracle recommends that you use the XMLIndex. Although this index type can be helpful for existsNode() queries, it is not required for XML searching. For more information on XML search, see here.

Theme Index

A document theme is a concept that is sufficiently developed in the document. By default in English and French, Oracle Text indexes theme information. Themes can be queried with the ABOUT operator.You can enable and disable theme indexing with the index_themes attribute of the BASIC_LEXER preference type. You can also index theme information in other languages provided you have loaded and compiled a knowledge base for the language.

Document Services

In addition to the search capabilities of Oracle Text, a number of other features are provided to simplify application development:

  • Document Format Support - In order to index documents stored in a variety of native formats, such as Word, Excel, PowerPoint, WordPerfect, HTML, and Acrobat/PDF, interMedia supplies a broad variety of "filters" that allow documents stored in their native formats to be indexed.
  • Document Viewing and Highlighting - Oracle Text Services can convert any supported document format to either plain text or formatted text (an HTML approximation retaining as much as possible of the original formatting; available for all formats except PDF). Both plain text and HTML versions may be viewed in a standard browser, allowing maximum flexibility in deployment, especially for public Web applications. Both plain text and HTML versions may be viewed with or without highlighting and navigation of the search words or themes. It is also possible to download the original document in its native form for viewing in either the original authoring system (Word, PowerPoint etc.) or in any third-party viewer. For viewing PDF documents, the Acrobat viewer should be used.
  • Document Storage - Oracle Text Services supports several document storage options. The most straightforward option is "direct" storage where documents are kept in an Oracle database table. Where this is not possible, documents may be indexed directly from a file system or URL address by simply storing a file pointer or URL in the indexed column.
  • Text Manager - Oracle Text supplies an administration tool, integrated with the Oracle. Enterprise Manager, through which all major text maintenance and administration functions may be performed.

Resources

Friday, October 8, 2010

JUnit in JDeveloper 11g

JUnit is a simple, open source framework to write and run repeatable tests. It is supported in JDeveloper 11g as an extension. In this article, we'll show how to setup JUnit extension within JDeveloper 11g.

Where to Get JDeveloper 11g?

You can download JDeveloper 11g from here. For example, I've downloaded the following version for Windows:
How to Get JUnit Extension?

JUnit is an extension in JDeveloper as shown below.

However, it's not bundled in your downloaded JDeveloper 11g. So, you need to install it by the following steps:
  • Help -> Check for Updates-> install the Junit extensions
If your machine is sitting behind the firewall, you will get an "Unable to Connect" dialog. Then you need to setup proxy as well:

At "Step 3 of 5", select "JUnit Integration 11.1.1.3.17.56.60":
Libraries and ClassPath

To start using JUnit framework, you need to include JUnit library in your "Libraries and ClassPath." Follow the steps below:
  • Project Properties -> Libraries and Class -> Add Library...
  • Select "JUnit 4 Runtime"

Create New Tests
After adding the JUnit extension, you can use JDeveloper to create:
  • Test Case
  • Test Fixture
  • Test Suite