You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/07/12 17:05:17 UTC
cvs commit: xml-axis/java/src/org/apache/axis/utils/cache JavaClass.java JavaMethod.java
gdaniels 01/07/12 08:05:16
Modified: java/src/org/apache/axis AxisEngine.java AxisFault.java
AxisServiceConfig.java Chain.java Constants.java
FaultableHandler.java Handler.java Message.java
MessageContext.java SimpleChain.java
SimpleTargetedChain.java TargetedChain.java
java/src/org/apache/axis/client AdminClient.java
java/src/org/apache/axis/encoding ArraySerializer.java
Base64.java BeanSerializer.java DateSerializer.java
DeserializationContext.java
SOAPTypeMappingRegistry.java
TypeMappingRegistry.java
java/src/org/apache/axis/handlers BasicHandler.java
JWSProcessor.java LogHandler.java LogMessage.java
SimpleAuthenticationHandler.java
SimpleAuthorizationHandler.java
java/src/org/apache/axis/handlers/http
HTTPActionHandler.java
java/src/org/apache/axis/message MessageElement.java
SAXAdapter.java
java/src/org/apache/axis/registries HandlerRegistry.java
SimpleRegistry.java
java/src/org/apache/axis/server AxisServer.java
Transport.java
java/src/org/apache/axis/suppliers SimpleChainSupplier.java
TargetedChainSupplier.java TransportSupplier.java
java/src/org/apache/axis/transport/http AdminServlet.java
AxisServlet.java HTTPSender.java
java/src/org/apache/axis/transport/local Handler.java
LocalResponder.java LocalSender.java
LocalTransport.java
java/src/org/apache/axis/utils Admin.java
AxisClassLoader.java DOM2Writer.java Debug.java
JavaUtils.java Options.java XMLUtils.java
tcpmon.java
java/src/org/apache/axis/utils/cache JavaClass.java
JavaMethod.java
Log:
Four space indents everywhere.
NOTE: I did not deal with all the longer-than-80-char lines. If you're
editing a file and see some of this, please clean it up.
Revision Changes Path
1.24 +35 -32 xml-axis/java/src/org/apache/axis/AxisEngine.java
Index: AxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- AxisEngine.java 2001/07/10 22:52:40 1.23
+++ AxisEngine.java 2001/07/12 15:02:44 1.24
@@ -92,7 +92,7 @@
/** This Engine's global type mappings */
protected TypeMappingRegistry _typeMappingRegistry =
- new TypeMappingRegistry();
+ new TypeMappingRegistry();
protected Properties props = new Properties();
@@ -127,13 +127,13 @@
*/
public void init() {
/** Load properties 1st, so that debug level gets
- * set ASAP.
- */
+ * set ASAP.
+ */
try {
File propFile = new File("axis.properties");
if (propFile.exists()) {
FileInputStream propFileInputStream =
- new FileInputStream(propFile);
+ new FileInputStream(propFile);
props.load(propFileInputStream);
}
} catch (Exception e) {
@@ -173,27 +173,27 @@
{
InputStream is;
try {
- is = new FileInputStream(engineConfigFilename);
+ is = new FileInputStream(engineConfigFilename);
} catch (Exception e) {
- is = getResourceStream(engineConfigFilename);
+ is = getResourceStream(engineConfigFilename);
}
if (is == null) {
- // TODO: Deal with this in a nicer way...
- System.err.println("No engine configuration in " +
- this.getClass().getPackage().getName() +
- " - aborting!");
- return;
+ // TODO: Deal with this in a nicer way...
+ System.err.println("No engine configuration in " +
+ this.getClass().getPackage().getName() +
+ " - aborting!");
+ return;
}
Document doc = XMLUtils.newDocument(is);
try {
- // ??? Clear registries first?
- Admin.processEngineConfig(doc, this);
+ // ??? Clear registries first?
+ Admin.processEngineConfig(doc, this);
} catch (Exception e) {
- System.err.println("Couldn't read engine config!");
- e.printStackTrace();
- return;
+ System.err.println("Couldn't read engine config!");
+ e.printStackTrace();
+ return;
}
}
@@ -202,13 +202,13 @@
public void saveConfiguration()
{
try {
- Document doc = Admin.listConfig(this);
- FileOutputStream fos = new FileOutputStream(engineConfigFilename);
- XMLUtils.DocumentToStream(doc, fos);
- fos.close();
+ Document doc = Admin.listConfig(this);
+ FileOutputStream fos = new FileOutputStream(engineConfigFilename);
+ XMLUtils.DocumentToStream(doc, fos);
+ fos.close();
} catch (Exception e) {
- System.err.println("Coudn't write engine config!");
- e.printStackTrace();
+ System.err.println("Coudn't write engine config!");
+ e.printStackTrace();
}
}
@@ -267,13 +267,13 @@
public abstract AxisEngine getClientEngine ();
/*********************************************************************
- * Administration and management APIs
- *
- * These can get called by various admin adapters, such as JMX MBeans,
- * our own Admin client, web applications, etc...
- *
- *********************************************************************
- */
+ * Administration and management APIs
+ *
+ * These can get called by various admin adapters, such as JMX MBeans,
+ * our own Admin client, web applications, etc...
+ *
+ *********************************************************************
+ */
/**
* Register a new global type mapping
@@ -283,13 +283,16 @@
DeserializerFactory deserFactory,
Serializer serializer)
{
- Debug.Print(3, "Registering type mapping " + qName + " -> " + cls.getName());
+ Debug.Print(3, "Registering type mapping " + qName + " -> " +
+ cls.getName());
if (deserFactory != null)
- _typeMappingRegistry.addDeserializerFactory(qName, cls, deserFactory);
+ _typeMappingRegistry.addDeserializerFactory(qName,
+ cls,
+ deserFactory);
if (serializer != null)
_typeMappingRegistry.addSerializer(cls, qName, serializer);
}
-
+
/**
* Unregister a global type mapping
*/
1.23 +116 -114 xml-axis/java/src/org/apache/axis/AxisFault.java
Index: AxisFault.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- AxisFault.java 2001/07/09 14:15:12 1.22
+++ AxisFault.java 2001/07/12 15:02:46 1.23
@@ -72,118 +72,120 @@
*/
public class AxisFault extends Exception {
- protected QFault faultCode ;
- protected String faultString ;
- protected String faultActor ;
- protected Vector faultDetails ; // vector of Element's
-
- public AxisFault(String code, String str, String actor, Element[] details) {
- setFaultCode( new QFault(Constants.AXIS_NS, code));
- setFaultString( str );
- setFaultActor( actor );
- setFaultDetails( details );
- }
-
- public AxisFault(QFault code, String str, String actor, Element[] details) {
- setFaultCode( code );
- setFaultString( str );
- setFaultActor( actor );
- setFaultDetails( details );
- }
-
- public AxisFault(Exception e) {
- String str ;
-
- setFaultCode( Constants.FAULT_SERVER_GENERAL );
- // setFaultString( e.toString() );
- // need to set details if we were in the body at the time!!
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream( stream );
- e.printStackTrace(ps);
- ps.close();
- setFaultString( stream.toString() );
- }
-
- public AxisFault(String message)
- {
- setFaultCode(Constants.FAULT_SERVER_GENERAL);
- setFaultString(message);
- }
-
- /**
- * No-arg constructor for building one from an XML stream.
- */
- public AxisFault()
- {
- }
-
- public void dump() {
- System.out.println( "AxisFault\n" +
- " faultCode: " + faultCode + "\n" +
- " faultString: " + faultString + "\n" +
- " faultActor: " + faultActor + "\n" +
- " faultDetails: " + faultDetails + "\n" );
- }
-
- public void setFaultCode(QFault code) {
- faultCode = code ;
- }
-
- public void setFaultCode(String code) {
- faultCode = new QFault(Constants.AXIS_NS, code);
- }
-
- public QFault getFaultCode() {
- return( faultCode );
- }
-
- public void setFaultString(String str) {
- faultString = str ;
- }
-
- public String getFaultString() {
- return( faultString );
- }
-
- public void setFaultActor(String actor) {
- faultActor = actor ;
- }
-
- public String getFaultActor() {
- return( faultActor );
- }
-
- public void setFaultDetails(Element[] details) {
- if ( details == null ) return ;
- faultDetails = new Vector( details.length );
- for ( int loop = 0 ; loop < details.length ; loop++ )
- faultDetails.add( details[loop] );
- }
-
- public Element[] getFaultDetails() {
- if (faultDetails == null) return null;
- Element result[] = new Element[faultDetails.size()];
- for (int i=0; i<result.length; i++)
- result[i] = (Element) faultDetails.elementAt(i);
- return result;
- }
-
- public void output(SerializationContext context) throws Exception {
-
- SOAPEnvelope envelope = new SOAPEnvelope();
-
- SOAPFaultElement fault =
- new SOAPFaultElement(this);
- envelope.addBodyElement(fault);
-
- envelope.output(context);
- }
-
- public String toString() {
- return( "AxisFault\n" +
- " faultCode: " + faultCode + "\n" +
- " faultString: " + faultString + "\n" +
- " faultActor: " + faultActor + "\n" +
- " faultDetails: " + faultDetails + "\n" );
- }
+ protected QFault faultCode ;
+ protected String faultString ;
+ protected String faultActor ;
+ protected Vector faultDetails ; // vector of Element's
+
+ public AxisFault(String code, String str,
+ String actor, Element[] details) {
+ setFaultCode( new QFault(Constants.AXIS_NS, code));
+ setFaultString( str );
+ setFaultActor( actor );
+ setFaultDetails( details );
+ }
+
+ public AxisFault(QFault code, String str,
+ String actor, Element[] details) {
+ setFaultCode( code );
+ setFaultString( str );
+ setFaultActor( actor );
+ setFaultDetails( details );
+ }
+
+ public AxisFault(Exception e) {
+ String str ;
+
+ setFaultCode( Constants.FAULT_SERVER_GENERAL );
+ // setFaultString( e.toString() );
+ // need to set details if we were in the body at the time!!
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream( stream );
+ e.printStackTrace(ps);
+ ps.close();
+ setFaultString( stream.toString() );
+ }
+
+ public AxisFault(String message)
+ {
+ setFaultCode(Constants.FAULT_SERVER_GENERAL);
+ setFaultString(message);
+ }
+
+ /**
+ * No-arg constructor for building one from an XML stream.
+ */
+ public AxisFault()
+ {
+ }
+
+ public void dump() {
+ System.out.println( "AxisFault\n" +
+ " faultCode: " + faultCode + "\n" +
+ " faultString: " + faultString + "\n" +
+ " faultActor: " + faultActor + "\n" +
+ " faultDetails: " + faultDetails + "\n" );
+ }
+
+ public void setFaultCode(QFault code) {
+ faultCode = code ;
+ }
+
+ public void setFaultCode(String code) {
+ faultCode = new QFault(Constants.AXIS_NS, code);
+ }
+
+ public QFault getFaultCode() {
+ return( faultCode );
+ }
+
+ public void setFaultString(String str) {
+ faultString = str ;
+ }
+
+ public String getFaultString() {
+ return( faultString );
+ }
+
+ public void setFaultActor(String actor) {
+ faultActor = actor ;
+ }
+
+ public String getFaultActor() {
+ return( faultActor );
+ }
+
+ public void setFaultDetails(Element[] details) {
+ if ( details == null ) return ;
+ faultDetails = new Vector( details.length );
+ for ( int loop = 0 ; loop < details.length ; loop++ )
+ faultDetails.add( details[loop] );
+ }
+
+ public Element[] getFaultDetails() {
+ if (faultDetails == null) return null;
+ Element result[] = new Element[faultDetails.size()];
+ for (int i=0; i<result.length; i++)
+ result[i] = (Element) faultDetails.elementAt(i);
+ return result;
+ }
+
+ public void output(SerializationContext context) throws Exception {
+
+ SOAPEnvelope envelope = new SOAPEnvelope();
+
+ SOAPFaultElement fault =
+ new SOAPFaultElement(this);
+ envelope.addBodyElement(fault);
+
+ envelope.output(context);
+ }
+
+ public String toString() {
+ return( "AxisFault\n" +
+ " faultCode: " + faultCode + "\n" +
+ " faultString: " + faultString + "\n" +
+ " faultActor: " + faultActor + "\n" +
+ " faultDetails: " + faultDetails + "\n" );
+ }
};
1.2 +63 -8 xml-axis/java/src/org/apache/axis/AxisServiceConfig.java
Index: AxisServiceConfig.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisServiceConfig.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AxisServiceConfig.java 2001/07/08 14:18:36 1.1
+++ AxisServiceConfig.java 2001/07/12 15:02:47 1.2
@@ -1,3 +1,58 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Axis" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
package org.apache.axis;
/** If a Java class which acts as the target for an Axis service
@@ -8,12 +63,12 @@
*/
public interface AxisServiceConfig
{
- /** Get the allowed method names.
- *
- * (The only method right now)
- *
- * @return a space-delimited list of method names which may be called
- * via SOAP.
- */
- public String getMethods();
+ /** Get the allowed method names.
+ *
+ * (The only method right now)
+ *
+ * @return a space-delimited list of method names which may be called
+ * via SOAP.
+ */
+ public String getMethods();
}
1.6 +21 -21 xml-axis/java/src/org/apache/axis/Chain.java
Index: Chain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Chain.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Chain.java 2001/02/10 04:39:53 1.5
+++ Chain.java 2001/07/12 15:02:48 1.6
@@ -63,30 +63,30 @@
*/
public interface Chain extends Handler {
- /**
- * Adds a handler to the end of the chain
- */
- public void addHandler(Handler handler);
+ /**
+ * Adds a handler to the end of the chain
+ */
+ public void addHandler(Handler handler);
- /**
- * Removes the specified handler from the chain
- */
- public void removeHandler(int index);
+ /**
+ * Removes the specified handler from the chain
+ */
+ public void removeHandler(int index);
- /**
- * Is this handler in the chain?
- */
- public boolean contains(Handler handler);
+ /**
+ * Is this handler in the chain?
+ */
+ public boolean contains(Handler handler);
- /**
- * Get the list of handlers in the chain - is Handler[] the right form?
- */
- public Handler[] getHandlers();
+ /**
+ * Get the list of handlers in the chain - is Handler[] the right form?
+ */
+ public Handler[] getHandlers();
- /**
- * Erase the contents of the chain
- */
- public void clear();
+ /**
+ * Erase the contents of the chain
+ */
+ public void clear();
- // How many do we want to force people to implement?
+ // How many do we want to force people to implement?
};
1.27 +113 -112 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Constants.java 2001/07/11 20:01:23 1.26
+++ Constants.java 2001/07/12 15:02:49 1.27
@@ -58,119 +58,120 @@
import org.apache.axis.utils.QFault;
public class Constants {
- // Some common Constants that should be used in local handler options
- // (Not all implementations will have these concepts - for example
- // not all Engines will have notion of registries but defining these
- // here should allow people to ask if they exist)
- //////////////////////////////////////////////////////////////////////////
-
- // Envelope Stuff
- //////////////////////////////////////////////////////////////////////////
- public static final String NSPREFIX_SOAP_ENV = "SOAP-ENV" ;
- public static final String NSPREFIX_SOAP_ENC = "SOAP-ENC" ;
- public static final String NSPREFIX_SCHEMA_XSI = "xsi" ;
- public static final String NSPREFIX_SCHEMA_XSD = "xsd" ;
-
-
- public static final String AXIS_NS = "http://xml.apache.org/axis/";
-
- //
- // SOAP 1.1 constants
- //
- public static final String URI_SOAP_ENV =
- "http://schemas.xmlsoap.org/soap/envelope/" ;
- public static final String URI_SOAP_ENC =
- "http://schemas.xmlsoap.org/soap/encoding/" ;
- public static final String URI_NEXT_ACTOR =
+ // Some common Constants that should be used in local handler options
+ // (Not all implementations will have these concepts - for example
+ // not all Engines will have notion of registries but defining these
+ // here should allow people to ask if they exist)
+ //////////////////////////////////////////////////////////////////////////
+
+ // Envelope Stuff
+ //////////////////////////////////////////////////////////////////////////
+ public static final String NSPREFIX_SOAP_ENV = "SOAP-ENV" ;
+ public static final String NSPREFIX_SOAP_ENC = "SOAP-ENC" ;
+ public static final String NSPREFIX_SCHEMA_XSI = "xsi" ;
+ public static final String NSPREFIX_SCHEMA_XSD = "xsd" ;
+
+
+ public static final String AXIS_NS = "http://xml.apache.org/axis/";
+
+ //
+ // SOAP 1.1 constants
+ //
+ public static final String URI_SOAP_ENV =
+ "http://schemas.xmlsoap.org/soap/envelope/" ;
+ public static final String URI_SOAP_ENC =
+ "http://schemas.xmlsoap.org/soap/encoding/" ;
+ public static final String URI_NEXT_ACTOR =
"http://schemas.xmlsoap.org/soap/actor/next" ;
-
- //
- // SOAP 1.2 constants
- //
- public static final String URI_SOAP12_ENV =
- "http://www.w3.org/2001/06/soap-envelope";
- public static final String URI_SOAP12_ENC =
- "http://www.w3.org/2001/06/soap-encoding";
- public static final String URI_SOAP12_NEXT_ACTOR =
+
+ //
+ // SOAP 1.2 constants
+ //
+ public static final String URI_SOAP12_ENV =
+ "http://www.w3.org/2001/06/soap-envelope";
+ public static final String URI_SOAP12_ENC =
+ "http://www.w3.org/2001/06/soap-encoding";
+ public static final String URI_SOAP12_NEXT_ACTOR =
"http://www.w3.org/2001/06/soap-envelope/actor/next";
- public static final String URI_SOAP12_FAULT_NS =
- "http://www.w3.org/2001/06/soap-faults";
- public static final String URI_SOAP12_UPGRADE_NS =
- "http://www.w3.org/2001/06/soap-upgrade";
-
-
- public static String NS_URI_XMLNS =
- "http://www.w3.org/2000/xmlns/";
-
- // Schema namespaces
- public static final String URI_1999_SCHEMA_XSI =
- "http://www.w3.org/1999/XMLSchema-instance";
- public static final String URI_1999_SCHEMA_XSD =
- "http://www.w3.org/1999/XMLSchema";
- public static final String URI_2000_SCHEMA_XSI =
- "http://www.w3.org/2000/10/XMLSchema-instance";
- public static final String URI_2000_SCHEMA_XSD =
- "http://www.w3.org/2000/10/XMLSchema";
- public static final String URI_2001_SCHEMA_XSI =
- "http://www.w3.org/2001/XMLSchema-instance";
- public static final String URI_2001_SCHEMA_XSD =
- "http://www.w3.org/2001/XMLSchema";
- public static final String URI_CURRENT_SCHEMA_XSI = URI_2001_SCHEMA_XSI;
- public static final String URI_CURRENT_SCHEMA_XSD = URI_2001_SCHEMA_XSD;
-
- public static final String[] URIS_SCHEMA_XSI = {
- URI_1999_SCHEMA_XSI,
- URI_2000_SCHEMA_XSI,
- URI_2001_SCHEMA_XSI,
- };
-
- public static final String[] URIS_SCHEMA_XSD = {
- URI_1999_SCHEMA_XSD,
- URI_2000_SCHEMA_XSD,
- URI_2001_SCHEMA_XSD,
- };
-
- public static final String ELEM_ENVELOPE = "Envelope" ;
- public static final String ELEM_HEADER = "Header" ;
- public static final String ELEM_BODY = "Body" ;
- public static final String ELEM_FAULT = "Fault" ;
-
- public static final String ELEM_MISUNDERSTOOD = "Misunderstood";
-
- public static final String ELEM_FAULT_CODE = "faultcode" ;
- public static final String ELEM_FAULT_STRING = "faultstring" ;
- public static final String ELEM_FAULT_DETAIL = "detail" ;
- public static final String ELEM_FAULT_ACTOR = "faultactor" ;
-
- public static final String ATTR_MUST_UNDERSTAND = "mustUnderstand" ;
- public static final String ATTR_ENCODING_STYLE = "encodingStyle" ;
- public static final String ATTR_ACTOR = "actor" ;
- public static final String ATTR_ROOT = "root" ;
- public static final String ATTR_ID = "id" ;
- public static final String ATTR_HREF = "href" ;
- public static final String ATTR_QNAME = "qname";
- public static final String ATTR_ARRAY_TYPE = "arrayType";
-
- // Fault Codes
- //////////////////////////////////////////////////////////////////////////
- public static final String FAULT_SERVER_GENERAL = "Server.generalException";
-
- public static final QFault FAULT_MUSTUNDERSTAND =
- new QFault(URI_SOAP_ENV, "MustUnderstand");
-
-
- // Misc Strings
- //////////////////////////////////////////////////////////////////////////
- public static final String URI_DEBUG = "http://xml.apache.org/axis/debug" ;
-
- public static final String MC_REALPATH = "realpath";
-
- /** The global input/out chains */
- public static final String GLOBAL_REQUEST = "global.request" ;
- public static final String GLOBAL_RECEIVE = "global.response" ;
-
- public static final String JWSPROCESSOR_TARGET = "JWSProcessor" ;
+ public static final String URI_SOAP12_FAULT_NS =
+ "http://www.w3.org/2001/06/soap-faults";
+ public static final String URI_SOAP12_UPGRADE_NS =
+ "http://www.w3.org/2001/06/soap-upgrade";
+
+
+ public static String NS_URI_XMLNS =
+ "http://www.w3.org/2000/xmlns/";
+
+ // Schema namespaces
+ public static final String URI_1999_SCHEMA_XSI =
+ "http://www.w3.org/1999/XMLSchema-instance";
+ public static final String URI_1999_SCHEMA_XSD =
+ "http://www.w3.org/1999/XMLSchema";
+ public static final String URI_2000_SCHEMA_XSI =
+ "http://www.w3.org/2000/10/XMLSchema-instance";
+ public static final String URI_2000_SCHEMA_XSD =
+ "http://www.w3.org/2000/10/XMLSchema";
+ public static final String URI_2001_SCHEMA_XSI =
+ "http://www.w3.org/2001/XMLSchema-instance";
+ public static final String URI_2001_SCHEMA_XSD =
+ "http://www.w3.org/2001/XMLSchema";
+ public static final String URI_CURRENT_SCHEMA_XSI = URI_2001_SCHEMA_XSI;
+ public static final String URI_CURRENT_SCHEMA_XSD = URI_2001_SCHEMA_XSD;
+
+ public static final String[] URIS_SCHEMA_XSI = {
+ URI_1999_SCHEMA_XSI,
+ URI_2000_SCHEMA_XSI,
+ URI_2001_SCHEMA_XSI,
+ };
+
+ public static final String[] URIS_SCHEMA_XSD = {
+ URI_1999_SCHEMA_XSD,
+ URI_2000_SCHEMA_XSD,
+ URI_2001_SCHEMA_XSD,
+ };
+
+ public static final String ELEM_ENVELOPE = "Envelope" ;
+ public static final String ELEM_HEADER = "Header" ;
+ public static final String ELEM_BODY = "Body" ;
+ public static final String ELEM_FAULT = "Fault" ;
+
+ public static final String ELEM_MISUNDERSTOOD = "Misunderstood";
+
+ public static final String ELEM_FAULT_CODE = "faultcode" ;
+ public static final String ELEM_FAULT_STRING = "faultstring" ;
+ public static final String ELEM_FAULT_DETAIL = "detail" ;
+ public static final String ELEM_FAULT_ACTOR = "faultactor" ;
+
+ public static final String ATTR_MUST_UNDERSTAND = "mustUnderstand" ;
+ public static final String ATTR_ENCODING_STYLE = "encodingStyle" ;
+ public static final String ATTR_ACTOR = "actor" ;
+ public static final String ATTR_ROOT = "root" ;
+ public static final String ATTR_ID = "id" ;
+ public static final String ATTR_HREF = "href" ;
+ public static final String ATTR_QNAME = "qname";
+ public static final String ATTR_ARRAY_TYPE = "arrayType";
+
+ // Fault Codes
+ //////////////////////////////////////////////////////////////////////////
+ public static final String FAULT_SERVER_GENERAL =
+ "Server.generalException";
+
+ public static final QFault FAULT_MUSTUNDERSTAND =
+ new QFault(URI_SOAP_ENV, "MustUnderstand");
+
+
+ // Misc Strings
+ //////////////////////////////////////////////////////////////////////////
+ public static final String URI_DEBUG = "http://xml.apache.org/axis/debug";
+
+ public static final String MC_REALPATH = "realpath";
+
+ /** The global input/out chains */
+ public static final String GLOBAL_REQUEST = "global.request" ;
+ public static final String GLOBAL_RECEIVE = "global.response" ;
+
+ public static final String JWSPROCESSOR_TARGET = "JWSProcessor" ;
- public static final String SERVER_CONFIG_FILE = "server-config.xml";
- public static final String CLIENT_CONFIG_FILE = "client-config.xml";
+ public static final String SERVER_CONFIG_FILE = "server-config.xml";
+ public static final String CLIENT_CONFIG_FILE = "client-config.xml";
}
1.14 +74 -73 xml-axis/java/src/org/apache/axis/FaultableHandler.java
Index: FaultableHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/FaultableHandler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FaultableHandler.java 2001/06/15 00:37:58 1.13
+++ FaultableHandler.java 2001/07/12 15:02:51 1.14
@@ -73,80 +73,81 @@
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class FaultableHandler extends BasicHandler {
- protected Handler workHandler ;
- protected Hashtable faultHandlers ;
-
- /** Constructor
- *
- * @param workHandler the Handler we're going to wrap with Fault semantics.
- */
- public FaultableHandler(Handler workHandler)
- {
- this.workHandler = workHandler;
- faultHandlers = new Hashtable();
- }
-
- public void init() {
- workHandler.init();
- }
-
- public void cleanup() {
- workHandler.cleanup();
- }
-
- /**
- * Invokes the specified handler. If there's a fault the appropriate
- * key will be calculated and used to find the fault chain to be
- * invoked. This assumes that the workHandler has caught the exception
- * and already processed it's undo logic - as needed.
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: FaultableHandler::invoke" );
- try {
- workHandler.invoke( msgContext );
+ protected Handler workHandler ;
+ protected Hashtable faultHandlers ;
+
+ /** Constructor
+ *
+ * @param workHandler the Handler we're going to wrap with Fault semantics.
+ */
+ public FaultableHandler(Handler workHandler)
+ {
+ this.workHandler = workHandler;
+ faultHandlers = new Hashtable();
}
- catch( Exception e ) {
- Debug.Print( 1, e );
- AxisFault fault;
- // Is this a Java Exception? a SOAPException? an AxisException?
- if ( e instanceof AxisFault ) {
- fault = (AxisFault)e;
- } else {
- fault = new AxisFault( e );
- }
-
- /** Index off fault code.
- *
- * !!! TODO: This needs to be able to handle searching by faultcode
- * hierarchy, i.e. "Server.General.*" or "Server.*", with the
- * most specific match winning.
- */
- QFault key = fault.getFaultCode() ;
- Handler faultHandler = (Handler) faultHandlers.get( key );
- if ( faultHandler != null ) {
- /** faultHandler will (re)throw if it's appropriate, but it might
- * also eat the fault. Which brings up another issue - should
- * we have a way to pass the Fault directly to the faultHandler?
- * Maybe another well-known MessageContext property?
- */
- faultHandler.invoke( msgContext );
- } else {
- throw (AxisFault) e ;
- }
+
+ public void init() {
+ workHandler.init();
+ }
+
+ public void cleanup() {
+ workHandler.cleanup();
}
- Debug.Print( 1, "Exit: FaultableHandler::invoke" );
- }
- /**
- * Some handler later on has faulted so we need to undo our work.
- */
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: FaultableHandler::undo" );
- workHandler.undo( msgContext );
- Debug.Print( 1, "Exit: FaultableHandler::undo" );
- };
-
- public boolean canHandleBlock(QName qname) {
- return( workHandler.canHandleBlock(qname) );
- }
+ /**
+ * Invokes the specified handler. If there's a fault the appropriate
+ * key will be calculated and used to find the fault chain to be
+ * invoked. This assumes that the workHandler has caught the exception
+ * and already processed it's undo logic - as needed.
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: FaultableHandler::invoke" );
+ try {
+ workHandler.invoke( msgContext );
+ }
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ AxisFault fault;
+ // Is this a Java Exception? a SOAPException? an AxisException?
+ if ( e instanceof AxisFault ) {
+ fault = (AxisFault)e;
+ } else {
+ fault = new AxisFault( e );
+ }
+
+ /** Index off fault code.
+ *
+ * !!! TODO: This needs to be able to handle searching by faultcode
+ * hierarchy, i.e. "Server.General.*" or "Server.*", with the
+ * most specific match winning.
+ */
+ QFault key = fault.getFaultCode() ;
+ Handler faultHandler = (Handler) faultHandlers.get( key );
+ if ( faultHandler != null ) {
+ /** faultHandler will (re)throw if it's appropriate, but it
+ * might also eat the fault. Which brings up another issue -
+ * should we have a way to pass the Fault directly to the
+ * faultHandler? Maybe another well-known MessageContext
+ * property?
+ */
+ faultHandler.invoke( msgContext );
+ } else {
+ throw (AxisFault) e ;
+ }
+ }
+ Debug.Print( 1, "Exit: FaultableHandler::invoke" );
+ }
+
+ /**
+ * Some handler later on has faulted so we need to undo our work.
+ */
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: FaultableHandler::undo" );
+ workHandler.undo( msgContext );
+ Debug.Print( 1, "Exit: FaultableHandler::undo" );
+ };
+
+ public boolean canHandleBlock(QName qname) {
+ return( workHandler.canHandleBlock(qname) );
+ }
};
1.12 +72 -72 xml-axis/java/src/org/apache/axis/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Handler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Handler.java 2001/06/21 17:02:36 1.11
+++ Handler.java 2001/07/12 15:02:53 1.12
@@ -67,76 +67,76 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public interface Handler extends Serializable {
- /**
- * Init is called when the chain containing this Handler object
- * is instantiated.
- */
- public void init();
-
- /**
- * Cleanup is called when the chain containing this Handler object
- * is done processing the chain.
- */
- public void cleanup();
-
- /**
- * Invoke is called to do the actual work of the Handler object.
- * If there is a fault during the processing of this method it is
- * invoke's job to catch the exception and undo any partial work
- * that has been completed. Once we leave 'invoke' if a fault
- * is thrown, this classes 'undo' method will be called to undo
- * the work that 'invoke' did.
- * Invoke should rethrow any exceptions it catches.
- */
- public void invoke(MessageContext msgContext) throws AxisFault ;
-
- /**
- * Called when a fault occurs to 'undo' whatever 'invoke' did.
- */
- public void undo(MessageContext msgContext);
-
- /**
- * Can this Handler process this QName?
- */
- public boolean canHandleBlock(QName qname);
-
- /**
- * Add the given option (name/value) to this handler's bag of options
- */
- public void addOption(String name, Object value);
-
- /**
- * Returns the option corresponding to the 'name' given
- */
- public Object getOption(String name);
-
- /**
- * Set the name (i.e. registry key) of this Handler
- */
- public void setName(String name);
-
- /**
- * Return the name (i.e. registry key) for this Handler
- */
- public String getName();
-
- /**
- * Return the entire list of options
- */
- public Hashtable getOptions();
-
- /**
- * Sets a whole list of options
- */
- public void setOptions(Hashtable opts);
-
- /**
- * This will return the root element of an XML doc that describes the
- * deployment information about this handler. This is NOT the WSDL,
- * this is all of the static internal data use by Axis - WSDL takes into
- * account run-time information (like which service we're talking about)
- * this is just the data that's stored in the registry. Used by the
- * 'list' Admin function.
- */
- public Element getDeploymentData(Document doc);
+ /**
+ * Init is called when the chain containing this Handler object
+ * is instantiated.
+ */
+ public void init();
+
+ /**
+ * Cleanup is called when the chain containing this Handler object
+ * is done processing the chain.
+ */
+ public void cleanup();
+
+ /**
+ * Invoke is called to do the actual work of the Handler object.
+ * If there is a fault during the processing of this method it is
+ * invoke's job to catch the exception and undo any partial work
+ * that has been completed. Once we leave 'invoke' if a fault
+ * is thrown, this classes 'undo' method will be called to undo
+ * the work that 'invoke' did.
+ * Invoke should rethrow any exceptions it catches.
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault ;
+
+ /**
+ * Called when a fault occurs to 'undo' whatever 'invoke' did.
+ */
+ public void undo(MessageContext msgContext);
+
+ /**
+ * Can this Handler process this QName?
+ */
+ public boolean canHandleBlock(QName qname);
+
+ /**
+ * Add the given option (name/value) to this handler's bag of options
+ */
+ public void addOption(String name, Object value);
+
+ /**
+ * Returns the option corresponding to the 'name' given
+ */
+ public Object getOption(String name);
+
+ /**
+ * Set the name (i.e. registry key) of this Handler
+ */
+ public void setName(String name);
+
+ /**
+ * Return the name (i.e. registry key) for this Handler
+ */
+ public String getName();
+
+ /**
+ * Return the entire list of options
+ */
+ public Hashtable getOptions();
+
+ /**
+ * Sets a whole list of options
+ */
+ public void setOptions(Hashtable opts);
+
+ /**
+ * This will return the root element of an XML doc that describes the
+ * deployment information about this handler. This is NOT the WSDL,
+ * this is all of the static internal data use by Axis - WSDL takes into
+ * account run-time information (like which service we're talking about)
+ * this is just the data that's stored in the registry. Used by the
+ * 'list' Admin function.
+ */
+ public Element getDeploymentData(Document doc);
};
1.37 +229 -220 xml-axis/java/src/org/apache/axis/Message.java
Index: Message.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Message.java 2001/07/10 22:52:41 1.36
+++ Message.java 2001/07/12 15:02:55 1.37
@@ -71,228 +71,237 @@
* @author Glen Daniels (gdaniels@allaire.com)
*/
public class Message {
- /**
- * Just a placeholder until we figure out what the actual Message
- * object is.
- */
- private Object originalMessage ;
- private Object currentMessage ;
-
- private static final int FORM_STRING = 1;
- private static final int FORM_INPUTSTREAM = 2;
- private static final int FORM_SOAPENVELOPE = 3;
- private static final int FORM_BYTES = 4;
- private static final int FORM_BODYINSTREAM = 5;
- private static final int FORM_FAULT = 6;
- private int currentForm ;
+ /**
+ * Just a placeholder until we figure out what the actual Message
+ * object is.
+ */
+ private Object originalMessage ;
+ private Object currentMessage ;
+
+ private static final int FORM_STRING = 1;
+ private static final int FORM_INPUTSTREAM = 2;
+ private static final int FORM_SOAPENVELOPE = 3;
+ private static final int FORM_BYTES = 4;
+ private static final int FORM_BODYINSTREAM = 5;
+ private static final int FORM_FAULT = 6;
+ private int currentForm ;
private static final String[] formNames =
{ "", "FORM_STRING", "FORM_INPUTSTREAM", "FORM_SOAPENVELOPE",
- "FORM_BYTES", "FORM_BODYINSTREAM", "FORM_FAULT" };
-
- private String messageType ;
- private MessageContext msgContext;
-
- /**
- * Just something to us working...
- */
- public Message(String stringForm) {
- Debug.Print( 2, "Enter Message ctor (String)" );
- originalMessage = stringForm;
- setCurrentMessage(stringForm, FORM_STRING);
- }
-
- public Message(SOAPEnvelope env) {
- Debug.Print( 2, "Enter Message ctor (SOAPEnvelope)" );
- originalMessage = env;
- setCurrentMessage(env, FORM_SOAPENVELOPE);
- }
-
- public Message(InputStream inputStream) {
- Debug.Print( 2, "Enter Message ctor (InputStream)" );
- originalMessage = inputStream;
- setCurrentMessage(inputStream, FORM_INPUTSTREAM);
- }
-
- public Message(InputStream inputStream, boolean isBody) {
- Debug.Print( 2, "Enter Message ctor (BodyInputStream)" );
- originalMessage = inputStream;
- setCurrentMessage(inputStream, isBody ? FORM_BODYINSTREAM :
- FORM_INPUTSTREAM);
- }
-
- public Message(byte [] bytes) {
- Debug.Print(2, "Enter Message ctor (byte[])" );
- originalMessage = bytes;
- setCurrentMessage(bytes, FORM_BYTES);
- }
-
- public Message(AxisFault fault) {
- Debug.Print(2, "Enter Message ctor (AxisFault)" );
- originalMessage = fault;
- setCurrentMessage(fault, FORM_FAULT);
- }
-
- public Object getOriginalMessage() {
- return( originalMessage );
- }
-
- public Object getCurrentMessage() {
- return( currentMessage );
- }
-
- private int getCurrentForm() {
- return( currentForm );
- }
-
- public void setMessageType(String messageType)
- {
- this.messageType = messageType;
- }
-
- public MessageContext getMessageContext()
- {
- return msgContext;
- }
- public void setMessageContext(MessageContext msgContext)
- {
- this.msgContext = msgContext;
- }
-
- private void setCurrentMessage(Object currMsg, int form) {
- Debug.Print( 2, "Setting current message form to: " + formNames[form] +" (currentMessage is now "+currMsg+")" );
- currentMessage = currMsg ;
- currentForm = form ;
- }
-
- public byte[] getAsBytes() {
- Debug.Print( 2, "Enter: Message::getAsBytes" );
- if ( currentForm == FORM_BYTES ) {
- Debug.Print( 2, "Exit: Message::getAsBytes" );
- return( (byte[]) currentMessage );
- }
-
- if ( currentForm == FORM_BODYINSTREAM ) {
- getAsSOAPEnvelope();
- }
-
- if ( currentForm == FORM_INPUTSTREAM ) {
- // Assumes we don't need a content length
- try {
- InputStream inp = (InputStream) currentMessage ;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buf = new byte[4096];
- int len ;
- while ( (len = inp.read(buf,0,4096)) != -1 )
- baos.write( buf, 0, len );
- buf = baos.toByteArray();
- // int len = inp.available();
- // byte[] buf = new byte[ len ];
- // inp.read( buf );
- setCurrentMessage( buf, FORM_BYTES );
- Debug.Print( 2, "Exit: Message::getAsByes" );
- return( (byte[]) currentMessage );
- }
- catch( Exception e ) {
- e.printStackTrace( System.err );
- }
- Debug.Print( 2, "Exit: Message::getAsByes" );
- return( null );
- }
-
- if ( currentForm == FORM_SOAPENVELOPE ||
- currentForm == FORM_FAULT )
- getAsString();
-
- if ( currentForm == FORM_STRING ) {
- setCurrentMessage( ((String)currentMessage).getBytes(), FORM_BYTES );
- Debug.Print( 2, "Exit: Message::getAsBytes" );
- return( (byte[]) currentMessage );
- }
-
- System.err.println("Can't convert " + currentForm + " to Bytes" );
- Debug.Print( 2, "Exit: Message::getAsBytes" );
- return( null );
- }
-
- public String getAsString() {
- Debug.Print( 2, "Enter: Message::getAsString" );
- if ( currentForm == FORM_STRING ) {
- Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+currentMessage );
- return( (String) currentMessage );
- }
-
- if ( currentForm == FORM_INPUTSTREAM ||
- currentForm == FORM_BODYINSTREAM ) {
- getAsBytes();
- // Fall thru to "Bytes"
- }
-
- if ( currentForm == FORM_BYTES ) {
- setCurrentMessage( new String((byte[]) currentMessage), FORM_STRING );
- Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+currentMessage );
- return( (String) currentMessage );
- }
-
- if ( currentForm == FORM_FAULT ) {
- StringWriter writer = new StringWriter();
- AxisFault env = (AxisFault)currentMessage;
- try {
- env.output(new SerializationContext(writer, msgContext));
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- setCurrentMessage(writer.getBuffer().toString(), FORM_STRING);
- return (String)currentMessage;
- }
-
- if ( currentForm == FORM_SOAPENVELOPE ) {
- StringWriter writer = new StringWriter();
- SOAPEnvelope env = (SOAPEnvelope)currentMessage;
- try {
- env.output(new SerializationContext(writer, msgContext));
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- setCurrentMessage(writer.getBuffer().toString(), FORM_STRING);
- return (String)currentMessage;
- }
-
- System.err.println("Can't convert form " + currentForm + " to String" );
- Debug.Print( 2, "Exit: Message::getAsString" );
- return( null );
- }
-
- public SOAPEnvelope getAsSOAPEnvelope() {
- Debug.Print( 2, "Enter: Message::getAsSOAPEnvelope; currentForm is "+formNames[currentForm] );
- if ( currentForm == FORM_SOAPENVELOPE )
- return( (SOAPEnvelope) currentMessage );
-
- if (currentForm == FORM_BODYINSTREAM) {
- InputStreamBody bodyEl = new InputStreamBody((InputStream)currentMessage);
- SOAPEnvelope env = new SOAPEnvelope();
- env.addBodyElement(bodyEl);
- setCurrentMessage(env, FORM_SOAPENVELOPE);
- return env;
- }
-
- InputSource is;
-
- if ( currentForm == FORM_INPUTSTREAM ) {
- is = new InputSource( (InputStream) currentMessage );
- } else {
- is = new InputSource(new StringReader(getAsString()));
- }
-
- SAXAdapter parser = new SAXAdapter(is, msgContext, messageType);
- SOAPEnvelope env = parser.getEnvelope();
- env.setMessageType(messageType);
-
- setCurrentMessage( env, FORM_SOAPENVELOPE );
- Debug.Print( 2, "Exit: Message::getAsSOAPEnvelope" );
- return( (SOAPEnvelope) currentMessage );
- }
+ "FORM_BYTES", "FORM_BODYINSTREAM", "FORM_FAULT" };
+
+ private String messageType ;
+ private MessageContext msgContext;
+
+ /**
+ * Just something to us working...
+ */
+ public Message(String stringForm) {
+ Debug.Print( 2, "Enter Message ctor (String)" );
+ originalMessage = stringForm;
+ setCurrentMessage(stringForm, FORM_STRING);
+ }
+
+ public Message(SOAPEnvelope env) {
+ Debug.Print( 2, "Enter Message ctor (SOAPEnvelope)" );
+ originalMessage = env;
+ setCurrentMessage(env, FORM_SOAPENVELOPE);
+ }
+
+ public Message(InputStream inputStream) {
+ Debug.Print( 2, "Enter Message ctor (InputStream)" );
+ originalMessage = inputStream;
+ setCurrentMessage(inputStream, FORM_INPUTSTREAM);
+ }
+
+ public Message(InputStream inputStream, boolean isBody) {
+ Debug.Print( 2, "Enter Message ctor (BodyInputStream)" );
+ originalMessage = inputStream;
+ setCurrentMessage(inputStream, isBody ? FORM_BODYINSTREAM :
+ FORM_INPUTSTREAM);
+ }
+
+ public Message(byte [] bytes) {
+ Debug.Print(2, "Enter Message ctor (byte[])" );
+ originalMessage = bytes;
+ setCurrentMessage(bytes, FORM_BYTES);
+ }
+
+ public Message(AxisFault fault) {
+ Debug.Print(2, "Enter Message ctor (AxisFault)" );
+ originalMessage = fault;
+ setCurrentMessage(fault, FORM_FAULT);
+ }
+
+ public Object getOriginalMessage() {
+ return( originalMessage );
+ }
+
+ public Object getCurrentMessage() {
+ return( currentMessage );
+ }
+
+ private int getCurrentForm() {
+ return( currentForm );
+ }
+
+ public void setMessageType(String messageType)
+ {
+ this.messageType = messageType;
+ }
+
+ public MessageContext getMessageContext()
+ {
+ return msgContext;
+ }
+ public void setMessageContext(MessageContext msgContext)
+ {
+ this.msgContext = msgContext;
+ }
+
+ private void setCurrentMessage(Object currMsg, int form) {
+ Debug.Print( 2, "Setting current message form to: " +
+ formNames[form] +" (currentMessage is now " +
+ currMsg + ")" );
+ currentMessage = currMsg ;
+ currentForm = form ;
+ }
+
+ public byte[] getAsBytes() {
+ Debug.Print( 2, "Enter: Message::getAsBytes" );
+ if ( currentForm == FORM_BYTES ) {
+ Debug.Print( 2, "Exit: Message::getAsBytes" );
+ return( (byte[]) currentMessage );
+ }
+
+ if ( currentForm == FORM_BODYINSTREAM ) {
+ getAsSOAPEnvelope();
+ }
+
+ if ( currentForm == FORM_INPUTSTREAM ) {
+ // Assumes we don't need a content length
+ try {
+ InputStream inp = (InputStream) currentMessage ;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buf = new byte[4096];
+ int len ;
+ while ( (len = inp.read(buf,0,4096)) != -1 )
+ baos.write( buf, 0, len );
+ buf = baos.toByteArray();
+ // int len = inp.available();
+ // byte[] buf = new byte[ len ];
+ // inp.read( buf );
+ setCurrentMessage( buf, FORM_BYTES );
+ Debug.Print( 2, "Exit: Message::getAsByes" );
+ return( (byte[]) currentMessage );
+ }
+ catch( Exception e ) {
+ e.printStackTrace( System.err );
+ }
+ Debug.Print( 2, "Exit: Message::getAsByes" );
+ return( null );
+ }
+
+ if ( currentForm == FORM_SOAPENVELOPE ||
+ currentForm == FORM_FAULT )
+ getAsString();
+
+ if ( currentForm == FORM_STRING ) {
+ setCurrentMessage( ((String)currentMessage).getBytes(),
+ FORM_BYTES );
+ Debug.Print( 2, "Exit: Message::getAsBytes" );
+ return( (byte[]) currentMessage );
+ }
+
+ System.err.println("Can't convert " + currentForm + " to Bytes" );
+ Debug.Print( 2, "Exit: Message::getAsBytes" );
+ return( null );
+ }
+
+ public String getAsString() {
+ Debug.Print( 2, "Enter: Message::getAsString" );
+ if ( currentForm == FORM_STRING ) {
+ Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+
+ currentMessage );
+ return( (String) currentMessage );
+ }
+
+ if ( currentForm == FORM_INPUTSTREAM ||
+ currentForm == FORM_BODYINSTREAM ) {
+ getAsBytes();
+ // Fall thru to "Bytes"
+ }
+
+ if ( currentForm == FORM_BYTES ) {
+ setCurrentMessage( new String((byte[]) currentMessage),
+ FORM_STRING );
+ Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+
+ currentMessage );
+ return( (String) currentMessage );
+ }
+
+ if ( currentForm == FORM_FAULT ) {
+ StringWriter writer = new StringWriter();
+ AxisFault env = (AxisFault)currentMessage;
+ try {
+ env.output(new SerializationContext(writer, msgContext));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ setCurrentMessage(writer.getBuffer().toString(), FORM_STRING);
+ return (String)currentMessage;
+ }
+
+ if ( currentForm == FORM_SOAPENVELOPE ) {
+ StringWriter writer = new StringWriter();
+ SOAPEnvelope env = (SOAPEnvelope)currentMessage;
+ try {
+ env.output(new SerializationContext(writer, msgContext));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ setCurrentMessage(writer.getBuffer().toString(), FORM_STRING);
+ return (String)currentMessage;
+ }
+
+ System.err.println("Can't convert form " + currentForm +
+ " to String" );
+ Debug.Print( 2, "Exit: Message::getAsString" );
+ return( null );
+ }
+
+ public SOAPEnvelope getAsSOAPEnvelope() {
+ Debug.Print( 2, "Enter: Message::getAsSOAPEnvelope; currentForm is "+
+ formNames[currentForm] );
+ if ( currentForm == FORM_SOAPENVELOPE )
+ return( (SOAPEnvelope) currentMessage );
+
+ if (currentForm == FORM_BODYINSTREAM) {
+ InputStreamBody bodyEl =
+ new InputStreamBody((InputStream)currentMessage);
+ SOAPEnvelope env = new SOAPEnvelope();
+ env.addBodyElement(bodyEl);
+ setCurrentMessage(env, FORM_SOAPENVELOPE);
+ return env;
+ }
+
+ InputSource is;
+
+ if ( currentForm == FORM_INPUTSTREAM ) {
+ is = new InputSource( (InputStream) currentMessage );
+ } else {
+ is = new InputSource(new StringReader(getAsString()));
+ }
+
+ SAXAdapter parser = new SAXAdapter(is, msgContext, messageType);
+ SOAPEnvelope env = parser.getEnvelope();
+ env.setMessageType(messageType);
+
+ setCurrentMessage( env, FORM_SOAPENVELOPE );
+ Debug.Print( 2, "Exit: Message::getAsSOAPEnvelope" );
+ return( (SOAPEnvelope) currentMessage );
+ }
};
1.44 +22 -22 xml-axis/java/src/org/apache/axis/MessageContext.java
Index: MessageContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- MessageContext.java 2001/07/10 22:52:42 1.43
+++ MessageContext.java 2001/07/12 15:02:57 1.44
@@ -144,7 +144,7 @@
private Hashtable bag ;
public MessageContext(AxisEngine engine) {
- this.axisEngine = engine;
+ this.axisEngine = engine;
}
@@ -256,27 +256,27 @@
};
public AxisClassLoader getClassLoader() {
- if ( classLoader == null )
- classLoader = AxisClassLoader.getClassLoader(null);
- return( classLoader );
+ if ( classLoader == null )
+ classLoader = AxisClassLoader.getClassLoader(null);
+ return( classLoader );
}
public AxisClassLoader getClassLoader(String name) {
- if ( name == null ) return( getClassLoader() );
- return( AxisClassLoader.getClassLoader(name) );
+ if ( name == null ) return( getClassLoader() );
+ return( AxisClassLoader.getClassLoader(name) );
}
public void setClassLoader(AxisClassLoader cl ) {
- classLoader = cl ;
+ classLoader = cl ;
}
public String getTargetService() {
- return( targetService );
+ return( targetService );
}
public AxisEngine getAxisEngine()
{
- return axisEngine;
+ return axisEngine;
}
/**
@@ -308,22 +308,22 @@
*/
private Handler serviceHandler ;
public Handler getServiceHandler() {
- return( serviceHandler );
+ return( serviceHandler );
}
public void setServiceHandler(Handler sh)
{
- Debug.Print(2,"MessageContext: setServiceHandler("+sh+")");
- serviceHandler = sh;
- if (sh != null && sh instanceof SOAPService) {
- SOAPService service = (SOAPService)sh;
- TypeMappingRegistry tmr = service.getTypeMappingRegistry();
- setTypeMappingRegistry(tmr);
-
- if (serviceDesc == null) {
- serviceDesc = service.getServiceDescription();
+ Debug.Print(2,"MessageContext: setServiceHandler("+sh+")");
+ serviceHandler = sh;
+ if (sh != null && sh instanceof SOAPService) {
+ SOAPService service = (SOAPService)sh;
+ TypeMappingRegistry tmr = service.getTypeMappingRegistry();
+ setTypeMappingRegistry(tmr);
+
+ if (serviceDesc == null) {
+ serviceDesc = service.getServiceDescription();
+ }
}
- }
}
/** Contains an instance of Handler, which is the
@@ -340,7 +340,7 @@
/** Has a quit been requested? Hackish... but useful... -- RobJ */
public static String QUIT_REQUESTED = "quit.requested";
-
+
/** A String with the user's ID (if available)
*/
public static String USERID = "user.id";
@@ -352,7 +352,7 @@
/** Just a util so we don't have to cast the result
*/
public String getStrProp(String propName) {
- return( (String) getProperty(propName) );
+ return( (String) getProperty(propName) );
}
public Object getProperty(String propName) {
1.18 +116 -115 xml-axis/java/src/org/apache/axis/SimpleChain.java
Index: SimpleChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleChain.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SimpleChain.java 2001/06/29 04:51:32 1.17
+++ SimpleChain.java 2001/07/12 15:02:58 1.18
@@ -67,120 +67,121 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class SimpleChain extends BasicHandler implements Chain {
- protected Vector handlers ;
- protected Hashtable options ;
+ protected Vector handlers ;
+ protected Hashtable options ;
- public void init() {
- for ( int i = 0 ; i < handlers.size() ; i++ )
- ((Handler) handlers.elementAt( i )).init();
- }
-
- public void cleanup() {
- for ( int i = 0 ; i < handlers.size() ; i++ )
- ((Handler) handlers.elementAt( i )).cleanup();
- }
-
- /**
- * Iterate over the chain invoking each handler. If there's a fault
- * then call 'undo' for each completed handler in reverse order, then
- * rethrow the exception.
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: SimpleChain::invoke" );
- int i = 0 ;
- try {
- for ( i = 0 ; handlers!= null && i<handlers.size() ; i++ )
- ((Handler) handlers.elementAt( i )).invoke( msgContext );
- }
- catch( Exception e ) {
- // undo in reverse order - rethrow
- Debug.Print( 1, e );
- if( !(e instanceof AxisFault ) )
- e = new AxisFault( e );
- while( --i >= 0 )
- ((Handler) handlers.elementAt( i )).undo( msgContext );
- throw (AxisFault) e ;
- }
- Debug.Print( 1, "Exit: SimpleChain::invoke" );
- }
-
- /**
- * Undo all of the work this chain completed because some handler
- * later on has faulted - in reverse order.
- */
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: SimpleChain::undo" );
- for ( int i = handlers.size()-1 ; i >= 0 ; i-- )
- ((Handler) handlers.elementAt( i )).undo( msgContext );
- Debug.Print( 1, "Exit: SimpleChain::undo" );
- }
-
- public boolean canHandleBlock(QName qname) {
- for ( int i = 0 ; i < handlers.size() ; i++ )
- if ( ((Handler) handlers.elementAt( i )).canHandleBlock(qname) )
- return( true );
- return( false );
- }
-
- public void addHandler(Handler handler) {
- if (handler == null)
- throw new NullPointerException("SimpleChain.addHandler: Null handler!");
-
- if ( handlers == null ) handlers = new Vector();
- handlers.add( handler );
- }
-
- public void removeHandler(int index) {
- if ( handlers != null )
- handlers.removeElementAt( index );
- }
-
- public void clear() {
- handlers.clear();
- }
-
- public boolean contains(Handler handler) {
- return( handlers != null ? handlers.contains( handler ) : false );
- }
-
- public Handler[] getHandlers() {
- if (handlers == null)
- return null;
-
- Handler [] ret = new Handler[handlers.size()];
- return( (Handler[]) handlers.toArray(ret) );
- }
-
- public Element getDeploymentData(Document doc) {
- Debug.Print( 1, "Enter: SimpleChain::getDeploymentData" );
-
- Element root = doc.createElement( "chain" );
-
- if (handlers != null ) {
- StringBuffer str = new StringBuffer();
- Handler h ;
- for ( int i = 0 ; i < handlers.size() ; i++ ) {
- if ( i != 0 ) str.append(",");
- h = (Handler) handlers.elementAt(i);
- str.append( h.getName() );
- }
- root.setAttribute( "flow", str.toString() );
- }
-
- options = this.getOptions();
- if ( options != null ) {
- Enumeration e = options.keys();
- while ( e.hasMoreElements() ) {
- String k = (String) e.nextElement();
- Object v = options.get(k);
- Element e1 = doc.createElement( "option" );
- e1.setAttribute( "name", k );
- e1.setAttribute( "value", v.toString() );
- root.appendChild( e1 );
- }
- }
-
- Debug.Print( 1, "Exit: SimpleChain::getDeploymentData" );
- return( root );
- }
+ public void init() {
+ for ( int i = 0 ; i < handlers.size() ; i++ )
+ ((Handler) handlers.elementAt( i )).init();
+ }
+
+ public void cleanup() {
+ for ( int i = 0 ; i < handlers.size() ; i++ )
+ ((Handler) handlers.elementAt( i )).cleanup();
+ }
+
+ /**
+ * Iterate over the chain invoking each handler. If there's a fault
+ * then call 'undo' for each completed handler in reverse order, then
+ * rethrow the exception.
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: SimpleChain::invoke" );
+ int i = 0 ;
+ try {
+ for ( i = 0 ; handlers!= null && i<handlers.size() ; i++ )
+ ((Handler) handlers.elementAt( i )).invoke( msgContext );
+ }
+ catch( Exception e ) {
+ // undo in reverse order - rethrow
+ Debug.Print( 1, e );
+ if( !(e instanceof AxisFault ) )
+ e = new AxisFault( e );
+ while( --i >= 0 )
+ ((Handler) handlers.elementAt( i )).undo( msgContext );
+ throw (AxisFault) e ;
+ }
+ Debug.Print( 1, "Exit: SimpleChain::invoke" );
+ }
+
+ /**
+ * Undo all of the work this chain completed because some handler
+ * later on has faulted - in reverse order.
+ */
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: SimpleChain::undo" );
+ for ( int i = handlers.size()-1 ; i >= 0 ; i-- )
+ ((Handler) handlers.elementAt( i )).undo( msgContext );
+ Debug.Print( 1, "Exit: SimpleChain::undo" );
+ }
+
+ public boolean canHandleBlock(QName qname) {
+ for ( int i = 0 ; i < handlers.size() ; i++ )
+ if ( ((Handler) handlers.elementAt( i )).canHandleBlock(qname) )
+ return( true );
+ return( false );
+ }
+
+ public void addHandler(Handler handler) {
+ if (handler == null)
+ throw new NullPointerException(
+ "SimpleChain.addHandler: Null handler!");
+
+ if ( handlers == null ) handlers = new Vector();
+ handlers.add( handler );
+ }
+
+ public void removeHandler(int index) {
+ if ( handlers != null )
+ handlers.removeElementAt( index );
+ }
+
+ public void clear() {
+ handlers.clear();
+ }
+
+ public boolean contains(Handler handler) {
+ return( handlers != null ? handlers.contains( handler ) : false );
+ }
+
+ public Handler[] getHandlers() {
+ if (handlers == null)
+ return null;
+
+ Handler [] ret = new Handler[handlers.size()];
+ return( (Handler[]) handlers.toArray(ret) );
+ }
+
+ public Element getDeploymentData(Document doc) {
+ Debug.Print( 1, "Enter: SimpleChain::getDeploymentData" );
+
+ Element root = doc.createElement( "chain" );
+
+ if (handlers != null ) {
+ StringBuffer str = new StringBuffer();
+ Handler h ;
+ for ( int i = 0 ; i < handlers.size() ; i++ ) {
+ if ( i != 0 ) str.append(",");
+ h = (Handler) handlers.elementAt(i);
+ str.append( h.getName() );
+ }
+ root.setAttribute( "flow", str.toString() );
+ }
+
+ options = this.getOptions();
+ if ( options != null ) {
+ Enumeration e = options.keys();
+ while ( e.hasMoreElements() ) {
+ String k = (String) e.nextElement();
+ Object v = options.get(k);
+ Element e1 = doc.createElement( "option" );
+ e1.setAttribute( "name", k );
+ e1.setAttribute( "value", v.toString() );
+ root.appendChild( e1 );
+ }
+ }
+
+ Debug.Print( 1, "Exit: SimpleChain::getDeploymentData" );
+ return( root );
+ }
};
1.16 +164 -156 xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
Index: SimpleTargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SimpleTargetedChain.java 2001/06/25 14:30:34 1.15
+++ SimpleTargetedChain.java 2001/07/12 15:02:59 1.16
@@ -66,162 +66,170 @@
*
* @author Doug Davis (dug@us.ibm.com)
*/
-public class SimpleTargetedChain extends BasicHandler implements TargetedChain {
- protected Handler requestHandler ;
- protected Handler pivotHandler ;
- protected Handler responseHandler ;
-
- public void init() {
- if ( requestHandler != null ) requestHandler.init();
- if ( pivotHandler != null ) pivotHandler.init();
- if ( responseHandler != null ) responseHandler.init();
- }
-
- public void cleanup() {
- if ( requestHandler != null ) requestHandler.cleanup();
- if ( pivotHandler != null ) pivotHandler.cleanup();
- if ( responseHandler != null ) responseHandler.cleanup();
- }
-
- /**
- * Invoke the request chain, pivot handler and response chain. If there's
- * a fault we need to make sure that we undo any completed handler
- * that has been successfully invoked and then rethrow the fault.
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: SimpleTargetedChain::invoke" );
- if ( requestHandler != null ) requestHandler.invoke( msgContext );
- try {
- if ( pivotHandler != null ) pivotHandler.invoke( msgContext );
- }
- catch( Exception e ) {
- Debug.Print( 1, e );
- if ( !(e instanceof AxisFault ) )
- e = new AxisFault( e );
- if ( requestHandler != null ) requestHandler.undo( msgContext );
- throw (AxisFault) e ;
- }
- try {
- if ( responseHandler != null ) responseHandler.invoke( msgContext );
- }
- catch( Exception e ) {
- Debug.Print( 1, e );
- if ( !(e instanceof AxisFault ) )
- e = new AxisFault( e );
- if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestHandler != null ) requestHandler.undo( msgContext );
- throw (AxisFault) e ;
- }
- Debug.Print( 1, "Exit: SimpleTargetedChain::invoke" );
- }
-
- /**
- * Undo all of the work - in reverse order.
- */
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: SimpleTargetedChain::undo" );
- if ( responseHandler != null ) responseHandler.undo( msgContext );
- if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestHandler != null ) requestHandler.undo( msgContext );
- Debug.Print( 1, "Exit: SimpleTargetedChain::undo" );
- }
-
- public boolean canHandleBlock(QName qname) {
- return( (requestHandler==null) ? false : requestHandler.canHandleBlock(qname) ||
- (pivotHandler==null) ? false : pivotHandler.canHandleBlock(qname) ||
- (responseHandler==null) ? false : responseHandler.canHandleBlock(qname) );
- }
-
- public Handler getRequestHandler() { return( requestHandler ); }
-
- public void setRequestHandler(Handler reqHandler)
- {
- requestHandler = reqHandler;
- }
-
- public Handler getPivotHandler() { return( pivotHandler ); }
-
- public void setPivotHandler(Handler handler) { pivotHandler = handler ; }
-
- public Handler getResponseHandler() { return( responseHandler ); }
-
- public void setResponseHandler(Handler respHandler)
- {
- responseHandler = respHandler;
- }
-
- public void clear() {
- requestHandler = null ;
- pivotHandler = null ;
- responseHandler = null ;
- }
-
- public Element getDeploymentData(Document doc) {
- Debug.Print( 1, "Enter: SimpleTargetedChain::getDeploymentData" );
-
- Element root = doc.createElement( "chain" );
- fillInDeploymentData(root);
-
- Debug.Print( 1, "Exit: SimpleTargetedChain::getDeploymentData" );
- return( root );
- }
-
- /**
- * Used by subclasses (i.e. SOAPService) to fill in deployment
- * data into an Element which might not be named "chain".
- *
- * @param root the Element to fill in with deployment data.
- */
- public void fillInDeploymentData(Element root)
- {
- Document doc = root.getOwnerDocument();
- StringBuffer str = new StringBuffer();
- Handler h ;
-
- if ( requestHandler != null ) {
- if (requestHandler instanceof Chain) {
- Handler[] handlers = ((Chain)requestHandler).getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
- }
- } else {
- str.append(requestHandler.getName());
- }
- root.setAttribute( "request", str.toString() );
- }
- if ( pivotHandler != null ) {
- root.setAttribute( "pivot", pivotHandler.getName() );
- }
- if ( responseHandler != null ) {
- if (responseHandler instanceof Chain) {
- Handler[] handlers = ((Chain)responseHandler).getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
- }
- } else {
- str.append(responseHandler.getName());
- }
- root.setAttribute( "response", str.toString() );
- }
-
- options = this.getOptions();
- if ( options != null ) {
- Enumeration e = options.keys();
- while ( e.hasMoreElements() ) {
- String k = (String) e.nextElement();
- Object v = options.get(k);
- Element e1 = doc.createElement( "option" );
- e1.setAttribute( "name", k );
- e1.setAttribute( "value", v.toString() );
- root.appendChild( e1 );
- }
+public class SimpleTargetedChain extends BasicHandler implements TargetedChain
+{
+ protected Handler requestHandler ;
+ protected Handler pivotHandler ;
+ protected Handler responseHandler ;
+
+ public void init() {
+ if ( requestHandler != null ) requestHandler.init();
+ if ( pivotHandler != null ) pivotHandler.init();
+ if ( responseHandler != null ) responseHandler.init();
+ }
+
+ public void cleanup() {
+ if ( requestHandler != null ) requestHandler.cleanup();
+ if ( pivotHandler != null ) pivotHandler.cleanup();
+ if ( responseHandler != null ) responseHandler.cleanup();
+ }
+
+ /**
+ * Invoke the request chain, pivot handler and response chain. If there's
+ * a fault we need to make sure that we undo any completed handler
+ * that has been successfully invoked and then rethrow the fault.
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: SimpleTargetedChain::invoke" );
+ if ( requestHandler != null ) requestHandler.invoke( msgContext );
+ try {
+ if ( pivotHandler != null ) pivotHandler.invoke( msgContext );
+ }
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ if ( !(e instanceof AxisFault ) )
+ e = new AxisFault( e );
+ if ( requestHandler != null )
+ requestHandler.undo( msgContext );
+ throw (AxisFault) e ;
+ }
+ try {
+ if ( responseHandler != null )
+ responseHandler.invoke( msgContext );
+ }
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ if ( !(e instanceof AxisFault ) )
+ e = new AxisFault( e );
+ if ( pivotHandler != null ) pivotHandler.undo( msgContext );
+ if ( requestHandler != null )
+ requestHandler.undo( msgContext );
+ throw (AxisFault) e ;
+ }
+ Debug.Print( 1, "Exit: SimpleTargetedChain::invoke" );
+ }
+
+ /**
+ * Undo all of the work - in reverse order.
+ */
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: SimpleTargetedChain::undo" );
+ if ( responseHandler != null ) responseHandler.undo( msgContext );
+ if ( pivotHandler != null ) pivotHandler.undo( msgContext );
+ if ( requestHandler != null ) requestHandler.undo( msgContext );
+ Debug.Print( 1, "Exit: SimpleTargetedChain::undo" );
+ }
+
+ public boolean canHandleBlock(QName qname) {
+ // TODO !!! : Need to look at this logic
+ return ((requestHandler==null) ? false :
+ (requestHandler.canHandleBlock(qname) ||
+ (pivotHandler==null)) ? false :
+ (pivotHandler.canHandleBlock(qname) ||
+ (responseHandler==null)) ? false :
+ responseHandler.canHandleBlock(qname) );
+ }
+
+ public Handler getRequestHandler() { return( requestHandler ); }
+
+ public void setRequestHandler(Handler reqHandler)
+ {
+ requestHandler = reqHandler;
+ }
+
+ public Handler getPivotHandler() { return( pivotHandler ); }
+
+ public void setPivotHandler(Handler handler) { pivotHandler = handler ; }
+
+ public Handler getResponseHandler() { return( responseHandler ); }
+
+ public void setResponseHandler(Handler respHandler)
+ {
+ responseHandler = respHandler;
+ }
+
+ public void clear() {
+ requestHandler = null ;
+ pivotHandler = null ;
+ responseHandler = null ;
+ }
+
+ public Element getDeploymentData(Document doc) {
+ Debug.Print( 1, "Enter: SimpleTargetedChain::getDeploymentData" );
+
+ Element root = doc.createElement( "chain" );
+ fillInDeploymentData(root);
+
+ Debug.Print( 1, "Exit: SimpleTargetedChain::getDeploymentData" );
+ return( root );
+ }
+
+ /**
+ * Used by subclasses (i.e. SOAPService) to fill in deployment
+ * data into an Element which might not be named "chain".
+ *
+ * @param root the Element to fill in with deployment data.
+ */
+ public void fillInDeploymentData(Element root)
+ {
+ Document doc = root.getOwnerDocument();
+ StringBuffer str = new StringBuffer();
+ Handler h ;
+
+ if ( requestHandler != null ) {
+ if (requestHandler instanceof Chain) {
+ Handler[] handlers = ((Chain)requestHandler).getHandlers();
+ str = new StringBuffer();
+ for ( int i = 0 ; i < handlers.length ; i++ ) {
+ h = (Handler) handlers[i];
+ if ( i != 0 ) str.append(",");
+ str.append( h.getName() );
+ }
+ } else {
+ str.append(requestHandler.getName());
+ }
+ root.setAttribute( "request", str.toString() );
+ }
+ if ( pivotHandler != null ) {
+ root.setAttribute( "pivot", pivotHandler.getName() );
+ }
+ if ( responseHandler != null ) {
+ if (responseHandler instanceof Chain) {
+ Handler[] handlers = ((Chain)responseHandler).getHandlers();
+ str = new StringBuffer();
+ for ( int i = 0 ; i < handlers.length ; i++ ) {
+ h = (Handler) handlers[i];
+ if ( i != 0 ) str.append(",");
+ str.append( h.getName() );
+ }
+ } else {
+ str.append(responseHandler.getName());
+ }
+ root.setAttribute( "response", str.toString() );
+ }
+
+ options = this.getOptions();
+ if ( options != null ) {
+ Enumeration e = options.keys();
+ while ( e.hasMoreElements() ) {
+ String k = (String) e.nextElement();
+ Object v = options.get(k);
+ Element e1 = doc.createElement( "option" );
+ e1.setAttribute( "name", k );
+ e1.setAttribute( "value", v.toString() );
+ root.appendChild( e1 );
+ }
+ }
}
- }
};
1.4 +1 -1 xml-axis/java/src/org/apache/axis/TargetedChain.java
Index: TargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/TargetedChain.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TargetedChain.java 2001/06/25 14:30:35 1.3
+++ TargetedChain.java 2001/07/12 15:03:00 1.4
@@ -58,7 +58,7 @@
* @author James Snell (jasnell@us.ibm.com)
*/
public interface TargetedChain extends Handler {
-
+
/**
* Returns the Request handler
*/
1.26 +62 -58 xml-axis/java/src/org/apache/axis/client/AdminClient.java
Index: AdminClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AdminClient.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- AdminClient.java 2001/07/07 13:19:56 1.25
+++ AdminClient.java 2001/07/12 15:03:23 1.26
@@ -81,71 +81,75 @@
public abstract class AdminClient {
public static void main (String[] args)
{
- try {
- Options opts = new Options( args );
-
- if (opts.isFlagSet('d') > 0) {
- Debug.setDebugLevel( opts.isFlagSet('d') );
- }
-
- args = opts.getRemainingArgs();
-
- if ( args == null ) {
- System.err.println( "Usage: AdminClient xml-files | list" );
- System.exit(1);
- }
-
- for ( int i = 0 ; i < args.length ; i++ ) {
- InputStream input = null ;
+ try {
+ Options opts = new Options( args );
- if ( args[i].equals("list") ) {
- System.err.println( "Doing a list" );
- String str = "<m:list xmlns:m=\"AdminService\"/>" ;
- input = new ByteArrayInputStream( str.getBytes() );
- } else if (args[i].equals("quit")) {
- System.out.println("Doing a quit");
- String str = "<m:quit xmlns:m=\"AdminService\"/>";
- input = new ByteArrayInputStream(str.getBytes());
- }
- else {
- System.out.println( "Processing file: " + args[i] );
- input = new FileInputStream( args[i] );
+ if (opts.isFlagSet('d') > 0) {
+ Debug.setDebugLevel( opts.isFlagSet('d') );
}
-
- ServiceClient client = new ServiceClient(opts.getURL());
-
- /** Unfortunately, this is transport-specific. However, no one
- * but the HTTP transport should pick this property up.
- */
- client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
- Message inMsg = new Message( input, true );
+ args = opts.getRemainingArgs();
- client.setRequestMessage( inMsg );
-
- client.set( Transport.USER, opts.getUser() );
- client.set( Transport.PASSWORD, opts.getPassword() );
-
- client.invoke();
-
- Message outMsg = client.getMessageContext().getResponseMessage();
- if (outMsg == null) {
- System.err.println("Null response message!");
- return;
+ if ( args == null ) {
+ System.err.println( "Usage: AdminClient xml-files | list" );
+ System.exit(1);
}
- client.getMessageContext().setServiceDescription(new ServiceDescription("Admin", false));
- input.close();
- SOAPEnvelope envelope = (SOAPEnvelope) outMsg.getAsSOAPEnvelope();
- SOAPBodyElement body = envelope.getFirstBody();
- StringWriter writer = new StringWriter();
- SerializationContext ctx = new SerializationContext(writer, client.getMessageContext());
- body.output(ctx);
- System.out.println(writer.toString());
+ for ( int i = 0 ; i < args.length ; i++ ) {
+ InputStream input = null ;
+
+ if ( args[i].equals("list") ) {
+ System.err.println( "Doing a list" );
+ String str = "<m:list xmlns:m=\"AdminService\"/>" ;
+ input = new ByteArrayInputStream( str.getBytes() );
+ } else if (args[i].equals("quit")) {
+ System.out.println("Doing a quit");
+ String str = "<m:quit xmlns:m=\"AdminService\"/>";
+ input = new ByteArrayInputStream(str.getBytes());
+ }
+ else {
+ System.out.println( "Processing file: " + args[i] );
+ input = new FileInputStream( args[i] );
+ }
+
+ ServiceClient client = new ServiceClient(opts.getURL());
+
+ /** Unfortunately, this is transport-specific. However, no one
+ * but the HTTP transport should pick this property up.
+ */
+ client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
+
+ Message inMsg = new Message( input, true );
+
+ client.setRequestMessage( inMsg );
+
+ client.set( Transport.USER, opts.getUser() );
+ client.set( Transport.PASSWORD, opts.getPassword() );
+
+ client.invoke();
+
+ Message outMsg = client.getMessageContext().
+ getResponseMessage();
+ if (outMsg == null) {
+ System.err.println("Null response message!");
+ return;
+ }
+
+ client.getMessageContext().setServiceDescription(
+ new ServiceDescription("Admin", false));
+ input.close();
+ SOAPEnvelope envelope =
+ (SOAPEnvelope) outMsg.getAsSOAPEnvelope();
+ SOAPBodyElement body = envelope.getFirstBody();
+ StringWriter writer = new StringWriter();
+ SerializationContext ctx = new SerializationContext(writer,
+ client.getMessageContext());
+ body.output(ctx);
+ System.out.println(writer.toString());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
- } catch (Exception e) {
- e.printStackTrace();
- }
}
}
1.10 +41 -38 xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java
Index: ArraySerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ArraySerializer.java 2001/07/09 21:31:20 1.9
+++ ArraySerializer.java 2001/07/12 15:03:27 1.10
@@ -80,13 +80,13 @@
static Hashtable primitives = new Hashtable();
static {
- primitives.put(Character.class, Character.TYPE);
- primitives.put(Byte.class, Byte.TYPE);
- primitives.put(Short.class, Short.TYPE);
- primitives.put(Integer.class, Integer.TYPE);
- primitives.put(Long.class, Long.TYPE);
- primitives.put(Float.class, Float.TYPE);
- primitives.put(Double.class, Double.TYPE);
+ primitives.put(Character.class, Character.TYPE);
+ primitives.put(Byte.class, Byte.TYPE);
+ primitives.put(Short.class, Short.TYPE);
+ primitives.put(Integer.class, Integer.TYPE);
+ primitives.put(Long.class, Long.TYPE);
+ primitives.put(Float.class, Float.TYPE);
+ primitives.put(Double.class, Double.TYPE);
}
public static class Factory implements DeserializerFactory {
@@ -95,7 +95,7 @@
}
}
public static DeserializerFactory factory = new Factory();
-
+
public QName arrayType = null;
public int curIndex = 0;
QName arrayItemType;
@@ -107,8 +107,8 @@
super.startElement(namespace, localName, qName, attributes);
QName arrayTypeValue = context.getQNameFromString(
- attributes.getValue(Constants.URI_SOAP_ENC,
- Constants.ATTR_ARRAY_TYPE));
+ attributes.getValue(Constants.URI_SOAP_ENC,
+ Constants.ATTR_ARRAY_TYPE));
if (arrayTypeValue == null)
throw new SAXException("No arrayType attribute for array!");
@@ -126,7 +126,7 @@
}
String componentTypeName =
- arrayTypeValueLocalPart.substring(0, leftBracketIndex);
+ arrayTypeValueLocalPart.substring(0, leftBracketIndex);
if (componentTypeName.endsWith("]"))
{
@@ -139,25 +139,27 @@
componentTypeName);
String lengthStr =
- arrayTypeValueLocalPart.substring(leftBracketIndex + 1,
- rightBracketIndex);
+ arrayTypeValueLocalPart.substring(leftBracketIndex + 1,
+ rightBracketIndex);
if (lengthStr.length() > 0)
{
if (lengthStr.indexOf(',') != -1)
{
- throw new IllegalArgumentException("Multi-dimensional arrays are " +
- "not supported '" +
+ throw new IllegalArgumentException(
+ "Multi-dimensional arrays are not supported '" +
lengthStr + "'.");
}
try
{
int length = Integer.parseInt(lengthStr);
- Class componentType = context.getTypeMappingRegistry().getClassForQName(arrayItemType);
-
+ Class componentType = context.getTypeMappingRegistry().
+ getClassForQName(arrayItemType);
+
if (componentType == null)
- throw new SAXException("No component type for " + arrayItemType);
+ throw new SAXException("No component type for " +
+ arrayItemType);
// Replace wrapper classes with primitive equivalents
/*
@@ -173,9 +175,9 @@
}
catch (NumberFormatException e)
{
- throw new IllegalArgumentException("Explicit array length is not a " +
- "valid integer '" + lengthStr +
- "'.");
+ throw new IllegalArgumentException(
+ "Explicit array length is not a valid integer '" +
+ lengthStr + "'.");
}
}
}
@@ -188,13 +190,13 @@
QName itemType = context.getTypeFromAttributes(attributes);
/*
if (itemType != null) {
- if (!arrayItemType.equals(itemType))
- throw new SAXException("Item type (" + itemType + ") didn't match ArrayType (" +
- arrayItemType + ")");
+ if (!arrayItemType.equals(itemType))
+ throw new SAXException("Item type (" + itemType + ") didn't match ArrayType (" +
+ arrayItemType + ")");
}
*/
if (itemType == null)
- itemType = arrayItemType;
+ itemType = arrayItemType;
DeserializerBase dSer = context.getDeserializer(itemType);
dSer.registerCallback(this, new Integer(curIndex++));
@@ -208,10 +210,10 @@
public void valueReady(Object value, Object hint)
{
- /*
+ /*
Array.set(this.value, ((Integer)hint).intValue(), value);
- */
- ((Vector)this.value).set(((Integer)hint).intValue(), value);
+ */
+ ((Vector)this.value).set(((Integer)hint).intValue(), value);
}
public void serialize(QName name, Attributes attributes,
@@ -220,28 +222,29 @@
{
if (value == null)
throw new IOException("Can't serialize null Arrays just yet...");
-
+
Class cls = value.getClass();
List list = null;
if (!cls.isArray()) {
- if (!(value instanceof List)) {
- throw new IOException("Can't serialize a " + cls.getName() +
- " with the ArraySerializer!");
- }
- list = (List)value;
+ if (!(value instanceof List)) {
+ throw new IOException("Can't serialize a " + cls.getName() +
+ " with the ArraySerializer!");
+ }
+ list = (List)value;
}
Class componentType;
if (list == null) {
- componentType = cls.getComponentType();
+ componentType = cls.getComponentType();
} else {
- componentType = list.get(0).getClass();
+ componentType = list.get(0).getClass();
}
QName componentQName = context.getQNameForClass(componentType);
if (componentQName == null)
- throw new IOException("No mapped schema type for " + componentType.getName());
+ throw new IOException("No mapped schema type for " +
+ componentType.getName());
String prefix = context.getPrefixForURI(componentQName.getNamespaceURI());
String arrayType = prefix + ":" + componentQName.getLocalPart();
int len = (list == null) ? Array.getLength(value) : list.size();
@@ -268,7 +271,7 @@
for (int index = 0; index < len; index++)
context.serialize(new QName("","item"), null,
(list == null) ? Array.get(value, index) :
- list.get(index));
+ list.get(index));
context.endElement();
}
1.3 +10 -10 xml-axis/java/src/org/apache/axis/encoding/Base64.java
Index: Base64.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/Base64.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Base64.java 2001/02/10 04:39:55 1.2
+++ Base64.java 2001/07/12 15:03:29 1.3
@@ -90,19 +90,19 @@
int b2 = S_DECODETABLE[ibuf[2]];
int b3 = S_DECODETABLE[ibuf[3]];
switch (outlen) {
- case 1:
+ case 1:
obuf[wp] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
return 1;
- case 2:
+ case 2:
obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
obuf[wp] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
return 2;
- case 3:
+ case 3:
obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
obuf[wp++] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
obuf[wp] = (byte)(b2 << 6 & 0xc0 | b3 & 0x3f);
return 3;
- default:
+ default:
throw new RuntimeException("Internal Errror");
}
}
@@ -219,8 +219,8 @@
int rest = len-off;
while (rest >= 3) {
int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
+ +((data[rindex+1]&0xff)<<8)
+ +(data[rindex+2]&0xff);
out[windex++] = S_BASE64CHAR[i>>18];
out[windex++] = S_BASE64CHAR[(i>>12)&0x3f];
out[windex++] = S_BASE64CHAR[(i>>6)&0x3f];
@@ -254,8 +254,8 @@
int rest = len-off;
while (rest >= 3) {
int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
+ +((data[rindex+1]&0xff)<<8)
+ +(data[rindex+2]&0xff);
out[0] = (byte)S_BASE64CHAR[i>>18];
out[1] = (byte)S_BASE64CHAR[(i>>12)&0x3f];
out[2] = (byte)S_BASE64CHAR[(i>>6)&0x3f];
@@ -292,8 +292,8 @@
int output = 0;
while (rest >= 3) {
int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
+ +((data[rindex+1]&0xff)<<8)
+ +(data[rindex+2]&0xff);
out[0] = S_BASE64CHAR[i>>18];
out[1] = S_BASE64CHAR[(i>>12)&0x3f];
out[2] = S_BASE64CHAR[(i>>6)&0x3f];
1.9 +1 -1 xml-axis/java/src/org/apache/axis/encoding/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/BeanSerializer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BeanSerializer.java 2001/07/10 02:29:29 1.8
+++ BeanSerializer.java 2001/07/12 15:03:30 1.9
@@ -281,7 +281,7 @@
context.serialize(new QName("", propName), null, propValue);
}
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new IOException(e.toString());
}
1.6 +67 -67 xml-axis/java/src/org/apache/axis/encoding/DateSerializer.java
Index: DateSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DateSerializer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DateSerializer.java 2001/07/08 14:18:37 1.5
+++ DateSerializer.java 2001/07/12 15:03:31 1.6
@@ -76,85 +76,85 @@
public class DateSerializer implements Serializer {
private static SimpleDateFormat zulu =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- // 0123456789 0 123456789
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ // 0123456789 0 123456789
static {
- zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
}
static class DateDeser extends SOAPTypeMappingRegistry.BasicDeser {
Object makeValue(String source) {
- Date result;
+ Date result;
- // validate fixed portion of format
- if (source.length() < 19)
- throw new NumberFormatException("invalid dateTime");
-
- if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
- source.charAt(10) != 'T')
- throw new NumberFormatException("invalid date");
-
- if (source.charAt(13) != ':' || source.charAt(16) != ':')
- throw new NumberFormatException("invalid time");
-
- // convert what we have validated so far
- try {
- result=zulu.parse(source.substring(0,19)+".000Z");
- } catch (Exception e) {
- throw new NumberFormatException(e.toString());
- }
-
- int pos = 19;
-
- // parse optional milliseconds
- if (pos < source.length() && source.charAt(pos)=='.') {
- int milliseconds = 0;
- int start = ++pos;
- while (pos<source.length() && Character.isDigit(source.charAt(pos)))
- pos++;
-
- String decimal=source.substring(start,pos);
- if (decimal.length()==3) {
- milliseconds=Integer.parseInt(decimal);
- } else if (decimal.length() < 3) {
- milliseconds=Integer.parseInt((decimal+"000").substring(0,3));
- } else {
- milliseconds=Integer.parseInt(decimal.substring(0,3));
- if (decimal.charAt(3)>='5') ++milliseconds;
+ // validate fixed portion of format
+ if (source.length() < 19)
+ throw new NumberFormatException("invalid dateTime");
+
+ if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
+ source.charAt(10) != 'T')
+ throw new NumberFormatException("invalid date");
+
+ if (source.charAt(13) != ':' || source.charAt(16) != ':')
+ throw new NumberFormatException("invalid time");
+
+ // convert what we have validated so far
+ try {
+ result=zulu.parse(source.substring(0,19)+".000Z");
+ } catch (Exception e) {
+ throw new NumberFormatException(e.toString());
}
- // add milliseconds to the current result
- result.setTime(result.getTime()+milliseconds);
- }
-
- // parse optional timezone
- if (pos+5 < source.length() &&
- (source.charAt(pos)=='+' || (source.charAt(pos)=='-')))
- {
- if (!Character.isDigit(source.charAt(pos+1)) ||
- !Character.isDigit(source.charAt(pos+2)) ||
- source.charAt(pos+3) != ':' ||
- !Character.isDigit(source.charAt(pos+4)) ||
- !Character.isDigit(source.charAt(pos+5)))
- throw new NumberFormatException("invalid timezone");
-
- int hours = (source.charAt(pos+1)-'0')*10+source.charAt(pos+2)-'0';
- int mins = (source.charAt(pos+4)-'0')*10+source.charAt(pos+5)-'0';
- int milliseconds = (hours*60+mins)*60*1000;
-
- // subtract milliseconds from the current result to obtain GMT
- if (source.charAt(pos)=='+') milliseconds=-milliseconds;
- result.setTime(result.getTime()+milliseconds);
- pos+=6;
- }
+ int pos = 19;
- if (pos < source.length() && source.charAt(pos)=='Z') pos++;
+ // parse optional milliseconds
+ if (pos < source.length() && source.charAt(pos)=='.') {
+ int milliseconds = 0;
+ int start = ++pos;
+ while (pos<source.length() && Character.isDigit(source.charAt(pos)))
+ pos++;
+
+ String decimal=source.substring(start,pos);
+ if (decimal.length()==3) {
+ milliseconds=Integer.parseInt(decimal);
+ } else if (decimal.length() < 3) {
+ milliseconds=Integer.parseInt((decimal+"000").substring(0,3));
+ } else {
+ milliseconds=Integer.parseInt(decimal.substring(0,3));
+ if (decimal.charAt(3)>='5') ++milliseconds;
+ }
- if (pos < source.length())
- throw new NumberFormatException("unexpected characters");
+ // add milliseconds to the current result
+ result.setTime(result.getTime()+milliseconds);
+ }
+
+ // parse optional timezone
+ if (pos+5 < source.length() &&
+ (source.charAt(pos)=='+' || (source.charAt(pos)=='-')))
+ {
+ if (!Character.isDigit(source.charAt(pos+1)) ||
+ !Character.isDigit(source.charAt(pos+2)) ||
+ source.charAt(pos+3) != ':' ||
+ !Character.isDigit(source.charAt(pos+4)) ||
+ !Character.isDigit(source.charAt(pos+5)))
+ throw new NumberFormatException("invalid timezone");
+
+ int hours = (source.charAt(pos+1)-'0')*10+source.charAt(pos+2)-'0';
+ int mins = (source.charAt(pos+4)-'0')*10+source.charAt(pos+5)-'0';
+ int milliseconds = (hours*60+mins)*60*1000;
+
+ // subtract milliseconds from the current result to obtain GMT
+ if (source.charAt(pos)=='+') milliseconds=-milliseconds;
+ result.setTime(result.getTime()+milliseconds);
+ pos+=6;
+ }
+
+ if (pos < source.length() && source.charAt(pos)=='Z') pos++;
+
+ if (pos < source.length())
+ throw new NumberFormatException("unexpected characters");
- return result;
+ return result;
}
}
1.14 +1 -1 xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
Index: DeserializationContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DeserializationContext.java 2001/07/10 03:30:49 1.13
+++ DeserializationContext.java 2001/07/12 15:03:31 1.14
@@ -137,7 +137,7 @@
type = attrs.getValue(Constants.URIS_SCHEMA_XSI[i], "type");
if (type == null)
- return null;
+ return null;
return getQNameFromString(type);
}
1.27 +9 -9 xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java
Index: SOAPTypeMappingRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SOAPTypeMappingRegistry.java 2001/07/10 16:04:33 1.26
+++ SOAPTypeMappingRegistry.java 2001/07/12 15:03:33 1.27
@@ -252,19 +252,19 @@
// handle the various datetime QNames...
addDeserializerFactory(
- new QName(Constants.URI_1999_SCHEMA_XSD, "timeInstant"),
- java.util.Date.class,
- new DateSerializer.DateDeserializerFactory());
+ new QName(Constants.URI_1999_SCHEMA_XSD, "timeInstant"),
+ java.util.Date.class,
+ new DateSerializer.DateDeserializerFactory());
addDeserializerFactory(
- new QName(Constants.URI_2000_SCHEMA_XSD, "timeInstant"),
- java.util.Date.class,
- new DateSerializer.DateDeserializerFactory());
+ new QName(Constants.URI_2000_SCHEMA_XSD, "timeInstant"),
+ java.util.Date.class,
+ new DateSerializer.DateDeserializerFactory());
addDeserializerFactory(
- new QName(Constants.URI_2001_SCHEMA_XSD, "dateTime"),
- java.util.Date.class,
- new DateSerializer.DateDeserializerFactory());
+ new QName(Constants.URI_2001_SCHEMA_XSD, "dateTime"),
+ java.util.Date.class,
+ new DateSerializer.DateDeserializerFactory());
addDeserializerFactory(XSD_ANYTYPE, java.lang.Object.class, new ObjDeserializerFactory());
addSerializer(java.lang.Object.class, XSD_ANYTYPE, new ObjSerializer());
1.19 +61 -59 xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
Index: TypeMappingRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TypeMappingRegistry.java 2001/07/09 21:31:29 1.18
+++ TypeMappingRegistry.java 2001/07/12 15:03:34 1.19
@@ -104,7 +104,7 @@
public boolean isEmpty()
{
- return (d == null || d.isEmpty());
+ return (d == null || d.isEmpty());
}
/**
@@ -261,73 +261,75 @@
public void dumpToSerializationContext(SerializationContext ctx)
throws IOException
{
- if (d == null) {
- return;
- }
-
- Enumeration enum = d.keys();
- while (enum.hasMoreElements()) {
- QName typeQName = (QName)enum.nextElement();
- DeserializerDescriptor desc =
+ if (d == null) {
+ return;
+ }
+
+ Enumeration enum = d.keys();
+ while (enum.hasMoreElements()) {
+ QName typeQName = (QName)enum.nextElement();
+ DeserializerDescriptor desc =
(DeserializerDescriptor)d.get(typeQName);
- if (desc.cls == null)
- continue;
+ if (desc.cls == null)
+ continue;
- AttributesImpl attrs = new AttributesImpl();
- attrs.addAttribute("", "type", "type",
- "CDATA", ctx.qName2String(typeQName));
- attrs.addAttribute("", "class", "class",
- "CDATA", desc.cls.getName());
-
- String dser = desc.factory.getClass().getName();
- attrs.addAttribute("", "dser", "dser",
- "CDATA", dser);
-
- SerializerDescriptor serDesc = (SerializerDescriptor)s.get(desc.cls);
- if (serDesc != null) {
- attrs.addAttribute("", "ser", "ser",
- "CDATA",
- serDesc.serializer.getClass().getName());
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "type", "type",
+ "CDATA", ctx.qName2String(typeQName));
+ attrs.addAttribute("", "class", "class",
+ "CDATA", desc.cls.getName());
+
+ String dser = desc.factory.getClass().getName();
+ attrs.addAttribute("", "dser", "dser",
+ "CDATA", dser);
+
+ SerializerDescriptor serDesc =
+ (SerializerDescriptor)s.get(desc.cls);
+ if (serDesc != null) {
+ attrs.addAttribute("", "ser", "ser",
+ "CDATA",
+ serDesc.serializer.getClass().getName());
+ }
+
+ ctx.startElement(typeMappingQName, attrs);
+ ctx.endElement();
}
-
- ctx.startElement(typeMappingQName, attrs);
- ctx.endElement();
- }
}
public void dumpToElement(Element root)
{
- if ((d == null) || (parent == null)) {
- return;
- }
-
- Document doc = root.getOwnerDocument();
-
- Enumeration enum = d.keys();
- while (enum.hasMoreElements()) {
- QName typeQName = (QName)enum.nextElement();
- DeserializerDescriptor desc =
- (DeserializerDescriptor)d.get(typeQName);
- if (desc.cls == null)
- continue;
-
- Element mapEl = doc.createElement("typeMapping");
+ if ((d == null) || (parent == null)) {
+ return;
+ }
- mapEl.setAttribute("type", "ns:" + typeQName.getLocalPart());
- mapEl.setAttribute("xmlns:ns", typeQName.getNamespaceURI());
-
- mapEl.setAttribute("classname", desc.cls.getName());
-
- String dser = desc.factory.getClass().getName();
- mapEl.setAttribute("deserializerFactory", dser);
+ Document doc = root.getOwnerDocument();
- SerializerDescriptor serDesc = (SerializerDescriptor)s.get(desc.cls);
- if (serDesc != null) {
- mapEl.setAttribute("serializer", serDesc.serializer.
- getClass().getName());
- }
+ Enumeration enum = d.keys();
+ while (enum.hasMoreElements()) {
+ QName typeQName = (QName)enum.nextElement();
+ DeserializerDescriptor desc =
+ (DeserializerDescriptor)d.get(typeQName);
+ if (desc.cls == null)
+ continue;
+
+ Element mapEl = doc.createElement("typeMapping");
+
+ mapEl.setAttribute("type", "ns:" + typeQName.getLocalPart());
+ mapEl.setAttribute("xmlns:ns", typeQName.getNamespaceURI());
+
+ mapEl.setAttribute("classname", desc.cls.getName());
+
+ String dser = desc.factory.getClass().getName();
+ mapEl.setAttribute("deserializerFactory", dser);
+
+ SerializerDescriptor serDesc =
+ (SerializerDescriptor)s.get(desc.cls);
+ if (serDesc != null) {
+ mapEl.setAttribute("serializer", serDesc.serializer.
+ getClass().getName());
+ }
- root.appendChild(mapEl);
- }
+ root.appendChild(mapEl);
+ }
}
}
1.8 +16 -16 xml-axis/java/src/org/apache/axis/handlers/BasicHandler.java
Index: BasicHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/BasicHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BasicHandler.java 2001/06/21 17:02:50 1.7
+++ BasicHandler.java 2001/07/12 15:03:44 1.8
@@ -144,24 +144,24 @@
}
public Element getDeploymentData(Document doc) {
- Debug.Print( 1, "Enter: BasicHandler::getDeploymentData" );
+ Debug.Print( 1, "Enter: BasicHandler::getDeploymentData" );
- Element root = doc.createElement( "handler" );
+ Element root = doc.createElement( "handler" );
- root.setAttribute( "class", this.getClass().getName() );
- options = this.getOptions();
- if ( options != null ) {
- Enumeration e = options.keys();
- while ( e.hasMoreElements() ) {
- String k = (String) e.nextElement();
- Object v = options.get(k);
- Element e1 = doc.createElement( "option" );
- e1.setAttribute( "name", k );
- e1.setAttribute( "value", v.toString() );
- root.appendChild( e1 );
+ root.setAttribute( "class", this.getClass().getName() );
+ options = this.getOptions();
+ if ( options != null ) {
+ Enumeration e = options.keys();
+ while ( e.hasMoreElements() ) {
+ String k = (String) e.nextElement();
+ Object v = options.get(k);
+ Element e1 = doc.createElement( "option" );
+ e1.setAttribute( "name", k );
+ e1.setAttribute( "value", v.toString() );
+ root.appendChild( e1 );
+ }
}
- }
- Debug.Print( 1, "Exit: BasicHandler::getDeploymentData" );
- return( root );
+ Debug.Print( 1, "Exit: BasicHandler::getDeploymentData" );
+ return( root );
}
}
1.13 +125 -125 xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
Index: JWSProcessor.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JWSProcessor.java 2001/07/01 14:42:17 1.12
+++ JWSProcessor.java 2001/07/12 15:03:45 1.13
@@ -79,134 +79,134 @@
*/
public class JWSProcessor extends BasicHandler
{
- static String errFile = "jws.err" ;
+ static String errFile = "jws.err" ;
- public void invoke(MessageContext msgContext) throws AxisFault
- {
- Debug.Print( 1, "Enter: JWSProcessor::invoke" );
- try {
- /* Grab the *.jws filename from the context - should have been */
- /* placed there by another handler (ie. HTTPActionHandler) */
- /***************************************************************/
- Runtime rt = Runtime.getRuntime();
- String jwsFile = msgContext.getStrProp(Constants.MC_REALPATH);
- Debug.Print( 2, "jwsFile: " + jwsFile );
- String jFile = jwsFile.substring(0, jwsFile.length()-3) + "java" ;
- String cFile = jwsFile.substring(0, jwsFile.length()-3) + "class" ;
- Debug.Print( 2, "jFile: " + jFile );
- Debug.Print( 2, "cFile: " + cFile );
-
- File f1 = new File( cFile );
- File f2 = new File( jwsFile );
-
- /* Get the class */
- /*****************/
- String clsName = f2.getName();
- clsName = clsName.substring( 0, clsName.length()-4 );
- Debug.Print( 2, "ClsName: " + clsName );
-
- /* Check to see if we need to recompile */
- /****************************************/
- if ( !f1.exists() || f2.lastModified() > f1.lastModified() ) {
- /* If the class file doesn't exist, or it's older than the */
- /* java file then recompile the java file. */
- /* Start by copying the *.jws file to *.java */
- /***********************************************************/
- Debug.Print(1, "Compiling: " + jwsFile );
- Debug.Print(3, "copy " + jwsFile + " " + jFile );
- FileReader fr = new FileReader( jwsFile );
- FileWriter fw = new FileWriter( jFile );
- char[] buf = new char[4096];
- int rc ;
- while ( (rc = fr.read( buf, 0, 4095)) >= 0 )
- fw.write( buf, 0, rc );
- fw.close();
- fr.close();
-
- /* Now run javac on the *.java file */
- /************************************/
- Debug.Print(2, "javac " + jFile );
- // Process proc = rt.exec( "javac " + jFile );
- // proc.waitFor();
- FileOutputStream out = new FileOutputStream( errFile );
- Main compiler = new Main( out, "javac" );
- String outdir = f1.getParent();
- String[] args = null ;
-
- if (outdir == null) outdir=".";
-
- args = new String[] { "-d", outdir,
- "-classpath",
- System.getProperty("java.class.path" ),
- jFile };
- boolean result = compiler.compile( args );
-
- /* Delete the temporary *.java file and check the return code */
- /**************************************************************/
- (new File(jFile)).delete();
-
- if ( !result ) {
- /* Delete the *class file - sometimes it gets created even */
- /* when there are errors - so erase it so it doesn't */
- /* confuse us. */
- /***********************************************************/
- (new File(cFile)).delete();
-
- Document doc = XMLUtils.newDocument();
-
- Element root = doc.createElement( "Errors" );
- StringBuffer sbuf = new StringBuffer();
- FileReader inp = new FileReader( errFile );
-
- buf = new char[4096];
-
- while ( (rc = inp.read(buf, 0, 4096)) > 0 )
- sbuf.append( buf, 0, rc );
- inp.close();
- root.appendChild( doc.createTextNode( sbuf.toString() ) );
- (new File(errFile)).delete();
- throw new AxisFault( "Server.compileError",
- "Error while compiling: " + jFile,
- null, new Element[] { root } );
+ public void invoke(MessageContext msgContext) throws AxisFault
+ {
+ Debug.Print( 1, "Enter: JWSProcessor::invoke" );
+ try {
+ /* Grab the *.jws filename from the context - should have been */
+ /* placed there by another handler (ie. HTTPActionHandler) */
+ /***************************************************************/
+ Runtime rt = Runtime.getRuntime();
+ String jwsFile = msgContext.getStrProp(Constants.MC_REALPATH);
+ Debug.Print( 2, "jwsFile: " + jwsFile );
+ String jFile = jwsFile.substring(0, jwsFile.length()-3) + "java" ;
+ String cFile = jwsFile.substring(0, jwsFile.length()-3) + "class" ;
+ Debug.Print( 2, "jFile: " + jFile );
+ Debug.Print( 2, "cFile: " + cFile );
+
+ File f1 = new File( cFile );
+ File f2 = new File( jwsFile );
+
+ /* Get the class */
+ /*****************/
+ String clsName = f2.getName();
+ clsName = clsName.substring( 0, clsName.length()-4 );
+ Debug.Print( 2, "ClsName: " + clsName );
+
+ /* Check to see if we need to recompile */
+ /****************************************/
+ if ( !f1.exists() || f2.lastModified() > f1.lastModified() ) {
+ /* If the class file doesn't exist, or it's older than the */
+ /* java file then recompile the java file. */
+ /* Start by copying the *.jws file to *.java */
+ /***********************************************************/
+ Debug.Print(1, "Compiling: " + jwsFile );
+ Debug.Print(3, "copy " + jwsFile + " " + jFile );
+ FileReader fr = new FileReader( jwsFile );
+ FileWriter fw = new FileWriter( jFile );
+ char[] buf = new char[4096];
+ int rc ;
+ while ( (rc = fr.read( buf, 0, 4095)) >= 0 )
+ fw.write( buf, 0, rc );
+ fw.close();
+ fr.close();
+
+ /* Now run javac on the *.java file */
+ /************************************/
+ Debug.Print(2, "javac " + jFile );
+ // Process proc = rt.exec( "javac " + jFile );
+ // proc.waitFor();
+ FileOutputStream out = new FileOutputStream( errFile );
+ Main compiler = new Main( out, "javac" );
+ String outdir = f1.getParent();
+ String[] args = null ;
+
+ if (outdir == null) outdir=".";
+
+ args = new String[] { "-d", outdir,
+ "-classpath",
+ System.getProperty("java.class.path" ),
+ jFile };
+ boolean result = compiler.compile( args );
+
+ /* Delete the temporary *.java file and check the return code */
+ /**************************************************************/
+ (new File(jFile)).delete();
+
+ if ( !result ) {
+ /* Delete the *class file - sometimes it gets created even */
+ /* when there are errors - so erase it so it doesn't */
+ /* confuse us. */
+ /***********************************************************/
+ (new File(cFile)).delete();
+
+ Document doc = XMLUtils.newDocument();
+
+ Element root = doc.createElement( "Errors" );
+ StringBuffer sbuf = new StringBuffer();
+ FileReader inp = new FileReader( errFile );
+
+ buf = new char[4096];
+
+ while ( (rc = inp.read(buf, 0, 4096)) > 0 )
+ sbuf.append( buf, 0, rc );
+ inp.close();
+ root.appendChild( doc.createTextNode( sbuf.toString() ) );
+ (new File(errFile)).delete();
+ throw new AxisFault( "Server.compileError",
+ "Error while compiling: " + jFile,
+ null, new Element[] { root } );
+ }
+ (new File(errFile)).delete();
+
+ AxisClassLoader.removeClassLoader( clsName );
+ }
+ AxisClassLoader cl = msgContext.getClassLoader( clsName );
+ if ( !cl.isClassRegistered(clsName) )
+ cl.registerClass( clsName, cFile );
+ msgContext.setClassLoader( cl );
+
+ /* Create a new RPCProvider - this will be the "service" */
+ /* that we invoke. */
+ /******************************************************************/
+ Handler rpc = new RPCProvider();
+ msgContext.setServiceHandler( rpc );
+
+ rpc.addOption( "className", clsName );
+
+ /** For now, allow all methods - we probably want to have a way to
+ * configure this in the future.
+ */
+ rpc.addOption( "methodName", "*");
+
+ rpc.init(); // ??
+ rpc.invoke( msgContext );
+ rpc.cleanup(); // ??
}
- (new File(errFile)).delete();
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
+ throw (AxisFault) e ;
+ }
- AxisClassLoader.removeClassLoader( clsName );
- }
- AxisClassLoader cl = msgContext.getClassLoader( clsName );
- if ( !cl.isClassRegistered(clsName) )
- cl.registerClass( clsName, cFile );
- msgContext.setClassLoader( cl );
-
- /* Create a new RPCProvider - this will be the "service" */
- /* that we invoke. */
- /******************************************************************/
- Handler rpc = new RPCProvider();
- msgContext.setServiceHandler( rpc );
-
- rpc.addOption( "className", clsName );
-
- /** For now, allow all methods - we probably want to have a way to
- * configure this in the future.
- */
- rpc.addOption( "methodName", "*");
-
- rpc.init(); // ??
- rpc.invoke( msgContext );
- rpc.cleanup(); // ??
- }
- catch( Exception e ) {
- Debug.Print( 1, e );
- if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
- throw (AxisFault) e ;
+ Debug.Print( 1, "Exit : JWSProcessor::invoke" );
}
- Debug.Print( 1, "Exit : JWSProcessor::invoke" );
- }
-
- public void undo(MessageContext msgContext)
- {
- Debug.Print( 1, "Enter: JWSProcessor::undo" );
- Debug.Print( 1, "Exit: JWSProcessor::undo" );
- }
+ public void undo(MessageContext msgContext)
+ {
+ Debug.Print( 1, "Enter: JWSProcessor::undo" );
+ Debug.Print( 1, "Exit: JWSProcessor::undo" );
+ }
}
1.12 +36 -36 xml-axis/java/src/org/apache/axis/handlers/LogHandler.java
Index: LogHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/LogHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- LogHandler.java 2001/06/12 15:43:10 1.11
+++ LogHandler.java 2001/07/12 15:03:45 1.12
@@ -67,44 +67,44 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class LogHandler extends BasicHandler {
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: LogHandler::invoke" );
- try {
- FileWriter fw = new FileWriter( "axis.log", true );
- PrintWriter pw = new PrintWriter( fw );
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: LogHandler::invoke" );
+ try {
+ FileWriter fw = new FileWriter( "axis.log", true );
+ PrintWriter pw = new PrintWriter( fw );
- Message inMsg = msgContext.getRequestMessage();
- Message outMsg = msgContext.getResponseMessage();
-
- pw.println( "=======================================================" );
- pw.println( "= " + ( new Time(System.currentTimeMillis()) ).toString() );
- pw.println( "= InMsg: " + inMsg );
- pw.println( "= InMsg: " + (inMsg == null ? "-" : inMsg.getAsString()));
- pw.println( "= OutMsg: " + outMsg );
- pw.println( "= OutMsg: " + (outMsg == null ? "-" : outMsg.getAsString()));
- pw.println( "=======================================================" );
-
- pw.close();
+ Message inMsg = msgContext.getRequestMessage();
+ Message outMsg = msgContext.getResponseMessage();
+
+ pw.println( "=======================================================" );
+ pw.println( "= " + ( new Time(System.currentTimeMillis()) ).toString() );
+ pw.println( "= InMsg: " + inMsg );
+ pw.println( "= InMsg: " + (inMsg == null ? "-" : inMsg.getAsString()));
+ pw.println( "= OutMsg: " + outMsg );
+ pw.println( "= OutMsg: " + (outMsg == null ? "-" : outMsg.getAsString()));
+ pw.println( "=======================================================" );
+
+ pw.close();
+ }
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ throw new AxisFault( e );
+ }
+ Debug.Print( 1, "Exit: LogHandler::invoke" );
}
- catch( Exception e ) {
- Debug.Print( 1, e );
- throw new AxisFault( e );
- }
- Debug.Print( 1, "Exit: LogHandler::invoke" );
- }
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Exit: LogHandler::undo" );
- try {
- FileWriter fw = new FileWriter( "axis.log", true );
- PrintWriter pw = new PrintWriter( fw );
- pw.println( "=====================" );
- pw.println( "= Fault occurred " );
- pw.println( "=====================" );
- pw.close();
- } catch( Exception e ) {
- Debug.Print( 1, e );
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Exit: LogHandler::undo" );
+ try {
+ FileWriter fw = new FileWriter( "axis.log", true );
+ PrintWriter pw = new PrintWriter( fw );
+ pw.println( "=====================" );
+ pw.println( "= Fault occurred " );
+ pw.println( "=====================" );
+ pw.close();
+ } catch( Exception e ) {
+ Debug.Print( 1, e );
+ }
+ Debug.Print( 1, "Exit: LogHandler::undo" );
}
- Debug.Print( 1, "Exit: LogHandler::undo" );
- }
};
1.2 +11 -11 xml-axis/java/src/org/apache/axis/handlers/LogMessage.java
Index: LogMessage.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/LogMessage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LogMessage.java 2001/05/22 05:25:34 1.1
+++ LogMessage.java 2001/07/12 15:03:46 1.2
@@ -64,15 +64,15 @@
*/
public class LogMessage extends BasicHandler
{
- public void invoke(MessageContext context)
- {
- String msg = (String)getOption("message");
- if (msg != null)
- Debug.Print(0, msg);
- }
-
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: URLMapper::undo" );
- Debug.Print( 1, "Exit: URLMapper::undo" );
- }
+ public void invoke(MessageContext context)
+ {
+ String msg = (String)getOption("message");
+ if (msg != null)
+ Debug.Print(0, msg);
+ }
+
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: URLMapper::undo" );
+ Debug.Print( 1, "Exit: URLMapper::undo" );
+ }
}
1.13 +70 -70 xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java
Index: SimpleAuthenticationHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SimpleAuthenticationHandler.java 2001/05/31 16:29:39 1.12
+++ SimpleAuthenticationHandler.java 2001/07/12 15:03:47 1.13
@@ -74,80 +74,80 @@
*/
public class SimpleAuthenticationHandler extends BasicHandler {
- // Simple hashtable of user and password. Null means everybody
- // will authenticate (replace with new Hashtable() if you want
- // the default to be that nobody will be authenticated.
- static private Hashtable entries = null;
-
- // load the users list
- static {
- File userFile = new File("users.lst");
- if (userFile.exists()) {
- entries = new Hashtable();
-
- try {
-
- FileReader fr = new FileReader( userFile );
- LineNumberReader lnr = new LineNumberReader( fr );
- String line = null ;
-
- // parse lines into user and passwd tokens and add result to hash table
- while ( (line = lnr.readLine()) != null ) {
- StringTokenizer st = new StringTokenizer( line );
- if ( st.hasMoreTokens() ) {
- String userID = st.nextToken();
- String passwd = (st.hasMoreTokens()) ? st.nextToken() : "";
-
- Debug.Print( 2, "From file: '", userID, "':'", passwd, "'" );
- entries.put(userID, passwd);
- }
+ // Simple hashtable of user and password. Null means everybody
+ // will authenticate (replace with new Hashtable() if you want
+ // the default to be that nobody will be authenticated.
+ static private Hashtable entries = null;
+
+ // load the users list
+ static {
+ File userFile = new File("users.lst");
+ if (userFile.exists()) {
+ entries = new Hashtable();
+
+ try {
+
+ FileReader fr = new FileReader( userFile );
+ LineNumberReader lnr = new LineNumberReader( fr );
+ String line = null ;
+
+ // parse lines into user and passwd tokens and add result to hash table
+ while ( (line = lnr.readLine()) != null ) {
+ StringTokenizer st = new StringTokenizer( line );
+ if ( st.hasMoreTokens() ) {
+ String userID = st.nextToken();
+ String passwd = (st.hasMoreTokens()) ? st.nextToken() : "";
+
+ Debug.Print( 2, "From file: '", userID, "':'", passwd, "'" );
+ entries.put(userID, passwd);
+ }
+ }
+
+ lnr.close();
+
+ } catch( Exception e ) {
+ Debug.Print( 1, e );
+ }
}
-
- lnr.close();
-
- } catch( Exception e ) {
- Debug.Print( 1, e );
- }
}
- }
- /**
- * Authenticate the user and password from the msgContext
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
-
- if (entries != null) {
- String userID = (String) msgContext.getProperty( MessageContext.USERID );
- Debug.Print( 1, "User: ", userID );
-
- // in order to authenticate, the user must exist
- if ( userID == null || userID.equals("") || !entries.containsKey(userID) )
- throw new AxisFault( "Server.Unauthenticated",
- "User '" + userID + "' not authenticated (unknown user)",
- null, null );
-
- String passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
- String valid = (String) entries.get(userID);
- Debug.Print( 2, "Pass: ", passwd );
-
- // if a password is defined, then it must match
- if ( valid.length()>0 && !valid.equals(passwd) )
- throw new AxisFault( "Server.Unauthenticated",
- "User '" + userID + "' not authenticated (bad password)",
- null, null );
+ /**
+ * Authenticate the user and password from the msgContext
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
+
+ if (entries != null) {
+ String userID = (String) msgContext.getProperty( MessageContext.USERID );
+ Debug.Print( 1, "User: ", userID );
+
+ // in order to authenticate, the user must exist
+ if ( userID == null || userID.equals("") || !entries.containsKey(userID) )
+ throw new AxisFault( "Server.Unauthenticated",
+ "User '" + userID + "' not authenticated (unknown user)",
+ null, null );
+
+ String passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
+ String valid = (String) entries.get(userID);
+ Debug.Print( 2, "Pass: ", passwd );
+
+ // if a password is defined, then it must match
+ if ( valid.length()>0 && !valid.equals(passwd) )
+ throw new AxisFault( "Server.Unauthenticated",
+ "User '" + userID + "' not authenticated (bad password)",
+ null, null );
- Debug.Print( 1, "User '", userID, "' authenticated to server" );
- }
+ Debug.Print( 1, "User '", userID, "' authenticated to server" );
+ }
- Debug.Print( 1, "Exit: SimpleAuthenticationHandler::invoke" );
- }
+ Debug.Print( 1, "Exit: SimpleAuthenticationHandler::invoke" );
+ }
- /**
- * Nothing to undo
- */
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: SimpleAuthenticationHandler::undo" );
- Debug.Print( 1, "Exit: SimpleAuthenticationHandler::undo" );
- }
+ /**
+ * Nothing to undo
+ */
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: SimpleAuthenticationHandler::undo" );
+ Debug.Print( 1, "Exit: SimpleAuthenticationHandler::undo" );
+ }
};
1.14 +71 -71 xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java
Index: SimpleAuthorizationHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SimpleAuthorizationHandler.java 2001/05/31 16:29:42 1.13
+++ SimpleAuthorizationHandler.java 2001/07/12 15:03:48 1.14
@@ -76,83 +76,83 @@
*/
public class SimpleAuthorizationHandler extends BasicHandler {
- // Simple hashtable of users. Null means everybody
- // will authorize (replace with new Hashtable() if you want
- // the default to be that nobody is authorized
- //
- // Values will be hashtables of valid actions for the user
- static private Hashtable entries = null;
-
- // load the perms list
- static {
- File permFile = new File("perms.lst");
- if (permFile.exists()) {
- entries = new Hashtable();
-
- try {
- FileReader fr = new FileReader( permFile );
- LineNumberReader lnr = new LineNumberReader( fr );
- String line = null ;
-
- // parse lines into user and passwd tokens and add result to hash table
- while ( (line = lnr.readLine()) != null ) {
- StringTokenizer st = new StringTokenizer( line );
- if ( st.hasMoreTokens() ) {
- String userID = st.nextToken();
- String action = (st.hasMoreTokens()) ? st.nextToken() : "";
-
- Debug.Print( 1, "User '", userID, "' authorized to: ", action );
-
- // if we haven't seen this user before, create an entry
- if (!entries.containsKey(userID))
- entries.put(userID, new Hashtable());
+ // Simple hashtable of users. Null means everybody
+ // will authorize (replace with new Hashtable() if you want
+ // the default to be that nobody is authorized
+ //
+ // Values will be hashtables of valid actions for the user
+ static private Hashtable entries = null;
+
+ // load the perms list
+ static {
+ File permFile = new File("perms.lst");
+ if (permFile.exists()) {
+ entries = new Hashtable();
+
+ try {
+ FileReader fr = new FileReader( permFile );
+ LineNumberReader lnr = new LineNumberReader( fr );
+ String line = null ;
+
+ // parse lines into user and passwd tokens and add result to hash table
+ while ( (line = lnr.readLine()) != null ) {
+ StringTokenizer st = new StringTokenizer( line );
+ if ( st.hasMoreTokens() ) {
+ String userID = st.nextToken();
+ String action = (st.hasMoreTokens()) ? st.nextToken() : "";
+
+ Debug.Print( 1, "User '", userID, "' authorized to: ", action );
+
+ // if we haven't seen this user before, create an entry
+ if (!entries.containsKey(userID))
+ entries.put(userID, new Hashtable());
+
+ // add this action to the list of actions permitted to this user
+ Hashtable authlist = (Hashtable) entries.get(userID);
+ authlist.put(action, action);
+ }
+ }
+
+ lnr.close();
+
+ } catch( Exception e ) {
+ Debug.Print( 1, e );
+ }
+ }
+ }
+
+ /**
+ * Authorize the user and targetService from the msgContext
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: SimpleAuthorizationHandler::invoke" );
+
+ String userID = (String) msgContext.getProperty( MessageContext.USERID );
+ String action = msgContext.getTargetService();
+
+ Debug.Print( 1, "User: '", userID, "'" );
+ Debug.Print( 1, "Action: '", action, "'" );
- // add this action to the list of actions permitted to this user
+ if (entries != null) { // perm.list exists
+
Hashtable authlist = (Hashtable) entries.get(userID);
- authlist.put(action, action);
- }
+ if ( authlist == null || !authlist.containsKey(action) ) {
+ throw new AxisFault( "Server.Unauthorized",
+ "User '" + userID + "' not authorized to '" + action + "'",
+ null, null );
+ }
}
- lnr.close();
+ Debug.Print( 1, "User '", userID, "' authorized to: ", action );
- } catch( Exception e ) {
- Debug.Print( 1, e );
- }
+ Debug.Print( 1, "Exit: SimpleAuthorizationHandler::invoke" );
}
- }
- /**
- * Authorize the user and targetService from the msgContext
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: SimpleAuthorizationHandler::invoke" );
-
- String userID = (String) msgContext.getProperty( MessageContext.USERID );
- String action = msgContext.getTargetService();
-
- Debug.Print( 1, "User: '", userID, "'" );
- Debug.Print( 1, "Action: '", action, "'" );
-
- if (entries != null) { // perm.list exists
-
- Hashtable authlist = (Hashtable) entries.get(userID);
- if ( authlist == null || !authlist.containsKey(action) ) {
- throw new AxisFault( "Server.Unauthorized",
- "User '" + userID + "' not authorized to '" + action + "'",
- null, null );
- }
+ /**
+ * Nothing to undo
+ */
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: SimpleAuthorizationHandler::undo" );
+ Debug.Print( 1, "Exit: SimpleAuthorizationHandler::undo" );
}
-
- Debug.Print( 1, "User '", userID, "' authorized to: ", action );
-
- Debug.Print( 1, "Exit: SimpleAuthorizationHandler::invoke" );
- }
-
- /**
- * Nothing to undo
- */
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: SimpleAuthorizationHandler::undo" );
- Debug.Print( 1, "Exit: SimpleAuthorizationHandler::undo" );
- }
};
1.5 +6 -6 xml-axis/java/src/org/apache/axis/handlers/http/HTTPActionHandler.java
Index: HTTPActionHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/http/HTTPActionHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HTTPActionHandler.java 2001/06/21 02:45:45 1.4
+++ HTTPActionHandler.java 2001/07/12 15:04:00 1.5
@@ -80,18 +80,18 @@
Debug.Print( 1, "Enter: HTTPActionHandler::invoke" );
/** If there's already a targetService then just return.
- */
+ */
if ( msgContext.getServiceHandler() == null ) {
String action = (String) msgContext.getProperty(
- HTTPConstants.MC_HTTP_SOAPACTION);
+ HTTPConstants.MC_HTTP_SOAPACTION);
Debug.Print( 2, " HTTP SOAPAction: " + action );
/** The idea is that this handler only goes in the chain IF this
- * service does a mapping between SOAPAction and target. Therefore
- * if we get here with no action, we're in trouble.
- */
+ * service does a mapping between SOAPAction and target. Therefore
+ * if we get here with no action, we're in trouble.
+ */
if (action == null) {
- throw new AxisFault( "Server.NoHTTPSOAPAction",
+ throw new AxisFault( "Server.NoHTTPSOAPAction",
"No HTTP SOAPAction property in context",
null, null );
}
1.30 +24 -24 xml-axis/java/src/org/apache/axis/message/MessageElement.java
Index: MessageElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- MessageElement.java 2001/07/11 20:02:10 1.29
+++ MessageElement.java 2001/07/12 15:04:06 1.30
@@ -249,10 +249,10 @@
public MessageElement getRealElement()
{
- if (href == null)
- return this;
-
- return context.getElementByID(href.substring(1));
+ if (href == null)
+ return this;
+
+ return context.getElementByID(href.substring(1));
}
public Object getValue()
@@ -304,26 +304,26 @@
public Object getValueAsType(QName typeQName) throws AxisFault
{
- MessageElement realEl = getRealElement();
-
- if (realEl.typeQName != null) {
- if (!realEl.typeQName.equals(typeQName))
- throw new AxisFault("Couldn't convert " + realEl.typeQName +
- " to requested type " + typeQName);
- return getValue();
- }
-
- DeserializerBase dser = realEl.context.getDeserializer(typeQName);
- if (dser == null)
- throw new AxisFault("No deserializer for type " + typeQName);
-
- try {
- realEl.publishToHandler(dser);
- } catch (SAXException e) {
- throw new AxisFault(e);
- }
-
- return dser.getValue();
+ MessageElement realEl = getRealElement();
+
+ if (realEl.typeQName != null) {
+ if (!realEl.typeQName.equals(typeQName))
+ throw new AxisFault("Couldn't convert " + realEl.typeQName +
+ " to requested type " + typeQName);
+ return getValue();
+ }
+
+ DeserializerBase dser = realEl.context.getDeserializer(typeQName);
+ if (dser == null)
+ throw new AxisFault("No deserializer for type " + typeQName);
+
+ try {
+ realEl.publishToHandler(dser);
+ } catch (SAXException e) {
+ throw new AxisFault(e);
+ }
+
+ return dser.getValue();
}
public DeserializerBase getContentHandler()
1.10 +5 -5 xml-axis/java/src/org/apache/axis/message/SAXAdapter.java
Index: SAXAdapter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SAXAdapter.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SAXAdapter.java 2001/07/10 16:04:43 1.9
+++ SAXAdapter.java 2001/07/12 15:04:07 1.10
@@ -39,11 +39,11 @@
*/
public void parse() throws SAXException
{
- try {
- _parser.parse(inputSource, this);
- } catch (java.io.IOException ioe) {
- throw new SAXException(ioe);
- }
+ try {
+ _parser.parse(inputSource, this);
+ } catch (java.io.IOException ioe) {
+ throw new SAXException(ioe);
+ }
}
/** Called by the control thread; let the parsing thread
1.7 +18 -18 xml-axis/java/src/org/apache/axis/registries/HandlerRegistry.java
Index: HandlerRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/HandlerRegistry.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HandlerRegistry.java 2001/06/21 17:02:58 1.6
+++ HandlerRegistry.java 2001/07/12 15:04:12 1.7
@@ -62,24 +62,24 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public interface HandlerRegistry {
- /**
- * Add a new Handler to the registry.
- */
- public void add(String key, Handler handler);
-
- /**
- * Remove a Handler (locate by key) from the registry - returns old
- * value if it was there - or null if not.
- */
- public Handler remove(String key);
+ /**
+ * Add a new Handler to the registry.
+ */
+ public void add(String key, Handler handler);
+
+ /**
+ * Remove a Handler (locate by key) from the registry - returns old
+ * value if it was there - or null if not.
+ */
+ public Handler remove(String key);
- /**
- * Given a 'key' return the corresponding Handler
- */
- public Handler find(String key);
+ /**
+ * Given a 'key' return the corresponding Handler
+ */
+ public Handler find(String key);
- /**
- * Return the list (in an array) of keys for the Handlers
- */
- public String[] list();
+ /**
+ * Return the list (in an array) of keys for the Handlers
+ */
+ public String[] list();
};
1.2 +79 -79 xml-axis/java/src/org/apache/axis/registries/SimpleRegistry.java
Index: SimpleRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/SimpleRegistry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleRegistry.java 2001/02/14 21:35:26 1.1
+++ SimpleRegistry.java 2001/07/12 15:04:14 1.2
@@ -66,85 +66,85 @@
* @author Glen Daniels (gdaniels@allaire.com)
*/
public class SimpleRegistry implements HandlerRegistry {
- protected String fileName;
- protected Hashtable handlers = null ;
-
- public SimpleRegistry(String fileName)
- {
- this.fileName = fileName;
- }
-
- /**
- * Init (ie. load settings...)
- */
- public void init() {
- load();
- }
-
- /**
- * Add a new Handler to the registry.
- */
- public void add(String key, Handler handler) {
- if ( handlers == null ) handlers = new Hashtable();
- handlers.put( key, handler );
- save();
- }
-
- /**
- * Remove a Handler (locate by key) from the registry - returns old
- * value if it was there - or null if not.
- */
- public Handler remove(String key) {
- if ( handlers == null ) return( null );
- Object old = handlers.remove( key );
- save();
- return( (Handler) old );
- }
-
- /**
- * Given a 'key' return the corresponding Handler
- */
- public Handler find(String key) {
- if ( handlers == null ) return( null );
- return( (Handler) handlers.get( key ) );
- }
-
- /**
- * Return the list (in an array) of keys for the Handlers
- */
- public String[] list(){
- int loop = 0 ;
-
- if ( handlers == null ) return( null );
- String[] result = new String[handlers.size()];
- Enumeration keys = handlers.keys();
- while ( keys.hasMoreElements() )
- result[loop++] = (String) keys.nextElement();
- return( result );
- }
-
- private void load() {
- try {
- FileInputStream fis = new FileInputStream( fileName );
- ObjectInputStream ois = new ObjectInputStream( fis );
- handlers = (Hashtable) ois.readObject();
- fis.close();
- }
- catch( Exception e ) {
- if ( !(e instanceof FileNotFoundException) )
- e.printStackTrace( System.err );
- }
- }
-
- private void save() {
- try {
- FileOutputStream fos = new FileOutputStream( fileName );
- ObjectOutputStream oos = new ObjectOutputStream( fos );
- oos.writeObject( handlers );
- fos.close();
+ protected String fileName;
+ protected Hashtable handlers = null ;
+
+ public SimpleRegistry(String fileName)
+ {
+ this.fileName = fileName;
}
- catch( Exception e ) {
- e.printStackTrace( System.err );
+
+ /**
+ * Init (ie. load settings...)
+ */
+ public void init() {
+ load();
}
- }
+
+ /**
+ * Add a new Handler to the registry.
+ */
+ public void add(String key, Handler handler) {
+ if ( handlers == null ) handlers = new Hashtable();
+ handlers.put( key, handler );
+ save();
+ }
+
+ /**
+ * Remove a Handler (locate by key) from the registry - returns old
+ * value if it was there - or null if not.
+ */
+ public Handler remove(String key) {
+ if ( handlers == null ) return( null );
+ Object old = handlers.remove( key );
+ save();
+ return( (Handler) old );
+ }
+
+ /**
+ * Given a 'key' return the corresponding Handler
+ */
+ public Handler find(String key) {
+ if ( handlers == null ) return( null );
+ return( (Handler) handlers.get( key ) );
+ }
+
+ /**
+ * Return the list (in an array) of keys for the Handlers
+ */
+ public String[] list(){
+ int loop = 0 ;
+
+ if ( handlers == null ) return( null );
+ String[] result = new String[handlers.size()];
+ Enumeration keys = handlers.keys();
+ while ( keys.hasMoreElements() )
+ result[loop++] = (String) keys.nextElement();
+ return( result );
+ }
+
+ private void load() {
+ try {
+ FileInputStream fis = new FileInputStream( fileName );
+ ObjectInputStream ois = new ObjectInputStream( fis );
+ handlers = (Hashtable) ois.readObject();
+ fis.close();
+ }
+ catch( Exception e ) {
+ if ( !(e instanceof FileNotFoundException) )
+ e.printStackTrace( System.err );
+ }
+ }
+
+ private void save() {
+ try {
+ FileOutputStream fos = new FileOutputStream( fileName );
+ ObjectOutputStream oos = new ObjectOutputStream( fos );
+ oos.writeObject( handlers );
+ fos.close();
+ }
+ catch( Exception e ) {
+ e.printStackTrace( System.err );
+ }
+ }
};
1.31 +103 -103 xml-axis/java/src/org/apache/axis/server/AxisServer.java
Index: AxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- AxisServer.java 2001/07/10 22:53:04 1.30
+++ AxisServer.java 2001/07/12 15:04:19 1.31
@@ -156,122 +156,122 @@
HandlerRegistry sr = getServiceRegistry();
try {
- hName = msgContext.getStrProp( MessageContext.ENGINE_HANDLER );
- if ( hName != null ) {
- if ( hr == null || (h = hr.find(hName)) == null ) {
- AxisClassLoader cl = msgContext.getClassLoader();
- try {
- Debug.Print( 2, "Trying to load class: " + hName );
- Class cls = cl.loadClass( hName );
- h = (Handler) cls.newInstance();
+ hName = msgContext.getStrProp( MessageContext.ENGINE_HANDLER );
+ if ( hName != null ) {
+ if ( hr == null || (h = hr.find(hName)) == null ) {
+ AxisClassLoader cl = msgContext.getClassLoader();
+ try {
+ Debug.Print( 2, "Trying to load class: " + hName );
+ Class cls = cl.loadClass( hName );
+ h = (Handler) cls.newInstance();
+ }
+ catch( Exception e ) {
+ h = null ;
+ }
}
- catch( Exception e ) {
- h = null ;
- }
- }
- if ( h != null )
- h.invoke(msgContext);
- else
- throw new AxisFault( "Server.error",
- "Can't locate handler: " + hName,
- null, null );
- }
- else {
- // This really should be in a handler - but we need to discuss it
- // first - to make sure that's what we want.
- /* Now we do the 'real' work. The flow is basically: */
- /* Transport Specific Request Handler/Chain */
- /* Global Request Handler/Chain */
- /* Protocol Specific-Handler(ie. SOAP, XP) */
- /* ie. For SOAP Handler: */
- /* - Service Specific Request Handler/Chain */
- /* - SOAP Semantic Checks */
- /* - Service Specific Response Handler/Chain */
- /* Global Response Handler/Chain */
- /* Transport Specific Response Handler/Chain */
- /**************************************************************/
-
- // When do we call init/cleanup??
- Debug.Print(1, "Calling default logic in AxisServer" );
+ if ( h != null )
+ h.invoke(msgContext);
+ else
+ throw new AxisFault( "Server.error",
+ "Can't locate handler: " + hName,
+ null, null );
+ }
+ else {
+ // This really should be in a handler - but we need to discuss it
+ // first - to make sure that's what we want.
+ /* Now we do the 'real' work. The flow is basically: */
+ /* Transport Specific Request Handler/Chain */
+ /* Global Request Handler/Chain */
+ /* Protocol Specific-Handler(ie. SOAP, XP) */
+ /* ie. For SOAP Handler: */
+ /* - Service Specific Request Handler/Chain */
+ /* - SOAP Semantic Checks */
+ /* - Service Specific Response Handler/Chain */
+ /* Global Response Handler/Chain */
+ /* Transport Specific Response Handler/Chain */
+ /**************************************************************/
+
+ // When do we call init/cleanup??
+ Debug.Print(1, "Calling default logic in AxisServer" );
- /* This is what the entirety of this logic might evolve to:
-
- hName = msgContext.getStrProp(MessageContext.TRANSPORT);
- if ( hName != null ) {
+ /* This is what the entirety of this logic might evolve to:
+
+ hName = msgContext.getStrProp(MessageContext.TRANSPORT);
+ if ( hName != null ) {
if ((h = hr.find( hName )) != null ) {
- h.invoke(msgContext);
+ h.invoke(msgContext);
} else {
- System.err.println("Couldn't find transport " + hName);
+ System.err.println("Couldn't find transport " + hName);
}
- } else {
+ } else {
// No transport set, so use the default (probably just
// calls the global->service handlers)
defaultTransport.invoke(msgContext);
- }
+ }
- */
-
- /* Process the Transport Specific Request Chain */
- /**********************************************/
- hName = msgContext.getTransportName();
- HandlerRegistry tr = getTransportRegistry();
- SimpleTargetedChain transportChain = null;
-
- Debug.Print(3, "AxisServer.invoke: Transport = '" + hName +"'");
- if ( hName != null && (h = tr.find( hName )) != null ) {
- if (h instanceof SimpleTargetedChain) {
- transportChain = (SimpleTargetedChain)h;
- h = transportChain.getRequestHandler();
- if (h != null)
- h.invoke(msgContext);
+ */
+
+ /* Process the Transport Specific Request Chain */
+ /**********************************************/
+ hName = msgContext.getTransportName();
+ HandlerRegistry tr = getTransportRegistry();
+ SimpleTargetedChain transportChain = null;
+
+ Debug.Print(3, "AxisServer.invoke: Transport = '" + hName +"'");
+ if ( hName != null && (h = tr.find( hName )) != null ) {
+ if (h instanceof SimpleTargetedChain) {
+ transportChain = (SimpleTargetedChain)h;
+ h = transportChain.getRequestHandler();
+ if (h != null)
+ h.invoke(msgContext);
+ }
}
- }
-
- /* Process the Global Request Chain */
- /**********************************/
- hName = Constants.GLOBAL_REQUEST ;
- if ( hName != null && (h = hr.find( hName )) != null )
- h.invoke(msgContext);
-
- /**
- * At this point, the service should have been set by someone
- * (either the originator of the MessageContext, or one of the
- * transport or global Handlers). If it hasn't been set, we
- * fault.
- */
- h = msgContext.getServiceHandler();
- if (h == null) {
- // It's possible that we haven't yet parsed the
- // message at this point. This is a kludge to
- // make sure we have. There probably wants to be
- // some kind of declarative "parse point" on the handler
- // chain instead....
- Message rm = msgContext.getRequestMessage();
- rm.getAsSOAPEnvelope().getFirstBody();
+
+ /* Process the Global Request Chain */
+ /**********************************/
+ hName = Constants.GLOBAL_REQUEST ;
+ if ( hName != null && (h = hr.find( hName )) != null )
+ h.invoke(msgContext);
+
+ /**
+ * At this point, the service should have been set by someone
+ * (either the originator of the MessageContext, or one of the
+ * transport or global Handlers). If it hasn't been set, we
+ * fault.
+ */
h = msgContext.getServiceHandler();
- if (h == null)
- throw new AxisFault("Server.NoService",
- "The Axis engine couldn't find a " +
- "target service to invoke! targetService is "+msgContext.getTargetService(),
- null, null );
- }
+ if (h == null) {
+ // It's possible that we haven't yet parsed the
+ // message at this point. This is a kludge to
+ // make sure we have. There probably wants to be
+ // some kind of declarative "parse point" on the handler
+ // chain instead....
+ Message rm = msgContext.getRequestMessage();
+ rm.getAsSOAPEnvelope().getFirstBody();
+ h = msgContext.getServiceHandler();
+ if (h == null)
+ throw new AxisFault("Server.NoService",
+ "The Axis engine couldn't find a " +
+ "target service to invoke! targetService is "+msgContext.getTargetService(),
+ null, null );
+ }
- h.invoke(msgContext);
-
- /* Process the Global Response Chain */
- /***********************************/
- hName = Constants.GLOBAL_RECEIVE ;
- if ( hName != null && (h = hr.find( hName )) != null )
h.invoke(msgContext);
-
- /* Process the Transport Specific Response Chain */
- /***********************************************/
- if (transportChain != null) {
- h = transportChain.getResponseHandler();
- if (h != null)
- h.invoke(msgContext);
- }
- }
+
+ /* Process the Global Response Chain */
+ /***********************************/
+ hName = Constants.GLOBAL_RECEIVE ;
+ if ( hName != null && (h = hr.find( hName )) != null )
+ h.invoke(msgContext);
+
+ /* Process the Transport Specific Response Chain */
+ /***********************************************/
+ if (transportChain != null) {
+ h = transportChain.getResponseHandler();
+ if (h != null)
+ h.invoke(msgContext);
+ }
+ }
}
catch( Exception e ) {
// Should we even bother catching it ?
1.2 +6 -6 xml-axis/java/src/org/apache/axis/server/Transport.java
Index: Transport.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/Transport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Transport.java 2001/06/29 13:14:36 1.1
+++ Transport.java 2001/07/12 15:04:21 1.2
@@ -68,13 +68,13 @@
public class Transport extends SimpleTargetedChain
{
public Element getDeploymentData(Document doc) {
- Debug.Print( 1, "Enter: Transport::getDeploymentData" );
+ Debug.Print( 1, "Enter: Transport::getDeploymentData" );
- Element root = doc.createElement( "transport" );
+ Element root = doc.createElement( "transport" );
- fillInDeploymentData(root);
-
- Debug.Print( 1, "Exit: Transport::getDeploymentData" );
- return( root );
+ fillInDeploymentData(root);
+
+ Debug.Print( 1, "Exit: Transport::getDeploymentData" );
+ return( root );
}
}
1.2 +22 -22 xml-axis/java/src/org/apache/axis/suppliers/SimpleChainSupplier.java
Index: SimpleChainSupplier.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/suppliers/SimpleChainSupplier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleChainSupplier.java 2001/06/25 14:31:04 1.1
+++ SimpleChainSupplier.java 2001/07/12 15:04:26 1.2
@@ -87,29 +87,29 @@
public Handler getHandler()
{
- if (_chain == null) {
- Debug.Print(2, "SimpleChainSupplier: Building chain '" + _myName +
- "'");
- Chain c = new SimpleChain();
- c.setOptions(_options);
- c.setName(_myName);
- try {
- for (int i = 0; i < _handlerNames.size(); i++) {
- Handler handler = _registry.find(
- (String)_handlerNames.elementAt(i));
- c.addHandler(handler);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return null;
+ if (_chain == null) {
+ Debug.Print(2, "SimpleChainSupplier: Building chain '" + _myName +
+ "'");
+ Chain c = new SimpleChain();
+ c.setOptions(_options);
+ c.setName(_myName);
+ try {
+ for (int i = 0; i < _handlerNames.size(); i++) {
+ Handler handler = _registry.find(
+ (String)_handlerNames.elementAt(i));
+ c.addHandler(handler);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ _chain = c;
}
+
+ Debug.Print(2, "SimpleChainSupplier: returning chain '" + _myName +
+ "'");
- _chain = c;
- }
-
- Debug.Print(2, "SimpleChainSupplier: returning chain '" + _myName +
- "'");
-
- return _chain;
+ return _chain;
}
}
1.4 +47 -47 xml-axis/java/src/org/apache/axis/suppliers/TargetedChainSupplier.java
Index: TargetedChainSupplier.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/suppliers/TargetedChainSupplier.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TargetedChainSupplier.java 2001/06/29 13:14:38 1.3
+++ TargetedChainSupplier.java 2001/07/12 15:04:27 1.4
@@ -95,64 +95,64 @@
private void addHandlersToChain(Vector names, Chain chain)
{
- if (names == null)
- return;
-
- Enumeration e = names.elements();
- while (e.hasMoreElements()) {
- String hName = (String)e.nextElement();
- Handler h = _registry.find(hName);
- chain.addHandler(h);
- }
+ if (names == null)
+ return;
+
+ Enumeration e = names.elements();
+ while (e.hasMoreElements()) {
+ String hName = (String)e.nextElement();
+ Handler h = _registry.find(hName);
+ chain.addHandler(h);
+ }
}
public SimpleTargetedChain getNewChain()
{
- return new SimpleTargetedChain();
+ return new SimpleTargetedChain();
}
public Handler getHandler()
{
- if (_chain == null) {
- Debug.Print(2, "TargetedChainSupplier: Building chain '" + _myName +
- "'");
+ if (_chain == null) {
+ Debug.Print(2, "TargetedChainSupplier: Building chain '" + _myName +
+ "'");
- Handler h;
- SimpleTargetedChain c = getNewChain();
- c.setOptions(_options);
- c.setName(_myName);
-
- if (!_requestNames.isEmpty()) {
- if (_requestNames.size() == 1) {
- h = _registry.find((String)_requestNames.elementAt(0));
- c.setRequestHandler(h);
- } else {
- Chain chain = new SimpleChain();
- addHandlersToChain(_requestNames, chain);
- c.setRequestHandler(chain);
- }
- }
-
- h = _registry.find(_pivotName);
- c.setPivotHandler(h);
+ Handler h;
+ SimpleTargetedChain c = getNewChain();
+ c.setOptions(_options);
+ c.setName(_myName);
+
+ if (!_requestNames.isEmpty()) {
+ if (_requestNames.size() == 1) {
+ h = _registry.find((String)_requestNames.elementAt(0));
+ c.setRequestHandler(h);
+ } else {
+ Chain chain = new SimpleChain();
+ addHandlersToChain(_requestNames, chain);
+ c.setRequestHandler(chain);
+ }
+ }
+
+ h = _registry.find(_pivotName);
+ c.setPivotHandler(h);
- if (!_responseNames.isEmpty()) {
- if (_responseNames.size() == 1) {
- h = _registry.find((String)_responseNames.elementAt(0));
- c.setResponseHandler(h);
- } else {
- Chain chain = new SimpleChain();
- addHandlersToChain(_responseNames, chain);
- c.setResponseHandler(chain);
- }
+ if (!_responseNames.isEmpty()) {
+ if (_responseNames.size() == 1) {
+ h = _registry.find((String)_responseNames.elementAt(0));
+ c.setResponseHandler(h);
+ } else {
+ Chain chain = new SimpleChain();
+ addHandlersToChain(_responseNames, chain);
+ c.setResponseHandler(chain);
+ }
+ }
+
+ _chain = c;
}
+
+ Debug.Print(2, "TargetedChainSupplier: Returning chain '" + _myName +
+ "'");
- _chain = c;
- }
-
- Debug.Print(2, "TargetedChainSupplier: Returning chain '" + _myName +
- "'");
-
- return _chain;
+ return _chain;
}
}
1.2 +8 -8 xml-axis/java/src/org/apache/axis/suppliers/TransportSupplier.java
Index: TransportSupplier.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/suppliers/TransportSupplier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportSupplier.java 2001/06/29 13:14:39 1.1
+++ TransportSupplier.java 2001/07/12 15:04:28 1.2
@@ -68,18 +68,18 @@
public class TransportSupplier extends TargetedChainSupplier
{
public TransportSupplier(String myName,
- Vector requestNames,
- Vector responseNames,
- String pivotName,
- Hashtable options,
- HandlerRegistry registry)
+ Vector requestNames,
+ Vector responseNames,
+ String pivotName,
+ Hashtable options,
+ HandlerRegistry registry)
{
- super(myName, requestNames, responseNames, pivotName,
- options, registry);
+ super(myName, requestNames, responseNames, pivotName,
+ options, registry);
}
public SimpleTargetedChain getNewChain()
{
- return new Transport();
+ return new Transport();
}
}
1.2 +21 -21 xml-axis/java/src/org/apache/axis/transport/http/AdminServlet.java
Index: AdminServlet.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AdminServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AdminServlet.java 2001/06/18 19:33:26 1.1
+++ AdminServlet.java 2001/07/12 15:04:35 1.2
@@ -72,28 +72,28 @@
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class AdminServlet extends HttpServlet {
- private AxisServer server;
-
- public void init() {
- server = AxisServer.getSingleton();
- }
-
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- res.setContentType("text/html");
- String str = "";
+ private AxisServer server;
- String cmd = req.getParameter("cmd");
- if (cmd != null) {
- if (cmd.equals("start"))
- server.start();
- else
- server.stop();
+ public void init() {
+ server = AxisServer.getSingleton();
}
+
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ res.setContentType("text/html");
+ String str = "";
+
+ String cmd = req.getParameter("cmd");
+ if (cmd != null) {
+ if (cmd.equals("start"))
+ server.start();
+ else
+ server.stop();
+ }
- str += "Server is " + (server.isRunning() ? "running" : "stopped");
- str += "<p><a href=\"?cmd=start\">start server</a>";
- str += "<p><a href=\"?cmd=stop\">stop server</a>";
- res.getWriter().println( str );
- }
+ str += "Server is " + (server.isRunning() ? "running" : "stopped");
+ str += "<p><a href=\"?cmd=start\">start server</a>";
+ str += "<p><a href=\"?cmd=stop\">stop server</a>";
+ res.getWriter().println( str );
+ }
}
1.30 +128 -128 xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
Index: AxisServlet.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AxisServlet.java 2001/07/11 20:02:38 1.29
+++ AxisServlet.java 2001/07/12 15:04:37 1.30
@@ -68,139 +68,139 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class AxisServlet extends HttpServlet {
- // These have default values.
- private String transportName = "http";
+ // These have default values.
+ private String transportName = "http";
- private static final String AXIS_ENGINE = "AxisEngine" ;
+ private static final String AXIS_ENGINE = "AxisEngine" ;
- public void init() {
- String param = getInitParameter("transport.name");
- ServletContext context = getServletConfig().getServletContext();
-
- if (param == null)
- param = context.getInitParameter("transport.name");
- if (param != null)
- transportName = param;
- }
-
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- res.setContentType("text/html");
- res.getWriter().println( "In doGet<p>" );
- res.getWriter().println(" TransportName = " + transportName);
- }
-
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- ServletConfig config = getServletConfig();
- ServletContext context = config.getServletContext();
- HttpSession session = req.getSession();
-
- AxisEngine engine = AxisServer.getSingleton();
-
- /* Place the Request message in the MessagContext object - notice */
- /* that we just leave it as a 'ServletRequest' object and let the */
- /* Message processing routine convert it - we don't do it since we */
- /* don't know how it's going to be used - perhaps it might not */
- /* even need to be parsed. */
- /*******************************************************************/
- MessageContext msgContext = new MessageContext(engine);
- InputStream inp = req.getInputStream();
- Message msg = new Message( inp );
-
- /* Set the request(incoming) message field in the context */
- /**********************************************************/
- msgContext.setRequestMessage( msg );
-
- /* Set the Transport */
- /*********************/
- msgContext.setTransportName(transportName);
-
- /* Save some HTTP specific info in the bag in case a handler needs it */
- /**********************************************************************/
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res );
-
- /* Save the SOAPAction header in the MessageContext bag - this will */
- /* be used to tell the Axis Engine which service is being invoked. */
- /* This will save us the trouble of having to parse the Request */
- /* message - although we will need to double-check later on that */
- /* the SOAPAction header does in fact match the URI in the body. */
- /* (is this last stmt true??? (I don't think so - Glen)) */
- /* if SOAPAction is "" then use the URL */
- /* if SOAPAction is null then we'll we be forced to scan the body */
- /* for it. */
- /********************************************************************/
- String tmp ;
- tmp = (String) req.getHeader( HTTPConstants.HEADER_SOAP_ACTION );
-
- try {
- /** Technically, if we don't find this header, we should probably fault.
- * It's required in the SOAP HTTP binding.
- */
- if ( tmp == null ) {
- throw new AxisFault( "Client.NoSOAPAction",
- "No SOAPAction header!",
- null, null );
- }
-
- if ( "".equals(tmp) )
- tmp = req.getContextPath(); // Is this right?
-
- if ( tmp != null )
- msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, tmp );
+ public void init() {
+ String param = getInitParameter("transport.name");
+ ServletContext context = getServletConfig().getServletContext();
- // Create a Session wrapper for the HTTP session.
- // These can/should be pooled at some point. (Sam is Watching! :-)
- msgContext.setSession(new AxisHttpSession(req.getSession()));
-
- /* Save the real path */
- /**********************/
- String realpath = context.getRealPath(req.getServletPath());
- if (realpath != null)
- msgContext.setProperty(Constants.MC_REALPATH, realpath);
-
- /* Invoke the Axis engine... */
- /*****************************/
- engine.invoke( msgContext );
+ if (param == null)
+ param = context.getInitParameter("transport.name");
+ if (param != null)
+ transportName = param;
}
- catch( Exception e ) {
- if ( e instanceof AxisFault ) {
- AxisFault af = (AxisFault) e ;
- if ( "Server.Unauthorized".equals( af.getFaultCode() ) )
- res.setStatus( HttpServletResponse.SC_UNAUTHORIZED );
- else
- res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- // It's been suggested that a lack of SOAPAction should produce some
- // other error code (in the 400s)...
- }
- else
- res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- if ( !(e instanceof AxisFault) )
- e = new AxisFault( e );
- msg = msgContext.getResponseMessage();
- if (msg == null) {
- msg = new Message((AxisFault)e);
- msgContext.setResponseMessage(msg);
- } else {
- SOAPEnvelope env = msg.getAsSOAPEnvelope();
- env.clearBody();
- env.addBodyElement(new SOAPFaultElement((AxisFault)e));
- }
+
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ res.setContentType("text/html");
+ res.getWriter().println( "In doGet<p>" );
+ res.getWriter().println(" TransportName = " + transportName);
}
+
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ ServletConfig config = getServletConfig();
+ ServletContext context = config.getServletContext();
+ HttpSession session = req.getSession();
- /* Send it back along the wire... */
- /***********************************/
- msg = msgContext.getResponseMessage();
- res.setContentType( "text/xml; charset=utf-8" );
- String response;
- if (msg == null) {
- response="No data";
- } else {
- response = (String)msg.getAsString();
+ AxisEngine engine = AxisServer.getSingleton();
+
+ /* Place the Request message in the MessagContext object - notice */
+ /* that we just leave it as a 'ServletRequest' object and let the */
+ /* Message processing routine convert it - we don't do it since we */
+ /* don't know how it's going to be used - perhaps it might not */
+ /* even need to be parsed. */
+ /*******************************************************************/
+ MessageContext msgContext = new MessageContext(engine);
+ InputStream inp = req.getInputStream();
+ Message msg = new Message( inp );
+
+ /* Set the request(incoming) message field in the context */
+ /**********************************************************/
+ msgContext.setRequestMessage( msg );
+
+ /* Set the Transport */
+ /*********************/
+ msgContext.setTransportName(transportName);
+
+ /* Save some HTTP specific info in the bag in case a handler needs it */
+ /**********************************************************************/
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this );
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req );
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res );
+
+ /* Save the SOAPAction header in the MessageContext bag - this will */
+ /* be used to tell the Axis Engine which service is being invoked. */
+ /* This will save us the trouble of having to parse the Request */
+ /* message - although we will need to double-check later on that */
+ /* the SOAPAction header does in fact match the URI in the body. */
+ /* (is this last stmt true??? (I don't think so - Glen)) */
+ /* if SOAPAction is "" then use the URL */
+ /* if SOAPAction is null then we'll we be forced to scan the body */
+ /* for it. */
+ /********************************************************************/
+ String tmp ;
+ tmp = (String) req.getHeader( HTTPConstants.HEADER_SOAP_ACTION );
+
+ try {
+ /** Technically, if we don't find this header, we should probably fault.
+ * It's required in the SOAP HTTP binding.
+ */
+ if ( tmp == null ) {
+ throw new AxisFault( "Client.NoSOAPAction",
+ "No SOAPAction header!",
+ null, null );
+ }
+
+ if ( "".equals(tmp) )
+ tmp = req.getContextPath(); // Is this right?
+
+ if ( tmp != null )
+ msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, tmp );
+
+ // Create a Session wrapper for the HTTP session.
+ // These can/should be pooled at some point. (Sam is Watching! :-)
+ msgContext.setSession(new AxisHttpSession(req.getSession()));
+
+ /* Save the real path */
+ /**********************/
+ String realpath = context.getRealPath(req.getServletPath());
+ if (realpath != null)
+ msgContext.setProperty(Constants.MC_REALPATH, realpath);
+
+ /* Invoke the Axis engine... */
+ /*****************************/
+ engine.invoke( msgContext );
+ }
+ catch( Exception e ) {
+ if ( e instanceof AxisFault ) {
+ AxisFault af = (AxisFault) e ;
+ if ( "Server.Unauthorized".equals( af.getFaultCode() ) )
+ res.setStatus( HttpServletResponse.SC_UNAUTHORIZED );
+ else
+ res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ // It's been suggested that a lack of SOAPAction should produce some
+ // other error code (in the 400s)...
+ }
+ else
+ res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ if ( !(e instanceof AxisFault) )
+ e = new AxisFault( e );
+ msg = msgContext.getResponseMessage();
+ if (msg == null) {
+ msg = new Message((AxisFault)e);
+ msgContext.setResponseMessage(msg);
+ } else {
+ SOAPEnvelope env = msg.getAsSOAPEnvelope();
+ env.clearBody();
+ env.addBodyElement(new SOAPFaultElement((AxisFault)e));
+ }
+ }
+
+ /* Send it back along the wire... */
+ /***********************************/
+ msg = msgContext.getResponseMessage();
+ res.setContentType( "text/xml; charset=utf-8" );
+ String response;
+ if (msg == null) {
+ response="No data";
+ } else {
+ response = (String)msg.getAsString();
+ }
+ res.setContentLength( response.length() );
+ res.getWriter().print( response );
}
- res.setContentLength( response.length() );
- res.getWriter().print( response );
- }
}
1.7 +274 -274 xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java
Index: HTTPSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HTTPSender.java 2001/07/09 14:16:41 1.6
+++ HTTPSender.java 2001/07/12 15:04:38 1.7
@@ -77,286 +77,286 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class HTTPSender extends BasicHandler {
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: HTTPSender::invoke" );
- /* Find the service we're invoking so we can grab it's options */
- /***************************************************************/
- String targetURL = null ;
- Message outMsg = null ;
- String reqEnv = null ;
-
- targetURL = msgContext.getStrProp( MessageContext.TRANS_URL);
- try {
- String host ;
- int port = 80 ;
- URL tmpURL = new URL( targetURL );
- byte[] buf = new byte[4097];
- int rc = 0 ;
-
- // default SOAPAction to request namespaceURI/method
- String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
- if (action == null) {
- Message rm = msgContext.getRequestMessage();
- MessageElement body = rm.getAsSOAPEnvelope().getFirstBody();
- action = body.getNamespaceURI() + "/" + body.getName();
- }
-
- host = tmpURL.getHost();
- if ( (port = tmpURL.getPort()) == -1 ) port = 80;
-
- Socket sock = null ;
-
- if (tmpURL.getProtocol().equalsIgnoreCase("https")) {
- if ( (port = tmpURL.getPort()) == -1 ) port = 443;
- String tunnelHost = System.getProperty("https.proxyHost");
- String tunnelPortString = System.getProperty("https.proxyPort");
- String tunnelUsername = System.getProperty("https.proxyUsername");
- String tunnelPassword = System.getProperty("https.proxyPassword");
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: HTTPSender::invoke" );
+ /* Find the service we're invoking so we can grab it's options */
+ /***************************************************************/
+ String targetURL = null ;
+ Message outMsg = null ;
+ String reqEnv = null ;
+
+ targetURL = msgContext.getStrProp( MessageContext.TRANS_URL);
try {
- Class SSLSocketFactoryClass =
- Class.forName("javax.net.ssl.SSLSocketFactory");
- Class SSLSocketClass = Class.forName("javax.net.ssl.SSLSocket");
- Method createSocketMethod =
- SSLSocketFactoryClass.getMethod("createSocket",
- new Class[] {String.class, Integer.TYPE});
- Method getDefaultMethod =
- SSLSocketFactoryClass.getMethod("getDefault", new Class[] {});
- Method startHandshakeMethod =
- SSLSocketClass.getMethod("startHandshake", new Class[] {});
- Object factory = getDefaultMethod.invoke(null, new Object[] {});
- Object sslSocket = null;
- if (tunnelHost == null || tunnelHost.equals("")) {
- // direct SSL connection
- sslSocket = createSocketMethod .invoke(factory,
- new Object[] {host, new Integer(port)});
- } else {
- // SSL tunnelling through proxy server
- Method createSocketMethod2 =
- SSLSocketFactoryClass.getMethod("createSocket",
- new Class[] {Socket.class, String.class, Integer.TYPE, Boolean.TYPE});
- int tunnelPort = (tunnelPortString != null? (Integer.parseInt(tunnelPortString) < 0? 443: Integer.parseInt(tunnelPortString)): 443);
- Object tunnel = createSocketMethod .invoke(factory,
- new Object[] {tunnelHost, new Integer(tunnelPort)});
- // The tunnel handshake method (condensed and made reflexive)
- OutputStream tunnelOutputStream = (OutputStream)SSLSocketClass.getMethod("getOutputStream", new Class[] {}).invoke(tunnel, new Object[] {});
- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(tunnelOutputStream)));
- out.print("CONNECT " + host + ":" + port + " HTTP/1.0\n\r\n\r");
- out.flush();
- InputStream tunnelInputStream = (InputStream)SSLSocketClass.getMethod("getInputStream", new Class[] {}).invoke(tunnel, new Object[] {});
- //BufferedReader in = new BufferedReader(new InputStreamReader(tunnelInputStream));
- //DataInputStream in = new DataInputStream(tunnelInputStream);
- Debug.Print(1, "Is tunnelInputStream null? " + String.valueOf(tunnelInputStream == null));
- String replyStr = ""; int i;
- while ((i = tunnelInputStream.read()) != '\n' && i != '\r' && i != -1) { replyStr += String.valueOf((char)i); Debug.Print(1, "got a character in reply, so far: " + replyStr); }
- if (!replyStr.startsWith("HTTP/1.0 200") && !replyStr.startsWith("HTTP/1.1 200")) {
- throw new IOException("Unable to tunnel through " + tunnelHost + ":" + tunnelPort + ". Proxy returns \"" + replyStr + "\"");
+ String host ;
+ int port = 80 ;
+ URL tmpURL = new URL( targetURL );
+ byte[] buf = new byte[4097];
+ int rc = 0 ;
+
+ // default SOAPAction to request namespaceURI/method
+ String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
+ if (action == null) {
+ Message rm = msgContext.getRequestMessage();
+ MessageElement body = rm.getAsSOAPEnvelope().getFirstBody();
+ action = body.getNamespaceURI() + "/" + body.getName();
}
- // End of condensed reflective tunnel handshake method
- sslSocket = createSocketMethod2.invoke(factory,
- new Object[] {tunnel, host, new Integer(port), new Boolean(true)});
- Debug.Print( 1, "Set up SSL tunnelling through " + tunnelHost + ":" +tunnelPort);
- }
- // must shake out hidden errors!
- startHandshakeMethod.invoke(sslSocket, new Object[] {});
- sock = (Socket)sslSocket;
- } catch (ClassNotFoundException cnfe) {
- Debug.Print( 1, "SSL feature disallowed: JSSE files not installed or present in classpath");
- throw new AxisFault(cnfe);
- } catch (NumberFormatException nfe) {
- Debug.Print( 1, "Proxy port number, \"" + tunnelPortString + "\", incorrectly formatted");
- throw new AxisFault(nfe);
- }
- Debug.Print( 1, "Created an SSL connection");
- } else {
- if ((port = tmpURL.getPort()) == -1 ) port = 80;
- sock = new Socket( host, port );
- Debug.Print( 1, "Created an insecure HTTP connection");
- }
-
- reqEnv = (String) msgContext.getRequestMessage().getAsString();
-
- //System.out.println("Msg: " + reqEnv);
-
- BufferedInputStream inp = new BufferedInputStream(sock.getInputStream());
- OutputStream out = sock.getOutputStream();
- StringBuffer otherHeaders = new StringBuffer();
- String userID = null ;
- String passwd = null ;
-
- userID = msgContext.getStrProp( MessageContext.USERID );
- passwd = msgContext.getStrProp( MessageContext.PASSWORD );
-
- if ( userID != null ) {
- StringBuffer tmpBuf = new StringBuffer();
- tmpBuf.append( userID )
- .append( ":" )
- .append( (passwd == null) ? "" : passwd) ;
- otherHeaders.append( HTTPConstants.HEADER_AUTHORIZATION )
- .append( ": Basic " )
- .append( Base64.encode( tmpBuf.toString().getBytes() ) )
- .append("\n" );
- }
-
- // don't forget the cookies!
- // mmm... cookies
- if (msgContext.getMaintainSession()) {
- String cookie = msgContext.getStrProp(HTTPConstants.HEADER_COOKIE);
- String cookie2 = msgContext.getStrProp(HTTPConstants.HEADER_COOKIE2);
+
+ host = tmpURL.getHost();
+ if ( (port = tmpURL.getPort()) == -1 ) port = 80;
+
+ Socket sock = null ;
+
+ if (tmpURL.getProtocol().equalsIgnoreCase("https")) {
+ if ( (port = tmpURL.getPort()) == -1 ) port = 443;
+ String tunnelHost = System.getProperty("https.proxyHost");
+ String tunnelPortString = System.getProperty("https.proxyPort");
+ String tunnelUsername = System.getProperty("https.proxyUsername");
+ String tunnelPassword = System.getProperty("https.proxyPassword");
+ try {
+ Class SSLSocketFactoryClass =
+ Class.forName("javax.net.ssl.SSLSocketFactory");
+ Class SSLSocketClass = Class.forName("javax.net.ssl.SSLSocket");
+ Method createSocketMethod =
+ SSLSocketFactoryClass.getMethod("createSocket",
+ new Class[] {String.class, Integer.TYPE});
+ Method getDefaultMethod =
+ SSLSocketFactoryClass.getMethod("getDefault", new Class[] {});
+ Method startHandshakeMethod =
+ SSLSocketClass.getMethod("startHandshake", new Class[] {});
+ Object factory = getDefaultMethod.invoke(null, new Object[] {});
+ Object sslSocket = null;
+ if (tunnelHost == null || tunnelHost.equals("")) {
+ // direct SSL connection
+ sslSocket = createSocketMethod .invoke(factory,
+ new Object[] {host, new Integer(port)});
+ } else {
+ // SSL tunnelling through proxy server
+ Method createSocketMethod2 =
+ SSLSocketFactoryClass.getMethod("createSocket",
+ new Class[] {Socket.class, String.class, Integer.TYPE, Boolean.TYPE});
+ int tunnelPort = (tunnelPortString != null? (Integer.parseInt(tunnelPortString) < 0? 443: Integer.parseInt(tunnelPortString)): 443);
+ Object tunnel = createSocketMethod .invoke(factory,
+ new Object[] {tunnelHost, new Integer(tunnelPort)});
+ // The tunnel handshake method (condensed and made reflexive)
+ OutputStream tunnelOutputStream = (OutputStream)SSLSocketClass.getMethod("getOutputStream", new Class[] {}).invoke(tunnel, new Object[] {});
+ PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(tunnelOutputStream)));
+ out.print("CONNECT " + host + ":" + port + " HTTP/1.0\n\r\n\r");
+ out.flush();
+ InputStream tunnelInputStream = (InputStream)SSLSocketClass.getMethod("getInputStream", new Class[] {}).invoke(tunnel, new Object[] {});
+ //BufferedReader in = new BufferedReader(new InputStreamReader(tunnelInputStream));
+ //DataInputStream in = new DataInputStream(tunnelInputStream);
+ Debug.Print(1, "Is tunnelInputStream null? " + String.valueOf(tunnelInputStream == null));
+ String replyStr = ""; int i;
+ while ((i = tunnelInputStream.read()) != '\n' && i != '\r' && i != -1) { replyStr += String.valueOf((char)i); Debug.Print(1, "got a character in reply, so far: " + replyStr); }
+ if (!replyStr.startsWith("HTTP/1.0 200") && !replyStr.startsWith("HTTP/1.1 200")) {
+ throw new IOException("Unable to tunnel through " + tunnelHost + ":" + tunnelPort + ". Proxy returns \"" + replyStr + "\"");
+ }
+ // End of condensed reflective tunnel handshake method
+ sslSocket = createSocketMethod2.invoke(factory,
+ new Object[] {tunnel, host, new Integer(port), new Boolean(true)});
+ Debug.Print( 1, "Set up SSL tunnelling through " + tunnelHost + ":" +tunnelPort);
+ }
+ // must shake out hidden errors!
+ startHandshakeMethod.invoke(sslSocket, new Object[] {});
+ sock = (Socket)sslSocket;
+ } catch (ClassNotFoundException cnfe) {
+ Debug.Print( 1, "SSL feature disallowed: JSSE files not installed or present in classpath");
+ throw new AxisFault(cnfe);
+ } catch (NumberFormatException nfe) {
+ Debug.Print( 1, "Proxy port number, \"" + tunnelPortString + "\", incorrectly formatted");
+ throw new AxisFault(nfe);
+ }
+ Debug.Print( 1, "Created an SSL connection");
+ } else {
+ if ((port = tmpURL.getPort()) == -1 ) port = 80;
+ sock = new Socket( host, port );
+ Debug.Print( 1, "Created an insecure HTTP connection");
+ }
+
+ reqEnv = (String) msgContext.getRequestMessage().getAsString();
- if (cookie != null) {
- otherHeaders.append(HTTPConstants.HEADER_COOKIE)
- .append(": ")
- .append(cookie)
- .append("\r\n");
+ //System.out.println("Msg: " + reqEnv);
+
+ BufferedInputStream inp = new BufferedInputStream(sock.getInputStream());
+ OutputStream out = sock.getOutputStream();
+ StringBuffer otherHeaders = new StringBuffer();
+ String userID = null ;
+ String passwd = null ;
+
+ userID = msgContext.getStrProp( MessageContext.USERID );
+ passwd = msgContext.getStrProp( MessageContext.PASSWORD );
+
+ if ( userID != null ) {
+ StringBuffer tmpBuf = new StringBuffer();
+ tmpBuf.append( userID )
+ .append( ":" )
+ .append( (passwd == null) ? "" : passwd) ;
+ otherHeaders.append( HTTPConstants.HEADER_AUTHORIZATION )
+ .append( ": Basic " )
+ .append( Base64.encode( tmpBuf.toString().getBytes() ) )
+ .append("\n" );
}
-
- if (cookie2 != null) {
- otherHeaders.append(HTTPConstants.HEADER_COOKIE2)
- .append(": ")
- .append(cookie2)
- .append("\r\n");
+
+ // don't forget the cookies!
+ // mmm... cookies
+ if (msgContext.getMaintainSession()) {
+ String cookie = msgContext.getStrProp(HTTPConstants.HEADER_COOKIE);
+ String cookie2 = msgContext.getStrProp(HTTPConstants.HEADER_COOKIE2);
+
+ if (cookie != null) {
+ otherHeaders.append(HTTPConstants.HEADER_COOKIE)
+ .append(": ")
+ .append(cookie)
+ .append("\r\n");
+ }
+
+ if (cookie2 != null) {
+ otherHeaders.append(HTTPConstants.HEADER_COOKIE2)
+ .append(": ")
+ .append(cookie2)
+ .append("\r\n");
+ }
}
- }
-
- StringBuffer header = new StringBuffer();
+
+ StringBuffer header = new StringBuffer();
- header.append( HTTPConstants.HEADER_POST )
- .append(" " )
- .append( ((tmpURL.getFile() == null ||
- tmpURL.getFile().equals(""))? "/": tmpURL.getFile()) )
- .append( " HTTP/1.0\r\n" )
- .append( HTTPConstants.HEADER_CONTENT_LENGTH )
- .append( ": " )
- .append(reqEnv.length() )
- .append( "\r\n" )
- .append( HTTPConstants.HEADER_CONTENT_TYPE )
- .append( ": text/xml; charset=utf-8\r\n" )
- .append( (otherHeaders == null ? "" : otherHeaders.toString()))
- .append( HTTPConstants.HEADER_SOAP_ACTION )
- .append( ": \"" )
- .append( action )
- .append( "\"\r\n");
-
- header.append("\r\n");
-
- out.write( header.toString().getBytes() );
- out.write( reqEnv.getBytes() );
-
- Debug.Print( 1, "XML sent:" );
- Debug.Print( 1, "---------------------------------------------------");
- Debug.Print( 1, header + reqEnv );
-
- byte lastB=0, b ;
- int len = 0 ;
- int colonIndex = -1 ;
- Hashtable headers = new Hashtable();
- String name, value ;
-
- // Need to add logic for getting the version # and the return code
- // but that's for tomorrow!
-
- for ( ;; ) {
- if ( (b = (byte) inp.read()) == -1 ) break ;
- if ( b != '\r' && b != '\n' ) {
- if ( b == ':' ) colonIndex = len ;
- lastB = (buf[len++] = b);
- }
- else if ( b == '\r' )
- continue ;
- else {
- if ( len == 0 ) break ;
- if ( colonIndex != -1 ) {
- name = new String( buf, 0, colonIndex );
- value = new String( buf, colonIndex+1, len-1-colonIndex );
- }
- else {
- name = new String( buf, 0, len );
- value = "" ;
- }
- Debug.Print( 1, name + value );
- if ( msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE)==null){
- // Reader status code
- int start = name.indexOf( ' ' ) + 1 ;
- String tmp = name.substring(start).trim();
- int end = tmp.indexOf( ' ' );
- if ( end != -1 ) tmp = tmp.substring( 0, end );
- rc = Integer.parseInt( tmp );
- msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_CODE,
- new Integer(rc) );
- msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_MESSAGE,
- name.substring(end+1));
- }
- else
- headers.put( name.toLowerCase(), value );
- len = 0 ;
- }
- }
+ header.append( HTTPConstants.HEADER_POST )
+ .append(" " )
+ .append( ((tmpURL.getFile() == null ||
+ tmpURL.getFile().equals(""))? "/": tmpURL.getFile()) )
+ .append( " HTTP/1.0\r\n" )
+ .append( HTTPConstants.HEADER_CONTENT_LENGTH )
+ .append( ": " )
+ .append(reqEnv.length() )
+ .append( "\r\n" )
+ .append( HTTPConstants.HEADER_CONTENT_TYPE )
+ .append( ": text/xml; charset=utf-8\r\n" )
+ .append( (otherHeaders == null ? "" : otherHeaders.toString()))
+ .append( HTTPConstants.HEADER_SOAP_ACTION )
+ .append( ": \"" )
+ .append( action )
+ .append( "\"\r\n");
+
+ header.append("\r\n");
- if ( b != -1 && Debug.getDebugLevel() > 8 ) {
- // Special case - if the debug level is this high then something
- // really bad must be going on - so just dump the input stream
- // to stdout.
- while ( (b = (byte) inp.read()) != -1 )
- System.err.print((char)b);
- System.err.println("");
- }
-
- if ( b != -1 ) {
- if (Debug.getDebugLevel() > 0) {
- String contentLength = (String) headers.get("content-length");
- if ( contentLength != null ) {
- contentLength = contentLength.trim();
- byte[] data = new byte[Integer.parseInt(contentLength)];
- for (len=0; len<data.length; )
- len+= inp.read(data,len,data.length-len);
- String xml = new String(data);
-
- outMsg = new Message( data );
-
- Debug.Print( 1, "\nXML received:" );
- Debug.Print( 1, "-----------------------------------------------");
- Debug.Print( 1, xml );
- }
- else {
- outMsg = new Message( inp );
- Debug.Print( 1, "\nNo Content-Length" );
- Debug.Print( 1, "\nXML received:" );
- Debug.Print( 1, "-----------------------------------------------");
- Debug.Print( 1, (String) outMsg.getAsString() );
- }
- } else {
- outMsg = new Message( inp );
- }
+ out.write( header.toString().getBytes() );
+ out.write( reqEnv.getBytes() );
- msgContext.setResponseMessage( outMsg );
-
- // if we are maintaining session state,
- // handle cookies (if any)
- if (msgContext.getMaintainSession()) {
- handleCookie(HTTPConstants.HEADER_COOKIE,
- HTTPConstants.HEADER_SET_COOKIE,
- headers,
- msgContext);
- handleCookie(HTTPConstants.HEADER_COOKIE2,
- HTTPConstants.HEADER_SET_COOKIE2,
- headers,
- msgContext);
- }
- }
- }
- catch( Exception e ) {
- Debug.Print( 1, e );
- e.printStackTrace();
- if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
- throw (AxisFault) e ;
+ Debug.Print( 1, "XML sent:" );
+ Debug.Print( 1, "---------------------------------------------------");
+ Debug.Print( 1, header + reqEnv );
+
+ byte lastB=0, b ;
+ int len = 0 ;
+ int colonIndex = -1 ;
+ Hashtable headers = new Hashtable();
+ String name, value ;
+
+ // Need to add logic for getting the version # and the return code
+ // but that's for tomorrow!
+
+ for ( ;; ) {
+ if ( (b = (byte) inp.read()) == -1 ) break ;
+ if ( b != '\r' && b != '\n' ) {
+ if ( b == ':' ) colonIndex = len ;
+ lastB = (buf[len++] = b);
+ }
+ else if ( b == '\r' )
+ continue ;
+ else {
+ if ( len == 0 ) break ;
+ if ( colonIndex != -1 ) {
+ name = new String( buf, 0, colonIndex );
+ value = new String( buf, colonIndex+1, len-1-colonIndex );
+ }
+ else {
+ name = new String( buf, 0, len );
+ value = "" ;
+ }
+ Debug.Print( 1, name + value );
+ if ( msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE)==null){
+ // Reader status code
+ int start = name.indexOf( ' ' ) + 1 ;
+ String tmp = name.substring(start).trim();
+ int end = tmp.indexOf( ' ' );
+ if ( end != -1 ) tmp = tmp.substring( 0, end );
+ rc = Integer.parseInt( tmp );
+ msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_CODE,
+ new Integer(rc) );
+ msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_MESSAGE,
+ name.substring(end+1));
+ }
+ else
+ headers.put( name.toLowerCase(), value );
+ len = 0 ;
+ }
+ }
+
+ if ( b != -1 && Debug.getDebugLevel() > 8 ) {
+ // Special case - if the debug level is this high then something
+ // really bad must be going on - so just dump the input stream
+ // to stdout.
+ while ( (b = (byte) inp.read()) != -1 )
+ System.err.print((char)b);
+ System.err.println("");
+ }
+
+ if ( b != -1 ) {
+ if (Debug.getDebugLevel() > 0) {
+ String contentLength = (String) headers.get("content-length");
+ if ( contentLength != null ) {
+ contentLength = contentLength.trim();
+ byte[] data = new byte[Integer.parseInt(contentLength)];
+ for (len=0; len<data.length; )
+ len+= inp.read(data,len,data.length-len);
+ String xml = new String(data);
+
+ outMsg = new Message( data );
+
+ Debug.Print( 1, "\nXML received:" );
+ Debug.Print( 1, "-----------------------------------------------");
+ Debug.Print( 1, xml );
+ }
+ else {
+ outMsg = new Message( inp );
+ Debug.Print( 1, "\nNo Content-Length" );
+ Debug.Print( 1, "\nXML received:" );
+ Debug.Print( 1, "-----------------------------------------------");
+ Debug.Print( 1, (String) outMsg.getAsString() );
+ }
+ } else {
+ outMsg = new Message( inp );
+ }
+
+ msgContext.setResponseMessage( outMsg );
+
+ // if we are maintaining session state,
+ // handle cookies (if any)
+ if (msgContext.getMaintainSession()) {
+ handleCookie(HTTPConstants.HEADER_COOKIE,
+ HTTPConstants.HEADER_SET_COOKIE,
+ headers,
+ msgContext);
+ handleCookie(HTTPConstants.HEADER_COOKIE2,
+ HTTPConstants.HEADER_SET_COOKIE2,
+ headers,
+ msgContext);
+ }
+ }
+ }
+ catch( Exception e ) {
+ Debug.Print( 1, e );
+ e.printStackTrace();
+ if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
+ throw (AxisFault) e ;
+ }
+ Debug.Print( 1, "Exit: HTTPDispatchHandler::invoke" );
}
- Debug.Print( 1, "Exit: HTTPDispatchHandler::invoke" );
- }
// little helper function for cookies
public void handleCookie
- (String cookieName, String setCookieName, Hashtable headers,
- MessageContext msgContext)
+ (String cookieName, String setCookieName, Hashtable headers,
+ MessageContext msgContext)
{
if (headers.containsKey(setCookieName.toLowerCase())) {
String cookie = (String)headers.get(setCookieName.toLowerCase());
@@ -369,12 +369,12 @@
msgContext.setProperty(cookieName, cookie);
}
}
-
-
+
+
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: HTTPDispatchHandler::undo" );
- Debug.Print( 1, "Exit: HTTPDispatchHandler::undo" );
- }
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: HTTPDispatchHandler::undo" );
+ Debug.Print( 1, "Exit: HTTPDispatchHandler::undo" );
+ }
};
1.2 +4 -4 xml-axis/java/src/org/apache/axis/transport/local/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/local/Handler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Handler.java 2001/06/29 19:59:08 1.1
+++ Handler.java 2001/07/12 15:04:43 1.2
@@ -65,8 +65,8 @@
*/
public class Handler extends URLStreamHandler
{
- protected URLConnection openConnection(URL u)
- {
- return null;
- }
+ protected URLConnection openConnection(URL u)
+ {
+ return null;
+ }
}
1.2 +9 -9 xml-axis/java/src/org/apache/axis/transport/local/LocalResponder.java
Index: LocalResponder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/local/LocalResponder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LocalResponder.java 2001/07/09 21:31:57 1.1
+++ LocalResponder.java 2001/07/12 15:04:45 1.2
@@ -66,14 +66,14 @@
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class LocalResponder extends BasicHandler {
- public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: LocalResponder::invoke" );
- msgContext.getResponseMessage().getAsString();
- Debug.Print( 1, "Enter: LocalResponder::invoke" );
- }
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Debug.Print( 1, "Enter: LocalResponder::invoke" );
+ msgContext.getResponseMessage().getAsString();
+ Debug.Print( 1, "Enter: LocalResponder::invoke" );
+ }
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: LocalResponder::undo" );
- Debug.Print( 1, "Exit: LocalResponder::undo" );
- }
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: LocalResponder::undo" );
+ Debug.Print( 1, "Exit: LocalResponder::undo" );
+ }
};
1.7 +79 -79 xml-axis/java/src/org/apache/axis/transport/local/LocalSender.java
Index: LocalSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/local/LocalSender.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LocalSender.java 2001/07/11 20:02:49 1.6
+++ LocalSender.java 2001/07/12 15:04:46 1.7
@@ -72,91 +72,91 @@
*/
public class LocalSender extends BasicHandler {
- private volatile AxisServer server;
+ private volatile AxisServer server;
- /**
- * Allocate an embedded Axis server to process requests and initialize it.
- */
- public synchronized void init() {
- AxisServer server = new AxisServer();
- server.init();
- this.server=server;
- }
-
- public void invoke(MessageContext clientContext) throws AxisFault {
- Debug.Print( 1, "Enter: LocalSender::invoke" );
-
- AxisServer targetServer = (AxisServer)clientContext.
- getProperty(LocalTransport.LOCAL_SERVER);
- Debug.Print(3, "LocalSender using server " + targetServer);
-
- if (targetServer == null) {
- // This should have already been done, but it doesn't appear to be
- // something that can be relied on. Oh, well...
- if (server == null) init();
- targetServer = server;
+ /**
+ * Allocate an embedded Axis server to process requests and initialize it.
+ */
+ public synchronized void init() {
+ AxisServer server = new AxisServer();
+ server.init();
+ this.server=server;
}
-
- // Define a new messageContext per request
- MessageContext serverContext = new MessageContext(targetServer);
-
- // copy the request, and force its format to String in order to
- // exercise the serializers.
- String msgStr = clientContext.getRequestMessage().getAsString();
-
- Debug.Print(3, "LocalSender sending XML:");
- Debug.Print(3, msgStr);
-
- serverContext.setRequestMessage(new Message(msgStr));
- serverContext.setTransportName("local");
-
- // copy soap action if it is present
- String action = clientContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
- if (action != null) {
- serverContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION, action);
- serverContext.setTransportName("http");
- }
+
+ public void invoke(MessageContext clientContext) throws AxisFault {
+ Debug.Print( 1, "Enter: LocalSender::invoke" );
- // set the realpath if possible
- String transURL = clientContext.getStrProp(MessageContext.TRANS_URL);
- if (transURL != null) {
- try {
- URL url = new URL(transURL);
- if (url.getProtocol().equals("file")) {
- String file = url.getFile();
- if (file.length()>0 && file.charAt(0)=='/') file = file.substring(1);
- serverContext.setProperty(Constants.MC_REALPATH, file);
+ AxisServer targetServer = (AxisServer)clientContext.
+ getProperty(LocalTransport.LOCAL_SERVER);
+ Debug.Print(3, "LocalSender using server " + targetServer);
+
+ if (targetServer == null) {
+ // This should have already been done, but it doesn't appear to be
+ // something that can be relied on. Oh, well...
+ if (server == null) init();
+ targetServer = server;
}
- } catch (Exception e) {
- }
- }
+
+ // Define a new messageContext per request
+ MessageContext serverContext = new MessageContext(targetServer);
+
+ // copy the request, and force its format to String in order to
+ // exercise the serializers.
+ String msgStr = clientContext.getRequestMessage().getAsString();
+
+ Debug.Print(3, "LocalSender sending XML:");
+ Debug.Print(3, msgStr);
+
+ serverContext.setRequestMessage(new Message(msgStr));
+ serverContext.setTransportName("local");
+
+ // copy soap action if it is present
+ String action = clientContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
+ if (action != null) {
+ serverContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION, action);
+ serverContext.setTransportName("http");
+ }
- // invoke the request
- try {
- targetServer.invoke(serverContext);
- } catch (AxisFault fault) {
- Message respMsg = serverContext.getResponseMessage();
- if (respMsg == null) {
- respMsg = new Message(fault);
- serverContext.setResponseMessage(respMsg);
- } else {
- SOAPFaultElement faultEl = new SOAPFaultElement(fault);
- SOAPEnvelope env = respMsg.getAsSOAPEnvelope();
- env.clearBody();
- env.addBodyElement(faultEl);
+ // set the realpath if possible
+ String transURL = clientContext.getStrProp(MessageContext.TRANS_URL);
+ if (transURL != null) {
+ try {
+ URL url = new URL(transURL);
+ if (url.getProtocol().equals("file")) {
+ String file = url.getFile();
+ if (file.length()>0 && file.charAt(0)=='/') file = file.substring(1);
+ serverContext.setProperty(Constants.MC_REALPATH, file);
+ }
+ } catch (Exception e) {
+ }
}
+
+ // invoke the request
+ try {
+ targetServer.invoke(serverContext);
+ } catch (AxisFault fault) {
+ Message respMsg = serverContext.getResponseMessage();
+ if (respMsg == null) {
+ respMsg = new Message(fault);
+ serverContext.setResponseMessage(respMsg);
+ } else {
+ SOAPFaultElement faultEl = new SOAPFaultElement(fault);
+ SOAPEnvelope env = respMsg.getAsSOAPEnvelope();
+ env.clearBody();
+ env.addBodyElement(faultEl);
+ }
+ }
+
+ // copy back the response, and force its format to String in order to
+ // exercise the deserializers.
+ clientContext.setResponseMessage(serverContext.getResponseMessage());
+ //clientContext.getResponseMessage().getAsString();
+
+ Debug.Print( 1, "Exit: LocalSender::invoke" );
}
- // copy back the response, and force its format to String in order to
- // exercise the deserializers.
- clientContext.setResponseMessage(serverContext.getResponseMessage());
- //clientContext.getResponseMessage().getAsString();
-
- Debug.Print( 1, "Exit: LocalSender::invoke" );
- }
-
- public void undo(MessageContext msgContext) {
- Debug.Print( 1, "Enter: LocalSender::undo" );
- Debug.Print( 1, "Exit: LocalSender::undo" );
- }
+ public void undo(MessageContext msgContext) {
+ Debug.Print( 1, "Enter: LocalSender::undo" );
+ Debug.Print( 1, "Exit: LocalSender::undo" );
+ }
};
1.3 +2 -2 xml-axis/java/src/org/apache/axis/transport/local/LocalTransport.java
Index: LocalTransport.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/local/LocalTransport.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalTransport.java 2001/07/01 03:31:09 1.2
+++ LocalTransport.java 2001/07/12 15:04:47 1.3
@@ -98,7 +98,7 @@
*/
public LocalTransport(AxisServer server)
{
- this.server = server;
+ this.server = server;
}
/**
@@ -111,7 +111,7 @@
{
mc.setTransportName("local");
if (server != null)
- mc.setProperty(LOCAL_SERVER, server);
+ mc.setProperty(LOCAL_SERVER, server);
}
}
1.54 +727 -727 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Admin.java 2001/07/10 22:53:10 1.53
+++ Admin.java 2001/07/12 15:04:52 1.54
@@ -79,756 +79,756 @@
*/
public class Admin {
- /**
- * Fill in options for a given handler.
- *
- * @param root the element containing the options
- * @param handler the Handler to set options on
- */
- private static void getOptions(Element root, Handler handler) {
- NodeList list = root.getElementsByTagName("option");
- for ( int i = 0 ; list != null && i < list.getLength() ; i++ ) {
- Element elem = (Element) list.item(i);
- String name = elem.getAttribute( "name" );
- String value = elem.getAttribute( "value" );
-
- if ( name != null && value != null )
- handler.addOption( name, value );
- }
- }
-
- private static void getOptions(Element root, Hashtable table) {
- NodeList list = root.getElementsByTagName("option");
- for ( int i = 0 ; list != null && i < list.getLength() ; i++ ) {
- Element elem = (Element) list.item(i);
- String name = elem.getAttribute( "name" );
- String value = elem.getAttribute( "value" );
-
- if ( name != null && value != null )
- table.put( name, value );
- }
- }
-
- /**
- * Register a set of type mappings for a service.
- *
- * @param root the Element containing the service configuration
- * @param service the SOAPService we're working with.
- */
- private static void registerTypeMappings(Element root, SOAPService service)
- throws Exception
- {
- TypeMappingRegistry reg = service.getTypeMappingRegistry();
- NodeList list = root.getElementsByTagName("beanMappings");
- for (int i = 0; list != null && i < list.getLength(); i++) {
- Element el = (Element)list.item(i);
- registerTypes(el, reg, true);
+ /**
+ * Fill in options for a given handler.
+ *
+ * @param root the element containing the options
+ * @param handler the Handler to set options on
+ */
+ private static void getOptions(Element root, Handler handler) {
+ NodeList list = root.getElementsByTagName("option");
+ for ( int i = 0 ; list != null && i < list.getLength() ; i++ ) {
+ Element elem = (Element) list.item(i);
+ String name = elem.getAttribute( "name" );
+ String value = elem.getAttribute( "value" );
+
+ if ( name != null && value != null )
+ handler.addOption( name, value );
+ }
}
-
- list = root.getElementsByTagName("typeMappings");
- for (int i = 0; list != null && i < list.getLength(); i++) {
- Element el = (Element)list.item(i);
- registerTypes(el, reg, false);
- }
- }
-
- private static void registerTypes(Element root,
- TypeMappingRegistry map,
- boolean isBean)
- throws Exception
- {
- NodeList list = root.getChildNodes();
- for (int i = 0; (list != null) && (i < list.getLength()); i++) {
- if (!(list.item(i) instanceof Element)) continue;
- registerTypeMapping((Element)list.item(i), map, isBean);
- }
- }
-
- /**
- * Process a given XML document - needs cleanup.
- */
- public Document AdminService(MessageContext msgContext, Document xml)
- throws AxisFault
- {
- Debug.Print( 1, "Enter: Admin:AdminService" );
- Document doc = process( msgContext, xml.getDocumentElement() );
- Debug.Print( 1, "Exit: Admin:AdminService" );
- return( doc );
- }
-
- /** Process an engine configuration file by deploying appropriate stuff
- * into the specified AxisEngine, and then telling it to save itself
- * when we're done.
- *
- * @param doc an XML document containing an Axis engine configuration
- * @param engine the AxisEngine in which to deploy
- * @exception Exception (should be DeploymentException?)
- */
- public static void processEngineConfig(Document doc, AxisEngine engine)
- throws Exception
- {
- Element el = doc.getDocumentElement();
- if (!el.getTagName().equals("engineConfig"))
- throw new Exception("Wanted 'engineConfig' element, got '" +
- el.getTagName() + "'");
-
- NodeList nl = el.getElementsByTagName("handlers");
- deploy(nl, engine);
-
- nl = el.getElementsByTagName("services");
- deploy(nl, engine);
-
- nl = el.getElementsByTagName("transports");
- deploy(nl, engine);
-
- nl = el.getElementsByTagName("typeMappings");
- deploy(nl, engine);
- /*
- if (nl.getLength() > 0)
- registerTypes((Element)nl.item(0),
- engine.getTypeMappingRegistry(),
- false);
- */
-
- engine.saveConfiguration();
- }
-
- /** Deploy a set of individual items.
- *
- * NOTE: as it stands this doesn't care about the relationship between
- * these items and the enclosing tag. We shouldn't really allow <service>
- * deployment underneath the <transports> tag, for instance. Since this
- * is going to mutate some more, this is the simple way to do it for now.
- *
- * @param nl a DOM NodeList of deployable items.
- * @param engine the AxisEngine into which we deploy.
- * @exception Exception (should be DeploymentException?)
- */
- static void deploy(NodeList nl, AxisEngine engine) throws Exception
- {
- for (int i = 0; i < nl.getLength(); i++) {
- Element el = (Element)nl.item(i);
-
- NodeList children = el.getChildNodes();
- for (int j = 0; j < children.getLength(); j++) {
- if (!(children.item(j) instanceof Element)) continue;
-
- Element item = (Element)children.item(j);
- String type = item.getTagName();
-
- if ( type.equals( "handler" ) ) {
- registerHandler(item, engine);
- }
- else if ( type.equals( "chain" ) ) {
- registerChain(item, engine);
- }
- else if ( type.equals( "service" ) ) {
- registerService(item, engine);
- }
- else if (type.equals("transport")) {
- registerTransport(item, engine);
- }
- else if (type.equals("typeMapping")) {
- registerTypeMapping(item, engine.getTypeMappingRegistry(), false);
- }
- }
- }
- }
-
- /**
- * The meat of the Admin service. Process an xML document rooted with
- * a "deploy", "undeploy", "list", or "quit" element.
- *
- * @param msgContext the MessageContext we're processing
- * @param root the root Element of the XML
- * @return an XML Document indicating the results.
- */
- public Document process(MessageContext msgContext, Element root)
- throws AxisFault
- {
- Document doc = null ;
-
- AxisEngine engine = msgContext.getAxisEngine();
- HandlerRegistry hr = engine.getHandlerRegistry();
- HandlerRegistry sr = engine.getServiceRegistry();
-
- try {
- String action = root.getLocalName();
- AxisClassLoader cl = AxisClassLoader.getClassLoader();
-
- if ( !action.equals("clientdeploy") && !action.equals("deploy") &&
- !action.equals("undeploy") &&
- !action.equals("list") && !action.equals("quit") )
- throw new AxisFault( "Admin.error",
- "Root element must be 'clientdeploy', 'deploy', 'undeploy', " +
- "'list', or 'quit'",
- null, null );
-
- if (action.equals("quit")) {
- System.err.println("Admin service requested to quit, quitting.");
- if (msgContext != null) {
- // put a flag into message context so listener will exit after
- // sending response
- msgContext.setProperty(msgContext.QUIT_REQUESTED, "true");
- }
- doc = XMLUtils.newDocument();
- doc.appendChild( root = doc.createElement( "Admin" ) );
- root.appendChild( doc.createTextNode( "Quitting" ) );
- return doc;
- }
-
- if ( action.equals("list") ) {
- return listConfig(engine);
- }
-
- if (action.equals("clientdeploy")) {
- // set engine to client engine
- engine = engine.getClientEngine();
- }
-
- NodeList list = root.getChildNodes();
- for ( int loop = 0 ; loop < list.getLength() ; loop++ ) {
- Node node = list.item(loop);
-
- if ( node.getNodeType() != Node.ELEMENT_NODE ) continue ;
-
- Element elem = (Element) node ;
- String type = elem.getTagName();
- String name = elem.getAttribute("name");
-
- if ( action.equals( "undeploy" ) ) {
- if ( type.equals("service") ) {
- Debug.Print( 2, "Undeploying " + type + ": " + name );
- engine.undeployService( name );
- }
- else if ( type.equals("handler") || type.equals("chain") ) {
- Debug.Print( 2, "Undeploying " + type + ": " + name );
- engine.undeployHandler( name );
- }
- else
- throw new AxisFault( "Admin.error",
- "Unknown type; " + type,
- null, null );
- continue ;
- }
-
- if ( type.equals( "handler" ) ) {
- registerHandler(elem, engine);
- }
- else if ( type.equals( "chain" ) ) {
- registerChain(elem, engine);
- }
- else if ( type.equals( "service" ) ) {
- registerService(elem, engine);
- }
- else if (type.equals("transport")) {
- registerTransport(elem, engine);
- }
-
- // A streamlined means of deploying both a serializer and a deserializer
- // for a bean at the same time.
- else if ( type.equals( "beanMappings" ) ) {
- TypeMappingRegistry engineTypeMap = engine.getTypeMappingRegistry();
- registerTypes(elem, engineTypeMap, true);
- }
- else if (type.equals("typeMappings")) {
- TypeMappingRegistry engineTypeMap = engine.getTypeMappingRegistry();
- registerTypes(elem, engineTypeMap, false);
- } else
- throw new AxisFault( "Admin.error",
- "Unknown type to " + action + ": " + type,
- null, null );
- }
- engine.saveConfiguration();
-
- doc = XMLUtils.newDocument();
- doc.appendChild( root = doc.createElement( "Admin" ) );
- root.appendChild( doc.createTextNode( "Done processing" ) );
- }
- catch( Exception e ) {
- e.printStackTrace();
- if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
- throw (AxisFault) e ;
- }
- return( doc );
- }
-
- /** Get an XML document representing this engine's configuration.
- *
- * This document is suitable for saving and reloading into the
- * engine.
- *
- * @param engine the AxisEngine to work with
- * @return an XML document holding the engine config
- * @exception AxisFault
- */
- public static Document listConfig(AxisEngine engine)
- throws AxisFault
- {
- Document doc = XMLUtils.newDocument();
-
- Element tmpEl = doc.createElement("engineConfig");
- doc.appendChild(tmpEl);
-
- Element el = doc.createElement("handlers");
- list(el, engine.getHandlerRegistry());
- tmpEl.appendChild(el);
-
- el = doc.createElement("services");
- list(el, engine.getServiceRegistry());
- tmpEl.appendChild(el);
-
- el = doc.createElement("transports");
- list(el, engine.getTransportRegistry());
- tmpEl.appendChild(el);
-
- Debug.Print(2, "Outputting registry");
- el = doc.createElement("typeMappings");
- engine.getTypeMappingRegistry().dumpToElement(el);
- tmpEl.appendChild(el);
-
- return( doc );
- }
-
- /**
- * Return an XML Element containing the configuration info for one
- * of the engine's Handler registries.
- *
- * @param root the Element to work with (same as the one we return)
- * @param registry the registry to write into this Element
- * @return Element our config element, suitable for pumping back through
- * Admin processing later, to redeploy.
- */
- public static Element list(Element root, HandlerRegistry registry)
- throws AxisFault
- {
- Document doc = root.getOwnerDocument();
-
- Element elem = null ;
- Hashtable opts = null ;
- String[] names ;
- Handler h ;
- int i ;
-
- names = registry.list();
-
- for( i = 0 ; names != null && i < names.length ; i++ ) {
- h = registry.find(names[i]);
- if (h == null)
- throw new AxisFault("Server", "Couldn't find registered handler '" + names[i] + "'", null, null);
- elem = h.getDeploymentData(doc);
- if ( elem == null ) continue ;
-
- elem.setAttribute( "name", names[i] );
- root.appendChild( doc.importNode(elem,true) );
+ private static void getOptions(Element root, Hashtable table) {
+ NodeList list = root.getElementsByTagName("option");
+ for ( int i = 0 ; list != null && i < list.getLength() ; i++ ) {
+ Element elem = (Element) list.item(i);
+ String name = elem.getAttribute( "name" );
+ String value = elem.getAttribute( "value" );
+
+ if ( name != null && value != null )
+ table.put( name, value );
+ }
}
- return root;
- }
-
- /**
- * Deploy a chain described in XML into an AxisEngine.
- *
- * @param elem the <chain> element
- * @param engine the AxisEngine in which to deploy
- */
- public static void registerChain(Element elem, AxisEngine engine)
- throws AxisFault
- {
- Handler tmpH = null;
- String hName;
- SupplierRegistry hr = (SupplierRegistry)engine.getHandlerRegistry();
-
- String name = elem.getAttribute( "name" );
- String flow = elem.getAttribute( "flow" );
- String request = elem.getAttribute( "request" );
- String pivot = elem.getAttribute( "pivot" );
- String response = elem.getAttribute( "response" );
- Hashtable options = new Hashtable();
-
- if ( flow != null && flow.equals("") ) flow = null ;
- if ( request != null && request.equals("") ) request = null ;
- if ( response != null && response.equals("") ) response = null ;
- if ( pivot != null && pivot.equals("") ) pivot = null ;
- if ( name != null && name.equals("") ) name = null ;
-
- if ( flow != null && flow.length() > 0 ) {
- Debug.Print( 2, "Deploying chain: " + name );
- Vector names = new Vector();
-
- StringTokenizer st = new StringTokenizer( flow, " \t\n\r\f," );
- while ( st.hasMoreElements() ) {
- names.addElement(st.nextToken());
- }
- getOptions( elem, options );
-
- SimpleChainSupplier supp = new SimpleChainSupplier(name,
- names,
- options,
- hr);
-
- hr.add(name, supp);
- }
- else {
- Debug.Print( 2, "Deploying chain: " + name );
-
- if ((request == null) &&
- (response == null) &&
- (pivot == null))
- throw new AxisFault("No request/response/pivot for chain '" + name + "'!");
-
- StringTokenizer st = null ;
- Vector reqNames = new Vector();
- Vector respNames = new Vector();
-
- if (request != null) {
- st = new StringTokenizer( request, " \t\n\r\f," );
- while ( st.hasMoreElements() ) {
- reqNames.addElement(st.nextToken());
- }
- }
-
- if (response != null) {
- st = new StringTokenizer( response, " \t\n\r\f," );
- while ( st.hasMoreElements() ) {
- respNames.addElement(st.nextToken());
- }
- }
-
- getOptions( elem, options );
-
- TargetedChainSupplier supp = new TargetedChainSupplier(name,
- reqNames,
- respNames,
- pivot,
- options,
- hr);
- hr.add(name,supp);
- }
- }
-
- /**
- * Deploy a service described in XML into an AxisEngine.
- *
- * @param elem the <service> element
- * @param engine the AxisEngine in which to deploy
- */
- public static void registerService(Element elem, AxisEngine engine)
- throws AxisFault
- {
- HandlerRegistry hr = engine.getHandlerRegistry();
- HandlerRegistry sr = engine.getServiceRegistry();
+ /**
+ * Register a set of type mappings for a service.
+ *
+ * @param root the Element containing the service configuration
+ * @param service the SOAPService we're working with.
+ */
+ private static void registerTypeMappings(Element root, SOAPService service)
+ throws Exception
+ {
+ TypeMappingRegistry reg = service.getTypeMappingRegistry();
+ NodeList list = root.getElementsByTagName("beanMappings");
+ for (int i = 0; list != null && i < list.getLength(); i++) {
+ Element el = (Element)list.item(i);
+ registerTypes(el, reg, true);
+ }
+
+ list = root.getElementsByTagName("typeMappings");
+ for (int i = 0; list != null && i < list.getLength(); i++) {
+ Element el = (Element)list.item(i);
+ registerTypes(el, reg, false);
+ }
+ }
- String name = elem.getAttribute( "name" );
- String request = elem.getAttribute( "request" );
- String pivot = elem.getAttribute( "pivot" );
- String response = elem.getAttribute( "response" );
-
- if ( request != null && request.equals("") ) request = null ;
- if ( response != null && response.equals("") ) response = null ;
- if ( pivot != null && pivot.equals("") ) pivot = null ;
- if ( name != null && name.equals("") ) name = null ;
-
- Debug.Print( 2, "Deploying service: " + name );
- String hName = null ;
- Handler tmpH = null ;
- StringTokenizer st = null ;
- SOAPService service = null ;
- Chain c = null ;
-
- if ( pivot == null && request == null && response == null )
- throw new AxisFault( "Admin.error",
- "Services must use targeted chains",
- null, null );
-
- service = (SOAPService) sr.find( name );
+ private static void registerTypes(Element root,
+ TypeMappingRegistry map,
+ boolean isBean)
+ throws Exception
+ {
+ NodeList list = root.getChildNodes();
+ for (int i = 0; (list != null) && (i < list.getLength()); i++) {
+ if (!(list.item(i) instanceof Element)) continue;
+ registerTypeMapping((Element)list.item(i), map, isBean);
+ }
+ }
- if ( service == null ) service = new SOAPService();
- else service.clear();
-
- if ( request != null && !"".equals(request) ) {
- st = new StringTokenizer( request, " \t\n\r\f," );
- c = null ;
- while ( st.hasMoreElements() ) {
- if ( c == null )
- service.setRequestHandler( c = new SimpleChain() );
- hName = st.nextToken();
- tmpH = hr.find( hName );
- if ( tmpH == null )
- throw new AxisFault( "Admin.error",
- "Unknown handler: " + hName,
- null, null );
- c.addHandler( tmpH );
- }
+ /**
+ * Process a given XML document - needs cleanup.
+ */
+ public Document AdminService(MessageContext msgContext, Document xml)
+ throws AxisFault
+ {
+ Debug.Print( 1, "Enter: Admin:AdminService" );
+ Document doc = process( msgContext, xml.getDocumentElement() );
+ Debug.Print( 1, "Exit: Admin:AdminService" );
+ return( doc );
+ }
+
+ /** Process an engine configuration file by deploying appropriate stuff
+ * into the specified AxisEngine, and then telling it to save itself
+ * when we're done.
+ *
+ * @param doc an XML document containing an Axis engine configuration
+ * @param engine the AxisEngine in which to deploy
+ * @exception Exception (should be DeploymentException?)
+ */
+ public static void processEngineConfig(Document doc, AxisEngine engine)
+ throws Exception
+ {
+ Element el = doc.getDocumentElement();
+ if (!el.getTagName().equals("engineConfig"))
+ throw new Exception("Wanted 'engineConfig' element, got '" +
+ el.getTagName() + "'");
+
+ NodeList nl = el.getElementsByTagName("handlers");
+ deploy(nl, engine);
+
+ nl = el.getElementsByTagName("services");
+ deploy(nl, engine);
+
+ nl = el.getElementsByTagName("transports");
+ deploy(nl, engine);
+
+ nl = el.getElementsByTagName("typeMappings");
+ deploy(nl, engine);
+ /*
+ if (nl.getLength() > 0)
+ registerTypes((Element)nl.item(0),
+ engine.getTypeMappingRegistry(),
+ false);
+ */
+
+ engine.saveConfiguration();
}
- if ( pivot != null && !"".equals(pivot) ) {
- tmpH = hr.find(pivot);
- if (tmpH == null)
- throw new AxisFault("Deploying service " + name +
- ": couldn't find pivot Handler '" + pivot + "'");
-
- service.setPivotHandler( tmpH );
-
- if (pivot.equals("MsgDispatcher")) {
- ServiceDescription sd = new ServiceDescription("msgService", false);
- service.setServiceDescription(sd);
- }
+ /** Deploy a set of individual items.
+ *
+ * NOTE: as it stands this doesn't care about the relationship between
+ * these items and the enclosing tag. We shouldn't really allow <service>
+ * deployment underneath the <transports> tag, for instance. Since this
+ * is going to mutate some more, this is the simple way to do it for now.
+ *
+ * @param nl a DOM NodeList of deployable items.
+ * @param engine the AxisEngine into which we deploy.
+ * @exception Exception (should be DeploymentException?)
+ */
+ static void deploy(NodeList nl, AxisEngine engine) throws Exception
+ {
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element el = (Element)nl.item(i);
+
+ NodeList children = el.getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ if (!(children.item(j) instanceof Element)) continue;
+
+ Element item = (Element)children.item(j);
+ String type = item.getTagName();
+
+ if ( type.equals( "handler" ) ) {
+ registerHandler(item, engine);
+ }
+ else if ( type.equals( "chain" ) ) {
+ registerChain(item, engine);
+ }
+ else if ( type.equals( "service" ) ) {
+ registerService(item, engine);
+ }
+ else if (type.equals("transport")) {
+ registerTransport(item, engine);
+ }
+ else if (type.equals("typeMapping")) {
+ registerTypeMapping(item, engine.getTypeMappingRegistry(), false);
+ }
+ }
+ }
}
-
- if ( response != null && !"".equals(response) ) {
- st = new StringTokenizer( response, " \t\n\r\f," );
- c = null ;
- while ( st.hasMoreElements() ) {
- if ( c == null )
- service.setResponseHandler( c = new SimpleChain() );
- hName = st.nextToken();
- tmpH = hr.find( hName );
- if ( tmpH == null )
- throw new AxisFault( "Admin.error",
- "Unknown handler: " + hName,
- null, null );
- c.addHandler( tmpH );
- }
+
+ /**
+ * The meat of the Admin service. Process an xML document rooted with
+ * a "deploy", "undeploy", "list", or "quit" element.
+ *
+ * @param msgContext the MessageContext we're processing
+ * @param root the root Element of the XML
+ * @return an XML Document indicating the results.
+ */
+ public Document process(MessageContext msgContext, Element root)
+ throws AxisFault
+ {
+ Document doc = null ;
+
+ AxisEngine engine = msgContext.getAxisEngine();
+ HandlerRegistry hr = engine.getHandlerRegistry();
+ HandlerRegistry sr = engine.getServiceRegistry();
+
+ try {
+ String action = root.getLocalName();
+ AxisClassLoader cl = AxisClassLoader.getClassLoader();
+
+ if ( !action.equals("clientdeploy") && !action.equals("deploy") &&
+ !action.equals("undeploy") &&
+ !action.equals("list") && !action.equals("quit") )
+ throw new AxisFault( "Admin.error",
+ "Root element must be 'clientdeploy', 'deploy', 'undeploy', " +
+ "'list', or 'quit'",
+ null, null );
+
+ if (action.equals("quit")) {
+ System.err.println("Admin service requested to quit, quitting.");
+ if (msgContext != null) {
+ // put a flag into message context so listener will exit after
+ // sending response
+ msgContext.setProperty(msgContext.QUIT_REQUESTED, "true");
+ }
+ doc = XMLUtils.newDocument();
+ doc.appendChild( root = doc.createElement( "Admin" ) );
+ root.appendChild( doc.createTextNode( "Quitting" ) );
+ return doc;
+ }
+
+ if ( action.equals("list") ) {
+ return listConfig(engine);
+ }
+
+ if (action.equals("clientdeploy")) {
+ // set engine to client engine
+ engine = engine.getClientEngine();
+ }
+
+ NodeList list = root.getChildNodes();
+ for ( int loop = 0 ; loop < list.getLength() ; loop++ ) {
+ Node node = list.item(loop);
+
+ if ( node.getNodeType() != Node.ELEMENT_NODE ) continue ;
+
+ Element elem = (Element) node ;
+ String type = elem.getTagName();
+ String name = elem.getAttribute("name");
+
+ if ( action.equals( "undeploy" ) ) {
+ if ( type.equals("service") ) {
+ Debug.Print( 2, "Undeploying " + type + ": " + name );
+ engine.undeployService( name );
+ }
+ else if ( type.equals("handler") || type.equals("chain") ) {
+ Debug.Print( 2, "Undeploying " + type + ": " + name );
+ engine.undeployHandler( name );
+ }
+ else
+ throw new AxisFault( "Admin.error",
+ "Unknown type; " + type,
+ null, null );
+ continue ;
+ }
+
+ if ( type.equals( "handler" ) ) {
+ registerHandler(elem, engine);
+ }
+ else if ( type.equals( "chain" ) ) {
+ registerChain(elem, engine);
+ }
+ else if ( type.equals( "service" ) ) {
+ registerService(elem, engine);
+ }
+ else if (type.equals("transport")) {
+ registerTransport(elem, engine);
+ }
+
+ // A streamlined means of deploying both a serializer and a deserializer
+ // for a bean at the same time.
+ else if ( type.equals( "beanMappings" ) ) {
+ TypeMappingRegistry engineTypeMap = engine.getTypeMappingRegistry();
+ registerTypes(elem, engineTypeMap, true);
+ }
+ else if (type.equals("typeMappings")) {
+ TypeMappingRegistry engineTypeMap = engine.getTypeMappingRegistry();
+ registerTypes(elem, engineTypeMap, false);
+ } else
+ throw new AxisFault( "Admin.error",
+ "Unknown type to " + action + ": " + type,
+ null, null );
+ }
+ engine.saveConfiguration();
+
+ doc = XMLUtils.newDocument();
+ doc.appendChild( root = doc.createElement( "Admin" ) );
+ root.appendChild( doc.createTextNode( "Done processing" ) );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
+ throw (AxisFault) e ;
+ }
+ return( doc );
+ }
+
+ /** Get an XML document representing this engine's configuration.
+ *
+ * This document is suitable for saving and reloading into the
+ * engine.
+ *
+ * @param engine the AxisEngine to work with
+ * @return an XML document holding the engine config
+ * @exception AxisFault
+ */
+ public static Document listConfig(AxisEngine engine)
+ throws AxisFault
+ {
+ Document doc = XMLUtils.newDocument();
+
+ Element tmpEl = doc.createElement("engineConfig");
+ doc.appendChild(tmpEl);
+
+ Element el = doc.createElement("handlers");
+ list(el, engine.getHandlerRegistry());
+ tmpEl.appendChild(el);
+
+ el = doc.createElement("services");
+ list(el, engine.getServiceRegistry());
+ tmpEl.appendChild(el);
+
+ el = doc.createElement("transports");
+ list(el, engine.getTransportRegistry());
+ tmpEl.appendChild(el);
+
+ Debug.Print(2, "Outputting registry");
+ el = doc.createElement("typeMappings");
+ engine.getTypeMappingRegistry().dumpToElement(el);
+ tmpEl.appendChild(el);
+
+ return( doc );
+ }
+
+ /**
+ * Return an XML Element containing the configuration info for one
+ * of the engine's Handler registries.
+ *
+ * @param root the Element to work with (same as the one we return)
+ * @param registry the registry to write into this Element
+ * @return Element our config element, suitable for pumping back through
+ * Admin processing later, to redeploy.
+ */
+ public static Element list(Element root, HandlerRegistry registry)
+ throws AxisFault
+ {
+ Document doc = root.getOwnerDocument();
+
+ Element elem = null ;
+ Hashtable opts = null ;
+ String[] names ;
+ Handler h ;
+ int i ;
+
+ names = registry.list();
+
+ for( i = 0 ; names != null && i < names.length ; i++ ) {
+ h = registry.find(names[i]);
+ if (h == null)
+ throw new AxisFault("Server", "Couldn't find registered handler '" + names[i] + "'", null, null);
+ elem = h.getDeploymentData(doc);
+
+ if ( elem == null ) continue ;
+
+ elem.setAttribute( "name", names[i] );
+ root.appendChild( doc.importNode(elem,true) );
+ }
+
+ return root;
}
-
- getOptions( elem, service );
- try {
- registerTypeMappings(elem, service);
- } catch (Exception e) {
- throw new AxisFault(e);
+ /**
+ * Deploy a chain described in XML into an AxisEngine.
+ *
+ * @param elem the <chain> element
+ * @param engine the AxisEngine in which to deploy
+ */
+ public static void registerChain(Element elem, AxisEngine engine)
+ throws AxisFault
+ {
+ Handler tmpH = null;
+ String hName;
+ SupplierRegistry hr = (SupplierRegistry)engine.getHandlerRegistry();
+
+ String name = elem.getAttribute( "name" );
+ String flow = elem.getAttribute( "flow" );
+ String request = elem.getAttribute( "request" );
+ String pivot = elem.getAttribute( "pivot" );
+ String response = elem.getAttribute( "response" );
+ Hashtable options = new Hashtable();
+
+ if ( flow != null && flow.equals("") ) flow = null ;
+ if ( request != null && request.equals("") ) request = null ;
+ if ( response != null && response.equals("") ) response = null ;
+ if ( pivot != null && pivot.equals("") ) pivot = null ;
+ if ( name != null && name.equals("") ) name = null ;
+
+ if ( flow != null && flow.length() > 0 ) {
+ Debug.Print( 2, "Deploying chain: " + name );
+ Vector names = new Vector();
+
+ StringTokenizer st = new StringTokenizer( flow, " \t\n\r\f," );
+ while ( st.hasMoreElements() ) {
+ names.addElement(st.nextToken());
+ }
+ getOptions( elem, options );
+
+ SimpleChainSupplier supp = new SimpleChainSupplier(name,
+ names,
+ options,
+ hr);
+
+ hr.add(name, supp);
+ }
+ else {
+ Debug.Print( 2, "Deploying chain: " + name );
+
+ if ((request == null) &&
+ (response == null) &&
+ (pivot == null))
+ throw new AxisFault("No request/response/pivot for chain '" + name + "'!");
+
+ StringTokenizer st = null ;
+ Vector reqNames = new Vector();
+ Vector respNames = new Vector();
+
+ if (request != null) {
+ st = new StringTokenizer( request, " \t\n\r\f," );
+ while ( st.hasMoreElements() ) {
+ reqNames.addElement(st.nextToken());
+ }
+ }
+
+ if (response != null) {
+ st = new StringTokenizer( response, " \t\n\r\f," );
+ while ( st.hasMoreElements() ) {
+ respNames.addElement(st.nextToken());
+ }
+ }
+
+ getOptions( elem, options );
+
+ TargetedChainSupplier supp = new TargetedChainSupplier(name,
+ reqNames,
+ respNames,
+ pivot,
+ options,
+ hr);
+ hr.add(name,supp);
+ }
}
-
- engine.deployService( name, service );
- }
-
- /**
- * Deploy a handler described in XML into an AxisEngine.
- *
- * @param elem the <handler> element
- * @param engine the AxisEngine in which to deploy
- */
- public static void registerHandler(Element elem, AxisEngine engine)
- throws AxisFault
- {
- HandlerRegistry hr = engine.getHandlerRegistry();
- try {
- AxisClassLoader cl = AxisClassLoader.getClassLoader();
- String name = elem.getAttribute( "name" );
- Handler h = null;
-
- if ( name != null && name.equals("") ) name = null ;
-
- String cls = elem.getAttribute( "class" );
- if ( cls != null && cls.equals("") ) cls = null ;
- Debug.Print( 2, "Deploying handler: " + name );
-
- h = hr.find( name );
- if ( h == null ) h = (Handler) cl.loadClass(cls).newInstance();
- getOptions( elem, h );
- engine.deployHandler( name, h );
- } catch (ClassNotFoundException cnfe) {
- throw new AxisFault(cnfe);
- } catch (InstantiationException ie) {
- throw new AxisFault(ie);
- } catch (IllegalAccessException iae) {
- throw new AxisFault(iae);
- }
- }
-
- /**
- * Deploy a transport described in XML into an AxisEngine.
- *
- * @param elem the <transport> element
- * @param engine the AxisEngine in which to deploy
- */
- public static void registerTransport(Element elem, AxisEngine engine)
- throws AxisFault
- {
- String name = elem.getAttribute( "name" );
- String request = elem.getAttribute( "request" );
- String sender = elem.getAttribute( "pivot" );
- String response = elem.getAttribute( "response" );
- Hashtable options = new Hashtable();
-
- if ( request != null && request.equals("") ) request = null ;
- if ( response != null && response.equals("") ) response = null ;
- if ( sender != null && sender.equals("") ) sender = null ;
- if ( name != null && name.equals("") ) name = null ;
-
- Debug.Print( 2, "Deploying Transport: " + name );
- StringTokenizer st = null ;
- Vector reqNames = new Vector();
- Vector respNames = new Vector();
-
- if (request != null) {
- st = new StringTokenizer( request, " \t\n\r\f," );
- while ( st.hasMoreElements() ) {
- reqNames.addElement(st.nextToken());
- }
- }
-
- if (response != null) {
- st = new StringTokenizer( response, " \t\n\r\f," );
- while ( st.hasMoreElements() ) {
- respNames.addElement(st.nextToken());
- }
+ /**
+ * Deploy a service described in XML into an AxisEngine.
+ *
+ * @param elem the <service> element
+ * @param engine the AxisEngine in which to deploy
+ */
+ public static void registerService(Element elem, AxisEngine engine)
+ throws AxisFault
+ {
+ HandlerRegistry hr = engine.getHandlerRegistry();
+ HandlerRegistry sr = engine.getServiceRegistry();
+
+ String name = elem.getAttribute( "name" );
+ String request = elem.getAttribute( "request" );
+ String pivot = elem.getAttribute( "pivot" );
+ String response = elem.getAttribute( "response" );
+
+ if ( request != null && request.equals("") ) request = null ;
+ if ( response != null && response.equals("") ) response = null ;
+ if ( pivot != null && pivot.equals("") ) pivot = null ;
+ if ( name != null && name.equals("") ) name = null ;
+
+ Debug.Print( 2, "Deploying service: " + name );
+ String hName = null ;
+ Handler tmpH = null ;
+ StringTokenizer st = null ;
+ SOAPService service = null ;
+ Chain c = null ;
+
+ if ( pivot == null && request == null && response == null )
+ throw new AxisFault( "Admin.error",
+ "Services must use targeted chains",
+ null, null );
+
+ service = (SOAPService) sr.find( name );
+
+ if ( service == null ) service = new SOAPService();
+ else service.clear();
+
+ if ( request != null && !"".equals(request) ) {
+ st = new StringTokenizer( request, " \t\n\r\f," );
+ c = null ;
+ while ( st.hasMoreElements() ) {
+ if ( c == null )
+ service.setRequestHandler( c = new SimpleChain() );
+ hName = st.nextToken();
+ tmpH = hr.find( hName );
+ if ( tmpH == null )
+ throw new AxisFault( "Admin.error",
+ "Unknown handler: " + hName,
+ null, null );
+ c.addHandler( tmpH );
+ }
+ }
+
+ if ( pivot != null && !"".equals(pivot) ) {
+ tmpH = hr.find(pivot);
+ if (tmpH == null)
+ throw new AxisFault("Deploying service " + name +
+ ": couldn't find pivot Handler '" + pivot + "'");
+
+ service.setPivotHandler( tmpH );
+
+ if (pivot.equals("MsgDispatcher")) {
+ ServiceDescription sd = new ServiceDescription("msgService", false);
+ service.setServiceDescription(sd);
+ }
+ }
+
+ if ( response != null && !"".equals(response) ) {
+ st = new StringTokenizer( response, " \t\n\r\f," );
+ c = null ;
+ while ( st.hasMoreElements() ) {
+ if ( c == null )
+ service.setResponseHandler( c = new SimpleChain() );
+ hName = st.nextToken();
+ tmpH = hr.find( hName );
+ if ( tmpH == null )
+ throw new AxisFault( "Admin.error",
+ "Unknown handler: " + hName,
+ null, null );
+ c.addHandler( tmpH );
+ }
+ }
+
+ getOptions( elem, service );
+
+ try {
+ registerTypeMappings(elem, service);
+ } catch (Exception e) {
+ throw new AxisFault(e);
+ }
+
+ engine.deployService( name, service );
}
-
- getOptions( elem, options );
- HandlerRegistry hr = engine.getHandlerRegistry();
- TargetedChainSupplier supp = new TransportSupplier(name,
+ /**
+ * Deploy a handler described in XML into an AxisEngine.
+ *
+ * @param elem the <handler> element
+ * @param engine the AxisEngine in which to deploy
+ */
+ public static void registerHandler(Element elem, AxisEngine engine)
+ throws AxisFault
+ {
+ HandlerRegistry hr = engine.getHandlerRegistry();
+
+ try {
+ AxisClassLoader cl = AxisClassLoader.getClassLoader();
+ String name = elem.getAttribute( "name" );
+ Handler h = null;
+
+ if ( name != null && name.equals("") ) name = null ;
+
+ String cls = elem.getAttribute( "class" );
+ if ( cls != null && cls.equals("") ) cls = null ;
+ Debug.Print( 2, "Deploying handler: " + name );
+
+ h = hr.find( name );
+ if ( h == null ) h = (Handler) cl.loadClass(cls).newInstance();
+ getOptions( elem, h );
+ engine.deployHandler( name, h );
+ } catch (ClassNotFoundException cnfe) {
+ throw new AxisFault(cnfe);
+ } catch (InstantiationException ie) {
+ throw new AxisFault(ie);
+ } catch (IllegalAccessException iae) {
+ throw new AxisFault(iae);
+ }
+ }
+
+ /**
+ * Deploy a transport described in XML into an AxisEngine.
+ *
+ * @param elem the <transport> element
+ * @param engine the AxisEngine in which to deploy
+ */
+ public static void registerTransport(Element elem, AxisEngine engine)
+ throws AxisFault
+ {
+ String name = elem.getAttribute( "name" );
+ String request = elem.getAttribute( "request" );
+ String sender = elem.getAttribute( "pivot" );
+ String response = elem.getAttribute( "response" );
+ Hashtable options = new Hashtable();
+
+ if ( request != null && request.equals("") ) request = null ;
+ if ( response != null && response.equals("") ) response = null ;
+ if ( sender != null && sender.equals("") ) sender = null ;
+ if ( name != null && name.equals("") ) name = null ;
+
+ Debug.Print( 2, "Deploying Transport: " + name );
+ StringTokenizer st = null ;
+ Vector reqNames = new Vector();
+ Vector respNames = new Vector();
+
+ if (request != null) {
+ st = new StringTokenizer( request, " \t\n\r\f," );
+ while ( st.hasMoreElements() ) {
+ reqNames.addElement(st.nextToken());
+ }
+ }
+
+ if (response != null) {
+ st = new StringTokenizer( response, " \t\n\r\f," );
+ while ( st.hasMoreElements() ) {
+ respNames.addElement(st.nextToken());
+ }
+ }
+
+ getOptions( elem, options );
+
+ HandlerRegistry hr = engine.getHandlerRegistry();
+ TargetedChainSupplier supp = new TransportSupplier(name,
reqNames,
respNames,
sender,
options,
hr);
- engine.deployTransport(name, supp);
- }
+ engine.deployTransport(name, supp);
+ }
- /**
- * Deploy a type mapping described in XML.
- *
- * @param root the type mapping element.
- * @param map the TypeMappingRegistry which gets this mapping.
- */
- private static void registerTypeMapping(Element elem,
- TypeMappingRegistry map,
- boolean isBean)
- throws Exception
- {
- Serializer ser;
- DeserializerFactory dserFactory;
-
- // Retrieve classname attribute
- String classname = elem.getAttribute("classname");
- if ((classname == null) || classname.equals(""))
- throw new AxisFault("Server.Admin.error",
- "No classname attribute in type mapping",
- null, null);
-
- // Resolve class name
+ /**
+ * Deploy a type mapping described in XML.
+ *
+ * @param root the type mapping element.
+ * @param map the TypeMappingRegistry which gets this mapping.
+ */
+ private static void registerTypeMapping(Element elem,
+ TypeMappingRegistry map,
+ boolean isBean)
+ throws Exception
+ {
+ Serializer ser;
+ DeserializerFactory dserFactory;
+
+ // Retrieve classname attribute
+ String classname = elem.getAttribute("classname");
+ if ((classname == null) || classname.equals(""))
+ throw new AxisFault("Server.Admin.error",
+ "No classname attribute in type mapping",
+ null, null);
+
+ // Resolve class name
- Class cls;
- QName qn;
-
- try {
- cls = Class.forName(classname);
- } catch (Exception e) {
- throw new AxisFault( "Admin.error", e.toString(), null, null);
- }
-
- if (isBean) {
- // Resolve qname based on prefix and localpart
-
- String namespaceURI = elem.getNamespaceURI();
- String localName = elem.getLocalName();
- qn = new QName(namespaceURI, localName);
-
- Debug.Print(2, "Registering mapping for " + qn + " -> " + classname);
-
- // register both serializers and deserializers for this bean
- ser = new BeanSerializer(cls);
- dserFactory = BeanSerializer.getFactory();
- } else {
- String typeName = elem.getAttribute("type");
- int idx = typeName.indexOf(":");
- String prefix = typeName.substring(0, idx);
- String localPart = typeName.substring(idx + 1);
-
- qn = new QName(XMLUtils.getNamespace(prefix, elem), localPart);
-
- classname = elem.getAttribute("serializer");
- Debug.Print(3, "Serializer class is " + classname);
- try {
- ser = (Serializer)Class.forName(classname).newInstance();
- } catch (Exception e) {
- throw new AxisFault( "Admin.error",
- "Couldn't load serializer class " + e.toString(),
- null, null);
- }
- classname = elem.getAttribute("deserializerFactory");
- Debug.Print(3, "DeserializerFactory class is " + classname);
- try {
- dserFactory = (DeserializerFactory)Class.forName(classname).
- newInstance();
- } catch (Exception e) {
- throw new AxisFault( "Admin.error",
- "Couldn't load deserializerFactory " +
- e.toString(),
- null, null);
- }
-
+ Class cls;
+ QName qn;
+
+ try {
+ cls = Class.forName(classname);
+ } catch (Exception e) {
+ throw new AxisFault( "Admin.error", e.toString(), null, null);
+ }
+
+ if (isBean) {
+ // Resolve qname based on prefix and localpart
+
+ String namespaceURI = elem.getNamespaceURI();
+ String localName = elem.getLocalName();
+ qn = new QName(namespaceURI, localName);
+
+ Debug.Print(2, "Registering mapping for " + qn + " -> " + classname);
+
+ // register both serializers and deserializers for this bean
+ ser = new BeanSerializer(cls);
+ dserFactory = BeanSerializer.getFactory();
+ } else {
+ String typeName = elem.getAttribute("type");
+ int idx = typeName.indexOf(":");
+ String prefix = typeName.substring(0, idx);
+ String localPart = typeName.substring(idx + 1);
+
+ qn = new QName(XMLUtils.getNamespace(prefix, elem), localPart);
+
+ classname = elem.getAttribute("serializer");
+ Debug.Print(3, "Serializer class is " + classname);
+ try {
+ ser = (Serializer)Class.forName(classname).newInstance();
+ } catch (Exception e) {
+ throw new AxisFault( "Admin.error",
+ "Couldn't load serializer class " + e.toString(),
+ null, null);
+ }
+ classname = elem.getAttribute("deserializerFactory");
+ Debug.Print(3, "DeserializerFactory class is " + classname);
+ try {
+ dserFactory = (DeserializerFactory)Class.forName(classname).
+ newInstance();
+ } catch (Exception e) {
+ throw new AxisFault( "Admin.error",
+ "Couldn't load deserializerFactory " +
+ e.toString(),
+ null, null);
+ }
+
+ }
+
+ map.addSerializer(cls, qn, ser);
+ map.addDeserializerFactory(qn, cls, dserFactory);
}
- map.addSerializer(cls, qn, ser);
- map.addDeserializerFactory(qn, cls, dserFactory);
- }
-
- public static void main(String args[]) throws Exception {
- int i = 0 ;
-
- if ( args.length < 2 || !(args[0].equals("client") ||
- args[0].equals("server")) ) {
- System.err.println( "Usage: Admin client|server <xml-file>\n" );
-
- System.err.println( "Where <xml-file> looks like:" );
- System.err.println( "<deploy>" );
- /*
- System.err.println( " <transport name=a request=\"a,b,c\" sender=\"s\"");
- System.err.println( " response=\"d,e\"/>" );
- */
- System.err.println( " <handler name=a class=className/>" );
- System.err.println( " <chain name=a flow=\"a,b,c\" />" );
- System.err.println( " <chain name=a request=\"a,b,c\" pivot=\"d\"" );
- System.err.println( " response=\"e,f,g\" />" );
- System.err.println( " <service name=a handler=b />" );
- System.err.println( "</deploy>" );
- System.err.println( "<undeploy>" );
- System.err.println( " <handler name=a/>" );
- System.err.println( " <chain name=a/>" );
- System.err.println( " <service name=a/>" );
- System.err.println( "</undeploy>\n" );
- System.err.println( "<list/>\n" );
-
-
- // throw an Exception which will go uncaught! this way, a test suite
- // can invoke main() and detect the exception
- throw new IllegalArgumentException();
- // System.exit( 1 );
- }
-
- Admin admin = new Admin();
-
- AxisEngine engine;
- if ( args[0].equals("client") )
- engine = new AxisClient();
- else
- engine = new AxisServer();
- engine.init();
- MessageContext msgContext = new MessageContext(engine);
-
- try {
- for ( i = 1 ; i < args.length ; i++ ) {
- System.out.println( "Processing '" + args[i] + "'" );
- Document doc = XMLUtils.newDocument( new FileInputStream( args[i] ) );
- admin.process(msgContext, doc.getDocumentElement());
- }
- }
- catch( AxisFault e ) {
- e.dump();
- //System.exit(1);
- throw e;
- }
- catch( Exception e ) {
- System.err.println( "Error processing '" + args[i] + "'" );
- e.printStackTrace( System.err );
- //System.exit( 1 );
- throw e;
+ public static void main(String args[]) throws Exception {
+ int i = 0 ;
+
+ if ( args.length < 2 || !(args[0].equals("client") ||
+ args[0].equals("server")) ) {
+ System.err.println( "Usage: Admin client|server <xml-file>\n" );
+
+ System.err.println( "Where <xml-file> looks like:" );
+ System.err.println( "<deploy>" );
+ /*
+ System.err.println( " <transport name=a request=\"a,b,c\" sender=\"s\"");
+ System.err.println( " response=\"d,e\"/>" );
+ */
+ System.err.println( " <handler name=a class=className/>" );
+ System.err.println( " <chain name=a flow=\"a,b,c\" />" );
+ System.err.println( " <chain name=a request=\"a,b,c\" pivot=\"d\"" );
+ System.err.println( " response=\"e,f,g\" />" );
+ System.err.println( " <service name=a handler=b />" );
+ System.err.println( "</deploy>" );
+ System.err.println( "<undeploy>" );
+ System.err.println( " <handler name=a/>" );
+ System.err.println( " <chain name=a/>" );
+ System.err.println( " <service name=a/>" );
+ System.err.println( "</undeploy>\n" );
+ System.err.println( "<list/>\n" );
+
+
+ // throw an Exception which will go uncaught! this way, a test suite
+ // can invoke main() and detect the exception
+ throw new IllegalArgumentException();
+ // System.exit( 1 );
+ }
+
+ Admin admin = new Admin();
+
+ AxisEngine engine;
+ if ( args[0].equals("client") )
+ engine = new AxisClient();
+ else
+ engine = new AxisServer();
+ engine.init();
+ MessageContext msgContext = new MessageContext(engine);
+
+ try {
+ for ( i = 1 ; i < args.length ; i++ ) {
+ System.out.println( "Processing '" + args[i] + "'" );
+ Document doc = XMLUtils.newDocument( new FileInputStream( args[i] ) );
+ admin.process(msgContext, doc.getDocumentElement());
+ }
+ }
+ catch( AxisFault e ) {
+ e.dump();
+ //System.exit(1);
+ throw e;
+ }
+ catch( Exception e ) {
+ System.err.println( "Error processing '" + args[i] + "'" );
+ e.printStackTrace( System.err );
+ //System.exit( 1 );
+ throw e;
+ }
}
- }
}
1.8 +96 -96 xml-axis/java/src/org/apache/axis/utils/AxisClassLoader.java
Index: AxisClassLoader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/AxisClassLoader.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AxisClassLoader.java 2001/05/02 23:19:24 1.7
+++ AxisClassLoader.java 2001/07/12 15:04:53 1.8
@@ -69,104 +69,104 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class AxisClassLoader extends ClassLoader {
- static Hashtable classLoaders = new Hashtable();
+ static Hashtable classLoaders = new Hashtable();
- Hashtable classCache = new Hashtable() ;
+ Hashtable classCache = new Hashtable() ;
- public AxisClassLoader() {
- super();
- }
-
- static public AxisClassLoader getClassLoader() {
- return( getClassLoader(null) );
- }
-
- static public AxisClassLoader getClassLoader(String name) {
- AxisClassLoader cl = null ;
- if ( name == null ) name = "<default_class_loader>" ;
- cl = (AxisClassLoader) classLoaders.get( name );
- if ( cl == null )
- classLoaders.put( name, cl = new AxisClassLoader() );
- return( cl );
- }
-
- static public void removeClassLoader(String name) {
- if ( name != null )
- classLoaders.remove( name );
- }
-
- public void registerClass( String name, String classFile )
- throws FileNotFoundException, IOException
- {
- /* Load the class file the *.class file */
- /****************************************/
- FileInputStream fis = new FileInputStream( classFile );
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte buf[] = new byte[1024];
- for(int i = 0; (i = fis.read(buf)) != -1; )
- baos.write(buf, 0, i);
- fis.close();
- baos.close();
-
- /* Create a new Class object from it */
- /*************************************/
- byte[] data = baos.toByteArray();
- Class cls = defineClass( name, data, 0, data.length );
-
- /* And finally register it */
- /***************************/
- registerClass( name, cls );
- }
-
- public synchronized void registerClass( String name, Class cls ) {
- /* And finally register it */
- /***************************/
- JavaClass oldClass = (JavaClass)classCache.get(name);
- if (oldClass!=null && oldClass.getJavaClass()==cls) return;
- classCache.put( name, new JavaClass(cls) );
- }
-
- public synchronized void deregisterClass( String name ) {
- /* Deregister the passed in className */
- /**************************************/
- classCache.remove( name);
- }
-
- public boolean isClassRegistered( String name ) {
- return( classCache != null && classCache.get(name) != null );
- }
-
- public Class loadClass(String name) throws ClassNotFoundException {
- Object obj ;
-
- /* Check the classCache for the className - if there just return */
- /* the class - if not there use the default class loader. */
- /*****************************************************************/
- if ( classCache != null ) {
- obj = classCache.get( name );
- if ( obj != null )
- return( ((JavaClass)obj).getJavaClass() );
- }
-
- ClassLoader cl = this.getClass().getClassLoader();
- Class cls = cl.loadClass( name );
- registerClass( name, cls );
- return cls;
- }
-
- /**
- * Find the cached JavaClass entry for this class, creating one
- * if necessary.
- * @param className name of the class desired
- * @return JavaClass entry
- */
- public JavaClass lookup(String className) throws ClassNotFoundException {
- JavaClass jc = (JavaClass) classCache.get( className );
- if ( jc == null ) {
- loadClass( className );
- jc = (JavaClass) classCache.get( className );
+ public AxisClassLoader() {
+ super();
}
- return jc;
- }
+ static public AxisClassLoader getClassLoader() {
+ return( getClassLoader(null) );
+ }
+
+ static public AxisClassLoader getClassLoader(String name) {
+ AxisClassLoader cl = null ;
+ if ( name == null ) name = "<default_class_loader>" ;
+ cl = (AxisClassLoader) classLoaders.get( name );
+ if ( cl == null )
+ classLoaders.put( name, cl = new AxisClassLoader() );
+ return( cl );
+ }
+
+ static public void removeClassLoader(String name) {
+ if ( name != null )
+ classLoaders.remove( name );
+ }
+
+ public void registerClass( String name, String classFile )
+ throws FileNotFoundException, IOException
+ {
+ /* Load the class file the *.class file */
+ /****************************************/
+ FileInputStream fis = new FileInputStream( classFile );
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte buf[] = new byte[1024];
+ for(int i = 0; (i = fis.read(buf)) != -1; )
+ baos.write(buf, 0, i);
+ fis.close();
+ baos.close();
+
+ /* Create a new Class object from it */
+ /*************************************/
+ byte[] data = baos.toByteArray();
+ Class cls = defineClass( name, data, 0, data.length );
+
+ /* And finally register it */
+ /***************************/
+ registerClass( name, cls );
+ }
+
+ public synchronized void registerClass( String name, Class cls ) {
+ /* And finally register it */
+ /***************************/
+ JavaClass oldClass = (JavaClass)classCache.get(name);
+ if (oldClass!=null && oldClass.getJavaClass()==cls) return;
+ classCache.put( name, new JavaClass(cls) );
+ }
+
+ public synchronized void deregisterClass( String name ) {
+ /* Deregister the passed in className */
+ /**************************************/
+ classCache.remove( name);
+ }
+
+ public boolean isClassRegistered( String name ) {
+ return( classCache != null && classCache.get(name) != null );
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ Object obj ;
+
+ /* Check the classCache for the className - if there just return */
+ /* the class - if not there use the default class loader. */
+ /*****************************************************************/
+ if ( classCache != null ) {
+ obj = classCache.get( name );
+ if ( obj != null )
+ return( ((JavaClass)obj).getJavaClass() );
+ }
+
+ ClassLoader cl = this.getClass().getClassLoader();
+ Class cls = cl.loadClass( name );
+ registerClass( name, cls );
+ return cls;
+ }
+
+ /**
+ * Find the cached JavaClass entry for this class, creating one
+ * if necessary.
+ * @param className name of the class desired
+ * @return JavaClass entry
+ */
+ public JavaClass lookup(String className) throws ClassNotFoundException {
+ JavaClass jc = (JavaClass) classCache.get( className );
+ if ( jc == null ) {
+ loadClass( className );
+ jc = (JavaClass) classCache.get( className );
+ }
+
+ return jc;
+ }
};
1.3 +275 -275 xml-axis/java/src/org/apache/axis/utils/DOM2Writer.java
Index: DOM2Writer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/DOM2Writer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM2Writer.java 2001/06/21 11:19:47 1.2
+++ DOM2Writer.java 2001/07/12 15:04:54 1.3
@@ -73,330 +73,330 @@
*/
public class DOM2Writer
{
- /**
- * The namespaceURI represented by the prefix <code>xmlns</code>.
- */
- private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
-
- /**
- * The prefered line separator
- */
- private static final String lineSeparator =
- System.getProperty("line.separator", "\n");
-
- /**
- * Return a string containing this node serialized as XML.
- */
- public static String nodeToString(Node node, boolean omitXMLDecl)
- {
- StringWriter sw = new StringWriter();
-
- serializeAsXML(node, sw, omitXMLDecl);
-
- return sw.toString();
- }
-
- /**
- * Serialize this node into the writer as XML.
- */
- public static void serializeAsXML(Node node, Writer writer,
- boolean omitXMLDecl)
- {
- PrintWriter out = new PrintWriter(writer);
- if (!omitXMLDecl)
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- print(node, null, out);
- out.flush();
- }
-
- private static void print(Node node, NSStack namespaceStack,
- PrintWriter out)
- {
- if (node == null)
+ /**
+ * The namespaceURI represented by the prefix <code>xmlns</code>.
+ */
+ private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
+
+ /**
+ * The prefered line separator
+ */
+ private static final String lineSeparator =
+ System.getProperty("line.separator", "\n");
+
+ /**
+ * Return a string containing this node serialized as XML.
+ */
+ public static String nodeToString(Node node, boolean omitXMLDecl)
{
- return;
- }
+ StringWriter sw = new StringWriter();
+
+ serializeAsXML(node, sw, omitXMLDecl);
- boolean hasChildren = false;
- int type = node.getNodeType();
+ return sw.toString();
+ }
- switch (type)
+ /**
+ * Serialize this node into the writer as XML.
+ */
+ public static void serializeAsXML(Node node, Writer writer,
+ boolean omitXMLDecl)
{
- case Node.DOCUMENT_NODE :
- {
- NodeList children = node.getChildNodes();
+ PrintWriter out = new PrintWriter(writer);
+ if (!omitXMLDecl)
+ out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ print(node, null, out);
+ out.flush();
+ }
- if (children != null)
+ private static void print(Node node, NSStack namespaceStack,
+ PrintWriter out)
+ {
+ if (node == null)
{
- int numChildren = children.getLength();
-
- for (int i = 0; i < numChildren; i++)
- {
- print(children.item(i), namespaceStack, out);
- }
+ return;
}
- break;
- }
-
- case Node.ELEMENT_NODE :
- {
- namespaceStack = new NSStack(namespaceStack);
- out.print('<' + node.getNodeName());
+ boolean hasChildren = false;
+ int type = node.getNodeType();
- String elPrefix = node.getPrefix();
- String elNamespaceURI = node.getNamespaceURI();
-
- if (elPrefix != null && elNamespaceURI != null)
+ switch (type)
{
- boolean prefixIsDeclared = false;
-
- try
- {
- String namespaceURI = namespaceStack.getNamespaceURI(elPrefix);
-
- if (elNamespaceURI.equals(namespaceURI))
+ case Node.DOCUMENT_NODE :
{
- prefixIsDeclared = true;
- }
- }
- catch (IllegalArgumentException e)
- {
- }
+ NodeList children = node.getChildNodes();
- if (!prefixIsDeclared)
- {
- printNamespaceDecl(node, namespaceStack, out);
- }
- }
-
- NamedNodeMap attrs = node.getAttributes();
- int len = (attrs != null) ? attrs.getLength() : 0;
+ if (children != null)
+ {
+ int numChildren = children.getLength();
+
+ for (int i = 0; i < numChildren; i++)
+ {
+ print(children.item(i), namespaceStack, out);
+ }
+ }
+ break;
+ }
- for (int i = 0; i < len; i++)
- {
- Attr attr = (Attr)attrs.item(i);
+ case Node.ELEMENT_NODE :
+ {
+ namespaceStack = new NSStack(namespaceStack);
- out.print(' ' + attr.getNodeName() +"=\"" +
- normalize(attr.getValue()) + '\"');
+ out.print('<' + node.getNodeName());
- String attrPrefix = attr.getPrefix();
- String attrNamespaceURI = attr.getNamespaceURI();
+ String elPrefix = node.getPrefix();
+ String elNamespaceURI = node.getNamespaceURI();
- if (attrPrefix != null && attrNamespaceURI != null)
- {
- boolean prefixIsDeclared = false;
+ if (elPrefix != null && elNamespaceURI != null)
+ {
+ boolean prefixIsDeclared = false;
+
+ try
+ {
+ String namespaceURI = namespaceStack.getNamespaceURI(elPrefix);
+
+ if (elNamespaceURI.equals(namespaceURI))
+ {
+ prefixIsDeclared = true;
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+
+ if (!prefixIsDeclared)
+ {
+ printNamespaceDecl(node, namespaceStack, out);
+ }
+ }
+
+ NamedNodeMap attrs = node.getAttributes();
+ int len = (attrs != null) ? attrs.getLength() : 0;
+
+ for (int i = 0; i < len; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+
+ out.print(' ' + attr.getNodeName() +"=\"" +
+ normalize(attr.getValue()) + '\"');
+
+ String attrPrefix = attr.getPrefix();
+ String attrNamespaceURI = attr.getNamespaceURI();
+
+ if (attrPrefix != null && attrNamespaceURI != null)
+ {
+ boolean prefixIsDeclared = false;
+
+ try
+ {
+ String namespaceURI = namespaceStack.getNamespaceURI(attrPrefix);
+
+ if (attrNamespaceURI.equals(namespaceURI))
+ {
+ prefixIsDeclared = true;
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+
+ if (!prefixIsDeclared)
+ {
+ printNamespaceDecl(attr, namespaceStack, out);
+ }
+ }
+ }
+
+ NodeList children = node.getChildNodes();
+
+ if (children != null)
+ {
+ int numChildren = children.getLength();
+
+ hasChildren = (numChildren > 0);
+
+ if (hasChildren)
+ {
+ out.print('>');
+ }
+
+ for (int i = 0; i < numChildren; i++)
+ {
+ print(children.item(i), namespaceStack, out);
+ }
+ }
+ else
+ {
+ hasChildren = false;
+ }
+
+ if (!hasChildren)
+ {
+ out.print("/>");
+ }
+ break;
+ }
- try
+ case Node.ENTITY_REFERENCE_NODE :
{
- String namespaceURI = namespaceStack.getNamespaceURI(attrPrefix);
-
- if (attrNamespaceURI.equals(namespaceURI))
- {
- prefixIsDeclared = true;
- }
+ out.print('&');
+ out.print(node.getNodeName());
+ out.print(';');
+ break;
}
- catch (IllegalArgumentException e)
+
+ case Node.CDATA_SECTION_NODE :
{
+ out.print("<![CDATA[");
+ out.print(node.getNodeValue());
+ out.print("]]>");
+ break;
}
- if (!prefixIsDeclared)
+ case Node.TEXT_NODE :
{
- printNamespaceDecl(attr, namespaceStack, out);
+ out.print(normalize(node.getNodeValue()));
+ break;
}
- }
- }
- NodeList children = node.getChildNodes();
-
- if (children != null)
- {
- int numChildren = children.getLength();
+ case Node.COMMENT_NODE :
+ {
+ out.print("<!--");
+ out.print(node.getNodeValue());
+ out.print("-->");
+ break;
+ }
- hasChildren = (numChildren > 0);
+ case Node.PROCESSING_INSTRUCTION_NODE :
+ {
+ out.print("<?");
+ out.print(node.getNodeName());
- if (hasChildren)
- {
- out.print('>');
- }
+ String data = node.getNodeValue();
- for (int i = 0; i < numChildren; i++)
- {
- print(children.item(i), namespaceStack, out);
- }
- }
- else
- {
- hasChildren = false;
- }
+ if (data != null && data.length() > 0)
+ {
+ out.print(' ');
+ out.print(data);
+ }
- if (!hasChildren)
- {
- out.print("/>");
+ out.println("?>");
+ break;
+ }
}
- break;
- }
-
- case Node.ENTITY_REFERENCE_NODE :
- {
- out.print('&');
- out.print(node.getNodeName());
- out.print(';');
- break;
- }
-
- case Node.CDATA_SECTION_NODE :
- {
- out.print("<![CDATA[");
- out.print(node.getNodeValue());
- out.print("]]>");
- break;
- }
-
- case Node.TEXT_NODE :
- {
- out.print(normalize(node.getNodeValue()));
- break;
- }
-
- case Node.COMMENT_NODE :
- {
- out.print("<!--");
- out.print(node.getNodeValue());
- out.print("-->");
- break;
- }
-
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- out.print("<?");
- out.print(node.getNodeName());
- String data = node.getNodeValue();
-
- if (data != null && data.length() > 0)
+ if (type == Node.ELEMENT_NODE && hasChildren == true)
{
- out.print(' ');
- out.print(data);
+ out.print("</");
+ out.print(node.getNodeName());
+ out.print('>');
+ hasChildren = false;
}
-
- out.println("?>");
- break;
- }
}
- if (type == Node.ELEMENT_NODE && hasChildren == true)
+ private static void printNamespaceDecl(Node node,
+ NSStack namespaceStack,
+ PrintWriter out)
{
- out.print("</");
- out.print(node.getNodeName());
- out.print('>');
- hasChildren = false;
- }
- }
-
- private static void printNamespaceDecl(Node node,
- NSStack namespaceStack,
- PrintWriter out)
- {
- switch (node.getNodeType())
- {
- case Node.ATTRIBUTE_NODE :
- {
- printNamespaceDecl(((Attr)node).getOwnerElement(), node,
- namespaceStack, out);
- break;
- }
-
- case Node.ELEMENT_NODE :
- {
- printNamespaceDecl((Element)node, node, namespaceStack, out);
- break;
- }
- }
- }
-
- private static void printNamespaceDecl(Element owner, Node node,
- NSStack namespaceStack,
- PrintWriter out)
- {
- String namespaceURI = node.getNamespaceURI();
- String prefix = node.getPrefix();
+ switch (node.getNodeType())
+ {
+ case Node.ATTRIBUTE_NODE :
+ {
+ printNamespaceDecl(((Attr)node).getOwnerElement(), node,
+ namespaceStack, out);
+ break;
+ }
- if (!(namespaceURI.equals(NS_URI_XMLNS) && prefix.equals("xmlns")))
- {
- if (XMLUtils.getNamespace(prefix, owner) == null)
- {
- out.print(" xmlns:" + prefix + "=\"" + namespaceURI + '\"');
- }
- }
- else
- {
- prefix = node.getLocalName();
- namespaceURI = node.getNodeValue();
+ case Node.ELEMENT_NODE :
+ {
+ printNamespaceDecl((Element)node, node, namespaceStack, out);
+ break;
+ }
+ }
}
-
- namespaceStack.add(namespaceURI, prefix);
- }
- public static String normalize(String s)
- {
- StringBuffer str = new StringBuffer();
- int len = (s != null) ? s.length() : 0;
-
- for (int i = 0; i < len; i++)
+ private static void printNamespaceDecl(Element owner, Node node,
+ NSStack namespaceStack,
+ PrintWriter out)
{
- char ch = s.charAt(i);
+ String namespaceURI = node.getNamespaceURI();
+ String prefix = node.getPrefix();
- switch (ch)
- {
- case '<' :
- {
- str.append("<");
- break;
- }
- case '>' :
- {
- str.append(">");
- break;
- }
- case '&' :
+ if (!(namespaceURI.equals(NS_URI_XMLNS) && prefix.equals("xmlns")))
{
- str.append("&");
- break;
+ if (XMLUtils.getNamespace(prefix, owner) == null)
+ {
+ out.print(" xmlns:" + prefix + "=\"" + namespaceURI + '\"');
+ }
}
- case '"' :
+ else
{
- str.append(""");
- break;
+ prefix = node.getLocalName();
+ namespaceURI = node.getNodeValue();
}
- case '\n' :
+
+ namespaceStack.add(namespaceURI, prefix);
+ }
+
+ public static String normalize(String s)
+ {
+ StringBuffer str = new StringBuffer();
+ int len = (s != null) ? s.length() : 0;
+
+ for (int i = 0; i < len; i++)
{
- if (i > 0)
- {
- char lastChar = str.charAt(str.length() - 1);
+ char ch = s.charAt(i);
- if (lastChar != '\r')
- {
- str.append(lineSeparator);
- }
- else
+ switch (ch)
{
- str.append('\n');
+ case '<' :
+ {
+ str.append("<");
+ break;
+ }
+ case '>' :
+ {
+ str.append(">");
+ break;
+ }
+ case '&' :
+ {
+ str.append("&");
+ break;
+ }
+ case '"' :
+ {
+ str.append(""");
+ break;
+ }
+ case '\n' :
+ {
+ if (i > 0)
+ {
+ char lastChar = str.charAt(str.length() - 1);
+
+ if (lastChar != '\r')
+ {
+ str.append(lineSeparator);
+ }
+ else
+ {
+ str.append('\n');
+ }
+ }
+ else
+ {
+ str.append(lineSeparator);
+ }
+ break;
+ }
+ default :
+ {
+ str.append(ch);
+ }
}
- }
- else
- {
- str.append(lineSeparator);
- }
- break;
}
- default :
- {
- str.append(ch);
- }
- }
- }
- return (str.toString());
- }
+ return (str.toString());
+ }
}
1.7 +85 -85 xml-axis/java/src/org/apache/axis/utils/Debug.java
Index: Debug.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Debug.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Debug.java 2001/06/25 14:31:09 1.6
+++ Debug.java 2001/07/12 15:04:55 1.7
@@ -68,102 +68,102 @@
import java.io.* ;
public class Debug {
- private static int debugLevel = 0 ;
- private static boolean toScreen = true ;
- private static boolean toFile = false ;
-
- public static void setDebugLevel( int dl ) {
- debugLevel = dl ;
- }
-
- public static int getDebugLevel() {
- return( debugLevel );
- }
-
- public static int incDebugLevel() {
- return( ++debugLevel );
- }
-
- public static int decDebugLevel() {
- return( debugLevel = ( (debugLevel == 0) ? 0 : (debugLevel-1) ) );
- }
-
- public static void setToScreen(boolean b) {
- toScreen = b ;
- }
-
- public static void setToFile(boolean b) {
- toFile = b ;
- }
-
- public static boolean DebugOn(int level) {
- return( debugLevel >= level );
- }
-
- public static void Print( int level, Exception exp ) {
- if ( debugLevel < level ) return ;
- try {
- String msg = "Exception: " + exp ;
- if ( toScreen ) {
- System.err.println( msg );
- exp.printStackTrace();
- }
- if ( toFile ) {
- FileWriter fw = new FileWriter( "AxisDebug.log", true );
- fw.write( msg, 0, msg.length() );
- PrintWriter pw = new PrintWriter( fw );
- exp.printStackTrace( pw );
- pw.close();
- fw.close();
- }
- }
- catch( Exception e ) {
- System.err.println( "Can't log debug info: " + e );
- e.printStackTrace();
- }
- }
-
- public static void Print( int level, String msg ) {
- if ( debugLevel >= level ) {
- if ( toScreen ) System.err.println( msg );
- if ( toFile ) {
+ private static int debugLevel = 0 ;
+ private static boolean toScreen = true ;
+ private static boolean toFile = false ;
+
+ public static void setDebugLevel( int dl ) {
+ debugLevel = dl ;
+ }
+
+ public static int getDebugLevel() {
+ return( debugLevel );
+ }
+
+ public static int incDebugLevel() {
+ return( ++debugLevel );
+ }
+
+ public static int decDebugLevel() {
+ return( debugLevel = ( (debugLevel == 0) ? 0 : (debugLevel-1) ) );
+ }
+
+ public static void setToScreen(boolean b) {
+ toScreen = b ;
+ }
+
+ public static void setToFile(boolean b) {
+ toFile = b ;
+ }
+
+ public static boolean DebugOn(int level) {
+ return( debugLevel >= level );
+ }
+
+ public static void Print( int level, Exception exp ) {
+ if ( debugLevel < level ) return ;
try {
- FileWriter fw = new FileWriter( "AxisDebug.log", true );
- fw.write( msg, 0, msg.length() );
- fw.write(System.getProperty("line.separator"));
- fw.close();
+ String msg = "Exception: " + exp ;
+ if ( toScreen ) {
+ System.err.println( msg );
+ exp.printStackTrace();
+ }
+ if ( toFile ) {
+ FileWriter fw = new FileWriter( "AxisDebug.log", true );
+ fw.write( msg, 0, msg.length() );
+ PrintWriter pw = new PrintWriter( fw );
+ exp.printStackTrace( pw );
+ pw.close();
+ fw.close();
+ }
}
catch( Exception e ) {
- System.err.println( "Can't log debug info: " + e );
- e.printStackTrace();
+ System.err.println( "Can't log debug info: " + e );
+ e.printStackTrace();
}
- }
}
- }
- public static void Print( int level, String msg1, Object msg2 ) {
- if ( debugLevel >= level ) {
- Print(level, msg1 + msg2);
+ public static void Print( int level, String msg ) {
+ if ( debugLevel >= level ) {
+ if ( toScreen ) System.err.println( msg );
+ if ( toFile ) {
+ try {
+ FileWriter fw = new FileWriter( "AxisDebug.log", true );
+ fw.write( msg, 0, msg.length() );
+ fw.write(System.getProperty("line.separator"));
+ fw.close();
+ }
+ catch( Exception e ) {
+ System.err.println( "Can't log debug info: " + e );
+ e.printStackTrace();
+ }
+ }
+ }
}
- }
- public static void Print( int level, String msg1, Object msg2, Object msg3 ) {
- if ( debugLevel >= level ) {
- Print(level, msg1 + msg2 + msg3);
+ public static void Print( int level, String msg1, Object msg2 ) {
+ if ( debugLevel >= level ) {
+ Print(level, msg1 + msg2);
+ }
}
- }
- public static void Print( int level, String msg1, Object msg2, Object msg3,
- Object msg4) {
- if ( debugLevel >= level ) {
- Print(level, msg1 + msg2 + msg3 + msg4);
+ public static void Print( int level, String msg1, Object msg2, Object msg3 ) {
+ if ( debugLevel >= level ) {
+ Print(level, msg1 + msg2 + msg3);
+ }
}
- }
- public static void Print( int level, String msg1, Object msg2, Object msg3,
- Object msg4, Object msg5) {
- if ( debugLevel >= level ) {
- Print(level, msg1 + msg2 + msg3 + msg4 + msg5);
+ public static void Print( int level, String msg1, Object msg2, Object msg3,
+ Object msg4) {
+ if ( debugLevel >= level ) {
+ Print(level, msg1 + msg2 + msg3 + msg4);
+ }
+ }
+
+ public static void Print( int level, String msg1, Object msg2, Object msg3,
+ Object msg4, Object msg5) {
+ if ( debugLevel >= level ) {
+ Print(level, msg1 + msg2 + msg3 + msg4 + msg5);
+ }
}
- }
}
1.2 +52 -52 xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
Index: JavaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavaUtils.java 2001/07/10 02:29:32 1.1
+++ JavaUtils.java 2001/07/12 15:04:56 1.2
@@ -65,63 +65,63 @@
*/
public class JavaUtils
{
- /** Utility function to convert an Object to some desired Class.
- *
- * Right now this only works for arrays <-> Lists, but it might be
- * expanded into a more general form later.
- *
- * @param arg the array to convert
- * @param destClass the actual class we want
- */
- public static Object convert(Object arg, Class destClass)
- {
- Debug.Print(3, "Trying to convert " + arg.getClass().getName() +
- " to " + destClass.getName());
-
- if (!(arg instanceof List))
- return arg;
-
- List list = (List)arg;
- int length = list.size();
-
- if (destClass.isArray()) {
- if (destClass.getComponentType().isPrimitive()) {
+ /** Utility function to convert an Object to some desired Class.
+ *
+ * Right now this only works for arrays <-> Lists, but it might be
+ * expanded into a more general form later.
+ *
+ * @param arg the array to convert
+ * @param destClass the actual class we want
+ */
+ public static Object convert(Object arg, Class destClass)
+ {
+ Debug.Print(3, "Trying to convert " + arg.getClass().getName() +
+ " to " + destClass.getName());
- Object array = Array.newInstance(destClass.getComponentType(),
- length);
- for (int i = 0; i < length; i++) {
- Array.set(array, i, list.get(i));
+ if (!(arg instanceof List))
+ return arg;
+
+ List list = (List)arg;
+ int length = list.size();
+
+ if (destClass.isArray()) {
+ if (destClass.getComponentType().isPrimitive()) {
+
+ Object array = Array.newInstance(destClass.getComponentType(),
+ length);
+ for (int i = 0; i < length; i++) {
+ Array.set(array, i, list.get(i));
+ }
+ return array;
+
+ } else {
+ Object [] array;
+ try {
+ array = (Object [])Array.newInstance(destClass.getComponentType(),
+ length);
+ } catch (Exception e) {
+ return arg;
+ }
+
+ return list.toArray(array);
+ }
}
- return array;
- } else {
- Object [] array;
- try {
- array = (Object [])Array.newInstance(destClass.getComponentType(),
- length);
- } catch (Exception e) {
- return arg;
+ if (List.class.isAssignableFrom(destClass)) {
+ List newList = null;
+ try {
+ newList = (List)destClass.newInstance();
+ } catch (Exception e) {
+ // Couldn't build one for some reason... so forget it.
+ return arg;
+ }
+
+ for (int j = 0; j < ((List)arg).size(); j++) {
+ newList.add(list.get(j));
+ }
+ return newList;
}
- return list.toArray(array);
- }
- }
-
- if (List.class.isAssignableFrom(destClass)) {
- List newList = null;
- try {
- newList = (List)destClass.newInstance();
- } catch (Exception e) {
- // Couldn't build one for some reason... so forget it.
return arg;
- }
-
- for (int j = 0; j < ((List)arg).size(); j++) {
- newList.add(list.get(j));
- }
- return newList;
}
-
- return arg;
- }
}
1.13 +206 -206 xml-axis/java/src/org/apache/axis/utils/Options.java
Index: Options.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Options.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Options.java 2001/06/29 19:59:16 1.12
+++ Options.java 2001/07/12 15:04:57 1.13
@@ -66,218 +66,218 @@
import java.util.* ;
public class Options {
- String args[] = null ;
+ String args[] = null ;
- //////////////////////////////////////////////////////////////////////////
- // SOASS (Start of Axis Specific Stuff)
+ //////////////////////////////////////////////////////////////////////////
+ // SOASS (Start of Axis Specific Stuff)
- String host ; // -h also -l (url)
- String port ; // -p
- String servlet ; // -s also -f (file)
- String protocol ;
-
- String user ; // -u
- String passwd ; // -w
-
- // EOASS
- //////////////////////////////////////////////////////////////////////////
-
- /**
- * Constructor - just pass in the <b>args</b> from the command line.
- */
- public Options(String _args[]) throws MalformedURLException {
- args = _args ;
-
- ///////////////////////////////////////////////////////////////////////
- // SOASS
+ String host ; // -h also -l (url)
+ String port ; // -p
+ String servlet ; // -s also -f (file)
+ String protocol ;
- /* Process these well known options first */
- /******************************************/
- try {
- getURL();
- } catch( MalformedURLException e ) {
- Debug.Print( 1, "getURL failed to correctly process URL; protocol not " +
- "supported" );
- throw e ;
- }
- getUser();
- getPassword();
+ String user ; // -u
+ String passwd ; // -w
// EOASS
- ///////////////////////////////////////////////////////////////////////
- }
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Constructor - just pass in the <b>args</b> from the command line.
+ */
+ public Options(String _args[]) throws MalformedURLException {
+ args = _args ;
+
+ ///////////////////////////////////////////////////////////////////////
+ // SOASS
+
+ /* Process these well known options first */
+ /******************************************/
+ try {
+ getURL();
+ } catch( MalformedURLException e ) {
+ Debug.Print( 1, "getURL failed to correctly process URL; protocol not " +
+ "supported" );
+ throw e ;
+ }
+ getUser();
+ getPassword();
+
+ // EOASS
+ ///////////////////////////////////////////////////////////////////////
+ }
+
+ /**
+ * Returns an int specifying the number of times that the flag was
+ * specified on the command line. Once this flag is looked for you
+ * must save the result because if you call it again for the same
+ * flag you'll get zero.
+ */
+ public int isFlagSet(char optChar) {
+ int value = 0 ;
+ int loop ;
+ int i ;
+
+ for ( loop = 0 ; loop < args.length ; loop++ ) {
+ if ( args[loop] == null || args[loop].length() == 0 ) continue ;
+ if ( args[loop].charAt(0) != '-' ) continue ;
+ while ( args[loop] != null && (i = args[loop].indexOf(optChar)) != -1 ) {
+ args[loop] = args[loop].substring(0, i) + args[loop].substring(i+1) ;
+ if ( args[loop].length() == 1 )
+ args[loop] = null ;
+ value++ ;
+ }
+ }
+ return( value );
+ }
+
+ /**
+ * Returns a string (or null) specifying the value for the passed
+ * option. If the option isn't there then null is returned. The
+ * option's value can be specified one of two ways:
+ * -x value
+ * -xvalue
+ * Note that: -ax value
+ * is not value (meaning flag 'a' followed by option 'x'.
+ * Options with values must be the first char after the '-'.
+ * If the option is specified more than once then the last one wins.
+ */
+ public String isValueSet(char optChar) {
+ String value = null ;
+ int loop ;
+ int i ;
+
+ for ( loop = 0 ; loop < args.length ; loop++ ) {
+ if ( args[loop] == null || args[loop].length() == 0 ) continue ;
+ if ( args[loop].charAt(0) != '-' ) continue ;
+ i = args[loop].indexOf( optChar );
+ if ( i != 1 ) continue ;
+ if ( i != args[loop].length()-1 ) {
+ // Not at end of arg, so use rest of arg as value
+ value = args[loop].substring(i+1) ;
+ args[loop] = args[loop].substring(0, i);
+ }
+ else {
+ // Remove the char from the current arg
+ args[loop] = args[loop].substring(0, i);
+
+ // Nothing after char so use next arg
+ if ( loop+1 < args.length && args[loop+1] != null ) {
+ // Next arg is there and non-null
+ if ( args[loop+1].charAt(0) != '-' ) {
+ value = args[loop+1];
+ args[loop+1] = null ;
+ }
+ }
+ else {
+ // Next is null or not there - do nothing
+ // value = null ;
+ }
+ }
+ if ( args[loop].length() == 1 )
+ args[loop] = null ;
+ // For now, keep looping to get that last on there
+ // break ;
+ }
+ return( value );
+ }
+
+ /**
+ * This just returns a string with the unprocessed flags - mainly
+ * for error reporting - so you can report the unknown flags.
+ */
+ public String getRemainingFlags() {
+ StringBuffer sb = null ;
+ int loop ;
+
+ for ( loop = 0 ; loop < args.length ; loop++ ) {
+ if ( args[loop] == null || args[loop].length() == 0 ) continue ;
+ if ( args[loop].charAt(0) != '-' ) continue ;
+ if ( sb == null ) sb = new StringBuffer();
+ sb.append( args[loop].substring(1) );
+ }
+ return( sb == null ? null : sb.toString() );
+ }
+
+ /**
+ * This returns an array of unused args - these are the non-option
+ * args from the command line.
+ */
+ public String[] getRemainingArgs() {
+ ArrayList al = null ;
+ int loop ;
+
+ for ( loop = 0 ; loop < args.length ; loop++ ) {
+ if ( args[loop] == null || args[loop].length() == 0 ) continue ;
+ if ( args[loop].charAt(0) == '-' ) continue ;
+ if ( al == null ) al = new ArrayList();
+ al.add( (String) args[loop] );
+ }
+ if ( al == null ) return( null );
+ String a[] = new String[ al.size() ];
+ for ( loop = 0 ; loop < al.size() ; loop++ )
+ a[loop] = (String) al.get(loop);
+ return( a );
+ }
- /**
- * Returns an int specifying the number of times that the flag was
- * specified on the command line. Once this flag is looked for you
- * must save the result because if you call it again for the same
- * flag you'll get zero.
- */
- public int isFlagSet(char optChar) {
- int value = 0 ;
- int loop ;
- int i ;
-
- for ( loop = 0 ; loop < args.length ; loop++ ) {
- if ( args[loop] == null || args[loop].length() == 0 ) continue ;
- if ( args[loop].charAt(0) != '-' ) continue ;
- while ( args[loop] != null && (i = args[loop].indexOf(optChar)) != -1 ) {
- args[loop] = args[loop].substring(0, i) + args[loop].substring(i+1) ;
- if ( args[loop].length() == 1 )
- args[loop] = null ;
- value++ ;
- }
- }
- return( value );
- }
-
- /**
- * Returns a string (or null) specifying the value for the passed
- * option. If the option isn't there then null is returned. The
- * option's value can be specified one of two ways:
- * -x value
- * -xvalue
- * Note that: -ax value
- * is not value (meaning flag 'a' followed by option 'x'.
- * Options with values must be the first char after the '-'.
- * If the option is specified more than once then the last one wins.
- */
- public String isValueSet(char optChar) {
- String value = null ;
- int loop ;
- int i ;
-
- for ( loop = 0 ; loop < args.length ; loop++ ) {
- if ( args[loop] == null || args[loop].length() == 0 ) continue ;
- if ( args[loop].charAt(0) != '-' ) continue ;
- i = args[loop].indexOf( optChar );
- if ( i != 1 ) continue ;
- if ( i != args[loop].length()-1 ) {
- // Not at end of arg, so use rest of arg as value
- value = args[loop].substring(i+1) ;
- args[loop] = args[loop].substring(0, i);
- }
- else {
- // Remove the char from the current arg
- args[loop] = args[loop].substring(0, i);
-
- // Nothing after char so use next arg
- if ( loop+1 < args.length && args[loop+1] != null ) {
- // Next arg is there and non-null
- if ( args[loop+1].charAt(0) != '-' ) {
- value = args[loop+1];
- args[loop+1] = null ;
- }
- }
- else {
- // Next is null or not there - do nothing
- // value = null ;
- }
- }
- if ( args[loop].length() == 1 )
- args[loop] = null ;
- // For now, keep looping to get that last on there
- // break ;
- }
- return( value );
- }
-
- /**
- * This just returns a string with the unprocessed flags - mainly
- * for error reporting - so you can report the unknown flags.
- */
- public String getRemainingFlags() {
- StringBuffer sb = null ;
- int loop ;
-
- for ( loop = 0 ; loop < args.length ; loop++ ) {
- if ( args[loop] == null || args[loop].length() == 0 ) continue ;
- if ( args[loop].charAt(0) != '-' ) continue ;
- if ( sb == null ) sb = new StringBuffer();
- sb.append( args[loop].substring(1) );
- }
- return( sb == null ? null : sb.toString() );
- }
-
- /**
- * This returns an array of unused args - these are the non-option
- * args from the command line.
- */
- public String[] getRemainingArgs() {
- ArrayList al = null ;
- int loop ;
-
- for ( loop = 0 ; loop < args.length ; loop++ ) {
- if ( args[loop] == null || args[loop].length() == 0 ) continue ;
- if ( args[loop].charAt(0) == '-' ) continue ;
- if ( al == null ) al = new ArrayList();
- al.add( (String) args[loop] );
- }
- if ( al == null ) return( null );
- String a[] = new String[ al.size() ];
- for ( loop = 0 ; loop < al.size() ; loop++ )
- a[loop] = (String) al.get(loop);
- return( a );
- }
-
- //////////////////////////////////////////////////////////////////////////
- // SOASS
- public String getURL() throws MalformedURLException {
- String tmp ;
- URL url = null ;
+ //////////////////////////////////////////////////////////////////////////
+ // SOASS
+ public String getURL() throws MalformedURLException {
+ String tmp ;
+ URL url = null ;
+
+ // Just in case...
+ org.apache.axis.client.ServiceClient.initialize();
+
+ if ( (tmp = isValueSet( 'l' )) != null ) {
+ url = new URL( tmp );
+ host = url.getHost();
+ port = "" + url.getPort();
+ servlet = url.getFile();
+ protocol = url.getProtocol();
+ }
+
+ if ( (tmp = isValueSet( 'f' )) != null ) {
+ host = "";
+ port = "-1";
+ servlet = tmp;
+ protocol = "file";
+ }
+
+ tmp = isValueSet( 'h' ); if ( host == null ) host = tmp ;
+ tmp = isValueSet( 'p' ); if ( port == null ) port = tmp ;
+ tmp = isValueSet( 's' ); if ( servlet == null ) servlet = tmp ;
+
+ if ( host == null ) host = "localhost" ;
+ if ( port == null ) port = "8080" ;
+ if ( servlet == null ) servlet = "/axis/servlet/AxisServlet" ;
+ else
+ if ( servlet.length()>0 && servlet.charAt(0)!='/' )
+ servlet = "/" + servlet ;
+
+ if (url == null) {
+ if (protocol == null) protocol = "http";
+ tmp = protocol + "://" + host ;
+ if ( port != null && !port.equals("-1")) tmp += ":" + port ;
+ if ( servlet != null ) tmp += servlet ;
+ } else tmp = url.toString();
+ Debug.Print( 3, "getURL returned: " + tmp );
+ return( tmp );
+ }
- // Just in case...
- org.apache.axis.client.ServiceClient.initialize();
+ public int getPort() {
+ return Integer.parseInt(port);
+ }
- if ( (tmp = isValueSet( 'l' )) != null ) {
- url = new URL( tmp );
- host = url.getHost();
- port = "" + url.getPort();
- servlet = url.getFile();
- protocol = url.getProtocol();
- }
-
- if ( (tmp = isValueSet( 'f' )) != null ) {
- host = "";
- port = "-1";
- servlet = tmp;
- protocol = "file";
- }
-
- tmp = isValueSet( 'h' ); if ( host == null ) host = tmp ;
- tmp = isValueSet( 'p' ); if ( port == null ) port = tmp ;
- tmp = isValueSet( 's' ); if ( servlet == null ) servlet = tmp ;
-
- if ( host == null ) host = "localhost" ;
- if ( port == null ) port = "8080" ;
- if ( servlet == null ) servlet = "/axis/servlet/AxisServlet" ;
- else
- if ( servlet.length()>0 && servlet.charAt(0)!='/' )
- servlet = "/" + servlet ;
-
- if (url == null) {
- if (protocol == null) protocol = "http";
- tmp = protocol + "://" + host ;
- if ( port != null && !port.equals("-1")) tmp += ":" + port ;
- if ( servlet != null ) tmp += servlet ;
- } else tmp = url.toString();
- Debug.Print( 3, "getURL returned: " + tmp );
- return( tmp );
- }
-
- public int getPort() {
- return Integer.parseInt(port);
- }
-
- public String getUser() {
- if ( user == null ) user = isValueSet( 'u' );
- return( user );
- }
-
- public String getPassword() {
- if ( passwd == null ) passwd = isValueSet( 'w' );
- return( passwd );
- }
- // EOASS
- //////////////////////////////////////////////////////////////////////////
+ public String getUser() {
+ if ( user == null ) user = isValueSet( 'u' );
+ return( user );
+ }
+
+ public String getPassword() {
+ if ( passwd == null ) passwd = isValueSet( 'w' );
+ return( passwd );
+ }
+ // EOASS
+ //////////////////////////////////////////////////////////////////////////
}
1.13 +198 -198 xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
Index: XMLUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XMLUtils.java 2001/07/01 12:58:53 1.12
+++ XMLUtils.java 2001/07/12 15:04:58 1.13
@@ -63,206 +63,206 @@
import org.apache.axis.Constants;
public class XMLUtils {
- private static DocumentBuilderFactory dbf = init();
- private static SAXParserFactory saxFactory;
-
- static {
- // Initialize SAX Parser factory defaults
- initSAXFactory(null, true, false);
- }
-
- /** Encode a string appropriately for XML.
- *
- * Lifted from ApacheSOAP 2.2 (org.apache.soap.Utils)
- *
- * @param orig the String to encode
- * @return a String in which XML special chars are repalced by entities
- */
- public static String xmlEncodeString(String orig)
- {
- if (orig == null)
+ private static DocumentBuilderFactory dbf = init();
+ private static SAXParserFactory saxFactory;
+
+ static {
+ // Initialize SAX Parser factory defaults
+ initSAXFactory(null, true, false);
+ }
+
+ /** Encode a string appropriately for XML.
+ *
+ * Lifted from ApacheSOAP 2.2 (org.apache.soap.Utils)
+ *
+ * @param orig the String to encode
+ * @return a String in which XML special chars are repalced by entities
+ */
+ public static String xmlEncodeString(String orig)
{
- return "";
+ if (orig == null)
+ {
+ return "";
+ }
+
+ StringBuffer strBuf = new StringBuffer();
+ char[] chars = orig.toCharArray();
+
+ for (int i = 0; i < chars.length; i++)
+ {
+ switch (chars[i])
+ {
+ case '&' : strBuf.append("&");
+ break;
+ case '\"' : strBuf.append(""");
+ break;
+ case '\'' : strBuf.append("'");
+ break;
+ case '<' : strBuf.append("<");
+ break;
+ case '>' : strBuf.append(">");
+ break;
+ default : strBuf.append(chars[i]);
+ break;
+ }
+ }
+
+ return strBuf.toString();
+ }
+
+ /** Initialize the SAX parser factory.
+ *
+ * @param factoryClassName The class name of the desired SAXParserFactory
+ * implementation. Will be assigned to the system
+ * property <b>javax.xml.parsers.SAXParserFactory</b>.
+ * @param namespaceAware true if we want a namespace-aware parser (which we do)
+ * @param validating true if we want a validating parser
+ *
+ */
+ public static void initSAXFactory(String factoryClassName,
+ boolean namespaceAware,
+ boolean validating)
+ {
+ if (factoryClassName != null) {
+ System.setProperty("javax.xml.parsers.SAXParserFactory",
+ factoryClassName);
+ }
+ saxFactory = SAXParserFactory.newInstance();
+ saxFactory.setNamespaceAware(namespaceAware);
+ saxFactory.setValidating(validating);
+ }
+
+ public static DocumentBuilderFactory init() {
+ Document doc = null ;
+
+ try {
+ dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ return( dbf );
+ }
+
+ /** Get a SAX parser instance from the JAXP factory.
+ *
+ * @return a SAXParser instance.
+ */
+ public static SAXParser getSAXParser() {
+ // Might want to cache the parser (on a per-thread basis, as I don't think
+ // SAX parsers are thread-safe)...
+ try {
+ return saxFactory.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ return null;
+ } catch (SAXException se) {
+ se.printStackTrace();
+ return null;
+ }
+ }
+
+ public static Document newDocument() {
+ try {
+ return dbf.newDocumentBuilder().newDocument();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static Document newDocument(InputSource inp) {
+ try {
+ return( dbf.newDocumentBuilder().parse( inp ) );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ return( null );
+ }
+ }
+
+ public static Document newDocument(InputStream inp) {
+ try {
+ return( dbf.newDocumentBuilder().parse( inp ) );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ return( null );
+ }
+ }
+
+ public static Document newDocument(String uri) {
+ try {
+ return( dbf.newDocumentBuilder().parse( uri ) );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ return( null );
+ }
}
-
- StringBuffer strBuf = new StringBuffer();
- char[] chars = orig.toCharArray();
- for (int i = 0; i < chars.length; i++)
+ private static String privateElementToString(Element element,
+ boolean omitXMLDecl)
{
- switch (chars[i])
- {
- case '&' : strBuf.append("&");
- break;
- case '\"' : strBuf.append(""");
- break;
- case '\'' : strBuf.append("'");
- break;
- case '<' : strBuf.append("<");
- break;
- case '>' : strBuf.append(">");
- break;
- default : strBuf.append(chars[i]);
- break;
- }
- }
-
- return strBuf.toString();
- }
-
- /** Initialize the SAX parser factory.
- *
- * @param factoryClassName The class name of the desired SAXParserFactory
- * implementation. Will be assigned to the system
- * property <b>javax.xml.parsers.SAXParserFactory</b>.
- * @param namespaceAware true if we want a namespace-aware parser (which we do)
- * @param validating true if we want a validating parser
- *
- */
- public static void initSAXFactory(String factoryClassName,
- boolean namespaceAware,
- boolean validating)
- {
- if (factoryClassName != null) {
- System.setProperty("javax.xml.parsers.SAXParserFactory",
- factoryClassName);
- }
- saxFactory = SAXParserFactory.newInstance();
- saxFactory.setNamespaceAware(namespaceAware);
- saxFactory.setValidating(validating);
- }
-
- public static DocumentBuilderFactory init() {
- Document doc = null ;
-
- try {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- return( dbf );
- }
-
- /** Get a SAX parser instance from the JAXP factory.
- *
- * @return a SAXParser instance.
- */
- public static SAXParser getSAXParser() {
- // Might want to cache the parser (on a per-thread basis, as I don't think
- // SAX parsers are thread-safe)...
- try {
- return saxFactory.newSAXParser();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- return null;
- } catch (SAXException se) {
- se.printStackTrace();
- return null;
- }
- }
-
- public static Document newDocument() {
- try {
- return dbf.newDocumentBuilder().newDocument();
- } catch (Exception e) {
- return null;
- }
- }
-
- public static Document newDocument(InputSource inp) {
- try {
- return( dbf.newDocumentBuilder().parse( inp ) );
- }
- catch( Exception e ) {
- e.printStackTrace();
- return( null );
- }
- }
-
- public static Document newDocument(InputStream inp) {
- try {
- return( dbf.newDocumentBuilder().parse( inp ) );
- }
- catch( Exception e ) {
- e.printStackTrace();
- return( null );
- }
- }
-
- public static Document newDocument(String uri) {
- try {
- return( dbf.newDocumentBuilder().parse( uri ) );
- }
- catch( Exception e ) {
- e.printStackTrace();
- return( null );
- }
- }
-
- private static String privateElementToString(Element element,
- boolean omitXMLDecl)
- {
- return DOM2Writer.nodeToString(element, omitXMLDecl);
- }
-
- public static String ElementToString(Element element) {
- return privateElementToString(element, true);
- }
-
- public static String DocumentToString(Document doc) {
- return privateElementToString(doc.getDocumentElement(), false);
- }
-
- public static void privateElementToStream(Element element, OutputStream out,
- boolean omitXMLDecl) {
- Writer writer = new OutputStreamWriter(out);
- DOM2Writer.serializeAsXML(element, writer, omitXMLDecl);
- }
-
- public static void ElementToStream(Element element, OutputStream out) {
- privateElementToStream(element, out, true);
- }
-
- public static void DocumentToStream(Document doc, OutputStream out) {
- privateElementToStream(doc.getDocumentElement(), out, false);
- }
-
- public static String getInnerXMLString(Element element) {
- String elementString = ElementToString(element);
- int start, end;
- start = elementString.indexOf(">") + 1;
- end = elementString.lastIndexOf("</");
- if (end > 0)
- return elementString.substring(start,end);
- else
- return null;
- }
-
- public static String getPrefix(String uri, Node e) {
- while (e != null && (e.getNodeType() == Element.ELEMENT_NODE)) {
- NamedNodeMap attrs = e.getAttributes();
- for (int n = 0; n < attrs.getLength(); n++) {
- Attr a = (Attr)attrs.item(n);
- String name;
- if ((name = a.getName()).startsWith("xmlns:") &&
- a.getNodeValue().equals(uri)) {
- return name.substring(6);
- }
- }
- e = e.getParentNode();
- }
- return null;
- }
-
- public static String getNamespace(String prefix, Node e) {
- while (e != null && (e.getNodeType() == Node.ELEMENT_NODE)) {
- String name =
- ((Element)e).getAttributeNS(Constants.NS_URI_XMLNS, prefix);
- if (name != null) return name;
- e = e.getParentNode();
- }
- return null;
- }
+ return DOM2Writer.nodeToString(element, omitXMLDecl);
+ }
+
+ public static String ElementToString(Element element) {
+ return privateElementToString(element, true);
+ }
+
+ public static String DocumentToString(Document doc) {
+ return privateElementToString(doc.getDocumentElement(), false);
+ }
+
+ public static void privateElementToStream(Element element, OutputStream out,
+ boolean omitXMLDecl) {
+ Writer writer = new OutputStreamWriter(out);
+ DOM2Writer.serializeAsXML(element, writer, omitXMLDecl);
+ }
+
+ public static void ElementToStream(Element element, OutputStream out) {
+ privateElementToStream(element, out, true);
+ }
+
+ public static void DocumentToStream(Document doc, OutputStream out) {
+ privateElementToStream(doc.getDocumentElement(), out, false);
+ }
+
+ public static String getInnerXMLString(Element element) {
+ String elementString = ElementToString(element);
+ int start, end;
+ start = elementString.indexOf(">") + 1;
+ end = elementString.lastIndexOf("</");
+ if (end > 0)
+ return elementString.substring(start,end);
+ else
+ return null;
+ }
+
+ public static String getPrefix(String uri, Node e) {
+ while (e != null && (e.getNodeType() == Element.ELEMENT_NODE)) {
+ NamedNodeMap attrs = e.getAttributes();
+ for (int n = 0; n < attrs.getLength(); n++) {
+ Attr a = (Attr)attrs.item(n);
+ String name;
+ if ((name = a.getName()).startsWith("xmlns:") &&
+ a.getNodeValue().equals(uri)) {
+ return name.substring(6);
+ }
+ }
+ e = e.getParentNode();
+ }
+ return null;
+ }
+
+ public static String getNamespace(String prefix, Node e) {
+ while (e != null && (e.getNodeType() == Node.ELEMENT_NODE)) {
+ String name =
+ ((Element)e).getAttributeNS(Constants.NS_URI_XMLNS, prefix);
+ if (name != null) return name;
+ e = e.getParentNode();
+ }
+ return null;
+ }
}
1.8 +796 -796 xml-axis/java/src/org/apache/axis/utils/tcpmon.java
Index: tcpmon.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/tcpmon.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tcpmon.java 2001/06/15 23:16:26 1.7
+++ tcpmon.java 2001/07/12 15:04:59 1.8
@@ -71,851 +71,851 @@
*/
public class tcpmon extends JFrame {
- private JTabbedPane notebook = null ;
+ private JTabbedPane notebook = null ;
- static private int STATE_COLUMN = 0 ;
- static private int TIME_COLUMN = 1 ;
- static private int INHOST_COLUMN = 2 ;
- static private int OUTHOST_COLUMN = 3 ;
-
- class AdminPage extends JPanel {
- public JTextField port, host, tport ;
- public JTabbedPane noteb ;
- public JCheckBox proxyBox ;
-
- public AdminPage( JTabbedPane notebook, String name ) {
- JPanel mainPane = null ;
- JPanel buttons = null ;
- JButton addButton = null ;
-
- setLayout( new BorderLayout() );
- noteb = notebook ;
-
- GridBagLayout layout = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
-
- mainPane = new JPanel(layout);
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = GridBagConstraints.REMAINDER;
- mainPane.add( new JLabel("Create a new TCP/IP Monitor... "), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = 1 ;
- mainPane.add( new JLabel("Listen Port # "), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = GridBagConstraints.REMAINDER ;
- mainPane.add( port = new JTextField(3), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = 1 ;
- mainPane.add( new JLabel("Target Hostname "), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = GridBagConstraints.REMAINDER ;
- mainPane.add( host = new JTextField(30), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = 1 ;
- mainPane.add( new JLabel("Target Port # "), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = GridBagConstraints.REMAINDER ;
- mainPane.add( tport = new JTextField(3), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = 1 ;
- mainPane.add( addButton = new JButton( "Add" ), c );
-
- c.anchor = GridBagConstraints.WEST ;
- c.gridwidth = 1 ;
- mainPane.add( proxyBox = new JCheckBox( "Act As A Proxy" ), c );
-
- add( new JScrollPane( mainPane ), BorderLayout.CENTER );
-
- // addButton.setEnabled( false );
- addButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ( "Add".equals(event.getActionCommand()) ) {
- String tmp ;
- int lPort = Integer.parseInt(port.getText());
- String tHost = host.getText();
- int tPort = 0 ;
- tmp = tport.getText();
- if ( tmp != null && !tmp.equals("") )
+ static private int STATE_COLUMN = 0 ;
+ static private int TIME_COLUMN = 1 ;
+ static private int INHOST_COLUMN = 2 ;
+ static private int OUTHOST_COLUMN = 3 ;
+
+ class AdminPage extends JPanel {
+ public JTextField port, host, tport ;
+ public JTabbedPane noteb ;
+ public JCheckBox proxyBox ;
+
+ public AdminPage( JTabbedPane notebook, String name ) {
+ JPanel mainPane = null ;
+ JPanel buttons = null ;
+ JButton addButton = null ;
+
+ setLayout( new BorderLayout() );
+ noteb = notebook ;
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ mainPane = new JPanel(layout);
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ mainPane.add( new JLabel("Create a new TCP/IP Monitor... "), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = 1 ;
+ mainPane.add( new JLabel("Listen Port # "), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = GridBagConstraints.REMAINDER ;
+ mainPane.add( port = new JTextField(3), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = 1 ;
+ mainPane.add( new JLabel("Target Hostname "), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = GridBagConstraints.REMAINDER ;
+ mainPane.add( host = new JTextField(30), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = 1 ;
+ mainPane.add( new JLabel("Target Port # "), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = GridBagConstraints.REMAINDER ;
+ mainPane.add( tport = new JTextField(3), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = 1 ;
+ mainPane.add( addButton = new JButton( "Add" ), c );
+
+ c.anchor = GridBagConstraints.WEST ;
+ c.gridwidth = 1 ;
+ mainPane.add( proxyBox = new JCheckBox( "Act As A Proxy" ), c );
+
+ add( new JScrollPane( mainPane ), BorderLayout.CENTER );
+
+ // addButton.setEnabled( false );
+ addButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ( "Add".equals(event.getActionCommand()) ) {
+ String tmp ;
+ int lPort = Integer.parseInt(port.getText());
+ String tHost = host.getText();
+ int tPort = 0 ;
+ tmp = tport.getText();
+ if ( tmp != null && !tmp.equals("") )
tPort = Integer.parseInt(tmp );
- new Listener( noteb, null, lPort, tHost, tPort,
- proxyBox.isSelected() );
+ new Listener( noteb, null, lPort, tHost, tPort,
+ proxyBox.isSelected() );
- port.setText(null);
- host.setText(null);
- tport.setText(null);
- }
- };
- });
-
- proxyBox.addChangeListener( new BasicButtonListener(proxyBox) {
- public void stateChanged(ChangeEvent event) {
- JCheckBox box = (JCheckBox) event.getSource();
- boolean state = box.isSelected();
- tport.setEnabled( !state );
- host.setEnabled( !state );
- }
- });
-
- notebook.addTab( name, this );
- notebook.repaint();
- notebook.setSelectedIndex( notebook.getTabCount()-1 );
- }
- };
+ port.setText(null);
+ host.setText(null);
+ tport.setText(null);
+ }
+ };
+ });
- class SocketWaiter extends Thread {
- ServerSocket sSocket = null ;
- Listener listener ;
- int port ;
- boolean pleaseStop = false ;
-
- public SocketWaiter(Listener l, int p) {
- listener = l ;
- port = p ;
- start();
- }
+ proxyBox.addChangeListener( new BasicButtonListener(proxyBox) {
+ public void stateChanged(ChangeEvent event) {
+ JCheckBox box = (JCheckBox) event.getSource();
+ boolean state = box.isSelected();
+ tport.setEnabled( !state );
+ host.setEnabled( !state );
+ }
+ });
- public void run() {
- try {
- listener.setLeft( new JLabel(" Waiting for Connection..." ) );
- sSocket = new ServerSocket( port );
- for(;;) {
- Socket inSocket = sSocket.accept();
- if ( pleaseStop ) break ;
- new Connection( listener, inSocket );
- inSocket = null ;
- }
- }
- catch( Exception exp ) {
- JLabel tmp = new JLabel( exp.toString() );
- tmp.setForeground( Color.red );
- listener.setLeft( tmp );
- listener.setRight( new JLabel("") );
- listener.stop();
- }
- }
+ notebook.addTab( name, this );
+ notebook.repaint();
+ notebook.setSelectedIndex( notebook.getTabCount()-1 );
+ }
+ };
- public void halt() {
- try {
- pleaseStop = true ;
- new Socket( "127.0.0.1", port );
- if ( sSocket != null ) sSocket.close();
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
- }
+ class SocketWaiter extends Thread {
+ ServerSocket sSocket = null ;
+ Listener listener ;
+ int port ;
+ boolean pleaseStop = false ;
+
+ public SocketWaiter(Listener l, int p) {
+ listener = l ;
+ port = p ;
+ start();
+ }
+
+ public void run() {
+ try {
+ listener.setLeft( new JLabel(" Waiting for Connection..." ) );
+ sSocket = new ServerSocket( port );
+ for(;;) {
+ Socket inSocket = sSocket.accept();
+ if ( pleaseStop ) break ;
+ new Connection( listener, inSocket );
+ inSocket = null ;
+ }
+ }
+ catch( Exception exp ) {
+ JLabel tmp = new JLabel( exp.toString() );
+ tmp.setForeground( Color.red );
+ listener.setLeft( tmp );
+ listener.setRight( new JLabel("") );
+ listener.stop();
+ }
+ }
- class SocketRR extends Thread {
- Socket inSocket = null ;
- Socket outSocket = null ;
- JTextArea textArea ;
- InputStream in = null ;
- OutputStream out = null ;
- boolean xmlFormat ;
-
- public SocketRR(Socket inputSocket, InputStream inputStream,
- Socket outputSocket, OutputStream outputStream,
- JTextArea _textArea, boolean format) {
- inSocket = inputSocket ;
- in = inputStream ;
- outSocket = outputSocket ;
- out = outputStream ;
- textArea = _textArea ;
- xmlFormat = format ;
- start();
+ public void halt() {
+ try {
+ pleaseStop = true ;
+ new Socket( "127.0.0.1", port );
+ if ( sSocket != null ) sSocket.close();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
}
- public void run() {
- try {
- byte[] buffer = new byte[4096];
- byte[] tmpbuffer = new byte[8192];
- int saved = 0 ;
- int len ;
- int i1, i2 ;
- int i ;
-
- int thisIndent, nextIndent=0 ;
-
- for ( ;; ) {
- len = in.available();
- if ( len == 0 ) len = 1 ;
- if ( saved+len > 4096 ) len = 4096-saved ;
- len = in.read(buffer,saved,len);
- if ( len == -1 ) break ;
-
- // No matter how we may (or may not) format it, send it
- // on unformatted - we don't want to mess with how its
- // sent to the other side, just how its displayed
- out.write( buffer, saved, len );
-
- if ( xmlFormat ) {
- // Do XML Formatting
- i1 = 0 ;
- i2 = 0 ;
- saved = 0 ;
- for( ; i1 < len ; i1++ ) {
- if ( buffer[i1] != '<' && buffer[i1] != '/' )
- tmpbuffer[i2++] = buffer[i1];
- else {
- if ( i1+1 < len ) {
- byte b1 = buffer[i1];
- byte b2 = buffer[i1+1];
- thisIndent = -1 ;
-
- if ( b1 == '<' ) {
- if ( b2 != '/' ) thisIndent = nextIndent++ ;
- else thisIndent = --nextIndent ;
- }
- else if ( b1 == '/' ) {
- if ( b2 == '>' ) nextIndent-- ;
- }
-
- if ( thisIndent != -1 ) {
- tmpbuffer[i2++] = (byte) '\n' ;
- for ( i = 0 ; i < thisIndent ; i++ )
- tmpbuffer[i2++] = (byte) ' ' ;
- }
+ class SocketRR extends Thread {
+ Socket inSocket = null ;
+ Socket outSocket = null ;
+ JTextArea textArea ;
+ InputStream in = null ;
+ OutputStream out = null ;
+ boolean xmlFormat ;
+
+ public SocketRR(Socket inputSocket, InputStream inputStream,
+ Socket outputSocket, OutputStream outputStream,
+ JTextArea _textArea, boolean format) {
+ inSocket = inputSocket ;
+ in = inputStream ;
+ outSocket = outputSocket ;
+ out = outputStream ;
+ textArea = _textArea ;
+ xmlFormat = format ;
+ start();
+ }
- tmpbuffer[i2++] = buffer[i1];
+ public void run() {
+ try {
+ byte[] buffer = new byte[4096];
+ byte[] tmpbuffer = new byte[8192];
+ int saved = 0 ;
+ int len ;
+ int i1, i2 ;
+ int i ;
+
+ int thisIndent, nextIndent=0 ;
+
+ for ( ;; ) {
+ len = in.available();
+ if ( len == 0 ) len = 1 ;
+ if ( saved+len > 4096 ) len = 4096-saved ;
+ len = in.read(buffer,saved,len);
+ if ( len == -1 ) break ;
+
+ // No matter how we may (or may not) format it, send it
+ // on unformatted - we don't want to mess with how its
+ // sent to the other side, just how its displayed
+ out.write( buffer, saved, len );
+
+ if ( xmlFormat ) {
+ // Do XML Formatting
+ i1 = 0 ;
+ i2 = 0 ;
+ saved = 0 ;
+ for( ; i1 < len ; i1++ ) {
+ if ( buffer[i1] != '<' && buffer[i1] != '/' )
+ tmpbuffer[i2++] = buffer[i1];
+ else {
+ if ( i1+1 < len ) {
+ byte b1 = buffer[i1];
+ byte b2 = buffer[i1+1];
+ thisIndent = -1 ;
+
+ if ( b1 == '<' ) {
+ if ( b2 != '/' ) thisIndent = nextIndent++ ;
+ else thisIndent = --nextIndent ;
+ }
+ else if ( b1 == '/' ) {
+ if ( b2 == '>' ) nextIndent-- ;
+ }
+
+ if ( thisIndent != -1 ) {
+ tmpbuffer[i2++] = (byte) '\n' ;
+ for ( i = 0 ; i < thisIndent ; i++ )
+ tmpbuffer[i2++] = (byte) ' ' ;
+ }
+
+ tmpbuffer[i2++] = buffer[i1];
+ }
+ else {
+ // last char is special - save it
+ saved = 1 ;
+ }
+ }
+ }
+ textArea.append( new String( tmpbuffer, 0, i2 ) );
+ }
+ else {
+ textArea.append( new String( buffer, 0, len ) );
+ }
+ this.sleep(3); // Let other threads have a chance to run
}
- else {
- // last char is special - save it
- saved = 1 ;
- }
- }
+ halt();
}
- textArea.append( new String( tmpbuffer, 0, i2 ) );
- }
- else {
- textArea.append( new String( buffer, 0, len ) );
- }
- this.sleep(3); // Let other threads have a chance to run
- }
- halt();
- }
- catch( Exception e ) {
- // e.printStackTrace();
- }
- }
- public void halt() {
- try {
- if ( inSocket != null ) inSocket.close();
- if ( outSocket != null ) outSocket.close();
- inSocket = null ;
- outSocket = null ;
- if ( in != null ) in.close();
- if ( out != null ) out.close();
- in = null ;
- out = null ;
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
+ catch( Exception e ) {
+ // e.printStackTrace();
+ }
+ }
+ public void halt() {
+ try {
+ if ( inSocket != null ) inSocket.close();
+ if ( outSocket != null ) outSocket.close();
+ inSocket = null ;
+ outSocket = null ;
+ if ( in != null ) in.close();
+ if ( out != null ) out.close();
+ in = null ;
+ out = null ;
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
}
- }
- class Connection extends Thread {
- Listener listener ;
- boolean active ;
- String fromHost ;
- String time ;
- JTextArea inputText ;
- JScrollPane inputScroll ;
- JTextArea outputText ;
- JScrollPane outputScroll ;
- Socket inSocket ;
- Socket outSocket ;
- Thread clientThread ;
- Thread serverThread ;
- SocketRR rr1 = null ;
- SocketRR rr2 = null ;
-
- public Connection(Listener l, Socket s ) {
- listener = l ;
- inSocket = s ;
- start();
- }
+ class Connection extends Thread {
+ Listener listener ;
+ boolean active ;
+ String fromHost ;
+ String time ;
+ JTextArea inputText ;
+ JScrollPane inputScroll ;
+ JTextArea outputText ;
+ JScrollPane outputScroll ;
+ Socket inSocket ;
+ Socket outSocket ;
+ Thread clientThread ;
+ Thread serverThread ;
+ SocketRR rr1 = null ;
+ SocketRR rr2 = null ;
+
+ public Connection(Listener l, Socket s ) {
+ listener = l ;
+ inSocket = s ;
+ start();
+ }
- public void run() {
- try {
- InetAddress h = inSocket.getInetAddress();
- DateFormat df = new SimpleDateFormat("MM/dd/yy hh:mm:ss aa");
-
- active = true ;
- fromHost = h.getHostName();
- time = df.format( new Date() );
-
- int count = listener.connections.size();
- listener.tableModel.insertRow(count+1, new Object[] { "Active",
- time,
- fromHost,
- "---" });
- listener.connections.add( this );
- inputText = new JTextArea( null, null, 20, 80 );
- inputScroll = new JScrollPane( inputText );
- outputText = new JTextArea( null, null, 20, 80 );
- outputScroll = new JScrollPane( outputText );
-
- ListSelectionModel lsm = listener.connectionTable.getSelectionModel();
- if ( count == 0 || lsm.getLeadSelectionIndex() == 0 ) {
- listener.outPane.setVisible( false );
- int divLoc = listener.outPane.getDividerLocation();
-
- listener.setLeft( inputScroll );
- listener.setRight( outputScroll );
-
- listener.removeButton.setEnabled(false);
- listener.removeAllButton.setEnabled(true);
- listener.saveButton.setEnabled(true);
- listener.outPane.setDividerLocation(divLoc);
- listener.outPane.setVisible( true );
- }
-
- String targetHost = listener.hostField.getText();
- int targetPort = Integer.parseInt(listener.tPortField.getText());
-
- InputStream tmpIn1 = null ;
- OutputStream tmpOut1 = null ;
-
- InputStream tmpIn2 = null ;
- OutputStream tmpOut2 = null ;
-
- tmpIn1 = inSocket.getInputStream();
- tmpOut1 = inSocket.getOutputStream();
-
- String bufferedData = null ;
-
- if ( listener.isProxyBox.isSelected() ) {
- // Check if we're a proxy
- int ch ;
- byte[] b = new byte[1];
- StringBuffer buf = new StringBuffer();
- String s ;
-
- for ( ;; ) {
- int len ;
-
- len = tmpIn1.read(b,0,1);
- if ( len == -1 ) break ;
- s = new String( b );
- buf.append( s );
- if ( b[0] != '\n' ) continue ;
- break ;
- }
-
- bufferedData = buf.toString();
-
- if ( bufferedData.startsWith( "GET " ) ||
- bufferedData.startsWith( "POST " ) ) {
- int start, end ;
- URL url ;
-
- start = bufferedData.indexOf( ' ' )+1;
- while( bufferedData.charAt(start) == ' ' ) start++ ;
- end = bufferedData.indexOf( ' ', start );
- String tmp = bufferedData.substring( start, end );
- if ( tmp.charAt(0) == '/' ) tmp = tmp.substring(1);
- url = new URL( tmp );
- targetHost = url.getHost();
- targetPort = url.getPort();
- if ( targetPort == -1 ) targetPort = 80 ;
- int index = listener.connections.indexOf( this );
- listener.tableModel.setValueAt( targetHost, index+1,
- OUTHOST_COLUMN );
-
- bufferedData = bufferedData.substring( 0, start) +
- url.getFile() +
- bufferedData.substring( end );
- }
- }
-
- outSocket = new Socket(targetHost, targetPort );
-
- tmpIn2 = outSocket.getInputStream();
- tmpOut2 = outSocket.getOutputStream();
-
- if ( bufferedData != null ) {
- byte[] b = bufferedData.getBytes();
- tmpOut2.write( b );
- inputText.append( bufferedData );
- }
-
- boolean format = listener.xmlFormatBox.isSelected();
-
- rr1 = new SocketRR( inSocket, tmpIn1, outSocket,
- tmpOut2, inputText, format );
- rr2 = new SocketRR( outSocket, tmpIn2, inSocket,
- tmpOut1, outputText, format );
-
- while( rr1.isAlive() || rr2.isAlive() ) {
- Thread.sleep( 10 );
- }
- rr1 = null ;
- rr2 = null ;
-
- active = false ;
- inSocket.close();
- inSocket = null ;
- outSocket.close();
- outSocket = null ;
-
- int index = listener.connections.indexOf( this );
- if ( index >= 0 )
- listener.tableModel.setValueAt( "Done", 1+index, STATE_COLUMN );
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
+ public void run() {
+ try {
+ InetAddress h = inSocket.getInetAddress();
+ DateFormat df = new SimpleDateFormat("MM/dd/yy hh:mm:ss aa");
+
+ active = true ;
+ fromHost = h.getHostName();
+ time = df.format( new Date() );
+
+ int count = listener.connections.size();
+ listener.tableModel.insertRow(count+1, new Object[] { "Active",
+ time,
+ fromHost,
+ "---" });
+ listener.connections.add( this );
+ inputText = new JTextArea( null, null, 20, 80 );
+ inputScroll = new JScrollPane( inputText );
+ outputText = new JTextArea( null, null, 20, 80 );
+ outputScroll = new JScrollPane( outputText );
+
+ ListSelectionModel lsm = listener.connectionTable.getSelectionModel();
+ if ( count == 0 || lsm.getLeadSelectionIndex() == 0 ) {
+ listener.outPane.setVisible( false );
+ int divLoc = listener.outPane.getDividerLocation();
+
+ listener.setLeft( inputScroll );
+ listener.setRight( outputScroll );
+
+ listener.removeButton.setEnabled(false);
+ listener.removeAllButton.setEnabled(true);
+ listener.saveButton.setEnabled(true);
+ listener.outPane.setDividerLocation(divLoc);
+ listener.outPane.setVisible( true );
+ }
- public void halt() {
- try {
- // if ( inSocket != null ) inSocket.close();
- // inSocket = null ;
- // if ( outSocket != null ) outSocket.close();
- // outSocket = null ;
- if ( rr1 != null ) rr1.halt();
- if ( rr2 != null ) rr2.halt();
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
+ String targetHost = listener.hostField.getText();
+ int targetPort = Integer.parseInt(listener.tPortField.getText());
+
+ InputStream tmpIn1 = null ;
+ OutputStream tmpOut1 = null ;
+
+ InputStream tmpIn2 = null ;
+ OutputStream tmpOut2 = null ;
+
+ tmpIn1 = inSocket.getInputStream();
+ tmpOut1 = inSocket.getOutputStream();
+
+ String bufferedData = null ;
+
+ if ( listener.isProxyBox.isSelected() ) {
+ // Check if we're a proxy
+ int ch ;
+ byte[] b = new byte[1];
+ StringBuffer buf = new StringBuffer();
+ String s ;
+
+ for ( ;; ) {
+ int len ;
+
+ len = tmpIn1.read(b,0,1);
+ if ( len == -1 ) break ;
+ s = new String( b );
+ buf.append( s );
+ if ( b[0] != '\n' ) continue ;
+ break ;
+ }
+
+ bufferedData = buf.toString();
+
+ if ( bufferedData.startsWith( "GET " ) ||
+ bufferedData.startsWith( "POST " ) ) {
+ int start, end ;
+ URL url ;
+
+ start = bufferedData.indexOf( ' ' )+1;
+ while( bufferedData.charAt(start) == ' ' ) start++ ;
+ end = bufferedData.indexOf( ' ', start );
+ String tmp = bufferedData.substring( start, end );
+ if ( tmp.charAt(0) == '/' ) tmp = tmp.substring(1);
+ url = new URL( tmp );
+ targetHost = url.getHost();
+ targetPort = url.getPort();
+ if ( targetPort == -1 ) targetPort = 80 ;
+ int index = listener.connections.indexOf( this );
+ listener.tableModel.setValueAt( targetHost, index+1,
+ OUTHOST_COLUMN );
+
+ bufferedData = bufferedData.substring( 0, start) +
+ url.getFile() +
+ bufferedData.substring( end );
+ }
+ }
+
+ outSocket = new Socket(targetHost, targetPort );
+
+ tmpIn2 = outSocket.getInputStream();
+ tmpOut2 = outSocket.getOutputStream();
+
+ if ( bufferedData != null ) {
+ byte[] b = bufferedData.getBytes();
+ tmpOut2.write( b );
+ inputText.append( bufferedData );
+ }
+
+ boolean format = listener.xmlFormatBox.isSelected();
+
+ rr1 = new SocketRR( inSocket, tmpIn1, outSocket,
+ tmpOut2, inputText, format );
+ rr2 = new SocketRR( outSocket, tmpIn2, inSocket,
+ tmpOut1, outputText, format );
+
+ while( rr1.isAlive() || rr2.isAlive() ) {
+ Thread.sleep( 10 );
+ }
+ rr1 = null ;
+ rr2 = null ;
+
+ active = false ;
+ inSocket.close();
+ inSocket = null ;
+ outSocket.close();
+ outSocket = null ;
+
+ int index = listener.connections.indexOf( this );
+ if ( index >= 0 )
+ listener.tableModel.setValueAt( "Done", 1+index, STATE_COLUMN );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ public void halt() {
+ try {
+ // if ( inSocket != null ) inSocket.close();
+ // inSocket = null ;
+ // if ( outSocket != null ) outSocket.close();
+ // outSocket = null ;
+ if ( rr1 != null ) rr1.halt();
+ if ( rr2 != null ) rr2.halt();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
- public void remove() {
- try {
- halt();
- int index = listener.connections.indexOf( this );
- listener.tableModel.removeRow( index+1 );
- listener.connections.remove( index );
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
+ public void remove() {
+ try {
+ halt();
+ int index = listener.connections.indexOf( this );
+ listener.tableModel.removeRow( index+1 );
+ listener.connections.remove( index );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
}
- }
-
- class Listener extends JPanel {
- public Socket inputSocket = null ;
- public Socket outputSocket = null ;
- public JTextField portField = null ;
- public JTextField hostField = null ;
- public JTextField tPortField = null ;
- public JCheckBox isProxyBox = null ;
- public JButton stopButton = null ;
- public JButton removeButton = null ;
- public JButton removeAllButton = null ;
- public JCheckBox xmlFormatBox = null ;
- public JButton saveButton = null ;
- public JButton switchButton = null ;
- public JButton closeButton = null ;
- public JTable connectionTable = null ;
- public DefaultTableModel tableModel = null ;
- public JSplitPane outPane = null ;
- public ServerSocket sSocket = null ;
- public SocketWaiter sw = null ;
- public JPanel leftPanel = null ;
- public JPanel rightPanel = null ;
- public JTabbedPane notebook = null ;
-
- final public Vector connections = new Vector();
-
- public Listener(JTabbedPane _notebook, String name,
- int listenPort, String host, int targetPort,
- boolean isProxy)
- {
- notebook = _notebook ;
- if ( name == null ) name = "Port " + listenPort ;
-
- setLayout( new BorderLayout() );
-
- // 1st component is just a row of labels and 1-line entry fields
- /////////////////////////////////////////////////////////////////////
- JPanel top = new JPanel();
- top.setLayout( new BoxLayout(top, BoxLayout.X_AXIS) );
- top.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- top.add( stopButton = new JButton( "Start" ) );
- top.add( Box.createRigidArea(new Dimension(5,0)) );
- top.add( new JLabel( " Listen Port: ", SwingConstants.RIGHT ) );
- top.add( portField = new JTextField( ""+listenPort, 3 ) );
- top.add( new JLabel( " Host:", SwingConstants.RIGHT ) );
- top.add( hostField = new JTextField( host, 30 ) );
- top.add( new JLabel( " Port: ", SwingConstants.RIGHT ) );
- top.add( tPortField = new JTextField( ""+targetPort, 3 ) );
- top.add( Box.createRigidArea(new Dimension(5,0)) );
- top.add( isProxyBox = new JCheckBox("Proxy") );
-
- isProxyBox.addChangeListener( new BasicButtonListener(isProxyBox) {
- public void stateChanged(ChangeEvent event) {
- JCheckBox box = (JCheckBox) event.getSource();
- boolean state = box.isSelected();
- tPortField.setEnabled( !state );
- hostField.setEnabled( !state );
- }
- });
- isProxyBox.setSelected(isProxy);
-
- portField.setEditable(false);
- portField.setMaximumSize(new Dimension(50, Short.MAX_VALUE) );
- hostField.setEditable(false);
- hostField.setMaximumSize(new Dimension(85,Short.MAX_VALUE) );
- tPortField.setEditable(false);
- tPortField.setMaximumSize(new Dimension(50,Short.MAX_VALUE) );
-
- stopButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ( "Stop".equals(event.getActionCommand()) ) stop();
- if ( "Start".equals(event.getActionCommand()) ) start();
- };
- });
-
- add( top, BorderLayout.NORTH );
-
- // 2nd component is a split pane with a table on the top
- // and the request/response text areas on the bottom
- /////////////////////////////////////////////////////////////////////
-
- tableModel = new DefaultTableModel(new String[] {"State",
- "Time",
- "Request Host",
- "Target Host"},
- 0 );
-
- connectionTable = new JTable(1,2);
- connectionTable.setModel( tableModel );
- connectionTable.setSelectionMode(ListSelectionModel.
- MULTIPLE_INTERVAL_SELECTION);
- TableColumn col ;
- col = connectionTable.getColumnModel().getColumn(STATE_COLUMN);
- col.setMaxWidth( col.getPreferredWidth()/2 );
-
- ListSelectionModel sel = connectionTable.getSelectionModel();
- sel.addListSelectionListener( new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent event) {
- if (event.getValueIsAdjusting()) return ;
- ListSelectionModel m = (ListSelectionModel) event.getSource();
- int divLoc = outPane.getDividerLocation();
- if (m.isSelectionEmpty()) {
- setLeft( new JLabel(" Waiting for Connection..." ) );
- setRight( new JLabel("") );
- removeButton.setEnabled(false);
- removeAllButton.setEnabled(false);
- saveButton.setEnabled(false);
- }
- else {
- int row = m.getLeadSelectionIndex();
- if ( row == 0 ) {
- if ( connections.size() == 0 ) {
+
+ class Listener extends JPanel {
+ public Socket inputSocket = null ;
+ public Socket outputSocket = null ;
+ public JTextField portField = null ;
+ public JTextField hostField = null ;
+ public JTextField tPortField = null ;
+ public JCheckBox isProxyBox = null ;
+ public JButton stopButton = null ;
+ public JButton removeButton = null ;
+ public JButton removeAllButton = null ;
+ public JCheckBox xmlFormatBox = null ;
+ public JButton saveButton = null ;
+ public JButton switchButton = null ;
+ public JButton closeButton = null ;
+ public JTable connectionTable = null ;
+ public DefaultTableModel tableModel = null ;
+ public JSplitPane outPane = null ;
+ public ServerSocket sSocket = null ;
+ public SocketWaiter sw = null ;
+ public JPanel leftPanel = null ;
+ public JPanel rightPanel = null ;
+ public JTabbedPane notebook = null ;
+
+ final public Vector connections = new Vector();
+
+ public Listener(JTabbedPane _notebook, String name,
+ int listenPort, String host, int targetPort,
+ boolean isProxy)
+ {
+ notebook = _notebook ;
+ if ( name == null ) name = "Port " + listenPort ;
+
+ setLayout( new BorderLayout() );
+
+ // 1st component is just a row of labels and 1-line entry fields
+ /////////////////////////////////////////////////////////////////////
+ JPanel top = new JPanel();
+ top.setLayout( new BoxLayout(top, BoxLayout.X_AXIS) );
+ top.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+ top.add( stopButton = new JButton( "Start" ) );
+ top.add( Box.createRigidArea(new Dimension(5,0)) );
+ top.add( new JLabel( " Listen Port: ", SwingConstants.RIGHT ) );
+ top.add( portField = new JTextField( ""+listenPort, 3 ) );
+ top.add( new JLabel( " Host:", SwingConstants.RIGHT ) );
+ top.add( hostField = new JTextField( host, 30 ) );
+ top.add( new JLabel( " Port: ", SwingConstants.RIGHT ) );
+ top.add( tPortField = new JTextField( ""+targetPort, 3 ) );
+ top.add( Box.createRigidArea(new Dimension(5,0)) );
+ top.add( isProxyBox = new JCheckBox("Proxy") );
+
+ isProxyBox.addChangeListener( new BasicButtonListener(isProxyBox) {
+ public void stateChanged(ChangeEvent event) {
+ JCheckBox box = (JCheckBox) event.getSource();
+ boolean state = box.isSelected();
+ tPortField.setEnabled( !state );
+ hostField.setEnabled( !state );
+ }
+ });
+ isProxyBox.setSelected(isProxy);
+
+ portField.setEditable(false);
+ portField.setMaximumSize(new Dimension(50, Short.MAX_VALUE) );
+ hostField.setEditable(false);
+ hostField.setMaximumSize(new Dimension(85,Short.MAX_VALUE) );
+ tPortField.setEditable(false);
+ tPortField.setMaximumSize(new Dimension(50,Short.MAX_VALUE) );
+
+ stopButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ( "Stop".equals(event.getActionCommand()) ) stop();
+ if ( "Start".equals(event.getActionCommand()) ) start();
+ };
+ });
+
+ add( top, BorderLayout.NORTH );
+
+ // 2nd component is a split pane with a table on the top
+ // and the request/response text areas on the bottom
+ /////////////////////////////////////////////////////////////////////
+
+ tableModel = new DefaultTableModel(new String[] {"State",
+ "Time",
+ "Request Host",
+ "Target Host"},
+ 0 );
+
+ connectionTable = new JTable(1,2);
+ connectionTable.setModel( tableModel );
+ connectionTable.setSelectionMode(ListSelectionModel.
+ MULTIPLE_INTERVAL_SELECTION);
+ TableColumn col ;
+ col = connectionTable.getColumnModel().getColumn(STATE_COLUMN);
+ col.setMaxWidth( col.getPreferredWidth()/2 );
+
+ ListSelectionModel sel = connectionTable.getSelectionModel();
+ sel.addListSelectionListener( new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent event) {
+ if (event.getValueIsAdjusting()) return ;
+ ListSelectionModel m = (ListSelectionModel) event.getSource();
+ int divLoc = outPane.getDividerLocation();
+ if (m.isSelectionEmpty()) {
+ setLeft( new JLabel(" Waiting for Connection..." ) );
+ setRight( new JLabel("") );
+ removeButton.setEnabled(false);
+ removeAllButton.setEnabled(false);
+ saveButton.setEnabled(false);
+ }
+ else {
+ int row = m.getLeadSelectionIndex();
+ if ( row == 0 ) {
+ if ( connections.size() == 0 ) {
setLeft(new JLabel(" Waiting for connection..."));
setRight(new JLabel(""));
removeButton.setEnabled(false);
removeAllButton.setEnabled(false);
saveButton.setEnabled(false);
- }
- else {
+ }
+ else {
Connection conn = (Connection) connections.lastElement();
setLeft( conn.inputScroll );
setRight( conn.outputScroll );
removeButton.setEnabled(false);
removeAllButton.setEnabled(true);
saveButton.setEnabled(true);
- }
- }
- else {
- Connection conn = (Connection) connections.get(row-1);
- setLeft( conn.inputScroll );
- setRight( conn.outputScroll );
- removeButton.setEnabled(true);
- removeAllButton.setEnabled(true);
- saveButton.setEnabled(true);
- }
- }
- outPane.setDividerLocation(divLoc);
- }} );
- tableModel.addRow( new Object[] { "---", "Most Recent", "---", "---" } );
-
- JPanel tablePane = new JPanel();
- tablePane.setLayout( new BorderLayout() );
-
- JScrollPane tableScrollPane = new JScrollPane( connectionTable );
- tablePane.add( tableScrollPane, BorderLayout.CENTER );
- JPanel buttons = new JPanel();
- buttons.setLayout( new BoxLayout(buttons, BoxLayout.X_AXIS) );
- buttons.setBorder( BorderFactory.createEmptyBorder(5,5,5,5) );
- buttons.add( removeButton = new JButton("Remove Selected") );
- buttons.add( Box.createRigidArea(new Dimension(5,0)) );
- buttons.add( removeAllButton = new JButton("Remove All") );
- tablePane.add( buttons, BorderLayout.SOUTH );
-
- removeButton.setEnabled( false );
- removeButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ( "Remove Selected".equals(event.getActionCommand()) ) remove();
- };
- });
-
- removeAllButton.setEnabled( false );
- removeAllButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ( "Remove All".equals(event.getActionCommand()) ) removeAll();
- };
- });
-
- // Add Response Section
- /////////////////////////////////////////////////////////////////////
- JPanel pane2 = new JPanel();
- pane2.setLayout( new BorderLayout() );
-
- leftPanel = new JPanel();
- leftPanel.setAlignmentX( Component.LEFT_ALIGNMENT );
- leftPanel.setLayout( new BoxLayout(leftPanel, BoxLayout.Y_AXIS) );
- leftPanel.add( new JLabel(" Request") );
- leftPanel.add( new JLabel(" Waiting for connection" ));
-
- rightPanel = new JPanel();
- rightPanel.setLayout( new BoxLayout(rightPanel, BoxLayout.Y_AXIS) );
- rightPanel.add( new JLabel(" Response") );
- rightPanel.add( new JLabel("") );
-
- outPane = new JSplitPane(0, leftPanel, rightPanel );
- outPane.setDividerSize(4);
- pane2.add( outPane, BorderLayout.CENTER );
-
- JPanel bottomButtons = new JPanel();
- bottomButtons.setLayout( new BoxLayout(bottomButtons, BoxLayout.X_AXIS));
- bottomButtons.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- bottomButtons.add( xmlFormatBox = new JCheckBox( "XML Format" ) );
- bottomButtons.add( Box.createRigidArea(new Dimension(5,0)) );
- bottomButtons.add( saveButton = new JButton( "Save" ) );
- bottomButtons.add( Box.createRigidArea(new Dimension(5,0)) );
- bottomButtons.add( switchButton = new JButton( "Switch Layout" ) );
- bottomButtons.add( Box.createHorizontalGlue() );
- bottomButtons.add( closeButton = new JButton( "Close" ) );
- pane2.add( bottomButtons, BorderLayout.SOUTH );
-
- saveButton.setEnabled( false );
- saveButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ( "Save".equals(event.getActionCommand()) ) save();
- };
- });
-
- switchButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ("Switch Layout".equals(event.getActionCommand()) ) {
- int v = outPane.getOrientation();
- if ( v == 0 ) // top/bottom
+ }
+ }
+ else {
+ Connection conn = (Connection) connections.get(row-1);
+ setLeft( conn.inputScroll );
+ setRight( conn.outputScroll );
+ removeButton.setEnabled(true);
+ removeAllButton.setEnabled(true);
+ saveButton.setEnabled(true);
+ }
+ }
+ outPane.setDividerLocation(divLoc);
+ }} );
+ tableModel.addRow( new Object[] { "---", "Most Recent", "---", "---" } );
+
+ JPanel tablePane = new JPanel();
+ tablePane.setLayout( new BorderLayout() );
+
+ JScrollPane tableScrollPane = new JScrollPane( connectionTable );
+ tablePane.add( tableScrollPane, BorderLayout.CENTER );
+ JPanel buttons = new JPanel();
+ buttons.setLayout( new BoxLayout(buttons, BoxLayout.X_AXIS) );
+ buttons.setBorder( BorderFactory.createEmptyBorder(5,5,5,5) );
+ buttons.add( removeButton = new JButton("Remove Selected") );
+ buttons.add( Box.createRigidArea(new Dimension(5,0)) );
+ buttons.add( removeAllButton = new JButton("Remove All") );
+ tablePane.add( buttons, BorderLayout.SOUTH );
+
+ removeButton.setEnabled( false );
+ removeButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ( "Remove Selected".equals(event.getActionCommand()) ) remove();
+ };
+ });
+
+ removeAllButton.setEnabled( false );
+ removeAllButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ( "Remove All".equals(event.getActionCommand()) ) removeAll();
+ };
+ });
+
+ // Add Response Section
+ /////////////////////////////////////////////////////////////////////
+ JPanel pane2 = new JPanel();
+ pane2.setLayout( new BorderLayout() );
+
+ leftPanel = new JPanel();
+ leftPanel.setAlignmentX( Component.LEFT_ALIGNMENT );
+ leftPanel.setLayout( new BoxLayout(leftPanel, BoxLayout.Y_AXIS) );
+ leftPanel.add( new JLabel(" Request") );
+ leftPanel.add( new JLabel(" Waiting for connection" ));
+
+ rightPanel = new JPanel();
+ rightPanel.setLayout( new BoxLayout(rightPanel, BoxLayout.Y_AXIS) );
+ rightPanel.add( new JLabel(" Response") );
+ rightPanel.add( new JLabel("") );
+
+ outPane = new JSplitPane(0, leftPanel, rightPanel );
+ outPane.setDividerSize(4);
+ pane2.add( outPane, BorderLayout.CENTER );
+
+ JPanel bottomButtons = new JPanel();
+ bottomButtons.setLayout( new BoxLayout(bottomButtons, BoxLayout.X_AXIS));
+ bottomButtons.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+ bottomButtons.add( xmlFormatBox = new JCheckBox( "XML Format" ) );
+ bottomButtons.add( Box.createRigidArea(new Dimension(5,0)) );
+ bottomButtons.add( saveButton = new JButton( "Save" ) );
+ bottomButtons.add( Box.createRigidArea(new Dimension(5,0)) );
+ bottomButtons.add( switchButton = new JButton( "Switch Layout" ) );
+ bottomButtons.add( Box.createHorizontalGlue() );
+ bottomButtons.add( closeButton = new JButton( "Close" ) );
+ pane2.add( bottomButtons, BorderLayout.SOUTH );
+
+ saveButton.setEnabled( false );
+ saveButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ( "Save".equals(event.getActionCommand()) ) save();
+ };
+ });
+
+ switchButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ("Switch Layout".equals(event.getActionCommand()) ) {
+ int v = outPane.getOrientation();
+ if ( v == 0 ) // top/bottom
outPane.setOrientation(1);
- else // left/right
+ else // left/right
outPane.setOrientation(0);
- outPane.setDividerLocation(0.5);
- }
- };
- });
+ outPane.setDividerLocation(0.5);
+ }
+ };
+ });
- closeButton.addActionListener( new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if ("Close".equals(event.getActionCommand()) )
- close();
- };
- });
-
- JSplitPane pane1 = new JSplitPane( 0 );
- pane1.setDividerSize(4);
- pane1.setTopComponent( tablePane );
- pane1.setBottomComponent( pane2 );
- pane1.setDividerLocation( 150 );
- add( pane1, BorderLayout.CENTER );
-
- //
- /////////////////////////////////////////////////////////////////////
- sel.setSelectionInterval(0,0);
- outPane.setDividerLocation( 150 );
- notebook.addTab( name, this );
- start();
- };
+ closeButton.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if ("Close".equals(event.getActionCommand()) )
+ close();
+ };
+ });
+
+ JSplitPane pane1 = new JSplitPane( 0 );
+ pane1.setDividerSize(4);
+ pane1.setTopComponent( tablePane );
+ pane1.setBottomComponent( pane2 );
+ pane1.setDividerLocation( 150 );
+ add( pane1, BorderLayout.CENTER );
+
+ //
+ /////////////////////////////////////////////////////////////////////
+ sel.setSelectionInterval(0,0);
+ outPane.setDividerLocation( 150 );
+ notebook.addTab( name, this );
+ start();
+ };
+
+ public void setLeft(Component left) {
+ leftPanel.remove(1);
+ leftPanel.add(left);
+ }
- public void setLeft(Component left) {
- leftPanel.remove(1);
- leftPanel.add(left);
- }
+ public void setRight(Component right) {
+ rightPanel.remove(1);
+ rightPanel.add(right);
+ }
- public void setRight(Component right) {
- rightPanel.remove(1);
- rightPanel.add(right);
- }
+ public void start() {
+ int port = Integer.parseInt( portField.getText() );
+ portField.setText( ""+port );
+ int i = notebook.indexOfComponent( this );
+ notebook.setTitleAt( i, "Port " + port );
+
+ int tmp = Integer.parseInt( tPortField.getText() );
+ tPortField.setText( ""+tmp );
+
+ sw = new SocketWaiter( this, port );
+ stopButton.setText( "Stop" );
+
+ portField.setEditable(false);
+ hostField.setEditable(false);
+ tPortField.setEditable(false);
+ isProxyBox.setEnabled(false);
+ }
- public void start() {
- int port = Integer.parseInt( portField.getText() );
- portField.setText( ""+port );
- int i = notebook.indexOfComponent( this );
- notebook.setTitleAt( i, "Port " + port );
-
- int tmp = Integer.parseInt( tPortField.getText() );
- tPortField.setText( ""+tmp );
-
- sw = new SocketWaiter( this, port );
- stopButton.setText( "Stop" );
-
- portField.setEditable(false);
- hostField.setEditable(false);
- tPortField.setEditable(false);
- isProxyBox.setEnabled(false);
- }
+ public void close() {
+ stop();
+ notebook.remove( this );
+ }
- public void close() {
- stop();
- notebook.remove( this );
- }
+ public void stop() {
+ try {
+ for ( int i = 0 ; i < connections.size() ; i++ ) {
+ Connection conn = (Connection) connections.get( i );
+ conn.halt();
+ }
+ sw.halt();
+ stopButton.setText( "Start" );
+ portField.setEditable(true);
+ hostField.setEditable(true);
+ tPortField.setEditable(true);
+ isProxyBox.setEnabled(true);
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
- public void stop() {
- try {
- for ( int i = 0 ; i < connections.size() ; i++ ) {
- Connection conn = (Connection) connections.get( i );
- conn.halt();
- }
- sw.halt();
- stopButton.setText( "Start" );
- portField.setEditable(true);
- hostField.setEditable(true);
- tPortField.setEditable(true);
- isProxyBox.setEnabled(true);
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
+ public void remove() {
+ ListSelectionModel lsm = connectionTable.getSelectionModel();
+ int bot = lsm.getMinSelectionIndex();
+ int top = lsm.getMaxSelectionIndex();
- public void remove() {
- ListSelectionModel lsm = connectionTable.getSelectionModel();
- int bot = lsm.getMinSelectionIndex();
- int top = lsm.getMaxSelectionIndex();
-
- for ( int i = top ; i >= bot ; i-- ) {
- ((Connection) connections.get(i-1)).remove();
- }
- if ( bot > connections.size() ) bot = connections.size();
- lsm.setSelectionInterval(bot,bot);
- }
+ for ( int i = top ; i >= bot ; i-- ) {
+ ((Connection) connections.get(i-1)).remove();
+ }
+ if ( bot > connections.size() ) bot = connections.size();
+ lsm.setSelectionInterval(bot,bot);
+ }
- public void removeAll() {
- while ( connections.size() > 0 )
- ((Connection)connections.get(0)).remove();
- ListSelectionModel lsm = connectionTable.getSelectionModel();
- lsm.clearSelection();
- lsm.setSelectionInterval(0,0);
- }
+ public void removeAll() {
+ while ( connections.size() > 0 )
+ ((Connection)connections.get(0)).remove();
+ ListSelectionModel lsm = connectionTable.getSelectionModel();
+ lsm.clearSelection();
+ lsm.setSelectionInterval(0,0);
+ }
- public void save() {
- JFileChooser dialog = new JFileChooser( "." );
- int rc = dialog.showSaveDialog( this );
- if ( rc == JFileChooser.APPROVE_OPTION ) {
- try {
- File file = dialog.getSelectedFile();
- FileOutputStream out = new FileOutputStream( file );
-
- ListSelectionModel lsm = connectionTable.getSelectionModel();
- rc = lsm.getLeadSelectionIndex();
- if ( rc == 0 ) rc = connections.size();
- Connection conn = (Connection) connections.get( rc-1 );
-
- rc = Integer.parseInt( portField.getText() );
- out.write( (new String("Listen Port: " + rc + "\n" )).getBytes() );
- out.write( (new String("Target Host: " + hostField.getText() +
- "\n" )).getBytes() );
- rc = Integer.parseInt( tPortField.getText() );
- out.write( (new String("Target Port: " + rc + "\n" )).getBytes() );
-
- out.write( (new String("==== Request ====\n" )).getBytes() );
- out.write( conn.inputText.getText().getBytes() );
-
- out.write( (new String("==== Response ====\n" )).getBytes() );
- out.write( conn.outputText.getText().getBytes() );
-
- out.close();
+ public void save() {
+ JFileChooser dialog = new JFileChooser( "." );
+ int rc = dialog.showSaveDialog( this );
+ if ( rc == JFileChooser.APPROVE_OPTION ) {
+ try {
+ File file = dialog.getSelectedFile();
+ FileOutputStream out = new FileOutputStream( file );
+
+ ListSelectionModel lsm = connectionTable.getSelectionModel();
+ rc = lsm.getLeadSelectionIndex();
+ if ( rc == 0 ) rc = connections.size();
+ Connection conn = (Connection) connections.get( rc-1 );
+
+ rc = Integer.parseInt( portField.getText() );
+ out.write( (new String("Listen Port: " + rc + "\n" )).getBytes() );
+ out.write( (new String("Target Host: " + hostField.getText() +
+ "\n" )).getBytes() );
+ rc = Integer.parseInt( tPortField.getText() );
+ out.write( (new String("Target Port: " + rc + "\n" )).getBytes() );
+
+ out.write( (new String("==== Request ====\n" )).getBytes() );
+ out.write( conn.inputText.getText().getBytes() );
+
+ out.write( (new String("==== Response ====\n" )).getBytes() );
+ out.write( conn.outputText.getText().getBytes() );
+
+ out.close();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
}
- catch( Exception e ) {
- e.printStackTrace();
+ };
+
+ public tcpmon(int listenPort, String targetHost, int targetPort) {
+ super( "TCPMonitor" );
+
+ notebook = new JTabbedPane();
+ this.getContentPane().add( notebook );
+
+ new AdminPage( notebook, "Admin" );
+
+ if ( listenPort != 0 ) {
+ if ( targetHost == null )
+ new Listener( notebook, null, listenPort,
+ targetHost, targetPort, true );
+ else
+ new Listener( notebook, null, listenPort,
+ targetHost, targetPort, false );
+ notebook.setSelectedIndex( 1 );
}
- }
- }
- };
- public tcpmon(int listenPort, String targetHost, int targetPort) {
- super( "TCPMonitor" );
+ this.pack();
+ this.setSize( 600, 600 );
+ this.setVisible( true );
+ }
- notebook = new JTabbedPane();
- this.getContentPane().add( notebook );
+ protected void processWindowEvent(WindowEvent event) {
+ switch( event.getID() ) {
+ case WindowEvent.WINDOW_CLOSING: exit();
+ break ;
+ default: super.processWindowEvent(event);
+ break ;
+ }
+ }
- new AdminPage( notebook, "Admin" );
-
- if ( listenPort != 0 ) {
- if ( targetHost == null )
- new Listener( notebook, null, listenPort,
- targetHost, targetPort, true );
- else
- new Listener( notebook, null, listenPort,
- targetHost, targetPort, false );
- notebook.setSelectedIndex( 1 );
+ private void exit() {
+ System.exit(0);
}
- this.pack();
- this.setSize( 600, 600 );
- this.setVisible( true );
- }
-
- protected void processWindowEvent(WindowEvent event) {
- switch( event.getID() ) {
- case WindowEvent.WINDOW_CLOSING: exit();
- break ;
- default: super.processWindowEvent(event);
- break ;
+ public void setInputPort(int port) {
}
- }
- private void exit() {
- System.exit(0);
- }
-
- public void setInputPort(int port) {
- }
-
- public void setOutputHostPort(char hostName, int port) {
- }
-
- public static void main(String[] args) {
- try {
- if ( args.length == 3 ) {
- int p1 = Integer.parseInt( args[0] );
- int p2 = Integer.parseInt( args[2] );
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- new tcpmon( p1, args[1], p2 );
- }
- else if ( args.length == 1 ) {
- int p1 = Integer.parseInt( args[0] );
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- new tcpmon( p1, null, 0 );
- }
- else if ( args.length != 0 ) {
- System.err.println( "Usage: " +
- "tcpmon [listenPort targetHost targetPort]\n");
- }
- else {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- new tcpmon(0,null,0);
- }
+ public void setOutputHostPort(char hostName, int port) {
}
- catch( Throwable exp ) {
- exp.printStackTrace();
+
+ public static void main(String[] args) {
+ try {
+ if ( args.length == 3 ) {
+ int p1 = Integer.parseInt( args[0] );
+ int p2 = Integer.parseInt( args[2] );
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ new tcpmon( p1, args[1], p2 );
+ }
+ else if ( args.length == 1 ) {
+ int p1 = Integer.parseInt( args[0] );
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ new tcpmon( p1, null, 0 );
+ }
+ else if ( args.length != 0 ) {
+ System.err.println( "Usage: " +
+ "tcpmon [listenPort targetHost targetPort]\n");
+ }
+ else {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ new tcpmon(0,null,0);
+ }
+ }
+ catch( Throwable exp ) {
+ exp.printStackTrace();
+ }
}
- }
}
1.2 +1 -1 xml-axis/java/src/org/apache/axis/utils/cache/JavaClass.java
Index: JavaClass.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/cache/JavaClass.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavaClass.java 2001/05/02 23:19:27 1.1
+++ JavaClass.java 2001/07/12 15:05:11 1.2
@@ -75,7 +75,7 @@
public JavaClass(Class jc) {
this.jc = jc;
}
-
+
/**
* Return the java.lang.Class associated with this entry
*/
1.5 +1 -1 xml-axis/java/src/org/apache/axis/utils/cache/JavaMethod.java
Index: JavaMethod.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/cache/JavaMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JavaMethod.java 2001/06/04 18:56:53 1.4
+++ JavaMethod.java 2001/07/12 15:05:13 1.5
@@ -102,7 +102,7 @@
workinglist.copyInto(this.methods);
}
}
-
+
/**
* Attempt to find the closest matching method based on the number
* of arguments only. Note: if there are multiple matches, one