FileDocCategorySizeDatePackage
TransformFilter.javaAPI DocGlassfish v2 API6867Thu Jul 19 08:14:28 BST 2007com.sun.enterprise.admin.wsmgmt.transform

TransformFilter

public class TransformFilter extends Object implements com.sun.enterprise.admin.wsmgmt.filter.spi.Filter
Filter that can implement XSLT transformations.

Fields Summary
private String
_applicationId
private String
_endpointId
private static final String
DELIM
private static final String
NAME_PREFIX
private FilterChain
reqChain
private FilterChain
resChain
private ReentrantReadWriteLock
_rwl
private Lock
_readLock
private Lock
_writeLock
private static final Logger
_logger
private static final com.sun.enterprise.util.i18n.StringManager
_stringMgr
Constructors Summary
public TransformFilter(String appId, String endpoint)
Public Constructor.

param
appId name of the application
param
endpoint end point name for which stats are collected

        _applicationId = appId;
        _endpointId    = endpoint;
        _rwl = new ReentrantReadWriteLock();
        _readLock = _rwl.readLock();
        _writeLock = _rwl.writeLock();
    
public TransformFilter(String appId, com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig wsc)
Public Constructor.

param
appId name of the application
param
endpoint end point name for which stats are collected

        _applicationId = appId;
        _endpointId    = wsc.getName();
        TransformationRule[] reqRules = wsc.getRequestTransformationRule();
        if ( reqRules != null) {
            reqChain = new FilterChain(reqRules, false);
            //reqChain.addFilter(reqRules, false);
        } else {
            reqChain = null;
        }
        TransformationRule[] resRules = wsc.getResponseTransformationRule();
        if (resRules != null) {
            resChain = new FilterChain(resRules, true);
            //resChain.addFilter(resRules, true);
        } else {
            resChain = null;
        }
        _rwl = new ReentrantReadWriteLock();
        _readLock = _rwl.readLock();
        _writeLock = _rwl.writeLock();
    
Methods Summary
public java.lang.StringgetName()
Returns the unique name for this filter

        return (NAME_PREFIX + _applicationId + DELIM + _endpointId);
    
public static java.lang.StringgetName(java.lang.String appId, com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig wsc)
Returns the unique name for this filter

        return (NAME_PREFIX + appId + DELIM + wsc.getName());
    
public voidprocess(java.lang.String stage, java.lang.String endpoint, com.sun.enterprise.admin.wsmgmt.filter.spi.FilterContext context)
Invoke the filter.

param
stage stage of the execution
param
endpoint name of the endpoint
param
context filter context


        _readLock.lock();
        try {
            // SOAP request
            if ( stage.equals(Filter.PROCESS_REQUEST) ) {
                // optmize this XXX
                if ( reqChain != null) {
                        reqChain.process(context);
                }
            // SOAP response
            } else if ( stage.equals(Filter.PROCESS_RESPONSE) ) {
                if ( resChain != null) {
                        resChain.process(context);
                }
            }
        } catch(Exception e) {
            // log a warning
            e.printStackTrace();
            String msg = _stringMgr.getString("transform_failed", endpoint);
            _logger.log(Level.INFO, msg, e.getMessage());
        } finally {
            _readLock.unlock();
        }

    
public voidresetRequestChain(com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] tRules)

        _writeLock.lock();  
        try {
            reqChain = new FilterChain(tRules, false);
        } finally {
           _writeLock.unlock();
        }
    
public voidresetResponseChain(com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] tRules)

        _writeLock.lock();  
        try {
            resChain = new FilterChain(tRules, true);
        } finally {
           _writeLock.unlock();
        }