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 rs...@apache.org on 2002/08/21 01:23:28 UTC
cvs commit: xml-axis/java/src/org/apache/axis/components/net SocketFactoryFactory.java TransportClientPropertiesFactory.java
rsitze 2002/08/20 16:23:28
Modified: java/src/org/apache/axis/components/compiler
CompilerFactory.java
java/src/org/apache/axis AxisProperties.java
java/src/org/apache/axis/components/net
SocketFactoryFactory.java
TransportClientPropertiesFactory.java
Log:
Cleanup factory use. In the long term it may make sense to let
exceptions go out further, but given current arch. this is sufficient
and reads cleaner.
Revision Changes Path
1.3 +15 -17 xml-axis/java/src/org/apache/axis/components/compiler/CompilerFactory.java
Index: CompilerFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/compiler/CompilerFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CompilerFactory.java 2 Aug 2002 17:27:41 -0000 1.2
+++ CompilerFactory.java 20 Aug 2002 23:23:27 -0000 1.3
@@ -59,6 +59,8 @@
import org.apache.axis.utils.ClassUtils;
import org.apache.axis.utils.JavaUtils;
+import org.apache.commons.discovery.base.SPInterface;
+
import org.apache.axis.components.logger.LogFactory;
import org.apache.commons.logging.Log;
@@ -74,23 +76,19 @@
protected static Log log =
LogFactory.getLog(CompilerFactory.class.getName());
- public static Compiler getCompiler()
- {
- String compilerClassName = AxisProperties.getProperty("axis.Compiler");
- log.debug("axis.Compiler:" + compilerClassName);
- if (compilerClassName != null) {
- try {
- Class compilerClass = ClassUtils.forName(compilerClassName);
- if (Compiler.class.isAssignableFrom(compilerClass))
- return (Compiler)compilerClass.newInstance();
- } catch (Exception e) {
- // If something goes wrong here, should we just fall
- // through and use the default one?
- log.error(JavaUtils.getMessage("exception00"), e);
- }
- }
+ public static Compiler getCompiler() {
+ Compiler compiler =
+ (Compiler)AxisProperties.newInstance(
+ new SPInterface(Compiler.class, "axis.Compiler"),
+ Javac.class);
+
+ if (compiler == null) {
log.debug(JavaUtils.getMessage("defaultCompiler"));
- Compiler compiler = new Javac();
- return compiler;
+ compiler = new Javac();
}
+
+ log.debug("axis.Compiler:" + compiler.getClass().getName());
+
+ return compiler;
+ }
}
1.11 +54 -38 xml-axis/java/src/org/apache/axis/AxisProperties.java
Index: AxisProperties.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisProperties.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AxisProperties.java 18 Aug 2002 14:19:49 -0000 1.10
+++ AxisProperties.java 20 Aug 2002 23:23:27 -0000 1.11
@@ -67,6 +67,11 @@
import org.apache.commons.discovery.base.SPInterface;
import org.apache.commons.discovery.tools.ManagedProperties;
+import org.apache.axis.components.logger.LogFactory;
+import org.apache.commons.logging.Log;
+
+import org.apache.axis.utils.JavaUtils;
+
/**
* <p>Configuration properties for AXIS.
@@ -99,62 +104,73 @@
* @author Richard A. Sitze
*/
public class AxisProperties {
+ protected static Log log =
+ LogFactory.getLog(AxisProperties.class.getName());
+
public static Environment getDiscoverEnvironment() {
return new Environment(getCommonsGroupContext());
}
public static Object newInstance(Class spiClass, String defaultClass)
- throws DiscoveryException,
- InstantiationException,
- IllegalAccessException,
- NoSuchMethodException,
- InvocationTargetException
{
- SPInterface spi = new SPInterface(spiClass);
- return DiscoverClass.newInstance(getDiscoverEnvironment(),
- spi,
- (String) null,
- spi.createImplClass(defaultClass));
+ Object object;
+ try {
+ SPInterface spi = new SPInterface(spiClass);
+ object = DiscoverClass.newInstance(getDiscoverEnvironment(),
+ spi,
+ (String) null,
+ spi.createImplClass(defaultClass));
+ } catch (Exception e) {
+ log.error(JavaUtils.getMessage("exception00"), e);
+ object = null;
+ }
+ return object;
}
public static Object newInstance(Class spiClass, Class defaultClass)
- throws DiscoveryException,
- InstantiationException,
- IllegalAccessException,
- NoSuchMethodException,
- InvocationTargetException
{
- SPInterface spi = new SPInterface(spiClass);
- return DiscoverClass.newInstance(getDiscoverEnvironment(),
- spi,
- (String) null,
- spi.createImplClass(defaultClass));
+ Object object;
+ try {
+ SPInterface spi = new SPInterface(spiClass);
+ object = DiscoverClass.newInstance(getDiscoverEnvironment(),
+ spi,
+ (String) null,
+ spi.createImplClass(defaultClass));
+ } catch (Exception e) {
+ log.error(JavaUtils.getMessage("exception00"), e);
+ object = null;
+ }
+ return object;
}
public static Object newInstance(SPInterface spi, String defaultClass)
- throws DiscoveryException,
- InstantiationException,
- IllegalAccessException,
- NoSuchMethodException,
- InvocationTargetException
{
- return DiscoverClass.newInstance(getDiscoverEnvironment(),
- spi,
- (String) null,
- spi.createImplClass(defaultClass));
+ Object object;
+ try {
+ object = DiscoverClass.newInstance(getDiscoverEnvironment(),
+ spi,
+ (String) null,
+ spi.createImplClass(defaultClass));
+ } catch (Exception e) {
+ log.error(JavaUtils.getMessage("exception00"), e);
+ object = null;
+ }
+ return object;
}
public static Object newInstance(SPInterface spi, Class defaultClass)
- throws DiscoveryException,
- InstantiationException,
- IllegalAccessException,
- NoSuchMethodException,
- InvocationTargetException
{
- return DiscoverClass.newInstance(getDiscoverEnvironment(),
- spi,
- (String) null,
- spi.createImplClass(defaultClass));
+ Object object;
+ try {
+ object = DiscoverClass.newInstance(getDiscoverEnvironment(),
+ spi,
+ (String) null,
+ spi.createImplClass(defaultClass));
+ } catch (Exception e) {
+ log.error(JavaUtils.getMessage("exception00"), e);
+ object = null;
+ }
+ return object;
}
1.5 +18 -27 xml-axis/java/src/org/apache/axis/components/net/SocketFactoryFactory.java
Index: SocketFactoryFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/SocketFactoryFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SocketFactoryFactory.java 16 Aug 2002 22:51:21 -0000 1.4
+++ SocketFactoryFactory.java 20 Aug 2002 23:23:28 -0000 1.5
@@ -61,7 +61,6 @@
import org.apache.axis.components.logger.LogFactory;
import org.apache.commons.logging.Log;
-import org.apache.commons.discovery.base.ImplClass;
import org.apache.commons.discovery.base.SPInterface;
import java.lang.reflect.Constructor;
@@ -85,6 +84,8 @@
/** secure socket factory */
private static SocketFactory theSecureFactory = null;
+ private static final Class classes[] = new Class[] { Hashtable.class };
+
/**
* Returns a copy of the environment's default socket factory.
*
@@ -94,19 +95,14 @@
*/
public static synchronized SocketFactory getFactory(Hashtable attributes) {
if (theFactory == null) {
- try {
- Class classes[] = new Class[] { Hashtable.class };
- Object objects[] = new Object[] { attributes };
-
- theFactory = (SocketFactory)AxisProperties.newInstance(
- new SPInterface(SocketFactory.class,
- "axis.socketFactory",
- classes,
- objects),
- "org.apache.axis.components.net.DefaultSocketFactory");
- } catch (Exception e) {
- log.error(JavaUtils.getMessage("exception00"), e);
- }
+ Object objects[] = new Object[] { attributes };
+
+ theFactory = (SocketFactory)AxisProperties.newInstance(
+ new SPInterface(SocketFactory.class,
+ "axis.socketFactory",
+ classes,
+ objects),
+ "org.apache.axis.components.net.DefaultSocketFactory");
}
return theFactory;
}
@@ -121,19 +117,14 @@
public static synchronized SocketFactory getSecureFactory(
Hashtable attributes) {
if (theSecureFactory == null) {
- try {
- Class classes[] = new Class[] { Hashtable.class };
- Object objects[] = new Object[] { attributes };
-
- theSecureFactory = (SocketFactory)AxisProperties.newInstance(
- new SPInterface(SocketFactory.class,
- "axis.socketSecureFactory",
- classes,
- objects),
- "org.apache.axis.components.net.JSSESocketFactory");
- } catch (Exception e) {
- log.error(JavaUtils.getMessage("exception00"), e);
- }
+ Object objects[] = new Object[] { attributes };
+
+ theSecureFactory = (SocketFactory)AxisProperties.newInstance(
+ new SPInterface(SocketFactory.class,
+ "axis.socketSecureFactory",
+ classes,
+ objects),
+ "org.apache.axis.components.net.JSSESocketFactory");
}
return theSecureFactory;
}
1.2 +8 -14 xml-axis/java/src/org/apache/axis/components/net/TransportClientPropertiesFactory.java
Index: TransportClientPropertiesFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/TransportClientPropertiesFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportClientPropertiesFactory.java 16 Aug 2002 22:51:21 -0000 1.1
+++ TransportClientPropertiesFactory.java 20 Aug 2002 23:23:28 -0000 1.2
@@ -80,23 +80,17 @@
public static TransportClientProperties create(String protocol)
{
- TransportClientProperties tcp = null;
+ TransportClientProperties tcp =
+ (TransportClientProperties)cache.get(protocol);
- try {
- tcp = (TransportClientProperties)cache.get(protocol);
-
- if (tcp == null) {
- tcp = (TransportClientProperties)
- AxisProperties.newInstance(TransportClientProperties.class,
- (Class)defaults.get(protocol));
+ if (tcp == null) {
+ tcp = (TransportClientProperties)
+ AxisProperties.newInstance(TransportClientProperties.class,
+ (Class)defaults.get(protocol));
- if (tcp != null) {
- cache.put(protocol, tcp);
- }
+ if (tcp != null) {
+ cache.put(protocol, tcp);
}
- } catch (Exception e) {
- log.error(JavaUtils.getMessage("exception00"), e);
- tcp = null;
}
return tcp;