From c539b46b061b2f48fad6b91396641133dbd97db8 Mon Sep 17 00:00:00 2001 From: joergviola Date: Wed, 28 Apr 2010 20:52:56 +0000 Subject: [PATCH] App Server support for base https://sourceforge.net/tracker/?func=detail&aid=2700937&group_id=176962&atid=879334 --- base/.classpath | 1 - base/META-INF/MANIFEST.MF | 3 +- base/build.properties | 22 +--- base/build.xml | 24 +++++ base/plugin.xml | 1 + .../org.adempiere.as.IApplicationServer.exsd | 102 ++++++++++++++++++ base/src/org/adempiere/as/ASFactory.java | 18 +--- .../org/adempiere/as/IApplicationServer.java | 4 +- base/src/org/adempiere/base/Service.java | 24 ++++- base/src/org/compiere/db/CConnection.java | 2 +- 10 files changed, 156 insertions(+), 45 deletions(-) create mode 100644 base/schema/org.adempiere.as.IApplicationServer.exsd diff --git a/base/.classpath b/base/.classpath index d0089b380c..545484a141 100644 --- a/base/.classpath +++ b/base/.classpath @@ -7,7 +7,6 @@ - diff --git a/base/META-INF/MANIFEST.MF b/base/META-INF/MANIFEST.MF index 1f3a8841a3..53b20775e5 100644 --- a/base/META-INF/MANIFEST.MF +++ b/base/META-INF/MANIFEST.MF @@ -62,4 +62,5 @@ Export-Package: org.adempiere.apps.graph, org.compiere.util, org.compiere.wf Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0", - org.adempiere.tools;bundle-version="0.0.0" + org.adempiere.tools;bundle-version="0.0.0", + org.adempiere.jboss;bundle-version="0.0.0" diff --git a/base/build.properties b/base/build.properties index f0410d0383..164171b6b9 100644 --- a/base/build.properties +++ b/base/build.properties @@ -1,26 +1,6 @@ -source.base.jar = src/ +source.base.jar = src/,build/ bin.includes = META-INF/,\ - ../tools/lib/commons-net-1.4.0.jar,\ - ../tools/lib/ant.jar,\ - ../tools/lib/jpedal.jar,\ - ../tools/lib/jnlp.jar,\ - ../tools/lib/junit.jar,\ - client/jbossall-client.jar,\ - ../tools/lib/postgresql.jar,\ - ../tools/lib/ocrs12.jar,\ - ../tools/lib/ojdbc14.jar,\ - ../tools/lib/c3p0-0.9.1.2.jar,\ - ../tools/lib/script-api.jar,\ - ../tools/lib/barbecue-1.5-beta1.jar,\ - ../tools/lib/poi-3.0.1-FINAL-20070705.jar,\ - ../tools/lib/jcommon-1.0.14.jar,\ - ../tools/lib/jfreechart-1.0.11.jar,\ - ../tools/lib/swingx-0.9.0.jar,\ - ../tools/lib/looks-2.0.4.jar,\ - ../tools/lib/commons-collections-3.1.jar,\ - ../tools/lib/activemq-core-5.0.0.jar,\ base.jar,\ - lib/looks-2.0.4.jar,\ plugin.xml jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\ platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\ diff --git a/base/build.xml b/base/build.xml index c1a02a9fda..ad7632522f 100644 --- a/base/build.xml +++ b/base/build.xml @@ -18,6 +18,7 @@ + @@ -105,6 +106,29 @@ + + + + + + + + + + + + diff --git a/base/plugin.xml b/base/plugin.xml index e956db1f4d..8041937132 100644 --- a/base/plugin.xml +++ b/base/plugin.xml @@ -5,5 +5,6 @@ + diff --git a/base/schema/org.adempiere.as.IApplicationServer.exsd b/base/schema/org.adempiere.as.IApplicationServer.exsd new file mode 100644 index 0000000000..3009c74a74 --- /dev/null +++ b/base/schema/org.adempiere.as.IApplicationServer.exsd @@ -0,0 +1,102 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/base/src/org/adempiere/as/ASFactory.java b/base/src/org/adempiere/as/ASFactory.java index 1235194f09..4a9e33b29c 100644 --- a/base/src/org/adempiere/as/ASFactory.java +++ b/base/src/org/adempiere/as/ASFactory.java @@ -14,6 +14,8 @@ package org.adempiere.as; import java.util.Hashtable; +import org.adempiere.base.Service; + /** * * @author Low Heng Sin @@ -28,24 +30,10 @@ public class ASFactory { JBOSS, GLASS_FISH }; - private final static String[] AS_Classes = new String[] { - "org.adempiere.as.jboss.JBoss", - "org.adempiere.as.glassfish.GlassFish" - }; - private static IApplicationServer applicationServer; static { - //detect the installed application server - for(String s : AS_Classes) { - try { - Class c = Class.forName(s); - IApplicationServer server = (IApplicationServer) c.newInstance(); - applicationServer = server; - break; - } catch (Throwable t) { - } - } + applicationServer = Service.locate(IApplicationServer.class); if (applicationServer == null) { applicationServer = new IApplicationServer() { diff --git a/base/src/org/adempiere/as/IApplicationServer.java b/base/src/org/adempiere/as/IApplicationServer.java index e42b090445..c5d6de51f6 100644 --- a/base/src/org/adempiere/as/IApplicationServer.java +++ b/base/src/org/adempiere/as/IApplicationServer.java @@ -14,12 +14,14 @@ package org.adempiere.as; import java.util.Hashtable; +import org.adempiere.base.IService; + /** * * @author Low Heng Sin * */ -public interface IApplicationServer { +public interface IApplicationServer extends IService { /** * @param AppsHost * @param AppsPort diff --git a/base/src/org/adempiere/base/Service.java b/base/src/org/adempiere/base/Service.java index bc397e5c24..763c77b313 100644 --- a/base/src/org/adempiere/base/Service.java +++ b/base/src/org/adempiere/base/Service.java @@ -18,8 +18,6 @@ package org.adempiere.base; import java.util.List; -import org.adempiere.base.equinox.EquinoxServiceLocator; - /** * This is a very simple factory for service locators * @@ -28,21 +26,37 @@ import org.adempiere.base.equinox.EquinoxServiceLocator; */ public class Service { + private static final String LOCATOR_CLASS = "ServiceLocator"; + private static final String DEFAULT_LOCATOR_CLASS = "org.adempiere.base.equinox.EquinoxServiceLocator"; + private static IServiceLocator theLocator; public static IServiceLocator locator() { if (theLocator == null) { synchronized (Service.class) { if (theLocator == null) { - theLocator = new EquinoxServiceLocator(); - System.out - .println("Started service locator: " + theLocator); + theLocator = createServiceLocator(); } } } return theLocator; } + private static IServiceLocator createServiceLocator() { + String className = System.getProperty(LOCATOR_CLASS); + if (className==null) + className = DEFAULT_LOCATOR_CLASS; + try { + Class clazz = Class.forName(className); + IServiceLocator locator = (IServiceLocator) clazz.newInstance(); + System.out.println("Started service locator: " + locator); + return locator; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + public static T locate(Class type) { return locator().locate(type); } diff --git a/base/src/org/compiere/db/CConnection.java b/base/src/org/compiere/db/CConnection.java index 690365119e..04e073984a 100644 --- a/base/src/org/compiere/db/CConnection.java +++ b/base/src/org/compiere/db/CConnection.java @@ -18,6 +18,7 @@ package org.compiere.db; import java.io.Serializable; import java.lang.reflect.Proxy; +import java.rmi.RMISecurityManager; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -1630,7 +1631,6 @@ public class CConnection implements Serializable, Cloneable private Object lookup(String jndiName) throws NamingException { InitialContext ctx = getInitialContext(Ini.isClient()); - if (useComponentNamespace) { try