User: jung
Date: 01/01/04 06:45:07
Modified: src/org/jboss/zoap Environment.java HttpServer.java
HttpServerMBean.java zoap.dfPackage
Log:
exception redesign. Improved null-pointer treatment. coherent environment and
logging facilities.
LGPL references.
Revision Changes Path
1.3 +146 -162 zoap/src/org/jboss/zoap/Environment.java
Index: Environment.java
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/jboss/zoap/Environment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Environment.java 2000/12/04 12:35:59 1.2
+++ Environment.java 2001/01/04 14:45:06 1.3
@@ -1,210 +1,185 @@
/*
- * $Id: Environment.java,v 1.2 2000/12/04 12:35:59 jung Exp $
- * Copyright (c) 2000 infor:business solutions AG, Hauerstrasse 12,
- * D-66299 Friedrichsthal, Germany. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * $Source: /products/cvs/ejboss/zoap/src/org/jboss/zoap/Environment.java,v $
+ * The Zero-effort Object Access Package is a library to support XML/SOAP
serialisation and invocation.
+ * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
+ * D-66299 Friedrichsthal, Germany. All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jboss.zoap;
-
-import java.util.Properties;
-import java.io.PrintStream;
-import java.io.InputStream;
-
+import org.zoap.soap.meta.builtin.DefaultBinding;
+import org.zoap.xml.Schema;
import de.infor.ce.util.URN;
+import java.util.StringTokenizer;
+import java.util.Properties;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import de.infor.ce.console.Console;
/**
- * Environment collects all package-local configurations and provides an
- * interface for file-based and method-based access to them
- * @see <related>
- * @author $Author: jung $
- * @version $Revision: 1.2 $
+ * Environment contains static variables and other helping stuff that either
influence
+ * the compilation of the package or initialise its runtime environment from config
files.
+ * @author jung
+ * @version $Revision: 1.3 $
*/
public abstract class Environment {
-
- /**
- * how this module is called
- */
-
- public static final String moduleName="zoap";
-
- /**
- * where the resources needed to configure this module are found
- */
- public static final String resourcePath="./";
+ //
+ // Place your non-final public statics here
+ //
- /**
- * where the resources needed to configure this module are found
- */
-
- public static final String configFileSuffix=".conf";
-
- /**
- * whether debug messages are produced, compile-time switch
- */
-
- public static final int DEBUG_LEVEL=0;
+ /** the port on which the httpService is provided */
+ public static int HTTP_PORT = 2121;
- /**
- * runtime logging settings
- */
+ /** the JMX Name under which this server runs */
+ public static String JMX_NAME= "zoap:server=HTTP";
- public static int LOG_LEVEL=2;
+ //
+ // non-final public system statics
+ //
+ /** runtime logging settings */
+ public static int LOG_LEVEL = 1;
- /**
- * whether a config file is loaded
- */
+ /** the properties belonging to this module */
+ public static Properties PROPERTIES = System.getProperties();
- public static final boolean readConfigFile=false;
+ /** the logger for this module */
+ public static Console CONSOLE = null;
- /**
- * runtime streams, can be rerouted
- */
+ //
+ // final public system static
+ //
- public final static PrintStream out=System.out;
- public final static InputStream in=System.in;
- public final static PrintStream err=System.err;
+ /** whether debug messages are produced, compile-time switch */
+ public static final int DEBUG_LEVEL = 0;
- /** the port on which the httpService is provided */
- public static int httpPort = 2121;
+ /** how this module is called */
+ public static final String MODULE_NAME =
Environment.class.getName().substring(0,
+ Environment.class.getName().length() - 12);
- /**
- * initialisation is done at class loading time
- */
+ /** where the resources needed to configure this module are found */
+ public static final String RESOURCE_PATH = "";
- static{
+ /** whether a config file is loaded */
+ public static final boolean READ_CONFIG_FILE = true;
- if(DEBUG_LEVEL>0)
- out.println(Environment.class.toString()+".static initializer");
+ /** where the resources needed to configure this module are found */
+ public static final String CONFIG_FILE_SUFFIX = ".conf";
- if(readConfigFile) {
-
- // clone the system settings
- Properties properties = new Properties(System.getProperties());
+ //
+ // static initialisation part, DO NOT MODIFY
+ //
- try{
+ /** initialisation is done at class loading time */
+ static {
- // and add your personal configuration file
- properties.load(Thread.currentThread().getContextClassLoader().
- getResourceAsStream(resourcePath+moduleName+configFileSuffix));
+ try {
+ CONSOLE =
de.infor.ce.console.Environment.CONSOLE_FACTORY.createConsole(MODULE_NAME);
+ } catch (Exception e) { }
- } catch(Exception e) {
+ if (READ_CONFIG_FILE) {
+ try {
- if(DEBUG_LEVEL>0 || LOG_LEVEL>0)
- err.println(Environment.class.toString()+".static initializer: "+
- " encountered "+e+" maybe config file does not exist.");
+ if (DEBUG_LEVEL > 0)
+ CONSOLE.log(Environment.class.toString() +
+ "_static initializer: trying to load
configuration resource file " +
+ RESOURCE_PATH + MODULE_NAME +
CONFIG_FILE_SUFFIX);
- }
+ // and add your personal configuration file
+ PROPERTIES.load(Environment.class.getClassLoader().
+ getResourceAsStream(RESOURCE_PATH + MODULE_NAME +
CONFIG_FILE_SUFFIX));
+ } catch (Exception e) {
- if(properties.contains(moduleName+".LOG_LEVEL")) {
- try{
- LOG_LEVEL=new
Integer(properties.getProperty(moduleName+".LOG_LEVEL")).intValue();
- } catch(Exception e) {
-
- if(DEBUG_LEVEL>0 || LOG_LEVEL>0)
- err.println(Environment.class.toString()+".static initializer: "+
- " encountered "+e+" while parsing property LOG_LEVEL.");
-
-
+ if (DEBUG_LEVEL > 0) {
+ CONSOLE.error(Environment.class.toString() +
+ "_static initializer: encountered " + e + "
while trying to load configuration resource file " +
+ RESOURCE_PATH + MODULE_NAME +
CONFIG_FILE_SUFFIX);
+ CONSOLE.exception(e);
+ }
+ }
}
- }
+ try {
+ Field[] fields = Environment.class.getFields();
- if(properties.contains(moduleName+".httpPort")) {
- try{
- httpPort=new
Integer(properties.getProperty(moduleName+".httpPort")).intValue();
- } catch(Exception e) {
-
- if(DEBUG_LEVEL>0 || LOG_LEVEL>0)
- err.println(Environment.class.toString()+".static initializer: "+
- " encountered "+e+" while parsing property httpPort.");
-
-
+ for (int count = 0; count < fields.length; count++) {
+ try {
+ if
(PROPERTIES.containsKey(fields[count].getName()) &&
+
Modifier.isStatic(fields[count].getModifiers()) &&
+
!Modifier.isFinal(fields[count].getModifiers())) {
+
+
+ if (DEBUG_LEVEL > 0)
+
CONSOLE.log(Environment.class.toString() +
+ "_static initializer: trying
to initialize field " + fields[count].getName()
+ + " with configuration
property " +
+
PROPERTIES.getProperty(fields[count].getName()));
+
+ fields[count].setAccessible(true);
+
+ if
(fields[count].getType().equals(boolean.class) ||
+
fields[count].getType().equals(Boolean.class)) {
+
fields[count].set(Environment.class,
+ new
Boolean(PROPERTIES.getProperty(fields[count].getName())));
+ } else if
(fields[count].getType().equals(int.class) ||
+
fields[count].getType().equals(Integer.class)) {
+
fields[count].set(Environment.class,
+ new
Integer(PROPERTIES.getProperty(fields[count].getName())));
+ } else if
(fields[count].getType().equals(double.class) ||
+
fields[count].getType().equals(Double.class)) {
+
fields[count].set(Environment.class,
+ new
Double(PROPERTIES.getProperty(fields[count].getName())));
+ } else if
(fields[count].getType().equals(float.class) ||
+
fields[count].getType().equals(Float.class)) {
+
fields[count].set(Environment.class,
+ new
Float(PROPERTIES.getProperty(fields[count].getName())));
+ } else if
(fields[count].getType().equals(String.class)) {
+
fields[count].set(Environment.class, PROPERTIES.
+
getProperty(fields[count].getName()));
+ } else {
+
+ if (DEBUG_LEVEL > 0)
+
CONSOLE.warning(Environment.class.toString() +
+ "_static initializer:
type " + fields[count].getType().getName() + " of field " +
+
fields[count].getName() + " is not supported by the reflection configurator.");
+
+ }
+
+ }
+ } catch (Exception e) {
+ if (DEBUG_LEVEL > 0) {
+
CONSOLE.error(Environment.class.toString() +
+ "_static initializer: encountered " +
e + " while trying to initialise field " + fields[count].getName());
+ CONSOLE.exception(e);
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (DEBUG_LEVEL > 0) {
+ CONSOLE.error(Environment.class.toString() +
+ "_static initializer: encountered " + e + " while
trying to get class fields");
+ CONSOLE.exception(e);
+ }
}
- }
-
- }
- } // static
+ } // static
+} // Environment
-}
-
-/*
- * $Log: Environment.java,v $
- * Revision 1.2 2000/12/04 12:35:59 jung
- * adopted to latest jboss container,
- *
- * added decimal and date
- *
- * removed some problems due to forward-referencing in meta-data
- *
- * added serialisation policy
- *
- * Revision 1.1.1.1 2000/08/10 21:06:52 jung
- * Initial import.
- *
- *
- * Revision 1.1.2.3 2000/08/04 17:20:18 jung
- * close to beta stadium. Meta-Data import now works.
- *
- * Revision 1.1.2.2 2000/07/17 12:46:15 jung
- * refactored package and meta-model
- *
- * Revision 1.1.2.1 2000/07/13 12:46:19 jung
- * package renaming, most of the zoap stuff now under org.zoap
- * util and http stay infor.ce, containerInvoker etc move to org.jboss
- *
- * changed the makefile, adopted most of the licenses
- *
- * Revision 1.1.1.1 2000/07/06 14:11:26 jung
- * Import of a pre beta version of ZOAP source with a new directory structure,
- * ant-based make, apache-kind of license, etc.
- *
- * jars are coming later because of cvs-history reasons.
- *
- * Revision 1.1.1.1 2000/06/19 12:04:12 jung
- * imported ZOAPackage that should
- * go into a seperate Open Source project
- *
- * Revision 1.1.2.2 2000/06/15 14:50:06 jung
- * first SOAP-enabled container runs
- *
- * Revision 1.1.2.1 2000/06/08 17:15:47 jung
- * added initial soap service that uses the infor:X framework.
- *
- * Revision 1.1 2000/06/05 09:16:55 jung
- * added an initial revision of infor:X, the
- * XML (de-)serialisation service of infor:CE.
- *
- * supports meta-data structures, namespaces, schemas.
- *
- * lacks collection support, forward-references, multiple roots
- * and external resolution.
- *
- * Revision 1.2 2000/05/16 15:29:33 jung
- * added initial vbsf support
- *
- * Revision 1.1.1.1 2000/05/15 10:38:34 jung
- * Initial import of the directory structure. Contains templates and a batch file to
- * create API documentation. Also contains the not yet
- * fully running directory service (AFDS).
- */
1.3 +22 -53 zoap/src/org/jboss/zoap/HttpServer.java
Index: HttpServer.java
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/jboss/zoap/HttpServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpServer.java 2000/12/04 12:35:59 1.2
+++ HttpServer.java 2001/01/04 14:45:06 1.3
@@ -1,21 +1,22 @@
-/*
- * $Id: HttpServer.java,v 1.2 2000/12/04 12:35:59 jung Exp $
- * Copyright (c) 2000 infor:business solutions AG, Hauerstrasse 12,
- * D-66299 Friedrichsthal, Germany. All Rights Reserved.
+/*
+ * $Source: /products/cvs/ejboss/zoap/src/org/jboss/zoap/HttpServer.java,v $
+ * The Zero-effort Object Access Package is a library to support XML/SOAP
serialisation and invocation.
+ * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
+ * D-66299 Friedrichsthal, Germany. All Rights Reserved.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jboss.zoap;
@@ -43,20 +44,13 @@
/** construct server */
public HttpServer() throws java.net.MalformedURLException,
java.net.UnknownHostException {
-
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + "()\n");
-
- server = new org.zoap.soap.HttpServer(Environment.httpPort);
+ server = new org.zoap.soap.HttpServer(Environment.HTTP_PORT);
}
/** start the server */
public void start() throws java.io.IOException {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".start()\n");
-
server.start();
}
@@ -64,8 +58,6 @@
public void stop() {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".stop()\n");
server.stop();
}
@@ -74,9 +66,8 @@
public void postDeregister() {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".postDeregister()\n");
+
server.stop();
}
@@ -85,35 +76,25 @@
* mabye we should restrict registrations to happen only after that state
*/
public void postRegister(Boolean p0) {
+
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".postDeregister()\n");
}
/** called before the service is deregistered maybe we should lock the server
not accept anymore registrations? */
public void preDeregister() throws Exception {
+
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".preDeregister()\n");
}
/** called before the service is registered in the MBeanserver with a given
name default is to start the HttpServer */
public ObjectName preRegister(MBeanServer p0, ObjectName p1) throws Exception {
-
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".preRegister()\n");
-
- return new ObjectName(Environment.moduleName + ":server=HTTP");
+ return new ObjectName(Environment.JMX_NAME);
}
public java.net.URL getURL() {
-
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".getURL()\n");
-
- return server.getURL();
+ return server.getURL();
}
/**
@@ -124,9 +105,6 @@
public void registerSoapRouter(String directory, SoapRouter object)
throws SoapDuplicateRegistrationException {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".registerSoapRouter(" +
directory + "," + object + ")\n");
-
server.registerSoapRouter(directory, object);
}
@@ -136,9 +114,6 @@
public void unRegisterSoapRouter(String directory)
throws SoapNotRegisteredException {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".unRegisterSoapRouter(" +
directory + ")\n");
-
server.unRegisterSoapRouter(directory);
}
@@ -150,8 +125,6 @@
SoapMessage response)
throws SoapMessageException {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".receiveRequest(" + handle
+ "," + msg + ")\n");
server.receiveRequest(handle, msg, response);
}
@@ -160,8 +133,6 @@
/** register a SOAP object @arg object in the server and return a handle @arg
String for its identification. */
public String registerSoapObject(SoapObject object) {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".registerSoapObject(" +
object + ")\n");
return server.registerSoapObject(object);
}
@@ -170,8 +141,6 @@
/** unRegister a SOAP object given its directory */
public void unRegisterSoapObject(String handle) throws
SoapNotRegisteredException {
- if (Environment.DEBUG_LEVEL > 0)
- Environment.out.print(toString() + ".unRegisterSoapObject(" +
handle + ")\n");
server.unRegisterSoapObject(handle);
}
1.3 +18 -19 zoap/src/org/jboss/zoap/HttpServerMBean.java
Index: HttpServerMBean.java
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/jboss/zoap/HttpServerMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpServerMBean.java 2000/12/04 12:35:59 1.2
+++ HttpServerMBean.java 2001/01/04 14:45:06 1.3
@@ -1,37 +1,36 @@
-/*
- * $Id: HttpServerMBean.java,v 1.2 2000/12/04 12:35:59 jung Exp $
- * Copyright (c) 2000 infor:business solutions AG, Hauerstrasse 12,
- * D-66299 Friedrichsthal, Germany. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+/*
+ * $Source: /products/cvs/ejboss/zoap/src/org/jboss/zoap/HttpServerMBean.java,v $
+ * The Zero-effort Object Access Package is a library to support XML/SOAP
serialisation and invocation.
+ * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
+ * D-66299 Friedrichsthal, Germany. All Rights Reserved.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jboss.zoap;
import org.jboss.util.ServiceMBean;
-
import org.zoap.soap.SoapServer;
-
/**
* This is the JMX interface of the HttpServer that is exposed for
* administration. Publishes a part of the SOAP server functionality, as well
*
* @see HttpServer
* @author $Author: jung $
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface HttpServerMBean extends SoapServer {
1.3 +5 -0 zoap/src/org/jboss/zoap/zoap.dfPackage
Index: zoap.dfPackage
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/jboss/zoap/zoap.dfPackage,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- zoap.dfPackage 2000/12/04 12:35:59 1.2
+++ zoap.dfPackage 2001/01/04 14:45:06 1.3
@@ -21,6 +21,11 @@
@__modelType reference
*/
class reference1 {
+}/**
+@__ref <oiref:java#Class#org.jboss.zoap.Environment:oiref><oihard>
+@__modelType reference
+*/
+class reference4 {
}}/**
@__tags
@shapeType ClassDiagram