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:
parent
e1ce7e9ec9
commit
db714f918e
|
@ -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);
|
||||||
|
|
|
@ -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,7 +129,8 @@ public class PackInApplicationActivator extends AbstractActivator {
|
||||||
service = null;
|
service = null;
|
||||||
Thread.currentThread().setContextClassLoader(cl);
|
Thread.currentThread().setContextClassLoader(cl);
|
||||||
}
|
}
|
||||||
t.cancel();
|
}
|
||||||
|
t.cancel();
|
||||||
}
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue