public Object getInstance(String deploymentId, String resource) { // First find in cache DeploymentCache<Object> deploymentCache = cacheInstance.get(deploymentId); if (deploymentCache == null) { deploymentCache = new DefaultDeploymentCache<Object>(); cacheInstance.put(deploymentId, deploymentCache); } Object instance = deploymentCache.get(resource); if (instance == null) { @SuppressWarnings("rawtypes") ProjectEngineFactory projectEngineFactory = get(deploymentId, resource); try { instance = projectEngineFactory.newInstance(); } catch (Exception e) { throw new ResourceCompileException( "Resource with name '" + resource + "' in deployment with id '" + deploymentId + "' compilation has been failed"); } deploymentCache.add(resource, instance); } return instance; }
public ResultValue execute(DelegateExecution execution, String resource, String methodName, Object... args) throws Exception { String processDefinitionId = execution.getProcessDefinitionId(); RepositoryService repositoryService = execution.getEngineServices().getRepositoryService(); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId); @SuppressWarnings("rawtypes") ProjectEngineFactory projectEngineFactory = OpenLRulesHelper.getInstance() .get(processDefinition.getDeploymentId(), resource); Object instance = OpenLRulesHelper.getInstance().getInstance(processDefinition.getDeploymentId(), resource); Class<?> interfaceClass = projectEngineFactory.getInterfaceClass(); assert interfaceClass != null; // Always Non-null Object result = org.openl.rules.activiti.spring.OpenLEngine.findAndInvokeMethod(methodName, instance, interfaceClass, args); return new ResultValue(result); } }
public ResultValue execute(DelegateExecution execution, String resource, String methodName, Object... args) throws Exception { String processDefinitionId = execution.getProcessDefinitionId(); RepositoryService repositoryService = execution.getEngineServices().getRepositoryService(); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId); @SuppressWarnings("rawtypes") ProjectEngineFactory projectEngineFactory = OpenLRulesHelper.getInstance() .get(processDefinition.getDeploymentId(), resource); Object instance = OpenLRulesHelper.getInstance().getInstance(processDefinition.getDeploymentId(), resource); Class<?> interfaceClass = projectEngineFactory.getInterfaceClass(); assert interfaceClass != null; // Always Non-null Object result = org.openl.rules.activiti.spring.OpenLEngine.findAndInvokeMethod(methodName, instance, interfaceClass, args); return new ResultValue(result); } }
public Object getInstance(String deploymentId, String resource) { // First find in cache DeploymentCache<Object> deploymentCache = cacheInstance.get(deploymentId); if (deploymentCache == null) { deploymentCache = new DefaultDeploymentCache<Object>(); cacheInstance.put(deploymentId, deploymentCache); } Object instance = deploymentCache.get(resource); if (instance == null) { @SuppressWarnings("rawtypes") ProjectEngineFactory projectEngineFactory = get(deploymentId, resource); try { instance = projectEngineFactory.newInstance(); } catch (Exception e) { throw new ResourceCompileException( "Resource with name '" + resource + "' in deployment with id '" + deploymentId + "' compilation has been failed"); } deploymentCache.add(resource, instance); } return instance; }