Author: jacopoc
Date: Fri Feb 26 08:01:21 2010 New Revision: 916608 URL: http://svn.apache.org/viewvc?rev=916608&view=rev Log: Added flag to switch off the debug mode for services that is causing out of memory errors for JVM PermGen space. Warning: the default setting is still set to true but it is highly recommended to set it to false, especially for non-development instances (production, demo etc...). Modified: ofbiz/trunk/framework/service/config/service.properties ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Modified: ofbiz/trunk/framework/service/config/service.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/config/service.properties?rev=916608&r1=916607&r2=916608&view=diff ============================================================================== --- ofbiz/trunk/framework/service/config/service.properties (original) +++ ofbiz/trunk/framework/service/config/service.properties Fri Feb 26 08:01:21 2010 @@ -17,5 +17,7 @@ # under the License. ############################################################################### +# If set to true then service definitions are wrapped with their filename and line number, for easier debugging; if enabled, JVM PermGen memory settings may need to be increased +servicedispatcher.servicedebugmode=false # flag to automatically export all services: same of setting export="true" for all service definitions remotedispatcher.exportall=false Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?rev=916608&r1=916607&r2=916608&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Fri Feb 26 08:01:21 2010 @@ -229,7 +229,9 @@ this.overrideParameters = model.overrideParameters; this.inheritedParameters = model.inheritedParameters(); this.internalGroup = model.internalGroup; - this.invoker = model.invoker.copy(this); + if (model.invoker != null) { + this.invoker = model.invoker.copy(this); + } List<ModelParam> modelParamList = model.getModelParamList(); for (ModelParam param: modelParamList) { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java?rev=916608&r1=916607&r2=916608&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java Fri Feb 26 08:01:21 2010 @@ -38,6 +38,7 @@ import org.ofbiz.base.config.ResourceHandler; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -65,6 +66,7 @@ public class ModelServiceReader implements Serializable { public static final String module = ModelServiceReader.class.getName(); + protected static boolean serviceDebugMode = true; /** is either from a URL or from a ResourceLoader (through the ResourceHandler) */ protected boolean isFromURL; @@ -93,6 +95,7 @@ this.readerURL = readerURL; this.handler = handler; this.dctx = dctx; + serviceDebugMode = "true".equals(UtilProperties.getPropertyValue("service", "servicedispatcher.servicedebugmode", "true")); } private Map<String, ModelService> getModelServices() { @@ -202,20 +205,21 @@ ModelService service = new ModelService(); service.name = UtilXml.checkEmpty(serviceElement.getAttribute("name")).intern(); - Wrap<GenericInvoker> wrap = new Wrap<GenericInvoker>().fileName(resourceLocation + '#' + service.name).wrappedClass(GenericInvokerImpl.class); - for (Method method: GenericInvokerImpl.class.getDeclaredMethods()) { - if (method.getName().startsWith("run")) { - wrap.wrap(method); - } else if (method.getName().startsWith("send")) { - wrap.wrap(method); + if (serviceDebugMode) { + Wrap<GenericInvoker> wrap = new Wrap<GenericInvoker>().fileName(resourceLocation + '#' + service.name).wrappedClass(GenericInvokerImpl.class); + for (Method method: GenericInvokerImpl.class.getDeclaredMethods()) { + if (method.getName().startsWith("run")) { + wrap.wrap(method); + } else if (method.getName().startsWith("send")) { + wrap.wrap(method); + } } + Object startLine = serviceElement.getUserData("startLine"); + if (startLine != null) { + wrap.lineNumber(((Integer) startLine).intValue()); + } + service.invoker = wrap.newInstance(new Class<?>[] {ModelService.class}, new Object[] {service}); } - Object startLine = serviceElement.getUserData("startLine"); - if (startLine != null) { - wrap.lineNumber(((Integer) startLine).intValue()); - } - service.invoker = wrap.newInstance(new Class<?>[] {ModelService.class}, new Object[] {service}); - service.definitionLocation = resourceLocation; service.engineName = UtilXml.checkEmpty(serviceElement.getAttribute("engine")).intern(); service.location = UtilXml.checkEmpty(serviceElement.getAttribute("location")).intern(); Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=916608&r1=916607&r2=916608&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Fri Feb 26 08:01:21 2010 @@ -30,6 +30,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -73,6 +74,7 @@ protected static boolean enableJM = true; protected static boolean enableJMS = true; protected static boolean enableSvcs = true; + protected static boolean serviceDebugMode = true; protected Delegator delegator = null; protected GenericEngineFactory factory = null; @@ -121,6 +123,7 @@ if (enableSvcs) { this.runStartupServices(); } + serviceDebugMode = "true".equals(UtilProperties.getPropertyValue("service", "servicedispatcher.servicedebugmode", "true")); } protected ServiceDispatcher(Delegator delegator) { @@ -391,8 +394,14 @@ // ===== invoke the service ===== if (!isError && !isFailure) { - Map<String, Object> invokeResult = modelService.invoker.runSync(localName, engine, context); - modelService.invoker.sendCallbacks(engine, context, invokeResult, null, GenericEngine.SYNC_MODE); + Map<String, Object> invokeResult = null; + if (serviceDebugMode) { + invokeResult = modelService.invoker.runSync(localName, engine, context); + modelService.invoker.sendCallbacks(engine, context, invokeResult, null, GenericEngine.SYNC_MODE); + } else { + invokeResult = engine.runSync(localName, modelService, context); + engine.sendCallbacks(modelService, context, invokeResult, GenericEngine.SYNC_MODE); + } if (invokeResult != null) { result.putAll(invokeResult); } else { @@ -508,7 +517,11 @@ } String errMsg = "Service [" + modelService.name + "] threw an unexpected exception/error"; Debug.logError(t, errMsg, module); - modelService.invoker.sendCallbacks(engine, context, null, t, GenericEngine.SYNC_MODE); + if (serviceDebugMode) { + modelService.invoker.sendCallbacks(engine, context, null, t, GenericEngine.SYNC_MODE); + } else { + engine.sendCallbacks(modelService, context, t, GenericEngine.SYNC_MODE); + } try { TransactionUtil.rollback(beganTrans, errMsg, t); } catch (GenericTransactionException te) { @@ -694,8 +707,17 @@ // run the service if (!isError && !isFailure) { - service.invoker.runAsync(localName, engine, context, requester, persist); - service.invoker.sendCallbacks(engine, context, null, null, GenericEngine.ASYNC_MODE); + if (serviceDebugMode) { + service.invoker.runAsync(localName, engine, context, requester, persist); + service.invoker.sendCallbacks(engine, context, null, null, GenericEngine.ASYNC_MODE); + } else { + if (requester != null) { + engine.runAsync(localName, service, context, requester, persist); + } else { + engine.runAsync(localName, service, context, persist); + } + engine.sendCallbacks(service, context, GenericEngine.ASYNC_MODE); + } } if (Debug.timingOn()) { @@ -708,7 +730,11 @@ } String errMsg = "Service [" + service.name + "] threw an unexpected exception/error"; Debug.logError(t, errMsg, module); - service.invoker.sendCallbacks(engine, context, null, t, GenericEngine.ASYNC_MODE); + if (serviceDebugMode) { + service.invoker.sendCallbacks(engine, context, null, t, GenericEngine.ASYNC_MODE); + } else { + engine.sendCallbacks(service, context, t, GenericEngine.ASYNC_MODE); + } try { TransactionUtil.rollback(beganTrans, errMsg, t); } catch (GenericTransactionException te) { |
Free forum by Nabble | Edit this page |