Author: azeez Date: Tue Jan 15 05:05:44 2008 New Revision: 12264 Log:
Adding tracer classes Added: trunk/commons/tracer/src/main/java/org/wso2/tracer/TracerUtils.java trunk/commons/tracer/src/main/java/org/wso2/tracer/module/TraceMessage.java Added: trunk/commons/tracer/src/main/java/org/wso2/tracer/TracerUtils.java ============================================================================== --- (empty file) +++ trunk/commons/tracer/src/main/java/org/wso2/tracer/TracerUtils.java Tue Jan 15 05:05:44 2008 @@ -0,0 +1,46 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.tracer; + +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axis2.Constants; +import org.apache.axis2.context.MessageContext; +import org.wso2.utils.xml.XMLPrettyPrinter; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; + +/** + * A collection of utility methods + */ +public class TracerUtils { + + /** + * Get a prettified XML string from the SOAPEnvelope + * + * @param env The SOAPEnvelope to be prettified + * + * @return prettified XML string from the SOAPEnvelope + */ + public static String getPrettyString(SOAPEnvelope env, MessageContext msgContext) { + InputStream xmlIn = new ByteArrayInputStream(env.toString().getBytes()); + String encoding = + (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); + XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, encoding); + return xmlPrettyPrinter.xmlFormat(); + } + +} Added: trunk/commons/tracer/src/main/java/org/wso2/tracer/module/TraceMessage.java ============================================================================== --- (empty file) +++ trunk/commons/tracer/src/main/java/org/wso2/tracer/module/TraceMessage.java Tue Jan 15 05:05:44 2008 @@ -0,0 +1,64 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.tracer.module; + +import org.apache.axiom.soap.SOAPEnvelope; + +/** + * The trace message which is stored in an in-memory buffer + */ +public class TraceMessage { + private String operationName; + private String serviceName; + private int messageFlow; + private long msgSequence; + private SOAPEnvelope soapEnvelope; + private long timestamp; + + public TraceMessage(String operationName, String serviceName, + int messageFlow, long msgSequence, SOAPEnvelope env) { + this.operationName = operationName; + this.serviceName = serviceName; + this.messageFlow = messageFlow; + this.msgSequence = msgSequence; + this.soapEnvelope = env; + this.timestamp = System.currentTimeMillis(); + } + + public String getOperationName() { + return operationName; + } + + public String getServiceName() { + return serviceName; + } + + public int getMessageFlow() { + return messageFlow; + } + + public SOAPEnvelope getSoapEnvelope() { + return soapEnvelope; + } + + public long getMsgSequence() { + return msgSequence; + } + + public long getTimestamp() { + return timestamp; + } +} _______________________________________________ Commons-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/commons-dev
