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/02/14 22:35:29 UTC
cvs commit: xml-axis/java/src/org/apache/axis/utils Admin.java Debug.java
gdaniels 01/02/14 13:35:29
Modified: java/src/org/apache/axis/client TransportRoutingClient.java
java/src/org/apache/axis/handlers Router.java
java/src/org/apache/axis/server SimpleAxisEngine.java
java/src/org/apache/axis/suppliers FactorySupplier.java
SimpleSupplier.java
java/src/org/apache/axis/utils Admin.java Debug.java
Added: java/src/org/apache/axis/registries SimpleRegistry.java
SupplierRegistry.java
Removed: java/src/org/apache/axis/registries
SimpleHandlerRegistry.java
SimpleServiceRegistry.java
Log:
Fix up a few things, and implement SupplierRegistries.
1) Make SupplierRegistry. This guy actually holds Suppliers,
not Handlers, and when he's asked for a Handler he looks
up the Supplier and calls its getHandler().
2) Merge SimpleHandlerRegistry and SimpleServiceRegistry into
SimpleRegistry, which takes a constructor argument pointing
to the .reg file to use.
3) Use SupplierRegistries as demonstrations in the Admin
utility and the SimpleAxisEngine class. Admin parses a
"lifecycle" attribute on Handler deployments, and creates
either a SimpleSupplier or a FactorySupplier as
appropriate.
4) Fix TransportRoutingClient to use TARGET_SERVICE instead
of TRANS_ID.
5) Fix Router to use generic HandlerRegistry, so it doesn't
care if it's a SimpleRegistry or a SupplierRegistry.
6) Add a little debugging info to Suppliers.
Revision Changes Path
1.4 +1 -1 xml-axis/java/src/org/apache/axis/client/TransportRoutingClient.java
Index: TransportRoutingClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/TransportRoutingClient.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransportRoutingClient.java 2001/02/12 01:11:13 1.3
+++ TransportRoutingClient.java 2001/02/14 21:35:24 1.4
@@ -96,7 +96,7 @@
/** The transport is http.
*/
- msgContext.setProperty(MessageContext.TRANS_ID, HTTPConstants.TRANSPORT_ID);
+ msgContext.setProperty(MessageContext.TARGET_SERVICE, Constants.SERVLET_TARGET);
/** If we were a real servlet, we might have made the SOAPAction
* HTTP header available like this...
1.4 +3 -3 xml-axis/java/src/org/apache/axis/handlers/Router.java
Index: Router.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/Router.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Router.java 2001/02/12 01:11:15 1.3
+++ Router.java 2001/02/14 21:35:25 1.4
@@ -55,7 +55,7 @@
package org.apache.axis.handlers;
import org.apache.axis.*;
-import org.apache.axis.registries.SimpleServiceRegistry;
+import org.apache.axis.registries.HandlerRegistry;
import org.apache.axis.utils.Debug;
/** A <code>Router</code> is a Handler which has only one purpose in life:
@@ -71,7 +71,7 @@
public void invoke(MessageContext msgContext) throws AxisFault
{
Debug.Print( 1, "Enter: Router::invoke" );
- SimpleServiceRegistry registry = (SimpleServiceRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
+ HandlerRegistry registry = (HandlerRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
if (registry == null)
throw new AxisFault(new NullPointerException("Router: No registry property in context!"));
@@ -96,7 +96,7 @@
public void undo(MessageContext msgContext)
{
Debug.Print( 1, "Enter: Router::undo" );
- SimpleServiceRegistry registry = (SimpleServiceRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
+ HandlerRegistry registry = (HandlerRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
String target = (String)msgContext.getProperty(MessageContext.TARGET_SERVICE);
1.1 xml-axis/java/src/org/apache/axis/registries/SimpleRegistry.java
Index: SimpleRegistry.java
===================================================================
/*
* 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.registries ;
import java.io.* ;
import java.util.* ;
import org.apache.axis.* ;
import org.apache.axis.registries.* ;
/**
*
* @author Doug Davis (dug@us.ibm.com)
* @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();
}
catch( Exception e ) {
e.printStackTrace( System.err );
}
}
};
1.1 xml-axis/java/src/org/apache/axis/registries/SupplierRegistry.java
Index: SupplierRegistry.java
===================================================================
/*
* 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.registries ;
import java.io.* ;
import java.util.* ;
import org.apache.axis.* ;
import org.apache.axis.registries.* ;
import org.apache.axis.suppliers.*;
/** A <code>SupplierRegistry</code> contains Suppliers, which are used
* by the find() method to obtain actual Handler references. This
* allows creational dynamics to be configured on a per-handler basis.
*
* @author Glen Daniels (gdaniels@allaire.com)
*/
public class SupplierRegistry implements HandlerRegistry {
protected String fileName;
protected Hashtable suppliers = null ;
public SupplierRegistry(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 ( suppliers == null ) suppliers = new Hashtable();
suppliers.put( key, new SimpleSupplier(handler) );
save();
}
public void add(String key, Supplier supplier) {
if ( suppliers == null ) suppliers = new Hashtable();
suppliers.put( key, supplier );
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 ( suppliers == null ) return( null );
Object old = suppliers.remove( key );
save();
// What should we do here?
return null;
}
/**
* Given a 'key' return the corresponding Handler
*/
public Handler find(String key) {
if ( suppliers == null ) return( null );
Supplier supplier = (Supplier)suppliers.get(key);
if (supplier == null) return null;
return supplier.getHandler();
}
/**
* Return the list (in an array) of keys for the Handlers
*/
public String[] list(){
int loop = 0 ;
if ( suppliers == null ) return( null );
String[] result = new String[suppliers.size()];
Enumeration keys = suppliers.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 );
suppliers = (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( suppliers );
fos.close();
}
catch( Exception e ) {
e.printStackTrace( System.err );
}
}
};
1.18 +4 -2 xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java
Index: SimpleAxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SimpleAxisEngine.java 2001/02/12 01:11:16 1.17
+++ SimpleAxisEngine.java 2001/02/14 21:35:27 1.18
@@ -91,12 +91,14 @@
public void init() {
// Load the simple handler registry and init it
Debug.Print( 1, "Enter: SimpleAxisEngine::init" );
- HandlerRegistry hr = new SimpleHandlerRegistry();
+ //HandlerRegistry hr = new SimpleRegistry("handlers.reg");
+ HandlerRegistry hr = new SupplierRegistry("handlers-supp.reg");
hr.init();
addOption( Constants.HANDLER_REGISTRY, hr );
// Load the simple deployed services registry and init it
- HandlerRegistry sr = new SimpleServiceRegistry();
+ //HandlerRegistry sr = new SimpleRegistry("services.reg");
+ HandlerRegistry sr = new SupplierRegistry("services-supp.reg");
sr.init();
addOption( Constants.SERVICE_REGISTRY, sr );
Debug.Print( 1, "Exit: SimpleAxisEngine::init" );
1.3 +2 -0 xml-axis/java/src/org/apache/axis/suppliers/FactorySupplier.java
Index: FactorySupplier.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/suppliers/FactorySupplier.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FactorySupplier.java 2001/02/10 04:39:58 1.2
+++ FactorySupplier.java 2001/02/14 21:35:27 1.3
@@ -58,6 +58,7 @@
import java.util.Hashtable;
import org.apache.axis.Supplier;
import org.apache.axis.Handler;
+import org.apache.axis.utils.Debug;
/** A <code>FactorySupplier</code> always gives you a new Handler instance.
*
@@ -79,6 +80,7 @@
try {
Handler handler = (Handler)_class.newInstance();
handler.setOptions(_options);
+ Debug.Print(1, "FactorySupplier returning new instance of " + _class.getName());
return handler;
} catch (IllegalAccessException e1) {
e1.printStackTrace();
1.3 +2 -0 xml-axis/java/src/org/apache/axis/suppliers/SimpleSupplier.java
Index: SimpleSupplier.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/suppliers/SimpleSupplier.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SimpleSupplier.java 2001/02/10 04:39:58 1.2
+++ SimpleSupplier.java 2001/02/14 21:35:27 1.3
@@ -57,6 +57,7 @@
import org.apache.axis.Supplier;
import org.apache.axis.Handler;
+import org.apache.axis.utils.Debug;
/** A <code>SimpleSupplier</code> just returns a single static instance.
*
@@ -73,6 +74,7 @@
public Handler getHandler()
{
+ Debug.Print(1, "SimpleSupplier returning " + _handler);
return _handler;
}
}
1.12 +28 -8 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Admin.java 2001/02/10 04:39:59 1.11
+++ Admin.java 2001/02/14 21:35:28 1.12
@@ -64,6 +64,7 @@
import org.apache.axis.registries.* ;
import org.apache.axis.handlers.* ;
import org.apache.axis.utils.* ;
+import org.apache.axis.suppliers.*;
import org.apache.axis.* ;
@@ -72,16 +73,18 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class Admin {
- private static SimpleHandlerRegistry hr = null ;
- private static SimpleServiceRegistry sr = null ;
+ private static HandlerRegistry hr = null ;
+ private static HandlerRegistry sr = null ;
private void init() {
if ( hr == null ) {
- hr = new SimpleHandlerRegistry();
+ // hr = new SimpleRegistry("handlers.reg");
+ hr = new SupplierRegistry("handlers-supp.reg");
hr.init();
}
if ( sr == null ) {
- sr = new SimpleServiceRegistry();
+ // sr = new SimpleRegistry("services.reg");
+ sr = new SupplierRegistry("services-supp.reg");
sr.init();
}
}
@@ -150,10 +153,27 @@
if ( type.equals( "handler" ) ) {
String cls = elem.getAttribute( "class" );
System.out.println( "Deploying handler: " + name );
- h = hr.find( name );
- if ( h == null ) h = (Handler) Class.forName(cls).newInstance();
- getOptions( elem, h );
- hr.add( name, h );
+
+ if (hr instanceof SupplierRegistry) {
+ String lifeCycle = elem.getAttribute("lifecycle");
+ Supplier supplier;
+
+ if ("factory".equals(lifeCycle)) {
+ supplier = new FactorySupplier(Class.forName(cls), new Hashtable());
+ } else if ("static".equals(lifeCycle)) {
+ supplier = new SimpleSupplier((Handler)Class.forName(cls).newInstance());
+ } else {
+ // Default to static for now
+ supplier = new SimpleSupplier((Handler)Class.forName(cls).newInstance());
+ }
+
+ ((SupplierRegistry)hr).add(name, supplier);
+ } else {
+ h = hr.find( name );
+ if ( h == null ) h = (Handler) Class.forName(cls).newInstance();
+ getOptions( elem, h );
+ hr.add( name, h );
+ }
}
else if ( type.equals( "chain" ) ) {
String flow = elem.getAttribute( "flow" );
1.4 +3 -1 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Debug.java 2001/02/10 04:39:59 1.3
+++ Debug.java 2001/02/14 21:35:28 1.4
@@ -104,8 +104,10 @@
if ( debugLevel < level ) return ;
try {
String msg = "Exception: " + exp ;
- if ( toScreen )
+ if ( toScreen ) {
System.err.println( msg );
+ exp.printStackTrace();
+ }
if ( toFile ) {
FileWriter fw = new FileWriter( "AxisDebug.log", true );
fw.write( msg, 0, msg.length() );