[view] allow running KernelUtils ouside Tomcat
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Aug 2018 09:01:48 +0200
changeset 35067 bbdf0c84c3e2
parent 35066 ca52c98e1149
child 35068 87f38633756b
[view] allow running KernelUtils ouside Tomcat
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java	Mon Aug 06 08:59:19 2018 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java	Mon Aug 06 09:01:48 2018 +0200
@@ -33,6 +33,7 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
+import org.openbravo.base.session.SessionFactoryController;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.weld.WeldUtils;
 import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
@@ -76,7 +77,11 @@
   }
 
   public KernelUtils() {
-    adcs = WeldUtils.getInstanceFromStaticBeanManager(ApplicationDictionaryCachedStructures.class);
+    if (SessionFactoryController.isRunningInWebContainer()) {
+      // allow running outside Web container for tests
+      adcs = WeldUtils
+          .getInstanceFromStaticBeanManager(ApplicationDictionaryCachedStructures.class);
+    }
   }
 
   public static synchronized void setInstance(KernelUtils instance) {