KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > msg > MessageFilter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.admin.wsmgmt.msg;
24
25 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants;
26 import com.sun.enterprise.admin.wsmgmt.filter.spi.Filter;
27 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterContext;
28 import com.sun.enterprise.admin.wsmgmt.msg.MessageTraceFactory;
29 import com.sun.appserv.management.ext.wsmgmt.MessageTrace;
30
31 /**
32  * Filter that can implement or collect web services management information
33  */

34 public class MessageFilter implements Filter {
35
36     /**
37      * Public Constructor.
38      *
39      * @param appId name of the application
40      * @param endpoint end point name for which stats are collected
41      * @param h endpoint handler
42      */

43     public MessageFilter(String JavaDoc appId, String JavaDoc endpoint, EndpointHandler h) {
44         _applicationId = appId;
45         _endpointId = endpoint;
46         _handler = h;
47     }
48
49     /**
50      * Returns the unique name for this filter
51      */

52     public String JavaDoc getName() {
53         return (NAME_PREFIX + _applicationId + DELIM + _endpointId);
54     }
55
56     /**
57      * Invoke the filter.
58      *
59      * @param stage stage of the execution
60      * @param endpoint name of the endpoint
61      * @param context filter context
62      */

63     public void process(String JavaDoc stage, String JavaDoc endpoint, FilterContext context) {
64
65         MessageTraceFactory mtf = MessageTraceFactory.getInstance();
66
67         // SOAP request
68
if ( stage.equals(Filter.PROCESS_REQUEST) ) {
69
70             // delegates to message trace factory for holding
71
mtf.processRequest(context, _applicationId);
72
73         // SOAP response
74
} else if ( stage.equals(Filter.PROCESS_RESPONSE) ) {
75             mtf.processResponse(context);
76
77         } else if (stage.equals(Filter.POST_PROCESS_RESPONSE) ) {
78             MessageTrace mt = mtf.postProcessResponse(context);
79
80             // adds the newly created message trace to the pool
81
_handler.addMessage(mt);
82         }
83     }
84
85     // -- PRIVATE - VARIABLES -------------------------
86
private String JavaDoc _applicationId = null;
87     private String JavaDoc _endpointId = null;
88     private EndpointHandler _handler = null;
89     private static final String JavaDoc DELIM = "#";
90     private static final String JavaDoc NAME_PREFIX = "MSGFILTER_";
91 }
92
Popular Tags