IDEMPIERE-3824 Implement apply packin from folder from command line / avoid the plugin running when started from the PackInFolderApplication / make log level a parameter

This commit is contained in:
Carlos Ruiz 2019-01-15 13:28:13 +01:00
parent e1ce7e9ec9
commit db714f918e
2 changed files with 17 additions and 3 deletions

View File

@ -49,12 +49,24 @@ public class PackInFolderApplication implements IApplication {
@Override @Override
public Object start(IApplicationContext context) throws Exception { public Object start(IApplicationContext context) throws Exception {
Adempiere.startup(false); Adempiere.startup(false);
CLogMgt.setLevel(Level.FINE); String logLevel = System.getProperty("LogLevel");
if (logLevel == null)
logLevel = "INFO";
switch (logLevel) {
case "SEVERE": CLogMgt.setLevel(Level.SEVERE); break;
case "WARNING": CLogMgt.setLevel(Level.WARNING); break;
case "INFO": CLogMgt.setLevel(Level.INFO); break;
case "CONFIG": CLogMgt.setLevel(Level.CONFIG); break;
case "FINE": CLogMgt.setLevel(Level.FINE); break;
case "FINER": CLogMgt.setLevel(Level.FINER); break;
case "FINEST": CLogMgt.setLevel(Level.FINEST); break;
default: CLogMgt.setLevel(Level.INFO); break;
}
Map<?, ?> args = context.getArguments(); Map<?, ?> args = context.getArguments();
String commandlineArgs[] = (String[]) args.get("application.args"); String commandlineArgs[] = (String[]) args.get("application.args");
if (commandlineArgs.length == 1) { if (commandlineArgs.length == 1) {
Properties ctx = Env.getCtx(); Properties ctx = Env.getCtx();
Env.setContext(ctx, "org.adempiere.base.PackInFolderApplication", "Y");
String directory = commandlineArgs[0]; String directory = commandlineArgs[0];
ProcessInfo pi = new ProcessInfo("PackInFolder", 200099); ProcessInfo pi = new ProcessInfo("PackInFolder", 200099);
pi.setAD_Client_ID(0); pi.setAD_Client_ID(0);

View File

@ -118,6 +118,7 @@ public class PackInApplicationActivator extends AbstractActivator {
t.schedule(new TimerTask() { t.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
if (! "Y".equals(Env.getContext(Env.getCtx(), "org.adempiere.base.PackInFolderApplication"))) {
ClassLoader cl = Thread.currentThread().getContextClassLoader(); ClassLoader cl = Thread.currentThread().getContextClassLoader();
try { try {
Thread.currentThread().setContextClassLoader(PackInApplicationActivator.class.getClassLoader()); Thread.currentThread().setContextClassLoader(PackInApplicationActivator.class.getClassLoader());
@ -128,6 +129,7 @@ public class PackInApplicationActivator extends AbstractActivator {
service = null; service = null;
Thread.currentThread().setContextClassLoader(cl); Thread.currentThread().setContextClassLoader(cl);
} }
}
t.cancel(); t.cancel();
} }
}, timeout); }, timeout);