BEA Logo BEA WebLogic Enterprise Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLE Doc Home   |   CORBA Programming & Related Topics   |   Previous   |   Next   |   Contents   |   Index

Starter Java Implementation File

This appendix contains a starter interceptor implementation file in Java that you can use as a place to begin implementing your Java interceptors. If you use this code example, replace the string YourInterceptor with the name of the interceptor you are implementing.

import org.omg.CORBA.*;
import com.beasys.Interceptors.*;
import com.beasys.RequestLevelInterceptor.*;
import com.beasys.Tobj.TP;
import com.beasys.CORBA.util.*;
import java.io.*;

/**
* Sample showing ORB simple interceptor functionality
*/
public class InterceptorTemplate implements TargetRequestInterceptor
{
private static String identity = new String("InterceptorTemplate");
private String instanceID;
private ORB theOrb = null;
private static int count = 0;

/**
* Default Constructor
*/
public InterceptorTemplate()
{
instanceID = new String(identity);
}

/**
* Constructor
*/
public InterceptorTemplate(ORB orb)
{
instanceID = new String(identity);
theOrb = orb;
}

/**
* The id accessor operation is used by the ORB to obtain
* the vendor assigned identity of the interceptor as a string
* value. This attribute is used primarily for debugging and
* tracing of operations on the interceptors called by the ORB.
*/
public String id()
{
return instanceID;
}

/**
* The exception_occurred operation is called on a request-level
* interceptor implementation when an exception occurred.
* It is called instead of the <xxx>_response
* method of that interceptor. The ORB calls this operation to
* allow the interceptor implementation to clean-up any state
* that it might have been managing that is specific to a request.
*/
public void exception_occurred(
com.beasys.RequestLevelInterceptor.ReplyContext replyContext,
org.omg.CORBA.SystemException exceptionValue)
{
TP.userlog(id() + ", InterceptorTemplate.exception_occurred");
}

/**
* The shutdown operation is used by the ORB to notify an
* implementation of an interceptor that the interceptor
* is being shutdown. The ORB will destroy the instance
* of the interceptor once control is returned from the
* operation back to the ORB.
*/
public com.beasys.Interceptors.ShutdownReturnStatus shutdown(
com.beasys.Interceptors.ShutdownReason reason,
org.omg.CORBA.SystemExceptionHolder excep_val)
{
if (reason.value() == ShutdownReason._ORB_SHUTDOWN)
{
TP.userlog(id() + ", ORB Shutdown");
excep_val.value = null;
}
return ShutdownReturnStatus.SHUTDOWN_NO_EXCEPTION;
}

/**
* The operation is called by the ORB anytime that an
* invocation is being received by a target object,
* regardless of whether the target object is in a
* different address space or the same address space
* as the target object.
*/
public com.beasys.Interceptors.InvokeReturnStatus target_invoke(
com.beasys.RequestLevelInterceptor.RequestContext request_context,
com.beasys.RequestLevelInterceptor.ServiceContextList service_context,
org.omg.CORBA.DataInputStream request_arg_stream,
org.omg.CORBA.DataOutputStream reply_arg_stream,
org.omg.CORBA.SystemExceptionHolder excep_val)
{
excep_val.value = null;
return InvokeReturnStatus.INVOKE_NO_EXCEPTION;
}

/**
* The operation is called by the ORB anytime that a reply
* to an invocation is being sent to the initiator of the
* request, regardless of whether the initiator is in a
* different address space or the same address space as
* the target object.
*/
public com.beasys.Interceptors.ResponseReturnStatus target_response(
com.beasys.RequestLevelInterce