bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Programming BPM Client Apps

 Previous Next Contents Index View as PDF  

Configuring Business Operations

A business operation represents a method call, implemented by an EJB or Java class instance, that allows you to create customized actions. For additional information, see "Configuring Business Operations" in Configuring Workflow Resources in Using the WebLogic Integration Studio.

This section describes the tasks associated with configuring business operations, including the following topics:

For more information about the methods described in this section, see the com.bea.wlpi.server.admin.Admin and com.bea.wlpi.server.catalog.EJBCatalog Javadoc.

 


Adding a Business Operation

To add a business operation, use one of the following com.bea.wlpi.server.admin.Admin methods.

Method 1

public java.lang.String addBusinessOperation(
com.bea.wlpi.common.EJBInvocationDescriptor descriptor
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

Method 2

public java.lang.String addBusinessOperation(
com.bea.wlpi.common.ClassInvocationDescriptor descriptor
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

Each method creates a business operation. The first method creates a business operation implemented by a session or entity EJB; the second, by a Java class instance that is accessible on the server.

Note: Although session EJBs can be stored in workflow variables, stateful session EJBs are not persisted as part of a workflow instance, but exist only for the life of the transaction in which they are created. For more information about the transaction model, see Understanding the BPM Transaction Model. Entity EJBs, stateless EJBs, and Java class instances, on the other hand, are persisted as part of a workflow instance.

The following table describes the addBusinessOperation() method parameter for which you must specify a value.

Table 10-1 addBusinessOperation() Method Parameter  

Parameter

Description

Valid Values

descriptor

Invocation descriptor for the business operation.

The invocation descriptor consists of meta-data that describes the method invocation on the EJB or Java class instance that implements the business operation.

One of the following values:

For information about getting the EJB or Java class invocation descriptor, see Getting EJB Descriptors or Getting Java Class Descriptors, respectively. For information about defining an EJBInvocationDescriptor or ClassInvocationDescriptor, see EJBInvocationDescriptor Object or ClassInvocationDescriptor Object, respectively.


 

Each method returns the ID of the new business operation.

For example, the following code adds the EJB business operation with the specified invocation descriptor, descriptor. In this example, admin represents the EJBObject reference to the Admin EJB.

String operationId = admin.addBusinessOperation(descriptor);

For more information about the addBusinessOperation() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Getting Business Operations

To get a list of defined business operations, use the following com.bea.wlpi.server.admin.Admin method:

public java.util.List getBusinessOperations(
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

This method returns a list of com.bea.wlpi.common.EJBInvocationDescriptor or com.bea.wlpi.common.ClassInvocationDescriptor objects, in which the currently defined business operations are identified. To access information about each object, use the EJBInvocationDescritor or ClassInvocationDescriptor object methods described in EJBInvocationDescriptor Object or ClassInvocationDescriptor Object, respectively.

For example, the following code gets the currently defined business operations. In this example, admin represents the EJBObject reference to the Admin EJB.

String operationsList = admin.getBusinessOperations();

For more information about the getBusinessOperations() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Updating a Business Operation

To update a business operation, use one of the following com.bea.wlpi.server.admin.Admin methods.

Method 1

public void updateBusinessOperation(
java.lang.String busOpId,
com.bea.wlpi.common.EJBInvocationDescriptor descriptor
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

Method 2

public void updateBusinessOperation(
java.lang.String busOpId,
com.bea.wlpi.common.EJBInvocationDescriptor descriptor
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

Each method updates a business operation. The first method updates a business operation implemented by a session or entity EJB; the second, by a Java class instance that is accessible on the server.

The following table describes the parameters for which you must specify a value for the updateBusinessOperation() methods.

Table 10-2 updateBusinessOperation() Method Parameters  

Parameter

Description

Valid Values

busOpId

ID of the business operation to be updated.

String specifying a valid business operation ID.

To get the business operation ID, use the following com.bea.wlpi.common.EJBInvocationDescriptor or com.bea.wlpi.common.ClassInvocationDescriptor method:

public java.lang.String getId()

For information about getting the EJB or Java class invocation descriptor, see Getting EJB Descriptors or Getting Java Class Descriptors, respectively. For information about defining an EJBInvocationDescriptor or ClassInvocationDescriptor, see EJBInvocationDescriptor Object or ClassInvocationDescriptor Object, respectively.

descriptor

Invocation descriptor for the business operation.

The invocation descriptor consists of meta-data that describes the method invocation on the EJB or Java class instance that implements the business operation.

One of the following values:

For information about getting the EJB or Java class descriptor, see Getting EJB Descriptors or Getting Java Class Descriptors, respectively.


 

For example, the following code updates the EJB business operation with the specified ID and invocation descriptor, descriptor. In this example, admin represents the EJBObject reference to the Admin EJB.

admin.updateBusinessOperation("12345", descriptor);

For more information about the updateBusinessOperation() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Deleting a Business Operation

To delete a business operation, use the following com.bea.wlpi.server.admin.Admin method:

public void deleteBusinessOperation(
java.lang.String busOpId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the deleteBusinessOperation() method parameter for which you must specify a value.

Table 10-3 deleteBusinessOperation() Method Parameter  

Parameter

Description

Valid Values

busOpId

ID of the business operation to delete.

String specifying a valid business operation ID.

To get the business operation ID, use the following com.bea.wlpi.common.EJBInvocationDescriptor or com.bea.wlpi.common.ClassInvocationDescriptor method:

public java.lang.String getId()

For information about getting the EJB or Java class invocation descriptor, see Getting EJB Descriptors or Getting Java Class Descriptors, respectively. For information about defining an EJBInvocationDescriptor or ClassInvocationDescriptor, see EJBInvocationDescriptor Object or ClassInvocationDescriptor Object, respectively.


 

For example, the following code deletes the specified business operation. In this example, admin represents the EJBObject reference to the Admin EJB.

admin.deleteBusinessOperation("124345");

For more information about the deleteBusinessOperation() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Getting EJB Descriptors

To add, update, or delete business operations that are implemented by an EJB, you need to get the EJB descriptor. To get an EJB descriptor, use the methods available via the com.bea.wlpi.server.catalog.EJBCatalog EJB.

Note: The EJBInvocationDescriptor class also provides methods for getting, setting, and invoking EJB descriptors. For more information, see EJBInvocationDescriptor Object.

The following table lists the com.bea.wlpi.server.catalog.EJBCatalog methods that can be used to set preferences for getting EJB descriptors.

Table 10-4 EJBCatalog EJB Methods for Setting Preferences for Getting an EJB Descriptor  

Method

Description

public void setCatalogRoot(
java.lang.String root
) throws java.rmi.RemoteException

Set the JNDI context to use when looking up installed EJBs.

root specifies a valid JNDI name of context containing EJB bindings.

public void setInspectAlways(
boolean inspectAlways
) throws java.rmi.RemoteException

Specify whether the process engine regenerates the JNDI names and EJBMetaData when getting an EJB descriptor or name.

inspectAlways specifies a Boolean argument to enable (true) or disable (false) automatic regeneration.

public boolean inspectAlways(
) throws java.rmi.RemoteException

Determine whether automatic regeneration is enabled or disabled.

Returns a Boolean argument specifying whether or not the JNDI names and EJBMetaData are regenerated when the process engine is getting an EJB descriptor or name.


 

The following table lists the com.bea.wlpi.server.catalog.EJBCatalog methods that can be used to get an EJB descriptor.

Table 10-5 EJBCatalog EJB Methods for Getting an EJB Descriptor  

Method

Description

public java.util.List getEJBDescriptors(
) throws com.bea.wlpi.common.WorkflowException, java.rmi.RemoteException

Get the EJBs installed in the previously specified JNDI context. The default implementation recursively iterates through all JNDI bindings within this context and builds a list containing an EJBMetaData object for each EJBHome object encountered.

This method returns a list of javax.ejb.EJBMetaData objects.

public java.util.List getEJBNames(
) throws com.bea.wlpi.common.WorkflowException, java.rmi.RemoteException

Get the JNDI names of the EJBs installed in the previously specified JNDI context. The default implementation recursively iterates through all JNDI bindings within this context and builds a list containing the JNDI names of all EJBHome objects encountered.

This method returns a list of JNDI names.


 

For example, the following code enables hot deployment of EJBs and gets the JNDI names of all EJBHome objects. In this example, catalog represents the EJBObject reference to the EJBCatalog EJB.

catalog.setInspectAlways(true);
List ejbList = catalog.getEJBNames();

For more information about the EJBCatalog methods, see the com.bea.wlpi.server.catalog.EJBCatalog Javadoc.

 


Getting Java Class Descriptors

To add, update, or delete business operations that are implemented by a Java class, you need to get the class descriptor. To get a class descriptor, use the methods available via the com.bea.wlpi.server.admin.Admin EJB.

Note: The ClassInvocationDescriptor class also provides methods for getting, setting, and invoking class descriptors. For more information, see ClassInvocationDescriptor Object.

To get a Java class descriptor, use the following com.bea.wlpi.server.admin.Admin method:

public com.bea.wlpi.common.ClassDescriptor getClassDescriptor(
java.lang.String className
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the getClassDescriptor() method parameter for which you must specify a value.

Table 10-6 getClassDescriptor() Method Parameter  

Parameter

Description

Valid Values

className

Fully-qualified Java class name for which you want a descriptor returned.

String specifying a valid, fully qualified Java class name.


 

This method returns a ClassDescriptor, consisting of meta-data for the specified Java class.

For example, the following code gets the class descriptor for the specified Java class, com.somedomain.someproduct.CreateWidget. In this example, admin represents the EJBObject reference to the Admin EJB.

ClassDescriptor descriptor = admin.getClassDescriptor
("com.somedomain.someproduct.CreateWidget");

For more information about the getClassDescriptor() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Examples of Configuring Business Operations

The following sections provide excerpts from the command-line administration client example showing how to configure the environment:

Example of Getting an EJB Descriptor

This section provides excerpts from the command-line administration example showing how to get EJB descriptors and set related preferences.

Note: For more information about the command-line administration example, see Command-Line Administration Example.

In this example, an input stream is defined to communicate with the user, and the user is prompted to specify one of the following actions to be performed:

Important lines of code are highlighted in bold. In this example, catalog represents the EJBObject reference to the EJBCatalog EJB.

/* Create an input stream to communicate with the user */
stdIn = new BufferedReader( new InputStreamReader( System.in ) )
/* Display Tool Title */
System.out.print( "\n--- Command Line Administration v1.1 ---" );

/* Display the main menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n--- Main Menu ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Organizations" );
System.out.println( "2) Roles" );
System.out.println( "3) Users" );
System.out.println( "4) Security Realm" );
System.out.println( "5) Business Operations" );
System.out.println( "6) Event Keys" );
System.out.println( "7) Business Calendars" );
System.out.println( "8) EJB Catalog" );
System.out.println( "9) Server Properties" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );
.
.
.

The mngEJBCatalog() method illustrates how to manage the EJB catalog, interacting with the user to retrieve the information required.

private static void mngEJBCatalog( ) {
boolean isInspectAlways;
List ejbList;
String answer;

/* Create an input stream to communicate with the user */
BufferedReader stdIn = new BufferedReader( new InputStreamReader( System.in ) );

try {
/* Display the menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n\n--- EJB Catalog ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Query Inspect Always Flag" );
System.out.println( "2) Set Inspect Always Flag" );
System.out.println( "3) List names of deployed EJBs" );
System.out.println( "4) List descriptors of deployed EJBs" );
System.out.println( "B) Back to previous menu" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );

/* Get user's selection */
String line = stdIn.readLine( );

/* User pressed enter without making a selection ? */
if( line.equals( "" ) )
continue;
/* User entered more than one char ? */
else if( line.length( ) > 1 ) {
System.out.println( "*** Invalid selection" );
continue;
}

/* Convert to uppercase and to char */
char choice = line.toUpperCase( ).charAt( 0 );

/* Process user's selection */
switch( choice ) {
.
.
.

Querying the Inspect Always Flag

The following excerpt shows how to query the inspect always flag:

      /* Query Inspect Always Flag */
case '1' :
/* WLPI Public API Method */
/* NOTE: Would be nice to add code to capture any
* thrown exceptions */
isInspectAlways = catalog.inspectAlways( );

if( isInspectAlways )
System.out.println( "\nInspect Always flag is set " +
"(EJB hot deployment is enabled)" );
else
System.out.println( "\nInspect Always flag is not set " +
"(EJB hot deployment is disabled)" );
break;
.
.
.

Setting the Inspect Always Flag

The following excerpt shows how to set the inspect always flag:

         /* Set Inspect Always Flag */
case '2' :
/* Get value to set the flag */
/* Prompt user to select if we need to set/unset Inspect
* Always flag */
if( ( answer = askQuestion( "\nEnable Inspect Always (y/n)?" ) )
== null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

/* Parse the answer */
isInspectAlways = ( answer.equals( "y" ) || answer.equals( "Y" ) );

try {
/* WLPI Public API Method */
/* Set Inspect Always Flag */
catalog.setInspectAlways( isInspectAlways );

/* Success (No exception thrown) */
System.out.println( "- Success" );
}
catch( Exception e ) {
System.out.println( "*** Failed to set Inspect Always flag" );
System.err.println( e );
}
break;
.
.
.

Getting Deployed EJB Names

The following excerpt shows how to get the deployed EJB names:

         /* List names of deployed EJBs */
case '3' :
/* WLPI Public API Method */
/* List the JNDI names of deployed EJBs */
/* NOTE: Would be nice to add code to capture any a
             * thrown exceptions */
ejbList = catalog.getEJBNames( );

/* Any EJBs deployed ? */
if( ejbList.size( ) == 0 )
System.out.println( "\nNo EJB deployed" );
else
System.out.println( "\nCataloged EJBs:" );

/* Process the list to display the names */
for( int i = 0; i < ejbList.size( ); i++ )
System.out.println( "- JNDI Name: " + ejbList.get( i ) );
break;
.
.
.

Getting EJB Deployment Descriptors

The following excerpt shows how to get the EJB deployment descriptors:

         /* List descriptors of deployed EJBs */
case '4' :
/* WLPI Public API Method */
/* List the deployed EJBs */
/* ejbList is a list of com.bea.wlpi.common.EJBDescriptor
* objects. */
/* NOTE: Would be nice to add code to capture any
* thrown exceptions */
ejbList = catalog.getEJBDescriptors( );

/* Any EJBs deployed ? */
if( ejbList.size( ) == 0 )
System.out.println( "\nNo EJB deployed" );
else
System.out.println( "\nCataloged EJBs:" );

/* Process the list to display miscelleanous attributes */
for( int i = 0; i < ejbList.size( ); i++ ) {
/* Retrieve an element from the list */
EJBDescriptor ejbDescriptor = ( EJBDescriptor )ejbList.get( i );

/* Display a sub-set of available attributes */
System.out.println( "\n- Deployment Name: " +
ejbDescriptor.getEJBDeploymentName( ) );
System.out.println( " Home Interface: " +
ejbDescriptor.getEJBHomeName( ) );
System.out.println( " Remote Interface: " +
ejbDescriptor.getEJBRemoteName( ) );
/* And so on ...
* See WLPI JavaDocs, Class EJBDescriptor,
* for a listing of all methods available */
}
break;
.
.
.

Examples of Configuring Business Operations

This section provides excerpts from the command-line administration example showing how to configure business operations.

Note: For more information about the command-line administration example, see Command-Line Administration Example.

In this example, an input stream is defined to communicate with the user, and the user is prompted to specify one of the following actions to be performed:

Important lines of code are highlighted in bold. In this example, admin represents the EJBObject reference to the Admin EJB.

/* Create an input stream to communicate with the user */
stdIn = new BufferedReader( new InputStreamReader( System.in ) );

/* Display Tool Title */
System.out.print( "\n--- Command Line Administration v1.1 ---" );

/* Display the main menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n--- Main Menu ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Organizations" );
System.out.println( "2) Roles" );
System.out.println( "3) Users" );
System.out.println( "4) Security Realm" );
System.out.println( "5) Business Operations" );
System.out.println( "6) Event Keys" );
System.out.println( "7) Business Calendars" );
System.out.println( "8) EJB Catalog" );
System.out.println( "9) Server Properties" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );
.
.
.
/**
* Method that interacts with the user to get all the required information
* to illustrate the Public API Methods available in the Admin interface.
* that are related to WLPI Business Operations.
*/
public static void mngBusinessOperations() {
ClassInvocationDescriptor operationClassInfo;
EJBInvocationDescriptor operationEjbInfo;
List operationList;
Object o;
String operationId;

/* Create an input stream to communicate with the user */
BufferedReader stdIn = new BufferedReader(
new InputStreamReader( System.in ) );

try {
/* Display the menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n\n--- Business Operations ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Delete a Business Operation" );
System.out.println( "2) List all Business Operations" );
System.out.println( "B) Back to previous menu" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );

/* Get user's selection */
String line = stdIn.readLine();

/* User pressed enter without making a selection ? */
if( line.equals( "" ) )
continue;
/* User entered more than one char ? */
else if( line.length() > 1 ) {
System.out.println( "*** Invalid selection" );
continue;
}

/* Convert to uppercase and to char */
char choice = line.toUpperCase().charAt( 0 );

/* Process user's selection */
switch( choice ) {
.
.
.

Deleting a Business Operation

The following excerpt shows how to delete a business operation:

         /* Delete a Business Operation */
case '1' :
/* Get operation ID for the operation to delete */
if( ( operationId = askQuestion( "\nEnter Business Operation
ID to delete" ) ) == null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

try {
/* WLPI Public API Method */
/* Delete the business operation */
admin.deleteBusinessOperation( operationId );

/* Success (No exception trown) */
System.out.println( "- Deleted" );
}
catch( Exception e ) {
System.out.println( "*** Unable to delete Business Operation" );
System.err.println( e );
}
break;
.
.
.

Getting All Business Operations

The following excerpt shows how to get all business operations:

         /* List all Business Operations */
case '2' :
try {
/* WLPI Public API Method */
/* Retrieve all business operations */
operationList = admin.getBusinessOperations();

/* Any operations defined ? */
if( operationList.size() == 0 )
System.out.println( "\nNo Business Operation defined" );
else
System.out.println( "\nDefined Business Operations:" );

/* Process the list to display operations and attributes */
for( int i = 0; i < operationList.size(); i++ ) {
/* Retrieve an element from the list */
o = operationList.get( i );

/* Is the Business Operation a Class ? */
if( o instanceof ClassInvocationDescriptor ) {
operationClassInfo = ( ClassInvocationDescriptor ) o;

/* Display business operation type */
System.out.println( "- Business Operation Type: Class" );

/* Retrieve and display the operation ID */
/* WLPI Public API Method */
System.out.println( " ID: " +
operationClassInfo.getId() );

/* Retrieve and display the class name */
/* WLPI Public API Method */
System.out.println( " Class Name: " +
operationClassInfo.getClassName() );

/* Retrieve and display the class description */
/* WLPI Public API Method */
System.out.println( " Description: " +
operationClassInfo.getDescription() );

/* And so on ...
* See WLPI JavaDocs, Class
* ClassInvocationDescriptor,
* for a listing of all methods available */
}
/* Is the Business Operation an EJB ? */
else if( o instanceof EJBInvocationDescriptor ) {
operationEjbInfo = ( EJBInvocationDescriptor ) o;

/* Display business operation type */
System.out.print( "- Business Operation Type: " );

/* Is it a session or entity EJB */
/* WLPI Public API Method */
if( operationEjbInfo.isSessionEJB() )
System.out.println( "Session EJB" );
else
System.out.println( "Entity EJB" );

/* Retrieve and display the operation ID */
/* WLPI Public API Method */
System.out.println( " ID: " +
operationEjbInfo.getId() );

/* Retrieve and display the EJB deployment name */
/* WLPI Public API Method */
System.out.println( " EJB deployment name: " +
operationEjbInfo.getEJBDeploymentName() );

/* Retrieve and display the bean description */
/* WLPI Public API Method */
System.out.println( " Description: " +
operationEjbInfo.getDescription() );

/* And so on ...
* See WLPI JavaDocs,
* Class EJBInvocationDescriptor,
* for a listing of all methods available */
}
}
}
catch( Exception e ) {
System.out.println( "*** Unable to list Business Operations" );
System.err.println( e );
}
break;
.
.
.
 

 

Back to Top Previous Next