remove application server dependency
This commit is contained in:
parent
389d0c94a2
commit
e4d11cfc8f
|
|
@ -24,7 +24,6 @@ Bundle-ClassPath: base.jar,
|
||||||
lib/commons-collections-3.1.jar,
|
lib/commons-collections-3.1.jar,
|
||||||
lib/activemq-core-5.0.0.jar
|
lib/activemq-core-5.0.0.jar
|
||||||
Export-Package: org.adempiere.apps.graph,
|
Export-Package: org.adempiere.apps.graph,
|
||||||
org.adempiere.as,
|
|
||||||
org.adempiere.base,
|
org.adempiere.base,
|
||||||
org.adempiere.exceptions,
|
org.adempiere.exceptions,
|
||||||
org.adempiere.impexp,
|
org.adempiere.impexp,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
source.base.jar = src/,build/
|
source.base.jar = src/
|
||||||
bin.includes = META-INF/,\
|
bin.includes = META-INF/,\
|
||||||
base.jar,\
|
base.jar,\
|
||||||
plugin.xml
|
plugin.xml
|
||||||
jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
|
jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\
|
|
||||||
platform:/plugin/org.adempiere.tools/lib/ant-commons-net.jar,\
|
platform:/plugin/org.adempiere.tools/lib/ant-commons-net.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/ant-contrib-1.0b1.jar,\
|
platform:/plugin/org.adempiere.tools/lib/ant-contrib-1.0b1.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/ant-launcher.jar,\
|
platform:/plugin/org.adempiere.tools/lib/ant-launcher.jar,\
|
||||||
|
|
@ -22,8 +21,8 @@ jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/groovy-engine.jar,\
|
platform:/plugin/org.adempiere.tools/lib/groovy-engine.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/iText-2.1.7.jar,\
|
platform:/plugin/org.adempiere.tools/lib/iText-2.1.7.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/javaee.jar,\
|
platform:/plugin/org.adempiere.tools/lib/javaee.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/jcommon-1.0.14.jar,\
|
platform:/plugin/org.adempiere.tools/lib/jcommon-1.0.16.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/jfreechart-1.0.11.jar,\
|
platform:/plugin/org.adempiere.tools/lib/jfreechart-1.0.13.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/jgraph.jar,\
|
platform:/plugin/org.adempiere.tools/lib/jgraph.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/jnlp.jar,\
|
platform:/plugin/org.adempiere.tools/lib/jnlp.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/jpayment.jar,\
|
platform:/plugin/org.adempiere.tools/lib/jpayment.jar,\
|
||||||
|
|
@ -38,17 +37,15 @@ jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/looks-2.0.4.jar,\
|
platform:/plugin/org.adempiere.tools/lib/looks-2.0.4.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/mail.jar,\
|
platform:/plugin/org.adempiere.tools/lib/mail.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/miglayout-3.7.1-swing.jar,\
|
platform:/plugin/org.adempiere.tools/lib/miglayout-3.7.1-swing.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/ocrs12.jar,\
|
platform:/plugin/org.adempiere.tools/lib/ojdbc6.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/ojdbc14.jar,\
|
|
||||||
platform:/plugin/org.adempiere.tools/lib/poi-3.0.1-FINAL-20070705.jar,\
|
platform:/plugin/org.adempiere.tools/lib/poi-3.0.1-FINAL-20070705.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/postgresql.jar,\
|
platform:/plugin/org.adempiere.tools/lib/postgresql.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/script-api.jar,\
|
platform:/plugin/org.adempiere.tools/lib/script-api.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/servlet-api.jar,\
|
platform:/plugin/org.adempiere.tools/lib/servlet-api.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/standard.jar,\
|
platform:/plugin/org.adempiere.tools/lib/standard.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/swingx-0.9.0.jar,\
|
platform:/plugin/org.adempiere.tools/lib/swingx-1.6.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/Verisign.jar,\
|
platform:/plugin/org.adempiere.tools/lib/Verisign.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/wizard.jar,\
|
platform:/plugin/org.adempiere.tools/lib/wizard.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/xercesImpl.jar,\
|
platform:/plugin/org.adempiere.tools/lib/xercesImpl.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/xjavadoc-1.1.jar,\
|
platform:/plugin/org.adempiere.tools/lib/xjavadoc-1.1.jar,\
|
||||||
platform:/plugin/org.adempiere.tools/lib/xml-apis.jar
|
platform:/plugin/org.adempiere.tools/lib/xml-apis.jar
|
||||||
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2008 Low Heng Sin *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. 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. *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.adempiere.as;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import org.adempiere.base.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Low Heng Sin
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ASFactory {
|
|
||||||
public final static String JBOSS = "JBoss";
|
|
||||||
|
|
||||||
public final static String GLASS_FISH = "GlassFish";
|
|
||||||
|
|
||||||
public final static String[] AS_Names = new String[] {
|
|
||||||
JBOSS, GLASS_FISH
|
|
||||||
};
|
|
||||||
|
|
||||||
private static IApplicationServer applicationServer;
|
|
||||||
|
|
||||||
static {
|
|
||||||
applicationServer = Service.locate(IApplicationServer.class);
|
|
||||||
if (applicationServer == null) {
|
|
||||||
applicationServer = new IApplicationServer() {
|
|
||||||
|
|
||||||
public int getDefaultNamingServicePort() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hashtable<String, String> getInitialContextEnvironment(
|
|
||||||
String AppsHost, int AppsPort, String principal,
|
|
||||||
String credential) {
|
|
||||||
return new Hashtable<String, String>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return IApplicationServer
|
|
||||||
*/
|
|
||||||
public static IApplicationServer getApplicationServer() {
|
|
||||||
return applicationServer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2008 Low Heng Sin *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. 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. *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.adempiere.as;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import org.adempiere.base.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Low Heng Sin
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface IApplicationServer extends IService {
|
|
||||||
/**
|
|
||||||
* @param AppsHost
|
|
||||||
* @param AppsPort
|
|
||||||
* @param principal
|
|
||||||
* @param credential
|
|
||||||
* @return Environment to construct initial context
|
|
||||||
*/
|
|
||||||
public Hashtable<String, String> getInitialContextEnvironment (String AppsHost, int AppsPort, String principal,
|
|
||||||
String credential);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return default naming service port
|
|
||||||
*/
|
|
||||||
public int getDefaultNamingServicePort();
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2009 Low Heng Sin *
|
|
||||||
* Copyright (C) 2009 Idalica Corporation *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. 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. *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.adempiere.util;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.compiere.interfaces.Server;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author hengsin
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class EmbeddedServerProxy implements InvocationHandler {
|
|
||||||
|
|
||||||
private Server server = null;
|
|
||||||
|
|
||||||
public EmbeddedServerProxy() {
|
|
||||||
ClassLoader loader = null;
|
|
||||||
loader = Thread.currentThread().getContextClassLoader();
|
|
||||||
if (loader == null)
|
|
||||||
loader = this.getClass().getClassLoader();
|
|
||||||
try {
|
|
||||||
Class<?> clazz = loader.loadClass("org.compiere.session.ServerBean");
|
|
||||||
server = (Server) clazz.newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IllegalStateException("Failed to load org.compiere.session.ServerBean.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object invoke(Object proxy, Method method, Object[] args)
|
|
||||||
throws Throwable {
|
|
||||||
Method m = Server.class.getMethod(method.getName(), method.getParameterTypes());
|
|
||||||
return m.invoke(server, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -17,27 +17,19 @@
|
||||||
package org.compiere.db;
|
package org.compiere.db;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
import java.rmi.RMISecurityManager;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.naming.CommunicationException;
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import org.adempiere.as.ASFactory;
|
|
||||||
import org.adempiere.util.EmbeddedServerProxy;
|
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.interfaces.Server;
|
import org.compiere.interfaces.Server;
|
||||||
import org.compiere.interfaces.Status;
|
import org.compiere.interfaces.Status;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
|
|
@ -81,11 +73,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final String PROFILE_WAN = "W";
|
public static final String PROFILE_WAN = "W";
|
||||||
|
|
||||||
private final static String COMPONENT_NS = "java:comp/env";
|
|
||||||
|
|
||||||
/** Prefer component namespace when running at server **/
|
|
||||||
private boolean useComponentNamespace = !Ini.isClient();
|
|
||||||
|
|
||||||
/** System property flag to embed server bean in process **/
|
/** System property flag to embed server bean in process **/
|
||||||
public final static String SERVER_EMBEDDED = "org.adempiere.server.embedded";
|
public final static String SERVER_EMBEDDED = "org.adempiere.server.embedded";
|
||||||
|
|
||||||
|
|
@ -116,7 +103,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
{
|
{
|
||||||
cc = new CConnection(apps_host);
|
cc = new CConnection(apps_host);
|
||||||
cc.setConnectionProfile(CConnection.PROFILE_LAN);
|
cc.setConnectionProfile(CConnection.PROFILE_LAN);
|
||||||
cc.setAppsPort(ASFactory.getApplicationServer().getDefaultNamingServicePort());
|
|
||||||
if (cc.testAppsServer() == null)
|
if (cc.testAppsServer() == null)
|
||||||
{
|
{
|
||||||
s_cc = cc;
|
s_cc = cc;
|
||||||
|
|
@ -210,7 +196,7 @@ public class CConnection implements Serializable, Cloneable
|
||||||
/** Application Host */
|
/** Application Host */
|
||||||
private String m_apps_host = "MyAppsServer";
|
private String m_apps_host = "MyAppsServer";
|
||||||
/** Application Port */
|
/** Application Port */
|
||||||
private int m_apps_port = ASFactory.getApplicationServer().getDefaultNamingServicePort();
|
private int m_apps_port = 0;
|
||||||
|
|
||||||
/** Database Type */
|
/** Database Type */
|
||||||
private String m_type = "";
|
private String m_type = "";
|
||||||
|
|
@ -222,9 +208,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
/** Database name */
|
/** Database name */
|
||||||
private String m_db_name = "MyDBName";
|
private String m_db_name = "MyDBName";
|
||||||
|
|
||||||
/** Connection Profile */
|
|
||||||
private String m_connectionProfile = PROFILE_LAN;
|
|
||||||
|
|
||||||
/** In Memory connection */
|
/** In Memory connection */
|
||||||
private boolean m_bequeath = false;
|
private boolean m_bequeath = false;
|
||||||
|
|
||||||
|
|
@ -264,9 +247,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
/** DB Info */
|
/** DB Info */
|
||||||
private String m_dbInfo = null;
|
private String m_dbInfo = null;
|
||||||
|
|
||||||
/** Had application server been query **/
|
|
||||||
private boolean m_queryAppsServer = false;
|
|
||||||
|
|
||||||
private final static String SECURITY_PRINCIPAL = "org.adempiere.security.principal";
|
private final static String SECURITY_PRINCIPAL = "org.adempiere.security.principal";
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
@ -314,7 +294,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
m_apps_host = apps_host;
|
m_apps_host = apps_host;
|
||||||
m_name = toString ();
|
m_name = toString ();
|
||||||
m_okApps = false;
|
m_okApps = false;
|
||||||
m_queryAppsServer = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -334,7 +313,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
{
|
{
|
||||||
m_apps_port = apps_port;
|
m_apps_port = apps_port;
|
||||||
m_okApps = false;
|
m_okApps = false;
|
||||||
m_queryAppsServer = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -363,49 +341,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
*/
|
*/
|
||||||
public boolean isAppsServerOK (boolean tryContactAgain)
|
public boolean isAppsServerOK (boolean tryContactAgain)
|
||||||
{
|
{
|
||||||
if (isServerEmbedded())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Ini.isClient() && !tryContactAgain && m_queryAppsServer)
|
|
||||||
return m_okApps;
|
|
||||||
|
|
||||||
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
|
|
||||||
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
|
|
||||||
log.warning (getAppsHost() + " ignored");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_queryAppsServer = true;
|
|
||||||
|
|
||||||
// Contact it
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Status status = (Status)lookup (Status.JNDI_NAME);
|
|
||||||
m_version = status.getDateVersion ();
|
|
||||||
m_okApps = true;
|
|
||||||
}
|
|
||||||
catch (Exception ce)
|
|
||||||
{
|
|
||||||
m_okApps = false;
|
|
||||||
String connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
if (connect == null || connect.trim().length() == 0)
|
|
||||||
connect = getAppsHost() + ":" + getAppsPort();
|
|
||||||
log.warning (connect
|
|
||||||
+ "\n - " + ce.toString ()
|
|
||||||
+ "\n - " + m_env);
|
|
||||||
ce.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
m_okApps = false;
|
|
||||||
String connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
if (connect == null || connect.trim().length() == 0)
|
|
||||||
connect = getAppsHost() + ":" + getAppsPort();
|
|
||||||
log.warning (connect
|
|
||||||
+ "\n - " + t.toString ()
|
|
||||||
+ "\n - " + m_env);
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
return m_okApps;
|
return m_okApps;
|
||||||
} // isAppsOK
|
} // isAppsOK
|
||||||
|
|
||||||
|
|
@ -425,32 +360,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
*/
|
*/
|
||||||
public Server getServer()
|
public Server getServer()
|
||||||
{
|
{
|
||||||
//only cache ServerHome for client
|
|
||||||
if (m_server == null || !Ini.isClient())
|
|
||||||
{
|
|
||||||
if (isServerEmbedded())
|
|
||||||
{
|
|
||||||
m_server = (Server)Proxy.newProxyInstance(Server.class.getClassLoader(),
|
|
||||||
new Class[]{Server.class}, new EmbeddedServerProxy());
|
|
||||||
return m_server;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Server server = (Server)lookup (Server.JNDI_NAME);
|
|
||||||
if (server != null)
|
|
||||||
if (Ini.isClient())
|
|
||||||
m_server = server;
|
|
||||||
else
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "", ex);
|
|
||||||
m_iContext = null;
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m_server;
|
return m_server;
|
||||||
} // getServer
|
} // getServer
|
||||||
|
|
||||||
|
|
@ -1397,9 +1306,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
private InitialContext m_iContext = null;
|
|
||||||
private Hashtable m_env = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Application Server Initial Context
|
* Get Application Server Initial Context
|
||||||
* @param useCache if true, use existing cache
|
* @param useCache if true, use existing cache
|
||||||
|
|
@ -1407,58 +1313,9 @@ public class CConnection implements Serializable, Cloneable
|
||||||
*/
|
*/
|
||||||
public InitialContext getInitialContext (boolean useCache)
|
public InitialContext getInitialContext (boolean useCache)
|
||||||
{
|
{
|
||||||
if (useCache && m_iContext != null)
|
return null;
|
||||||
return m_iContext;
|
|
||||||
|
|
||||||
// Set Environment
|
|
||||||
if (m_env == null || !useCache)
|
|
||||||
{
|
|
||||||
SecurityPrincipal sp = (SecurityPrincipal) Env.getCtx().get(SECURITY_PRINCIPAL);
|
|
||||||
String principal = sp != null ? sp.principal : null;
|
|
||||||
String credential = sp != null ? sp.credential : null;
|
|
||||||
m_env = getInitialEnvironment(getAppsHost(), getAppsPort(), false,
|
|
||||||
principal, credential);
|
|
||||||
}
|
|
||||||
String connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
Env.setContext(Env.getCtx(), Context.PROVIDER_URL, connect);
|
|
||||||
|
|
||||||
// Get Context
|
|
||||||
m_iContext = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_iContext = new InitialContext (m_env);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_okApps = false;
|
|
||||||
m_appsException = ex;
|
|
||||||
if (connect == null)
|
|
||||||
connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
log.severe(connect
|
|
||||||
+ "\n - " + ex.toString ()
|
|
||||||
+ "\n - " + m_env);
|
|
||||||
if (CLogMgt.isLevelFinest())
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
return m_iContext;
|
|
||||||
} // getInitialContext
|
} // getInitialContext
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Initial Environment
|
|
||||||
* @param AppsHost host
|
|
||||||
* @param AppsPort port
|
|
||||||
* @param RMIoverHTTP ignore, retained for backward compatibility
|
|
||||||
* @param principal
|
|
||||||
* @param credential
|
|
||||||
* @return environment
|
|
||||||
*/
|
|
||||||
private Hashtable getInitialEnvironment (String AppsHost, int AppsPort,
|
|
||||||
boolean RMIoverHTTP, String principal, String credential)
|
|
||||||
{
|
|
||||||
return ASFactory.getApplicationServer()
|
|
||||||
.getInitialContextEnvironment(AppsHost, AppsPort, principal, credential);
|
|
||||||
} // getInitialEnvironment
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query Application Server Status.
|
* Query Application Server Status.
|
||||||
* update okApps
|
* update okApps
|
||||||
|
|
@ -1466,49 +1323,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
*/
|
*/
|
||||||
private boolean queryAppsServerInfo ()
|
private boolean queryAppsServerInfo ()
|
||||||
{
|
{
|
||||||
log.finer(getAppsHost());
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
m_okApps = false;
|
|
||||||
m_queryAppsServer = true;
|
|
||||||
m_appsException = null;
|
|
||||||
|
|
||||||
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
|
|
||||||
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
|
|
||||||
log.warning (getAppsHost() + " ignored");
|
|
||||||
return m_okApps; // false
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Status status = (Status)lookup (Status.JNDI_NAME);
|
|
||||||
//
|
|
||||||
updateInfoFromServer(status);
|
|
||||||
//
|
|
||||||
m_okApps = true;
|
|
||||||
}
|
|
||||||
catch (CommunicationException ce) // not a "real" error
|
|
||||||
{
|
|
||||||
m_appsException = ce;
|
|
||||||
String connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
if (connect == null || connect.trim().length() == 0)
|
|
||||||
connect = getAppsHost() + ":" + getAppsPort();
|
|
||||||
log.warning (connect
|
|
||||||
+ "\n - " + ce.toString ()
|
|
||||||
+ "\n - " + m_env);
|
|
||||||
ce.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_appsException = e;
|
|
||||||
String connect = (String)m_env.get(Context.PROVIDER_URL);
|
|
||||||
if (connect == null || connect.trim().length() == 0)
|
|
||||||
connect = getAppsHost() + ":" + getAppsPort();
|
|
||||||
log.warning (connect
|
|
||||||
+ "\n - " + e.toString ()
|
|
||||||
+ "\n - " + m_env);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
log.fine("Success=" + m_okApps + " - " + (System.currentTimeMillis()-start) + "ms");
|
|
||||||
return m_okApps;
|
return m_okApps;
|
||||||
} // setAppsServerInfo
|
} // setAppsServerInfo
|
||||||
|
|
||||||
|
|
@ -1614,8 +1428,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
sp.principal = principal;
|
sp.principal = principal;
|
||||||
sp.credential = credential;
|
sp.credential = credential;
|
||||||
Env.getCtx().put(SECURITY_PRINCIPAL, sp);
|
Env.getCtx().put(SECURITY_PRINCIPAL, sp);
|
||||||
m_iContext = null;
|
|
||||||
m_env = null;
|
|
||||||
m_server = null;
|
m_server = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1629,26 +1441,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object lookup(String jndiName) throws NamingException {
|
|
||||||
InitialContext ctx = getInitialContext(Ini.isClient());
|
|
||||||
if (useComponentNamespace)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ctx.lookup(COMPONENT_NS + "/" + jndiName);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.warning("Component name space not available - " + e.getLocalizedMessage());
|
|
||||||
//not available
|
|
||||||
useComponentNamespace = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//global jndi lookup
|
|
||||||
return ctx.lookup(jndiName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Testing
|
* Testing
|
||||||
* @param args ignored
|
* @param args ignored
|
||||||
|
|
|
||||||
|
|
@ -909,21 +909,21 @@ public class MClient extends X_AD_Client
|
||||||
|
|
||||||
public static boolean isClientAccounting() {
|
public static boolean isClientAccounting() {
|
||||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||||
CLIENT_ACCOUNTING_DISABLED, // default
|
CLIENT_ACCOUNTING_QUEUE, // default
|
||||||
Env.getAD_Client_ID(Env.getCtx()));
|
Env.getAD_Client_ID(Env.getCtx()));
|
||||||
return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE));
|
return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClientAccountingQueue() {
|
public static boolean isClientAccountingQueue() {
|
||||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||||
CLIENT_ACCOUNTING_DISABLED, // default
|
CLIENT_ACCOUNTING_QUEUE, // default
|
||||||
Env.getAD_Client_ID(Env.getCtx()));
|
Env.getAD_Client_ID(Env.getCtx()));
|
||||||
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE);
|
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClientAccountingImmediate() {
|
public static boolean isClientAccountingImmediate() {
|
||||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||||
CLIENT_ACCOUNTING_DISABLED, // default
|
CLIENT_ACCOUNTING_QUEUE, // default
|
||||||
Env.getAD_Client_ID(Env.getCtx()));
|
Env.getAD_Client_ID(Env.getCtx()));
|
||||||
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE);
|
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1218,39 +1218,9 @@ public class DocumentEngine implements DocAction
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String error = null;
|
String error = null;
|
||||||
if (MClient.isClientAccounting()) {
|
|
||||||
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
|
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
|
||||||
error = Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName);
|
error = Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName);
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to get from Server when enabled
|
|
||||||
if (CConnection.get().isAppsServerOK(true))
|
|
||||||
{
|
|
||||||
log.config("trying server");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Server server = CConnection.get().getServer();
|
|
||||||
if (server != null)
|
|
||||||
{
|
|
||||||
Properties p = Env.getRemoteCallCtx(Env.getCtx());
|
|
||||||
error = server.postImmediate(p, AD_Client_ID,
|
|
||||||
AD_Table_ID, Record_ID, force, null); // don't pass transaction to server
|
|
||||||
log.config("from Server: " + error== null ? "OK" : error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error = "NoAppsServer";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.WARNING, "(RE)", e);
|
|
||||||
error = e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
} // postImmediate
|
} // postImmediate
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue