FileDocCategorySizeDatePackage
AggregateStatsFilter.javaAPI DocGlassfish v2 API4955Fri May 04 22:24:42 BST 2007com.sun.enterprise.admin.wsmgmt.filter.impl

AggregateStatsFilter

public class AggregateStatsFilter extends Object implements com.sun.enterprise.admin.wsmgmt.filter.spi.Filter
Filter that can implement or collect web services management information

Fields Summary
Constructors Summary
public AggregateStatsFilter()
Public Constructor.

param
epName End point name for which stats are collected

    
Methods Summary
public java.lang.StringgetName()
Returns the unique name for this filter

        return Constants.AGGREGATE_STATS_FILTER;
    
public voidprocess(java.lang.String stage, java.lang.String endpoint, com.sun.enterprise.admin.wsmgmt.filter.spi.FilterContext context)
Invoke the filter.


        WebServiceEndpointStatsProviderImpl impl = (
            WebServiceEndpointStatsProviderImpl) StatsProviderManager.
            getInstance().getEndpointStatsProvider(endpoint);

        if ( stage.equals(Filter.PRE_PROCESS_REQUEST) ) {
            impl.setRequestTimeStamp( System.currentTimeMillis(),null, null, 0);
        } else {
            if ( stage.equals(Filter.POST_PROCESS_RESPONSE) ) {

               SOAPMessageContext smc = context.getMessageContext(); 
               SOAPMessage sm = null;
               SOAPFault fault = null;
               try {
                   if (smc != null)
                       sm = smc.getMessage();
                    if (sm != null) {
                        SOAPBody sb = sm.getSOAPBody();
                        if (sb != null) {
                            fault = sb.getFault();
                        }
                    }
                } catch ( Exception e) {
                    // if body can not be obtained, consider this as failure
                    // (fault) case, however fault information is not available
                    impl.setFault(0,
                    System.currentTimeMillis(), context.getExecutionTime(), null,null, null);
                    return;
                }
 
                if ( fault == null) { 
                    impl.setSuccess(0, System.currentTimeMillis(),
                    context.getExecutionTime());
                } else {
                    impl.setFault(0,
                    System.currentTimeMillis(),context.getExecutionTime(),
                    fault.getFaultCode(), fault.getFaultString(), 
                    fault.getFaultString() );
                }
            } else {
                throw new RuntimeException(" Should not be called for this stage of execution of web service end point " + endpoint);
            }
        }