* move thread local context implementation to core.
This commit is contained in:
parent
1a9a979dcc
commit
043080586d
|
@ -47,5 +47,6 @@ Require-Bundle: org.adempiere.tools;bundle-version="1.0.0",
|
||||||
com.springsource.javax.jms;bundle-version="1.1.0"
|
com.springsource.javax.jms;bundle-version="1.1.0"
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Eclipse-ExtensibleAPI: true
|
Eclipse-ExtensibleAPI: true
|
||||||
Import-Package: org.eclipse.core.runtime;version="3.4.0"
|
Import-Package: net.sf.cglib.proxy,
|
||||||
|
org.eclipse.core.runtime;version="3.4.0"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Posterita Ajax UI *
|
||||||
|
* Copyright (C) 2007 Posterita Ltd. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius *
|
||||||
|
* or via info@posterita.org or http://www.posterita.org/ *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package org.adempiere.util;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
|
* @date Feb 25, 2007
|
||||||
|
* @version $Revision: 0.10 $
|
||||||
|
*/
|
||||||
|
public final class ServerContext
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* generated serial version Id
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -8274580404204046413L;
|
||||||
|
|
||||||
|
private ServerContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static InheritableThreadLocal<Properties> context = new InheritableThreadLocal<Properties>() {
|
||||||
|
protected Properties initialValue()
|
||||||
|
{
|
||||||
|
Properties ctx = new Properties();
|
||||||
|
ctx.put(Env.LANGUAGE, Language.getBaseAD_Language());
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get server context for current thread
|
||||||
|
* @return Properties
|
||||||
|
*/
|
||||||
|
public static Properties getCurrentInstance()
|
||||||
|
{
|
||||||
|
return (Properties)context.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dispose server context for current thread
|
||||||
|
*/
|
||||||
|
public static void dispose()
|
||||||
|
{
|
||||||
|
context.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set server context for current thread
|
||||||
|
* @param ctx
|
||||||
|
*/
|
||||||
|
public static void setCurrentInstance(Properties ctx)
|
||||||
|
{
|
||||||
|
context.set(ctx);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.util;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import net.sf.cglib.proxy.InvocationHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intercaptor for Server context properties that delegate to the threadlocal instance
|
||||||
|
* @author Low Heng Sin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ServerContextCallback implements InvocationHandler, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args)
|
||||||
|
throws Throwable {
|
||||||
|
Properties context = ServerContext.getCurrentInstance();
|
||||||
|
//optimize for the 2 most common access
|
||||||
|
if (method.getName().equals("getProperty")) {
|
||||||
|
Class<?>[] types = method.getParameterTypes();
|
||||||
|
if (types != null && types.length == 1 && types[0] == String.class &&
|
||||||
|
args != null && args.length == 1 && args[0] instanceof String) {
|
||||||
|
return context.getProperty((String)args[0]);
|
||||||
|
}
|
||||||
|
else if (types != null && types.length == 2 && types[0] == String.class &&
|
||||||
|
types[1] == String.class && args != null && args[0] instanceof String &&
|
||||||
|
args[1] instanceof String)
|
||||||
|
return context.getProperty((String)args[0], (String)args[1]);
|
||||||
|
}
|
||||||
|
Method m = context.getClass().getMethod(method.getName(), method.getParameterTypes());
|
||||||
|
return m.invoke(context, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Low Heng Sin hengsin@avantz.com
|
||||||
|
* _____________________________________________
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.util;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
|
|
||||||
|
import org.compiere.util.ContextProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Low Heng Sin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ServerContextProvider implements ContextProvider {
|
||||||
|
|
||||||
|
private final static ServerContextCallback callback = new ServerContextCallback();
|
||||||
|
private final static Properties context = (Properties) Enhancer.create(Properties.class, callback);
|
||||||
|
|
||||||
|
public final static ServerContextProvider INSTANCE = new ServerContextProvider();
|
||||||
|
|
||||||
|
private ServerContextProvider() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get server context proxy
|
||||||
|
*/
|
||||||
|
public Properties getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show url at zk desktop
|
||||||
|
*/
|
||||||
|
public void showURL(String url) {
|
||||||
|
ServerContextURLHandler handler = (ServerContextURLHandler) getContext().get(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER);
|
||||||
|
if (handler != null)
|
||||||
|
handler.showURL(url);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.adempiere.util;
|
||||||
|
|
||||||
|
public interface ServerContextURLHandler {
|
||||||
|
public final static String SERVER_CONTEXT_URL_HANDLER = "SERVER_CONTEXT_URL_HANDLER";
|
||||||
|
public void showURL(String url);
|
||||||
|
}
|
|
@ -22,7 +22,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -32,8 +31,6 @@ import javax.jnlp.UnavailableServiceException;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import org.adempiere.base.Core;
|
import org.adempiere.base.Core;
|
||||||
import org.adempiere.base.IResourceFinder;
|
|
||||||
import org.adempiere.base.Service;
|
|
||||||
import org.compiere.db.CConnection;
|
import org.compiere.db.CConnection;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MSystem;
|
import org.compiere.model.MSystem;
|
||||||
|
@ -47,7 +44,6 @@ import org.compiere.util.Ini;
|
||||||
import org.compiere.util.Login;
|
import org.compiere.util.Login;
|
||||||
import org.compiere.util.SecureEngine;
|
import org.compiere.util.SecureEngine;
|
||||||
import org.compiere.util.SecureInterface;
|
import org.compiere.util.SecureInterface;
|
||||||
//import org.compiere.util.Splash;
|
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +76,6 @@ public final class Adempiere
|
||||||
static private final String s_file32x32 = "images/AD32.gif";
|
static private final String s_file32x32 = "images/AD32.gif";
|
||||||
/** 100*30 Product Image. */
|
/** 100*30 Product Image. */
|
||||||
static private final String s_file100x30 = "images/AD10030.png";
|
static private final String s_file100x30 = "images/AD10030.png";
|
||||||
// static private final String s_file100x30HR = "images/AD10030HR.png";
|
|
||||||
/** 48*15 Product Image. */
|
/** 48*15 Product Image. */
|
||||||
static private final String s_file48x15 = "images/Adempiere.png";
|
static private final String s_file48x15 = "images/Adempiere.png";
|
||||||
static private final String s_file48x15HR = "images/AdempiereHR.png";
|
static private final String s_file48x15HR = "images/AdempiereHR.png";
|
||||||
|
|
|
@ -48,6 +48,7 @@ import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.adempiere.base.Core;
|
import org.adempiere.base.Core;
|
||||||
import org.adempiere.base.IResourceFinder;
|
import org.adempiere.base.IResourceFinder;
|
||||||
|
import org.adempiere.util.ServerContextProvider;
|
||||||
import org.compiere.db.CConnection;
|
import org.compiere.db.CConnection;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MLookupCache;
|
import org.compiere.model.MLookupCache;
|
||||||
|
@ -72,12 +73,14 @@ public final class Env
|
||||||
/** Logging */
|
/** Logging */
|
||||||
private static CLogger s_log = CLogger.getCLogger(Env.class);
|
private static CLogger s_log = CLogger.getCLogger(Env.class);
|
||||||
|
|
||||||
private static ContextProvider contextProvider = new DefaultContextProvider();
|
private final static ContextProvider clientContextProvider = new DefaultContextProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param provider
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public static void setContextProvider(ContextProvider provider)
|
public static void setContextProvider(ContextProvider provider)
|
||||||
{
|
{
|
||||||
contextProvider = provider;
|
|
||||||
getCtx().put(LANGUAGE, Language.getBaseAD_Language());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,9 +211,16 @@ public final class Env
|
||||||
*/
|
*/
|
||||||
public static final Properties getCtx()
|
public static final Properties getCtx()
|
||||||
{
|
{
|
||||||
return contextProvider.getContext();
|
return getContextProvider().getContext();
|
||||||
} // getCtx
|
} // getCtx
|
||||||
|
|
||||||
|
public static ContextProvider getContextProvider() {
|
||||||
|
if (Ini.isClient())
|
||||||
|
return clientContextProvider;
|
||||||
|
else
|
||||||
|
return ServerContextProvider.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Context
|
* Set Context
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -1562,7 +1572,7 @@ public final class Env
|
||||||
public static void startBrowser (String url)
|
public static void startBrowser (String url)
|
||||||
{
|
{
|
||||||
s_log.info(url);
|
s_log.info(url);
|
||||||
contextProvider.showURL(url);
|
getContextProvider().showURL(url);
|
||||||
} // startBrowser
|
} // startBrowser
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,10 +52,10 @@ import org.compiere.model.ModelValidationEngine;
|
||||||
* Load & Save INI Settings from property file
|
* Load & Save INI Settings from property file
|
||||||
* Initiated in Adempiere.startup
|
* Initiated in Adempiere.startup
|
||||||
* Settings activated in ALogin.getIni
|
* Settings activated in ALogin.getIni
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
* <li>FR [ 1658127 ] Select charset encoding on import
|
* <li>FR [ 1658127 ] Select charset encoding on import
|
||||||
* <li>FR [ 2406123 ] Ini.saveProperties fails if target directory does not exist
|
* <li>FR [ 2406123 ] Ini.saveProperties fails if target directory does not exist
|
||||||
|
@ -63,7 +63,7 @@ import org.compiere.model.ModelValidationEngine;
|
||||||
public final class Ini implements Serializable
|
public final class Ini implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3666529972922769528L;
|
private static final long serialVersionUID = 3666529972922769528L;
|
||||||
|
|
||||||
|
@ -103,16 +103,16 @@ public final class Ini implements Serializable
|
||||||
|
|
||||||
private static final String DEFAULT_UI_LOOK = AdempiereLookAndFeel.NAME;
|
private static final String DEFAULT_UI_LOOK = AdempiereLookAndFeel.NAME;
|
||||||
/** UI Theme */
|
/** UI Theme */
|
||||||
|
|
||||||
private static final String DEFAULT_UI_THEME = AdempiereThemeInnova.NAME;
|
private static final String DEFAULT_UI_THEME = AdempiereThemeInnova.NAME;
|
||||||
/** UI Theme */
|
/** UI Theme */
|
||||||
public static final String P_UI_THEME = "UITheme";
|
public static final String P_UI_THEME = "UITheme";
|
||||||
|
|
||||||
/** Flat Color UI
|
/** Flat Color UI
|
||||||
public static final String P_UI_FLAT = "UIFlat";
|
public static final String P_UI_FLAT = "UIFlat";
|
||||||
private static final boolean DEFAULT_UI_FLAT = false;
|
private static final boolean DEFAULT_UI_FLAT = false;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Auto Save */
|
/** Auto Save */
|
||||||
public static final String P_A_COMMIT = "AutoCommit";
|
public static final String P_A_COMMIT = "AutoCommit";
|
||||||
private static final boolean DEFAULT_A_COMMIT = true;
|
private static final boolean DEFAULT_A_COMMIT = true;
|
||||||
|
@ -167,11 +167,11 @@ public final class Ini implements Serializable
|
||||||
/** Validate connection on startup */
|
/** Validate connection on startup */
|
||||||
public static final String P_VALIDATE_CONNECTION_ON_STARTUP = "ValidateConnectionOnStartup";
|
public static final String P_VALIDATE_CONNECTION_ON_STARTUP = "ValidateConnectionOnStartup";
|
||||||
private static final boolean DEFAULT_VALIDATE_CONNECTION_ON_STARTUP = false;
|
private static final boolean DEFAULT_VALIDATE_CONNECTION_ON_STARTUP = false;
|
||||||
|
|
||||||
/** Single instance per window id **/
|
/** Single instance per window id **/
|
||||||
public static final String P_SINGLE_INSTANCE_PER_WINDOW = "SingleInstancePerWindow";
|
public static final String P_SINGLE_INSTANCE_PER_WINDOW = "SingleInstancePerWindow";
|
||||||
public static final boolean DEFAULT_SINGLE_INSTANCE_PER_WINDOW = false;
|
public static final boolean DEFAULT_SINGLE_INSTANCE_PER_WINDOW = false;
|
||||||
|
|
||||||
/** Open new windows as maximized **/
|
/** Open new windows as maximized **/
|
||||||
public static final String P_OPEN_WINDOW_MAXIMIZED = "OpenWindowMaximized";
|
public static final String P_OPEN_WINDOW_MAXIMIZED = "OpenWindowMaximized";
|
||||||
public static final boolean DEFAULT_OPEN_WINDOW_MAXIMIZED = false;
|
public static final boolean DEFAULT_OPEN_WINDOW_MAXIMIZED = false;
|
||||||
|
@ -180,7 +180,7 @@ public final class Ini implements Serializable
|
||||||
private static final String DEFAULT_WARNING = "Do_not_change_any_of_the_data_as_they_will_have_undocumented_side_effects.";
|
private static final String DEFAULT_WARNING = "Do_not_change_any_of_the_data_as_they_will_have_undocumented_side_effects.";
|
||||||
private static final String P_WARNING_de = "WarningD";
|
private static final String P_WARNING_de = "WarningD";
|
||||||
private static final String DEFAULT_WARNING_de ="Einstellungen_nicht_aendern,_da_diese_undokumentierte_Nebenwirkungen_haben.";
|
private static final String DEFAULT_WARNING_de ="Einstellungen_nicht_aendern,_da_diese_undokumentierte_Nebenwirkungen_haben.";
|
||||||
|
|
||||||
/** Charset */
|
/** Charset */
|
||||||
public static final String P_CHARSET = "Charset";
|
public static final String P_CHARSET = "Charset";
|
||||||
/** Charser Default Value */
|
/** Charser Default Value */
|
||||||
|
@ -188,17 +188,17 @@ public final class Ini implements Serializable
|
||||||
|
|
||||||
/** Load tab fields meta data using background thread **/
|
/** Load tab fields meta data using background thread **/
|
||||||
public static final String P_LOAD_TAB_META_DATA_BG = "LoadTabMetaDataBackground";
|
public static final String P_LOAD_TAB_META_DATA_BG = "LoadTabMetaDataBackground";
|
||||||
|
|
||||||
public static final String DEFAULT_LOAD_TAB_META_DATA_BG = "N";
|
public static final String DEFAULT_LOAD_TAB_META_DATA_BG = "N";
|
||||||
|
|
||||||
/** Ini Properties */
|
/** Ini Properties */
|
||||||
private static final String[] PROPERTIES = new String[] {
|
private static final String[] PROPERTIES = new String[] {
|
||||||
P_UID, P_PWD, P_TRACELEVEL, P_TRACEFILE,
|
P_UID, P_PWD, P_TRACELEVEL, P_TRACEFILE,
|
||||||
P_LANGUAGE, P_INI,
|
P_LANGUAGE, P_INI,
|
||||||
P_CONNECTION, P_STORE_PWD,
|
P_CONNECTION, P_STORE_PWD,
|
||||||
P_UI_LOOK, P_UI_THEME, /* P_UI_FLAT,*/
|
P_UI_LOOK, P_UI_THEME, /* P_UI_FLAT,*/
|
||||||
P_A_COMMIT, P_A_LOGIN, P_A_NEW,
|
P_A_COMMIT, P_A_LOGIN, P_A_NEW,
|
||||||
P_ADEMPIERESYS, P_LOGMIGRATIONSCRIPT, P_SHOW_ACCT, P_SHOW_TRL,
|
P_ADEMPIERESYS, P_LOGMIGRATIONSCRIPT, P_SHOW_ACCT, P_SHOW_TRL,
|
||||||
P_SHOW_ADVANCED, P_CACHE_WINDOW,
|
P_SHOW_ADVANCED, P_CACHE_WINDOW,
|
||||||
P_CONTEXT, P_TEMP_DIR,
|
P_CONTEXT, P_TEMP_DIR,
|
||||||
P_ROLE, P_CLIENT, P_ORG, P_PRINTER, P_WAREHOUSE, P_TODAY,
|
P_ROLE, P_CLIENT, P_ORG, P_PRINTER, P_WAREHOUSE, P_TODAY,
|
||||||
|
@ -216,7 +216,7 @@ public final class Ini implements Serializable
|
||||||
DEFAULT_CONNECTION, DEFAULT_STORE_PWD?"Y":"N",
|
DEFAULT_CONNECTION, DEFAULT_STORE_PWD?"Y":"N",
|
||||||
DEFAULT_UI_LOOK, DEFAULT_UI_THEME, /* DEFAULT_UI_FLAT?"Y":"N", */
|
DEFAULT_UI_LOOK, DEFAULT_UI_THEME, /* DEFAULT_UI_FLAT?"Y":"N", */
|
||||||
DEFAULT_A_COMMIT?"Y":"N", DEFAULT_A_LOGIN?"Y":"N", DEFAULT_A_NEW?"Y":"N",
|
DEFAULT_A_COMMIT?"Y":"N", DEFAULT_A_LOGIN?"Y":"N", DEFAULT_A_NEW?"Y":"N",
|
||||||
DEFAULT_ADEMPIERESYS?"Y":"N", DEFAULT_LOGMIGRATIONSCRIPT?"Y":"N", DEFAULT_SHOW_ACCT?"Y":"N", DEFAULT_SHOW_TRL?"Y":"N",
|
DEFAULT_ADEMPIERESYS?"Y":"N", DEFAULT_LOGMIGRATIONSCRIPT?"Y":"N", DEFAULT_SHOW_ACCT?"Y":"N", DEFAULT_SHOW_TRL?"Y":"N",
|
||||||
DEFAULT_SHOW_ADVANCED?"Y":"N", DEFAULT_CACHE_WINDOW?"Y":"N",
|
DEFAULT_SHOW_ADVANCED?"Y":"N", DEFAULT_CACHE_WINDOW?"Y":"N",
|
||||||
DEFAULT_CONTEXT, DEFAULT_TEMP_DIR,
|
DEFAULT_CONTEXT, DEFAULT_TEMP_DIR,
|
||||||
DEFAULT_ROLE, DEFAULT_CLIENT, DEFAULT_ORG, DEFAULT_PRINTER, DEFAULT_WAREHOUSE, DEFAULT_TODAY.toString(),
|
DEFAULT_ROLE, DEFAULT_CLIENT, DEFAULT_ORG, DEFAULT_PRINTER, DEFAULT_WAREHOUSE, DEFAULT_TODAY.toString(),
|
||||||
|
@ -230,11 +230,11 @@ public final class Ini implements Serializable
|
||||||
|
|
||||||
/** Container for Properties */
|
/** Container for Properties */
|
||||||
private static Properties s_prop = new Properties();
|
private static Properties s_prop = new Properties();
|
||||||
|
|
||||||
private static String s_propertyFileName = null;
|
private static String s_propertyFileName = null;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = null;
|
private static Logger log = Logger.getLogger(Ini.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save INI parameters to disk
|
* Save INI parameters to disk
|
||||||
|
@ -301,16 +301,16 @@ public final class Ini implements Serializable
|
||||||
boolean loadOK = true;
|
boolean loadOK = true;
|
||||||
boolean firstTime = false;
|
boolean firstTime = false;
|
||||||
s_prop = new Properties();
|
s_prop = new Properties();
|
||||||
|
|
||||||
PersistenceService ps;
|
|
||||||
|
|
||||||
try {
|
PersistenceService ps;
|
||||||
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
|
|
||||||
} catch (UnavailableServiceException e) {
|
try {
|
||||||
ps = null;
|
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
|
||||||
|
} catch (UnavailableServiceException e) {
|
||||||
|
ps = null;
|
||||||
log.log(Level.SEVERE, e.toString());
|
log.log(Level.SEVERE, e.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileContents fc = null;
|
FileContents fc = null;
|
||||||
try {
|
try {
|
||||||
|
@ -324,16 +324,16 @@ public final class Ini implements Serializable
|
||||||
ps.setTag(getCodeBase(), PersistenceService.DIRTY);
|
ps.setTag(getCodeBase(), PersistenceService.DIRTY);
|
||||||
fc = ps.get(getCodeBase());
|
fc = ps.get(getCodeBase());
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log(Level.SEVERE, e.toString());
|
log.log(Level.SEVERE, e.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream is = fc.getInputStream();
|
InputStream is = fc.getInputStream();
|
||||||
s_prop.load(is);
|
s_prop.load(is);
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
@ -351,28 +351,28 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
checkProperties();
|
checkProperties();
|
||||||
|
|
||||||
// Save if not exist or could not be read
|
// Save if not exist or could not be read
|
||||||
if (!loadOK || firstTime)
|
if (!loadOK || firstTime)
|
||||||
saveWebStartProperties();
|
saveWebStartProperties();
|
||||||
s_loaded = true;
|
s_loaded = true;
|
||||||
s_propertyFileName = getCodeBase().toString();
|
s_propertyFileName = getCodeBase().toString();
|
||||||
|
|
||||||
return firstTime;
|
return firstTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void saveWebStartProperties() {
|
private static void saveWebStartProperties() {
|
||||||
PersistenceService ps;
|
PersistenceService ps;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
|
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
|
||||||
} catch (UnavailableServiceException e) {
|
} catch (UnavailableServiceException e) {
|
||||||
ps = null;
|
ps = null;
|
||||||
log.log(Level.SEVERE, e.toString());
|
log.log(Level.SEVERE, e.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OutputStream os = ps.get(getCodeBase()).getOutputStream(true);
|
OutputStream os = ps.get(getCodeBase()).getOutputStream(true);
|
||||||
|
@ -385,7 +385,7 @@ public final class Ini implements Serializable
|
||||||
log.log(Level.SEVERE, "Cannot save Properties to " + getCodeBase() + " - " + t.toString());
|
log.log(Level.SEVERE, "Cannot save Properties to " + getCodeBase() + " - " + t.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,16 +396,16 @@ public final class Ini implements Serializable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
|
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
|
||||||
URL url = bs.getCodeBase();
|
URL url = bs.getCodeBase();
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
catch(UnavailableServiceException ue)
|
catch(UnavailableServiceException ue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} // getCodeBase
|
} // getCodeBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if client is started using web start
|
* @return True if client is started using web start
|
||||||
*/
|
*/
|
||||||
|
@ -413,7 +413,7 @@ public final class Ini implements Serializable
|
||||||
{
|
{
|
||||||
return getCodeBase() != null;
|
return getCodeBase() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load INI parameters from filename.
|
* Load INI parameters from filename.
|
||||||
* Logger is on default level (INFO)
|
* Logger is on default level (INFO)
|
||||||
|
@ -457,14 +457,14 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
checkProperties();
|
checkProperties();
|
||||||
|
|
||||||
// Save if not exist or could not be read
|
// Save if not exist or could not be read
|
||||||
if (!loadOK || firstTime)
|
if (!loadOK || firstTime)
|
||||||
saveProperties(true);
|
saveProperties(true);
|
||||||
s_loaded = true;
|
s_loaded = true;
|
||||||
log.info(filename + " #" + s_prop.size());
|
log.info(filename + " #" + s_prop.size());
|
||||||
s_propertyFileName = filename;
|
s_propertyFileName = filename;
|
||||||
|
|
||||||
return firstTime;
|
return firstTime;
|
||||||
} // loadProperties
|
} // loadProperties
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // deleteProperties
|
} // deleteProperties
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load property and set to default, if not existing
|
* Load property and set to default, if not existing
|
||||||
*
|
*
|
||||||
|
@ -564,7 +564,7 @@ public final class Ini implements Serializable
|
||||||
return base + ADEMPIERE_PROPERTY_FILE;
|
return base + ADEMPIERE_PROPERTY_FILE;
|
||||||
} // getFileName
|
} // getFileName
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Set Property
|
* Set Property
|
||||||
* @param key Key
|
* @param key Key
|
||||||
|
@ -627,7 +627,7 @@ public final class Ini implements Serializable
|
||||||
if (retStr == null || retStr.length() == 0)
|
if (retStr == null || retStr.length() == 0)
|
||||||
return "";
|
return "";
|
||||||
//
|
//
|
||||||
String value = SecureEngine.decrypt(retStr);
|
String value = SecureEngine.decrypt(retStr);
|
||||||
// log.finer(key + "=" + value);
|
// log.finer(key + "=" + value);
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return "";
|
return "";
|
||||||
|
@ -652,7 +652,7 @@ public final class Ini implements Serializable
|
||||||
{
|
{
|
||||||
return getProperty (P_CACHE_WINDOW).equals("Y");
|
return getProperty (P_CACHE_WINDOW).equals("Y");
|
||||||
} // isCacheWindow
|
} // isCacheWindow
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get Properties
|
* Get Properties
|
||||||
*
|
*
|
||||||
|
@ -670,7 +670,7 @@ public final class Ini implements Serializable
|
||||||
public static String getAsString()
|
public static String getAsString()
|
||||||
{
|
{
|
||||||
StringBuffer buf = new StringBuffer ("Ini[");
|
StringBuffer buf = new StringBuffer ("Ini[");
|
||||||
Enumeration e = s_prop.keys();
|
Enumeration<?> e = s_prop.keys();
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
{
|
{
|
||||||
String key = (String)e.nextElement();
|
String key = (String)e.nextElement();
|
||||||
|
@ -681,7 +681,7 @@ public final class Ini implements Serializable
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/** System environment prefix */
|
/** System environment prefix */
|
||||||
|
@ -711,13 +711,10 @@ public final class Ini implements Serializable
|
||||||
*/
|
*/
|
||||||
public static void setClient (boolean client)
|
public static void setClient (boolean client)
|
||||||
{
|
{
|
||||||
if (log != null) //already initialized
|
|
||||||
return;
|
|
||||||
s_client = client;
|
s_client = client;
|
||||||
CLogMgt.initialize(client);
|
CLogMgt.initialize(client);
|
||||||
log = Logger.getLogger(Ini.class.getName());
|
|
||||||
} // setClient
|
} // setClient
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show license dialog for new setup
|
* Set show license dialog for new setup
|
||||||
* @param b
|
* @param b
|
||||||
|
@ -726,7 +723,7 @@ public final class Ini implements Serializable
|
||||||
{
|
{
|
||||||
s_license_dialog = b;
|
s_license_dialog = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is show license dialog for new setup
|
* Is show license dialog for new setup
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
@ -734,8 +731,8 @@ public final class Ini implements Serializable
|
||||||
public static boolean isShowLicenseDialog()
|
public static boolean isShowLicenseDialog()
|
||||||
{
|
{
|
||||||
return s_license_dialog;
|
return s_license_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are the properties loaded?
|
* Are the properties loaded?
|
||||||
* @return true if properties loaded.
|
* @return true if properties loaded.
|
||||||
|
@ -763,7 +760,7 @@ public final class Ini implements Serializable
|
||||||
// teo_sarca: if you uncomment the line below you will get an NPE when generating models
|
// teo_sarca: if you uncomment the line below you will get an NPE when generating models
|
||||||
//log.fine( "Not found 'java:comp/env/"+ADEMPIERE_HOME+"' in Initial Context. " +e.getMessage());
|
//log.fine( "Not found 'java:comp/env/"+ADEMPIERE_HOME+"' in Initial Context. " +e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (env == null || "".equals(env) ) // Fallback
|
if (env == null || "".equals(env) ) // Fallback
|
||||||
env = File.separator + "Adempiere";
|
env = File.separator + "Adempiere";
|
||||||
|
@ -789,7 +786,7 @@ public final class Ini implements Serializable
|
||||||
String ch = getAdempiereHome();
|
String ch = getAdempiereHome();
|
||||||
if (ch != null)
|
if (ch != null)
|
||||||
return ch;
|
return ch;
|
||||||
|
|
||||||
File[] roots = File.listRoots();
|
File[] roots = File.listRoots();
|
||||||
for (int i = 0; i < roots.length; i++)
|
for (int i = 0; i < roots.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -798,7 +795,7 @@ public final class Ini implements Serializable
|
||||||
File[] subs = roots[i].listFiles();
|
File[] subs = roots[i].listFiles();
|
||||||
if (subs == null)
|
if (subs == null)
|
||||||
continue;
|
continue;
|
||||||
for (int j = 0; j < subs.length; j++)
|
for (int j = 0; j < subs.length; j++)
|
||||||
{
|
{
|
||||||
if (!subs[j].isDirectory())
|
if (!subs[j].isDirectory())
|
||||||
continue;
|
continue;
|
||||||
|
@ -816,7 +813,7 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
} // findAdempiereHome
|
} // findAdempiereHome
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get Window Dimension
|
* Get Window Dimension
|
||||||
* @param AD_Window_ID window no
|
* @param AD_Window_ID window no
|
||||||
|
@ -842,9 +839,9 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getWindowDimension
|
} // getWindowDimension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Window Dimension
|
* Set Window Dimension
|
||||||
* @param AD_Window_ID window
|
* @param AD_Window_ID window
|
||||||
* @param windowDimension dimension - null to remove
|
* @param windowDimension dimension - null to remove
|
||||||
*/
|
*/
|
||||||
|
@ -859,7 +856,7 @@ public final class Ini implements Serializable
|
||||||
else
|
else
|
||||||
s_prop.remove(key);
|
s_prop.remove(key);
|
||||||
} // setWindowDimension
|
} // setWindowDimension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Window Location
|
* Get Window Location
|
||||||
* @param AD_Window_ID window id
|
* @param AD_Window_ID window id
|
||||||
|
@ -885,7 +882,7 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getWindowLocation
|
} // getWindowLocation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Window Location
|
* Set Window Location
|
||||||
* @param AD_Window_ID window
|
* @param AD_Window_ID window
|
||||||
|
@ -902,7 +899,7 @@ public final class Ini implements Serializable
|
||||||
else
|
else
|
||||||
s_prop.remove(key);
|
s_prop.remove(key);
|
||||||
} // setWindowLocation
|
} // setWindowLocation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Divider Location
|
* Get Divider Location
|
||||||
* @return location
|
* @return location
|
||||||
|
@ -922,7 +919,7 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // getDividerLocation
|
} // getDividerLocation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Divider Location
|
* Set Divider Location
|
||||||
* @param dividerLocation location
|
* @param dividerLocation location
|
||||||
|
@ -945,7 +942,7 @@ public final class Ini implements Serializable
|
||||||
col.toArray(arr);
|
col.toArray(arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current charset
|
* Get current charset
|
||||||
* @return current charset
|
* @return current charset
|
||||||
|
@ -961,8 +958,8 @@ public final class Ini implements Serializable
|
||||||
}
|
}
|
||||||
return Charset.defaultCharset();
|
return Charset.defaultCharset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPropertyFileName()
|
public static String getPropertyFileName()
|
||||||
{
|
{
|
||||||
return s_propertyFileName;
|
return s_propertyFileName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue