This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit e68a25e6dcd21bc85d515919667127466ae8efbb Author: Guillaume Nodet <[email protected]> AuthorDate: Wed Aug 19 13:06:14 2020 +0200 [CAMEL-14578] Reformat --- .../component/jbpm/JBPMCamelConsumerAware.java | 6 +- .../apache/camel/component/jbpm/JBPMComponent.java | 4 +- .../camel/component/jbpm/JBPMConfiguration.java | 21 ++-- .../apache/camel/component/jbpm/JBPMConstants.java | 5 +- .../apache/camel/component/jbpm/JBPMConsumer.java | 85 ++++++++------- .../apache/camel/component/jbpm/JBPMEndpoint.java | 11 +- .../apache/camel/component/jbpm/JBPMProducer.java | 119 +++++++++++++-------- .../component/jbpm/config/CamelContextBuilder.java | 3 +- .../component/jbpm/emitters/CamelEventEmitter.java | 16 +-- .../emitters/ServiceRegistryBoundEventEmitter.java | 10 +- .../jbpm/listeners/CamelCaseEventListener.java | 7 +- .../jbpm/listeners/CamelProcessEventListener.java | 5 +- .../jbpm/listeners/CamelTaskEventListener.java | 10 +- .../jbpm/server/CamelKieServerExtension.java | 27 ++--- .../jbpm/workitem/AbstractCamelCommand.java | 24 ++--- .../workitem/AbstractCamelWorkItemHandler.java | 66 ++++++------ .../workitem/DeploymentContextCamelCommand.java | 3 +- .../jbpm/workitem/GlobalContextCamelCommand.java | 12 +-- .../jbpm/workitem/InOnlyCamelWorkItemHandler.java | 58 +++++----- .../jbpm/workitem/InOutCamelWorkItemHandler.java | 56 +++++----- 20 files changed, 296 insertions(+), 252 deletions(-) diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java index b4ec415..4b9ffc3 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java @@ -17,12 +17,12 @@ package org.apache.camel.component.jbpm; /** - * Indicates that class implementing this interface should receive (at some point) - * JBPMConsumer instance that is required to operate. + * Indicates that class implementing this interface should receive (at some point) JBPMConsumer instance that is + * required to operate. */ public interface JBPMCamelConsumerAware { void addConsumer(JBPMConsumer consumer); - + void removeConsumer(JBPMConsumer consumer); } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java index d0c5475..0871252 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java @@ -30,7 +30,7 @@ public class JBPMComponent extends DefaultComponent { JBPMConfiguration configuration = new JBPMConfiguration(); if (remaining.startsWith("events")) { configuration.setEventListenerType(remaining.split(":")[1]); - } else { + } else { configuration.setConnectionURL(new URL(remaining)); } JBPMEndpoint endpoint = new JBPMEndpoint(uri, this, configuration); @@ -38,4 +38,4 @@ public class JBPMComponent extends DefaultComponent { return endpoint; } -} \ No newline at end of file +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java index 7f27b75..b92c204 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java @@ -161,8 +161,7 @@ public class JBPMConfiguration { } /** - * the data associated with this event when signalEvent operation is - * performed + * the data associated with this event when signalEvent operation is performed */ public void setEvent(Object event) { this.event = event; @@ -393,8 +392,7 @@ public class JBPMConfiguration { } /** - * Sets if event produced by emitter should be sent as single items or - * complete collection + * Sets if event produced by emitter should be sent as single items or complete collection */ public void setEmitterSendItems(Boolean emiterSendItems) { this.emitterSendItems = emiterSendItems; @@ -402,11 +400,16 @@ public class JBPMConfiguration { @Override public String toString() { - return "JBPMConfiguration [connectionURL=" + connectionURL + ", operation=" + operation + ", deploymentId=" + deploymentId + ", processInstanceId=" + processInstanceId - + ", value=" + value + ", processId=" + processId + ", eventType=" + eventType + ", event=" + event + ", maxNumber=" + maxNumber + ", identifier=" + identifier - + ", workItemId=" + workItemId + ", taskId=" + taskId + ", userId=" + userId + ", page=" + page + ", pageSize=" + pageSize + ", targetUserId=" + targetUserId - + ", attachmentId=" + attachmentId + ", contentId=" + contentId + ", task=" + task + ", entities=" + entities + ", statuses=" + statuses + ", userName=" + userName - + ", password=" + password + ", timeout=" + timeout + ", parameters=" + parameters + ", extraJaxbClasses=" + Arrays.toString(extraJaxbClasses) + return "JBPMConfiguration [connectionURL=" + connectionURL + ", operation=" + operation + ", deploymentId=" + + deploymentId + ", processInstanceId=" + processInstanceId + + ", value=" + value + ", processId=" + processId + ", eventType=" + eventType + ", event=" + event + + ", maxNumber=" + maxNumber + ", identifier=" + identifier + + ", workItemId=" + workItemId + ", taskId=" + taskId + ", userId=" + userId + ", page=" + page + ", pageSize=" + + pageSize + ", targetUserId=" + targetUserId + + ", attachmentId=" + attachmentId + ", contentId=" + contentId + ", task=" + task + ", entities=" + entities + + ", statuses=" + statuses + ", userName=" + userName + + ", password=" + password + ", timeout=" + timeout + ", parameters=" + parameters + ", extraJaxbClasses=" + + Arrays.toString(extraJaxbClasses) + ", eventListenerType=" + eventListenerType + "]"; } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java index c16e5fc..a56da17 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java @@ -30,7 +30,7 @@ public interface JBPMConstants { String TASK_ID = "CamelJBPMTaskId"; String TASK = "CamelJBPMTask"; String USER_ID = "CamelJBPMUserId"; - String TARGET_USER_ID = "CamelJBPMTargetUserId"; + String TARGET_USER_ID = "CamelJBPMTargetUserId"; String ATTACHMENT_ID = "CamelJBPMAttachmentId"; String CONTENT_ID = "CamelJBPMContentId"; String ENTITY_LIST = "CamelJBPMEntityList"; @@ -49,8 +49,7 @@ public interface JBPMConstants { String HANDLE_EXCEPTION_WI_PARAM = "HandleExceptions"; String RESPONSE_WI_PARAM = "Response"; String MESSAGE_WI_PARAM = "Message"; - + String CAMEL_CONTEXT_BUILDER_KEY = "CamelContextBuilder"; - } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java index 55ec0dd..20e86fa 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java @@ -37,17 +37,16 @@ import org.kie.internal.runtime.manager.InternalRuntimeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class JBPMConsumer extends DefaultConsumer implements DeploymentEventListener { - + private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMConsumer.class); - + private JBPMEndpoint endpoint; private JBPMConfiguration configuration; - + public JBPMConsumer(Endpoint endpoint, Processor processor) { super(endpoint, processor); - + this.endpoint = (JBPMEndpoint) endpoint; this.configuration = ((JBPMEndpoint) getEndpoint()).getConfiguration(); } @@ -55,51 +54,53 @@ public class JBPMConsumer extends DefaultConsumer implements DeploymentEventList @Override protected void doStart() throws Exception { super.doStart(); - - DeploymentService deploymentService = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); - + + DeploymentService deploymentService + = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); + if (configuration.getDeploymentId() != null) { - InternalRuntimeManager manager = (InternalRuntimeManager) deploymentService.getRuntimeManager(configuration.getDeploymentId()); + InternalRuntimeManager manager + = (InternalRuntimeManager) deploymentService.getRuntimeManager(configuration.getDeploymentId()); configure(manager, this); - + LOGGER.debug("JBPM Camel Consumer configured and started for deployment id {}", configuration.getDeploymentId()); } else { - + ((ListenerSupport) deploymentService).addListener(this); - + for (DeployedUnit deployed : deploymentService.getDeployedUnits()) { InternalRuntimeManager manager = (InternalRuntimeManager) deployed.getRuntimeManager(); - configure(manager, this); + configure(manager, this); } - + LOGGER.debug("JBPM Camel Consumer configured and started on all available deployments"); } - - + } @Override protected void doStop() throws Exception { super.doStop(); - DeploymentService deploymentService = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); + DeploymentService deploymentService + = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); if (configuration.getDeploymentId() != null) { LOGGER.debug("JBPM Camel Consumer unconfigured and stopped for deployment id {}", configuration.getDeploymentId()); } else { ((ListenerSupport) deploymentService).removeListener(this); - + LOGGER.debug("JBPM Camel Consumer unconfigured and stopped on all available deployments"); } - + if (JBPMConstants.JBPM_EVENT_EMITTER.equals(configuration.getEventListenerType())) { ServiceRegistry.get().remove("CamelEventEmitter"); } - + } public void sendMessage(String eventType, Object body) { Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOnly); exchange.getIn().setHeader("EventType", eventType); - + exchange.getIn().setBody(body); if (!endpoint.isSynchronous()) { @@ -125,64 +126,65 @@ public class JBPMConsumer extends DefaultConsumer implements DeploymentEventList } } } - + @Override public void onDeploy(DeploymentEvent event) { InternalRuntimeManager manager = (InternalRuntimeManager) event.getDeployedUnit().getRuntimeManager(); - configure(manager, this); + configure(manager, this); } @Override - public void onUnDeploy(DeploymentEvent event) { + public void onUnDeploy(DeploymentEvent event) { // no-op } @Override public void onActivate(DeploymentEvent event) { // no-op - + } @Override public void onDeactivate(DeploymentEvent event) { // no-op - + } - protected void configure(InternalRuntimeManager manager, JBPMConsumer consumer) { String eventListenerType = configuration.getEventListenerType(); if (eventListenerType == null) { return; } - - + configureConsumer(eventListenerType, manager, consumer); - + } - + protected void configureConsumer(String eventListenerType, InternalRuntimeManager manager, JBPMConsumer consumer) { LOGGER.debug("Configuring Camel JBPM Consumer for {} on runtime manager {}", eventListenerType, manager); - + CacheManager cacheManager = manager.getCacheManager(); JBPMCamelConsumerAware consumerAware = null; if (JBPMConstants.JBPM_PROCESS_EVENT_LISTENER.equals(eventListenerType)) { - consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()"); + consumerAware = (JBPMCamelConsumerAware) cacheManager + .get("new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()"); if (consumerAware == null) { consumerAware = new CamelProcessEventListener(); cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()", consumerAware); } LOGGER.debug("Configuring JBPMConsumer on process event listener {}", consumerAware); } else if (JBPMConstants.JBPM_TASK_EVENT_LISTENER.equals(eventListenerType)) { - consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()"); + consumerAware = (JBPMCamelConsumerAware) cacheManager + .get("new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()"); if (consumerAware == null) { consumerAware = new CamelTaskEventListener(); cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()", consumerAware); } LOGGER.debug("Configuring JBPMConsumer on task event listener {}", consumerAware); } else if (JBPMConstants.JBPM_CASE_EVENT_LISTENER.equals(eventListenerType)) { - consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()"); + consumerAware = (JBPMCamelConsumerAware) cacheManager + .get("new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()"); if (consumerAware == null) { consumerAware = new CamelCaseEventListener(); cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()", consumerAware); @@ -190,14 +192,15 @@ public class JBPMConsumer extends DefaultConsumer implements DeploymentEventList LOGGER.debug("Configuring JBPMConsumer on case event listener {}", consumerAware); } else if (JBPMConstants.JBPM_EVENT_EMITTER.equals(eventListenerType)) { LOGGER.debug("Configuring JBPMConsumer for event emitter"); - ServiceRegistry.get().register("CamelEventEmitter", new CamelEventEmitter(this, configuration.getEmitterSendItems())); - + ServiceRegistry.get().register("CamelEventEmitter", + new CamelEventEmitter(this, configuration.getEmitterSendItems())); + return; - } - + } + LOGGER.debug("Adding consumer {} on {}", consumer, consumerAware); - consumerAware.addConsumer(consumer); - + consumerAware.addConsumer(consumer); + } @Override diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java index 6c9f9b7..379ba67 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java @@ -38,21 +38,24 @@ import org.slf4j.LoggerFactory; /** * Interact with jBPM workflow engine over REST. */ -@UriEndpoint(firstVersion = "2.6.0", scheme = "jbpm", title = "JBPM", syntax = "jbpm:connectionURL", category = {Category.API, Category.WORKFLOW}) +@UriEndpoint(firstVersion = "2.6.0", scheme = "jbpm", title = "JBPM", syntax = "jbpm:connectionURL", + category = { Category.API, Category.WORKFLOW }) public class JBPMEndpoint extends DefaultEndpoint { private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMEndpoint.class); @UriParam private JBPMConfiguration configuration; - public JBPMEndpoint(String uri, JBPMComponent component, JBPMConfiguration configuration) throws URISyntaxException, MalformedURLException { + public JBPMEndpoint(String uri, JBPMComponent component, JBPMConfiguration configuration) throws URISyntaxException, + MalformedURLException { super(uri, component); this.configuration = configuration; } public Producer createProducer() throws Exception { - KieServicesConfiguration kieConfiguration = KieServicesFactory.newRestConfiguration(configuration.getConnectionURL().toExternalForm(), configuration.getUserName(), - configuration.getPassword()); + KieServicesConfiguration kieConfiguration = KieServicesFactory.newRestConfiguration( + configuration.getConnectionURL().toExternalForm(), configuration.getUserName(), + configuration.getPassword()); if (configuration.getTimeout() != null) { kieConfiguration.setTimeout(configuration.getTimeout()); diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java index bd178b5..8f83a1e 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java @@ -94,7 +94,8 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - Long processInstance = processClient.startProcess(configuration.getDeploymentId(), getProcessId(configuration, exchange), getParameters(configuration, exchange)); + Long processInstance = processClient.startProcess(configuration.getDeploymentId(), + getProcessId(configuration, exchange), getParameters(configuration, exchange)); setResult(exchange, processInstance); } }, @@ -102,7 +103,8 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - processClient.abortProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); + processClient.abortProcessInstance(configuration.getDeploymentId(), + safe(getProcessInstanceId(configuration, exchange))); } }, signalEvent { @@ -111,10 +113,12 @@ public class JBPMProducer extends DefaultProducer { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); Long processInstanceId = getProcessInstanceId(configuration, exchange); if (processInstanceId != null) { - processClient.signalProcessInstance(configuration.getDeploymentId(), processInstanceId, getEventType(configuration, exchange), - getEvent(configuration, exchange)); + processClient.signalProcessInstance(configuration.getDeploymentId(), processInstanceId, + getEventType(configuration, exchange), + getEvent(configuration, exchange)); } else { - processClient.signal(configuration.getDeploymentId(), getEventType(configuration, exchange), getEvent(configuration, exchange)); + processClient.signal(configuration.getDeploymentId(), getEventType(configuration, exchange), + getEvent(configuration, exchange)); } } }, @@ -122,7 +126,8 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - ProcessInstance processInstance = processClient.getProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); + ProcessInstance processInstance = processClient.getProcessInstance(configuration.getDeploymentId(), + safe(getProcessInstanceId(configuration, exchange))); setResult(exchange, processInstance); } }, @@ -130,7 +135,8 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class); - Collection<ProcessInstance> processInstances = queryClient.findProcessInstances(getPage(configuration, exchange), getPageSize(configuration, exchange)); + Collection<ProcessInstance> processInstances = queryClient + .findProcessInstances(getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, processInstances); } }, @@ -149,7 +155,8 @@ public class JBPMProducer extends DefaultProducer { } else { commands.add(commandsFactory.newFireAllRules()); } - ServiceResponse<ExecutionResults> reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + ServiceResponse<ExecutionResults> reply + = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); setResult(exchange, reply.getResult()); } }, @@ -162,7 +169,8 @@ public class JBPMProducer extends DefaultProducer { String identifier = getIdentifier(configuration, exchange); commands.add(commandsFactory.newGetGlobal(identifier, identifier)); - ServiceResponse<ExecutionResults> reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + ServiceResponse<ExecutionResults> reply + = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); setResult(exchange, reply.getResult().getValue(identifier)); } }, @@ -173,7 +181,8 @@ public class JBPMProducer extends DefaultProducer { List<Command<?>> commands = new ArrayList<Command<?>>(); BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands); - commands.add(commandsFactory.newSetGlobal(getIdentifier(configuration, exchange), getValue(configuration, exchange))); + commands.add(commandsFactory.newSetGlobal(getIdentifier(configuration, exchange), + getValue(configuration, exchange))); ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); } @@ -184,15 +193,17 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - processClient.abortWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange))); + processClient.abortWorkItem(configuration.getDeploymentId(), + safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange))); } }, completeWorkItem { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - processClient.completeWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange)), - getParameters(configuration, exchange)); + processClient.completeWorkItem(configuration.getDeploymentId(), + safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange)), + getParameters(configuration, exchange)); } }, @@ -201,53 +212,60 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.activateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.activateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, claimTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.claimTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.claimTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, completeTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.completeAutoProgress(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), - getParameters(configuration, exchange)); + taskClient.completeAutoProgress(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange), + getParameters(configuration, exchange)); } }, delegateTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.delegateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), - getTargetUserId(configuration, exchange)); + taskClient.delegateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange), + getTargetUserId(configuration, exchange)); } }, exitTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.exitTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.exitTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, failTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.failTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), - getParameters(configuration, exchange)); + taskClient.failTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange), + getParameters(configuration, exchange)); } }, getAttachment { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - TaskAttachment attachment = taskClient.getTaskAttachmentById(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), - safe(getAttachmentId(configuration, exchange))); + TaskAttachment attachment = taskClient.getTaskAttachmentById(configuration.getDeploymentId(), + safe(getTaskId(configuration, exchange)), + safe(getAttachmentId(configuration, exchange))); setResult(exchange, attachment); } }, @@ -255,8 +273,9 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List<TaskSummary> taskSummaries = taskClient.findTasksAssignedAsBusinessAdministrator(getUserId(configuration, exchange), getPage(configuration, exchange), - getPageSize(configuration, exchange)); + List<TaskSummary> taskSummaries = taskClient.findTasksAssignedAsBusinessAdministrator( + getUserId(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, taskSummaries); } }, @@ -264,8 +283,9 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List<TaskSummary> taskSummaries = taskClient.findTasksAssignedAsPotentialOwner(getUserId(configuration, exchange), getStatuses(configuration, exchange), - getPage(configuration, exchange), getPageSize(configuration, exchange)); + List<TaskSummary> taskSummaries = taskClient.findTasksAssignedAsPotentialOwner( + getUserId(configuration, exchange), getStatuses(configuration, exchange), + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, taskSummaries); } }, @@ -289,7 +309,8 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - Map<String, Object> content = taskClient.getTaskOutputContentByTaskId(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange))); + Map<String, Object> content = taskClient.getTaskOutputContentByTaskId(configuration.getDeploymentId(), + safe(getTaskId(configuration, exchange))); setResult(exchange, content); } }, @@ -297,8 +318,9 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List<TaskSummary> processInstanceIds = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), Collections.emptyList(), - getPage(configuration, exchange), getPageSize(configuration, exchange)); + List<TaskSummary> processInstanceIds = taskClient.findTasksByStatusByProcessInstanceId( + safe(getProcessInstanceId(configuration, exchange)), Collections.emptyList(), + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, processInstanceIds); } }, @@ -306,9 +328,10 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List<TaskSummary> taskSummaryList = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), - getStatuses(configuration, exchange), getPage(configuration, exchange), - getPageSize(configuration, exchange)); + List<TaskSummary> taskSummaryList + = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), + getStatuses(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, taskSummaryList); } }, @@ -316,8 +339,9 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List<TaskSummary> summaryList = taskClient.findTasksOwned(getUserId(configuration, exchange), getPage(configuration, exchange), - getPageSize(configuration, exchange)); + List<TaskSummary> summaryList + = taskClient.findTasksOwned(getUserId(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, summaryList); } }, @@ -325,50 +349,57 @@ public class JBPMProducer extends DefaultProducer { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.nominateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), - getEntities(configuration, exchange)); + taskClient.nominateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange), + getEntities(configuration, exchange)); } }, releaseTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.releaseTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.releaseTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, resumeTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.resumeTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.resumeTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, skipTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.skipTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.skipTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, startTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.startTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.startTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, stopTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.stopTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.stopTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }, suspendTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.suspendTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + taskClient.suspendTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + getUserId(configuration, exchange)); } }; diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/config/CamelContextBuilder.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/config/CamelContextBuilder.java index 3aadf91..62f1777 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/config/CamelContextBuilder.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/config/CamelContextBuilder.java @@ -26,10 +26,11 @@ public interface CamelContextBuilder { /** * Default implementation that allows to simply return <code>DefaultCamelContext</code> instance + * * @return returns <code>DefaultCamelContext</code> instance */ default CamelContext buildCamelContext() { - + return new DefaultCamelContext(); } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java index a1b9b27..5f48ba5 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java @@ -25,19 +25,19 @@ import org.jbpm.persistence.api.integration.InstanceView; import org.jbpm.persistence.api.integration.base.BaseEventCollection; public class CamelEventEmitter implements EventEmitter { - + private JBPMConsumer consumer; private boolean sendItems; - + public CamelEventEmitter(JBPMConsumer consumer, boolean sendItems) { - this.consumer = consumer; + this.consumer = consumer; this.sendItems = sendItems; } @Override public void deliver(Collection<InstanceView<?>> data) { // no-op - + } @Override @@ -45,12 +45,12 @@ public class CamelEventEmitter implements EventEmitter { if (consumer == null || data.isEmpty()) { return; } - + if (sendItems) { - + data.forEach(item -> consumer.sendMessage("Emitter", item)); } else { - + consumer.sendMessage("Emitter", data); } } @@ -58,7 +58,7 @@ public class CamelEventEmitter implements EventEmitter { @Override public void drop(Collection<InstanceView<?>> data) { // no-op - + } @Override diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java index 8c13af4..86e52e9 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java @@ -24,9 +24,9 @@ import org.jbpm.persistence.api.integration.InstanceView; import org.jbpm.services.api.service.ServiceRegistry; public class ServiceRegistryBoundEventEmitter implements EventEmitter { - + private EventEmitter delegate; - + public ServiceRegistryBoundEventEmitter() { this.delegate = (EventEmitter) ServiceRegistry.get().service("CamelEventEmitter"); } @@ -34,7 +34,7 @@ public class ServiceRegistryBoundEventEmitter implements EventEmitter { @Override public void deliver(Collection<InstanceView<?>> data) { delegate.deliver(data); - + } @Override @@ -45,7 +45,7 @@ public class ServiceRegistryBoundEventEmitter implements EventEmitter { @Override public void drop(Collection<InstanceView<?>> data) { delegate.drop(data); - + } @Override @@ -55,7 +55,7 @@ public class ServiceRegistryBoundEventEmitter implements EventEmitter { @Override public void close() { - + } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java index 33144f4..de3f739 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java @@ -34,11 +34,10 @@ import org.jbpm.casemgmt.api.event.CaseRoleAssignmentEvent; import org.jbpm.casemgmt.api.event.CaseStartEvent; import org.kie.internal.runtime.Cacheable; +public class CamelCaseEventListener implements CaseEventListener, Cacheable, JBPMCamelConsumerAware { -public class CamelCaseEventListener implements CaseEventListener, Cacheable, JBPMCamelConsumerAware { - private Set<JBPMConsumer> consumers = new LinkedHashSet<>(); - + @Override public void beforeCaseStarted(CaseStartEvent event) { if (consumers.isEmpty()) { @@ -277,7 +276,7 @@ public class CamelCaseEventListener implements CaseEventListener, Cacheable, JBP public void removeConsumer(JBPMConsumer consumer) { this.consumers.remove(consumer); } - + protected void sendMessage(String eventType, Object event) { this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java index b630765..dfefd53 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java @@ -29,7 +29,6 @@ import org.kie.api.event.process.ProcessStartedEvent; import org.kie.api.event.process.ProcessVariableChangedEvent; import org.kie.internal.runtime.Cacheable; - public class CamelProcessEventListener implements ProcessEventListener, Cacheable, JBPMCamelConsumerAware { private Set<JBPMConsumer> consumers = new LinkedHashSet<>(); @@ -48,7 +47,7 @@ public class CamelProcessEventListener implements ProcessEventListener, Cacheabl if (consumers.isEmpty()) { return; } - + sendMessage("afterProcessStarted", event); } @@ -130,7 +129,7 @@ public class CamelProcessEventListener implements ProcessEventListener, Cacheabl public void removeConsumer(JBPMConsumer consumer) { this.consumers.remove(consumer); } - + protected void sendMessage(String eventType, Object event) { this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java index 3583b44..95973d7 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java @@ -25,11 +25,10 @@ import org.kie.api.task.TaskEvent; import org.kie.api.task.TaskLifeCycleEventListener; import org.kie.internal.runtime.Cacheable; - public class CamelTaskEventListener implements Cacheable, TaskLifeCycleEventListener, JBPMCamelConsumerAware { private Set<JBPMConsumer> consumers = new LinkedHashSet<>(); - + @Override public void beforeTaskActivatedEvent(TaskEvent event) { if (consumers.isEmpty()) { @@ -298,23 +297,22 @@ public class CamelTaskEventListener implements Cacheable, TaskLifeCycleEventList } @Override - public void close() { + public void close() { } @Override public void addConsumer(JBPMConsumer consumer) { - this.consumers.add(consumer); + this.consumers.add(consumer); } @Override public void removeConsumer(JBPMConsumer consumer) { this.consumers.remove(consumer); } - + protected void sendMessage(String eventType, Object event) { this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); } - } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java index 43f6fa5..36dfadb 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java @@ -93,13 +93,14 @@ public class CamelKieServerExtension implements KieServerExtension { @Override public void init(KieServerImpl kieServer, KieServerRegistry registry) { if (this.managedCamel && this.camelContext == null) { - this.camelContext = (DefaultCamelContext)buildGlobalContext(); + this.camelContext = (DefaultCamelContext) buildGlobalContext(); this.camelContext.setName("KIE Server Camel context"); try (InputStream is = this.getClass().getResourceAsStream("/global-camel-routes.xml")) { if (is != null) { ExtendedCamelContext ecc = camelContext.adapt(ExtendedCamelContext.class); - RoutesDefinition routes = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(camelContext, is); + RoutesDefinition routes + = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(camelContext, is); camelContext.addRouteDefinitions(routes.getRoutes()); } } catch (Exception e) { @@ -130,14 +131,15 @@ public class CamelKieServerExtension implements KieServerExtension { try (InputStream is = classloader.getResourceAsStream("camel-routes.xml")) { if (is != null) { - DefaultCamelContext context = (DefaultCamelContext)buildDeploymentContext(id, classloader); + DefaultCamelContext context = (DefaultCamelContext) buildDeploymentContext(id, classloader); context.setName("KIE Server Camel context for container " + kieContainerInstance.getContainerId()); ExtendedCamelContext ecc = context.adapt(ExtendedCamelContext.class); - RoutesDefinition routes = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(context, is); + RoutesDefinition routes + = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(context, is); annotateKJarRoutes(routes, id); context.addRouteDefinitions(routes.getRoutes()); - + context.start(); camelContexts.put(id, context); @@ -156,7 +158,8 @@ public class CamelKieServerExtension implements KieServerExtension { } @Override - public boolean isUpdateContainerAllowed(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) { + public boolean isUpdateContainerAllowed( + String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) { return true; } @@ -259,19 +262,19 @@ public class CamelKieServerExtension implements KieServerExtension { } protected CamelContext buildDeploymentContext(String identifier, ClassLoader classloader) { - - - InternalRuntimeManager runtimeManager = (InternalRuntimeManager)RuntimeManagerRegistry.get().getManager(identifier); + + InternalRuntimeManager runtimeManager = (InternalRuntimeManager) RuntimeManagerRegistry.get().getManager(identifier); if (runtimeManager != null) { - CamelContextBuilder deploymentContextBuilder = (CamelContextBuilder)runtimeManager.getEnvironment().getEnvironment().get(JBPMConstants.CAMEL_CONTEXT_BUILDER_KEY); + CamelContextBuilder deploymentContextBuilder = (CamelContextBuilder) runtimeManager.getEnvironment() + .getEnvironment().get(JBPMConstants.CAMEL_CONTEXT_BUILDER_KEY); if (deploymentContextBuilder != null) { return deploymentContextBuilder.buildCamelContext(); } } - CamelContext camelContext = new CamelContextBuilder() { - }.buildCamelContext(); + CamelContext camelContext = new CamelContextBuilder() { + }.buildCamelContext(); camelContext.setApplicationContextClassLoader(classloader); return camelContext; } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelCommand.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelCommand.java index bacde64..fb53b11 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelCommand.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelCommand.java @@ -32,31 +32,31 @@ import org.slf4j.LoggerFactory; /** * Camel jBPM {@link Command} which allows to call Camel routes with a <code>direct</code> endpoint. * <p/> - * The command passes the {@WorkItem} retrieved from the {@link CommandContext} to the route that has a consumer on the endpoint-id - * that can be passed with the <code>camel-endpoint-id</code> {@link WorkItem} parameter. E.g. when a the value "myCamelEndpoint" is passed to the - * {link WorkItem} via the <code>camel-endpoint-id</code> parameter, this {@link Command} will send the {@link WorkItem} to - * the Camel URI <code>direct:myCamelEndpoint</code>. + * The command passes the {@WorkItem} retrieved from the {@link CommandContext} to the route that has a consumer on the + * endpoint-id that can be passed with the <code>camel-endpoint-id</code> {@link WorkItem} parameter. E.g. when a the + * value "myCamelEndpoint" is passed to the {link WorkItem} via the <code>camel-endpoint-id</code> parameter, this + * {@link Command} will send the {@link WorkItem} to the Camel URI <code>direct:myCamelEndpoint</code>. * <p/> - * The body of the result {@link Message} of the invocation is returned via the <code>Response</code> parameter. Access to the raw response - * {@link Message} is provided via the <code>Message</code> parameter. This gives the user access to more advanced fields like message headers - * and attachments. + * The body of the result {@link Message} of the invocation is returned via the <code>Response</code> parameter. Access + * to the raw response {@link Message} is provided via the <code>Message</code> parameter. This gives the user access to + * more advanced fields like message headers and attachments. */ public abstract class AbstractCamelCommand implements Command, Cacheable { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCamelCommand.class); public AbstractCamelCommand() { } - + @Override public ExecutionResults execute(CommandContext ctx) throws Exception { - + WorkItem workItem = (WorkItem) ctx.getData("workItem"); - + String camelEndpointId = (String) workItem.getParameter(JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM); // We only support direct. We don't need to support more, as direct simply gives us the entrypoint into the actual Camel Routes. String camelUri = "direct:" + camelEndpointId; - + ProducerTemplate producerTemplate = getProducerTemplate(ctx); Exchange inExchange = ExchangeBuilder.anExchange(producerTemplate.getCamelContext()).withBody(workItem).build(); Exchange outExchange = producerTemplate.send(camelUri, inExchange); @@ -78,4 +78,4 @@ public abstract class AbstractCamelCommand implements Command, Cacheable { protected abstract ProducerTemplate getProducerTemplate(CommandContext ctx); -} \ No newline at end of file +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelWorkItemHandler.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelWorkItemHandler.java index cae1e1b..eb330af 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelWorkItemHandler.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/AbstractCamelWorkItemHandler.java @@ -36,25 +36,28 @@ import org.slf4j.LoggerFactory; * Camel jBPM {@link WorkItemHandler} which allows to call Camel routes with a <code>direct</code> endpoint. * <p/> * The handler passes the {@WorkItem} to the route that has a consumer on the endpoint-id that can be passed with the - * <code>CamelEndpointId</code>{@link WorkItem} parameter. E.g. when a the value "myCamelEndpoint" is passed to the {link WorkItem} via the - * <code>CamelEndpointId</code> parameter, this command will send the {@link WorkItem} to the Camel URI - * <code>direct:myCamelEndpoint</code>. + * <code>CamelEndpointId</code>{@link WorkItem} parameter. E.g. when a the value "myCamelEndpoint" is passed to the + * {link WorkItem} via the <code>CamelEndpointId</code> parameter, this command will send the {@link WorkItem} to the + * Camel URI <code>direct:myCamelEndpoint</code>. * <p/> - * The body of the result {@link Message} of the invocation is returned via the <code>Response</code> parameter. Access to the raw response - * {@link Message} is provided via the <code>Message</code> parameter. This gives the user access to more advanced fields like message - * headers and attachments. + * The body of the result {@link Message} of the invocation is returned via the <code>Response</code> parameter. Access + * to the raw response {@link Message} is provided via the <code>Message</code> parameter. This gives the user access to + * more advanced fields like message headers and attachments. * <p/> - * The handler can be configured to always wrap exceptions coming from Camel in a {@link WorkItemHandlerRuntimeException}. This is the default behaviour, but - * can also be explicitly configured by setting the <code>HandleExceptions</code> workitem parameter to <code>true</code>/ When - * the <code>HandleExceptions</code> workitem parameter is set to <code>false</code>, any exceptions coming from the Camel route will simply be - * re-thrown. This makes the Camel route's exception handling logic responsible for correctly handling any exceptions. + * The handler can be configured to always wrap exceptions coming from Camel in a + * {@link WorkItemHandlerRuntimeException}. This is the default behaviour, but can also be explicitly configured by + * setting the <code>HandleExceptions</code> workitem parameter to <code>true</code>/ When the + * <code>HandleExceptions</code> workitem parameter is set to <code>false</code>, any exceptions coming from the Camel + * route will simply be re-thrown. This makes the Camel route's exception handling logic responsible for correctly + * handling any exceptions. * <p/> - * This handler can be constructed in multiple ways. When you don't pass a {@link RuntimeManager} to the constructor, the handler will try - * to find the global KIE {@link CamelContext} from the <code>jBPM</code> {@link ServiceRegistry}. When the {@link RuntimeManager} is passed - * to the constructor, the handler will retrieve and use the {@link CamelContext} bound to the {@link RuntimeManage} from the - * {@link ServiceRegistry}. When a <code>CamelEndpointId</code> is passed to the constructor, the handler will send all requests to the - * Camel route that is consuming from that endpoint, unless the endpoint is overridden by passing a the <code>CamelEndpointId</code> in the - * {@link WorkItem} parameters. + * This handler can be constructed in multiple ways. When you don't pass a {@link RuntimeManager} to the constructor, + * the handler will try to find the global KIE {@link CamelContext} from the <code>jBPM</code> {@link ServiceRegistry}. + * When the {@link RuntimeManager} is passed to the constructor, the handler will retrieve and use the + * {@link CamelContext} bound to the {@link RuntimeManage} from the {@link ServiceRegistry}. When a + * <code>CamelEndpointId</code> is passed to the constructor, the handler will send all requests to the Camel route that + * is consuming from that endpoint, unless the endpoint is overridden by passing a the <code>CamelEndpointId</code> in + * the {@link WorkItem} parameters. * */ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWorkItemHandler implements Cacheable { @@ -84,8 +87,8 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor } /** - * Constructor which accepts {@link RuntimeManager}. This causes this WorkItemHanlder to create a {@link ProducerTemplate} for the - * runtime specific {@link CamelContext}. + * Constructor which accepts {@link RuntimeManager}. This causes this WorkItemHanlder to create a + * {@link ProducerTemplate} for the runtime specific {@link CamelContext}. */ public AbstractCamelWorkItemHandler(RuntimeManager runtimeManager) { this(runtimeManager, ""); @@ -103,8 +106,8 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor this.initialized = true; } catch (IllegalArgumentException iae) { String message = "CamelContext with identifier '" + camelContextKey - + "' not found in ServiceRegistry. This can be caused by the order in which the platform extensions are initialized. " - + "Deferring Camel ProducerTemplate creation until the first WorkItemHandler call."; + + "' not found in ServiceRegistry. This can be caused by the order in which the platform extensions are initialized. " + + "Deferring Camel ProducerTemplate creation until the first WorkItemHandler call."; logger.info(message, iae); } } @@ -114,7 +117,6 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor return this.producerTemplate = camelContext.createProducerTemplate(); } - public void executeWorkItem(WorkItem workItem, final WorkItemManager manager) { if (!initialized) { this.producerTemplate = buildProducerTemplate(camelContextKey); @@ -132,12 +134,14 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor if (isHandleExceptionParamValue == null) { isHandleException = true; } else if (isHandleExceptionParamValue instanceof String) { - isHandleException = Boolean.parseBoolean((String)isHandleExceptionParamValue); + isHandleException = Boolean.parseBoolean((String) isHandleExceptionParamValue); } else if (isHandleExceptionParamValue instanceof Boolean) { - isHandleException = ((Boolean)isHandleExceptionParamValue).booleanValue(); + isHandleException = ((Boolean) isHandleExceptionParamValue).booleanValue(); } else { - throw new IllegalArgumentException("Unsupported type '" + isHandleExceptionParamValue.getClass().getCanonicalName() + "' for workitem parameter '" - + JBPMConstants.HANDLE_EXCEPTION_WI_PARAM + "'."); + throw new IllegalArgumentException( + "Unsupported type '" + isHandleExceptionParamValue.getClass().getCanonicalName() + + "' for workitem parameter '" + + JBPMConstants.HANDLE_EXCEPTION_WI_PARAM + "'."); } String workItemCamelEndpointId = getCamelEndpointId(workItem); @@ -163,7 +167,7 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor if (isHandleException) { handleException(e); } else { - throw (RuntimeException)e; + throw (RuntimeException) e; } } } @@ -175,8 +179,8 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor if (workItemCamelEndpointId != null && !workItemCamelEndpointId.isEmpty()) { logger.debug( "The Camel Endpoint ID has been set on both the WorkItemHanlder and WorkItem. The '" - + JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM - + "' configured on the WorkItem overrides the global configuation."); + + JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM + + "' configured on the WorkItem overrides the global configuation."); } else { workItemCamelEndpointId = camelEndpointId; } @@ -185,8 +189,8 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor if (workItemCamelEndpointId == null || workItemCamelEndpointId.isEmpty()) { throw new IllegalArgumentException( "No Camel Endpoint ID specified. Please configure the '" + JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM - + "' in either the constructor of this WorkItemHandler, or pass it via the " - + JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM + "' WorkItem parameter."); + + "' in either the constructor of this WorkItemHandler, or pass it via the " + + JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM + "' WorkItem parameter."); } return workItemCamelEndpointId; } @@ -209,4 +213,4 @@ public abstract class AbstractCamelWorkItemHandler extends AbstractLogOrThrowWor } } -} \ No newline at end of file +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/DeploymentContextCamelCommand.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/DeploymentContextCamelCommand.java index 8da33fb..c18fffe 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/DeploymentContextCamelCommand.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/DeploymentContextCamelCommand.java @@ -28,7 +28,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * CamelCommand that uses the {@link CamelContext} registered on the {@link ServiceRegistry} for this specific deployment. + * CamelCommand that uses the {@link CamelContext} registered on the {@link ServiceRegistry} for this specific + * deployment. */ public class DeploymentContextCamelCommand extends AbstractCamelCommand { private static final Logger LOGGER = LoggerFactory.getLogger(DeploymentContextCamelCommand.class); diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/GlobalContextCamelCommand.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/GlobalContextCamelCommand.java index 8e205fe..c40242a 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/GlobalContextCamelCommand.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/GlobalContextCamelCommand.java @@ -29,19 +29,20 @@ import org.slf4j.LoggerFactory; */ public class GlobalContextCamelCommand extends AbstractCamelCommand { private static final Logger LOGGER = LoggerFactory.getLogger(GlobalContextCamelCommand.class); - + private final ProducerTemplate globalContextProducerTemplate; - + public GlobalContextCamelCommand() { - CamelContext globalCamelContext = (CamelContext) ServiceRegistry.get().service(JBPMConstants.GLOBAL_CAMEL_CONTEXT_SERVICE_KEY); + CamelContext globalCamelContext + = (CamelContext) ServiceRegistry.get().service(JBPMConstants.GLOBAL_CAMEL_CONTEXT_SERVICE_KEY); this.globalContextProducerTemplate = globalCamelContext.createProducerTemplate(); } - + @Override protected ProducerTemplate getProducerTemplate(CommandContext ctx) { return globalContextProducerTemplate; } - + @Override public void close() { try { @@ -51,6 +52,5 @@ public class GlobalContextCamelCommand extends AbstractCamelCommand { // Not much we can do here, so swallowing exception. } } - } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOnlyCamelWorkItemHandler.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOnlyCamelWorkItemHandler.java index 02158e3..c01cbd8 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOnlyCamelWorkItemHandler.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOnlyCamelWorkItemHandler.java @@ -35,14 +35,15 @@ import org.kie.api.runtime.process.WorkItemHandler; import org.kie.api.runtime.process.WorkItemManager; /** - * Camel jBPM {@link WorkItemHandler} that sends {@link Exchange Exchanges} with an <code>InOnly</code> Message Exchange Pattern. + * Camel jBPM {@link WorkItemHandler} that sends {@link Exchange Exchanges} with an <code>InOnly</code> Message Exchange + * Pattern. * <p/> - * This handler does <b>NOT<b/> complete the {@link WorkItem}, and will not parse any response from the Camel route, other than possible exceptions. - * The use-case for this handler is asynchronous, one-way, communication, where an external party is responsible for completing the - * {@link WorkItem} at a later point in time. + * This handler does <b>NOT<b/> complete the {@link WorkItem}, and will not parse any response from the Camel route, + * other than possible exceptions. The use-case for this handler is asynchronous, one-way, communication, where an + * external party is responsible for completing the {@link WorkItem} at a later point in time. * <p/> - * The handler creates a Camel Exchange and sets the {@link WorkItem} as the body of the {@link Message}. Furthermore, the following message - * headers are set: + * The handler creates a Camel Exchange and sets the {@link WorkItem} as the body of the {@link Message}. Furthermore, + * the following message headers are set: * <ul> * <li>deploymentId</li> * <li>processInstanceId</li> @@ -50,29 +51,28 @@ import org.kie.api.runtime.process.WorkItemManager; * </ul> */ @Wid( - widfile = "InOnlyCamelConnector.wid", - name = "InOnlyCamelConnector", - displayName = "InOnlyCamelConnector", - category = "Camel", - defaultHandler = "mvel: new org.apache.camel.component.jbpm.workitem.InOnlyCamelWorkItemHandler()", - documentation = "${artifactId}/index.html", - parameters = { - @WidParameter(name = JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM) - }, - results = { - @WidResult(name = JBPMConstants.RESPONSE_WI_PARAM), - @WidResult(name = JBPMConstants.MESSAGE_WI_PARAM) }, - mavenDepends = { - @WidMavenDepends(group = "${groupId}", - artifact = "${artifactId}", - version = "${version}") - }, - serviceInfo = @WidService(category = "${name}", - description = "${description}", - keywords = "apache,camel,payload,route,connector", - action = @WidAction(title = "Send payload to a Camel endpoint")), - icon = "InOnlyCamelConnector.png" - ) + widfile = "InOnlyCamelConnector.wid", + name = "InOnlyCamelConnector", + displayName = "InOnlyCamelConnector", + category = "Camel", + defaultHandler = "mvel: new org.apache.camel.component.jbpm.workitem.InOnlyCamelWorkItemHandler()", + documentation = "${artifactId}/index.html", + parameters = { + @WidParameter(name = JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM) + }, + results = { + @WidResult(name = JBPMConstants.RESPONSE_WI_PARAM), + @WidResult(name = JBPMConstants.MESSAGE_WI_PARAM) }, + mavenDepends = { + @WidMavenDepends(group = "${groupId}", + artifact = "${artifactId}", + version = "${version}") + }, + serviceInfo = @WidService(category = "${name}", + description = "${description}", + keywords = "apache,camel,payload,route,connector", + action = @WidAction(title = "Send payload to a Camel endpoint")), + icon = "InOnlyCamelConnector.png") public class InOnlyCamelWorkItemHandler extends AbstractCamelWorkItemHandler { public InOnlyCamelWorkItemHandler() { diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOutCamelWorkItemHandler.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOutCamelWorkItemHandler.java index 26bc0a2..aeb7315 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOutCamelWorkItemHandler.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/workitem/InOutCamelWorkItemHandler.java @@ -38,13 +38,14 @@ import org.kie.api.runtime.process.WorkItemHandler; import org.kie.api.runtime.process.WorkItemManager; /** - * Camel jBPM {@link WorkItemHandler} that sends {@link Exchange Exchanges} with an <code>InOut</code> Message Exchange Pattern. + * Camel jBPM {@link WorkItemHandler} that sends {@link Exchange Exchanges} with an <code>InOut</code> Message Exchange + * Pattern. * <p/> - * This handler parses the response message from the given Camel route and completes the {@link WorkItem}. The use-case for this handler is - * synchronous, request-response style, communication. + * This handler parses the response message from the given Camel route and completes the {@link WorkItem}. The use-case + * for this handler is synchronous, request-response style, communication. * <p/> - * The handler creates a Camel Exchange and sets the {@link WorkItem} as the body of the {@link Message}. Furthermore, the following message - * headers are set: + * The handler creates a Camel Exchange and sets the {@link WorkItem} as the body of the {@link Message}. Furthermore, + * the following message headers are set: * <ul> * <li>deploymentId</li> * <li>processInstanceId</li> @@ -52,29 +53,28 @@ import org.kie.api.runtime.process.WorkItemManager; * </ul> */ @Wid( - widfile = "InOutCamelConnector.wid", - name = "InOutCamelConnector", - displayName = "InOutCamelConnector", - category = "Camel", - defaultHandler = "mvel: new org.apache.camel.component.jbpm.workitem.InOutCamelWorkItemHandler()", - documentation = "${artifactId}/index.html", - parameters = { - @WidParameter(name = JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM) - }, - results = { - @WidResult(name = JBPMConstants.RESPONSE_WI_PARAM), - @WidResult(name = JBPMConstants.MESSAGE_WI_PARAM) }, - mavenDepends = { - @WidMavenDepends(group = "${groupId}", - artifact = "${artifactId}", - version = "${version}") - }, - serviceInfo = @WidService(category = "${name}", - description = "${description}", - keywords = "apache,camel,payload,route,connector", - action = @WidAction(title = "Send payload to a Camel endpoint")), - icon = "InOutCamelConnector.png" - ) + widfile = "InOutCamelConnector.wid", + name = "InOutCamelConnector", + displayName = "InOutCamelConnector", + category = "Camel", + defaultHandler = "mvel: new org.apache.camel.component.jbpm.workitem.InOutCamelWorkItemHandler()", + documentation = "${artifactId}/index.html", + parameters = { + @WidParameter(name = JBPMConstants.CAMEL_ENDPOINT_ID_WI_PARAM) + }, + results = { + @WidResult(name = JBPMConstants.RESPONSE_WI_PARAM), + @WidResult(name = JBPMConstants.MESSAGE_WI_PARAM) }, + mavenDepends = { + @WidMavenDepends(group = "${groupId}", + artifact = "${artifactId}", + version = "${version}") + }, + serviceInfo = @WidService(category = "${name}", + description = "${description}", + keywords = "apache,camel,payload,route,connector", + action = @WidAction(title = "Send payload to a Camel endpoint")), + icon = "InOutCamelConnector.png") public class InOutCamelWorkItemHandler extends AbstractCamelWorkItemHandler { public InOutCamelWorkItemHandler() {
