FileDocCategorySizeDatePackage
SFSBClientRequestInterceptor.javaAPI DocGlassfish v2 API6732Thu Aug 30 23:54:18 BST 2007com.sun.enterprise.iiop

SFSBClientRequestInterceptor

public class SFSBClientRequestInterceptor extends SFSBAbstractInterceptor implements ClientRequestInterceptor
This is the implementation of the JTS PI-based client/server interceptor. This will be called during request/reply invocation path.

Fields Summary
private static final Level
TRACE_LEVEL
private static final Level
TRACE_LEVEL_FINE
Constructors Summary
public SFSBClientRequestInterceptor(org.omg.IOP.Codec codec)

    
       
        super("com.sun.enterprise.iiop.SFSBClientRequestInterceptor", codec);
    
Methods Summary
public booleandoesSFSBVersionPolicyExist(ClientRequestInfo ri)

        boolean result = false;
        try {
            TaggedComponent sfsbVersionTag = ri
                    .get_effective_component(POARemoteReferenceFactory.SFSB_VERSION_POLICY_TYPE);
            result = (sfsbVersionTag != null);
        } catch (BAD_PARAM e) {
            // ignore
        }
        return result;
    
private voidreceiveSFSBVersionNumber(java.lang.String callName, ClientRequestInfo ri)

        try {
            if (doesSFSBVersionPolicyExist(ri)) {
                EJBTargetKeyInfo oidInfo = new EJBTargetKeyInfo(ri.effective_target());
                ServiceContext ctx = ri.get_reply_service_context(
                        SFSBVersionConstants.SFSB_VERSION_SERVICE_CONTEXT_ID);
                if (ctx != null) {
                    long version = Utility.bytesToLong(ctx.context_data, 0);
                    SFSBClientVersionManager.setClientVersion(oidInfo.getContainerId(),
                        oidInfo.getInstanceKey(), version);
                    if (_logger.isLoggable(TRACE_LEVEL)) {
                        _logger.log(TRACE_LEVEL, "SFSBClientInterceptor." + callName
                                + " " + ri.operation() + " " + oidInfo
                                + " version: " + version);
                    }
                }
            }
        } catch (Throwable th) {
            _logger.log(Level.FINE, "SFSBClientInterceptor::receiveSFSBVersionNumber"
                    + " Got exception: ", th);
        }
    
public voidreceive_exception(ClientRequestInfo ri)

        receiveSFSBVersionNumber("receive_exception", ri);
    
public voidreceive_other(ClientRequestInfo ri)

        if (doesSFSBVersionPolicyExist(ri)) {
            EJBTargetKeyInfo oidInfo = new EJBTargetKeyInfo(ri
                    .effective_target());
            if (_logger.isLoggable(Level.WARNING)) {
                _logger.log(Level.WARNING, "**SFSBClientInterceptor.receive_other...: "
                    + oidInfo);
            }
        }
    
public voidreceive_reply(ClientRequestInfo ri)

        receiveSFSBVersionNumber("receive_reply", ri);
    
public voidsend_poll(ClientRequestInfo ri)

        // do nothing.
    
public voidsend_request(ClientRequestInfo ri)

        if (doesSFSBVersionPolicyExist(ri)) {
            EJBTargetKeyInfo oidInfo = new EJBTargetKeyInfo(ri
                    .effective_target());
            if (_logger.isLoggable(TRACE_LEVEL_FINE)) {
                _logger.log(TRACE_LEVEL_FINE, "**SFSBClientInterceptor.send_request...: "
                    + ri.operation() + " " + oidInfo);
            }
            
            try {
                //Any anyData = ri.get_slot(getSlotID());
                long version = SFSBClientVersionManager.getClientVersion(oidInfo.getContainerId(),
                        oidInfo.getInstanceKey());
                //version = ++versionCounter;
                //anyData.insert_longlong(version);
                byte[] data = new byte[8];
                Utility.longToBytes(version, data, 0);
                ri.add_request_service_context(new ServiceContext(
                        SFSBVersionConstants.SFSB_VERSION_SERVICE_CONTEXT_ID, data),
                        false);
                if (_logger.isLoggable(TRACE_LEVEL)) {
                    _logger.log(TRACE_LEVEL, "SFSBClientInterceptor.send_request. anyData: " + version);
                }
            } catch (Exception e) {
                if (_logger.isLoggable(TRACE_LEVEL)) {
                    _logger.log(TRACE_LEVEL, "SFSBClientInterceptor.send_request. Exception", e);
                }
            }
        }