forked from kiegroup/droolsjbpm-integration
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DROOLS-1473] camel component (kiegroup#848)
[DROOLS-1473] camel component
- Loading branch information
1 parent
97ce822
commit e2ba2d3
Showing
13 changed files
with
877 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/target | ||
/local | ||
|
||
# Eclipse, Netbeans and IntelliJ files | ||
/.* | ||
!.gitignore | ||
/nbproject | ||
/*.ipr | ||
/*.iws | ||
/*.iml | ||
|
||
# Repository wide ignore mac DS_Store files | ||
.DS_Store | ||
|
||
# test files | ||
/*.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2017 Red Hat, Inc. and/or its affiliates. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.drools</groupId> | ||
<artifactId>droolsjbpm-integration</artifactId> | ||
<version>7.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>org.kie</groupId> | ||
<artifactId>kie-camel</artifactId> | ||
<packaging>bundle</packaging> | ||
|
||
<name>Kie :: Camel</name> | ||
<description>Drools and jBPM integration for Camel.</description> | ||
|
||
<properties> | ||
<osgi.Bundle-SymbolicName>org.kie.camel</osgi.Bundle-SymbolicName> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.tomakehurst</groupId> | ||
<artifactId>wiremock</artifactId> | ||
<version>${version.com.github.tomakehurst.wiremock}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-internal</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.kie.server</groupId> | ||
<artifactId>kie-server-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.kie.server</groupId> | ||
<artifactId>kie-server-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency><!-- For unit test logging: configure in src/test/resources/logback-test.xml --> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>jcl-over-slf4j</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.tomakehurst</groupId> | ||
<artifactId>wiremock</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<_removeheaders>Ignore-Package</_removeheaders> | ||
<Bundle-Name>Kie Camel</Bundle-Name> | ||
<Import-Package> | ||
!org.kie.camel*, | ||
* | ||
</Import-Package> | ||
<Export-Package> | ||
org.kie.camel* | ||
</Export-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
kie-camel/src/main/java/org/kie/camel/KieCamelConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2017 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.camel; | ||
|
||
public class KieCamelConstants { | ||
|
||
public static final String KIE_HEADERS_PREFIX = "kie."; | ||
|
||
public static final String KIE_CLIENT = "kie-client"; | ||
public static final String KIE_OPERATION = "kie-operation"; | ||
|
||
public static final String RESPONSE_TYPE = "CamelKieResponseType"; | ||
public static final String RESPONSE_MESSAGE = "CamelKieResponseMessage"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2017 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.camel; | ||
|
||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Message; | ||
import org.apache.camel.util.ExchangeHelper; | ||
|
||
public class KieCamelUtils { | ||
|
||
public static Message getResultMessage( Exchange exchange ) { | ||
return ExchangeHelper.isOutCapable( exchange ) ? exchange.getOut() : exchange.getIn(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2017 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.camel; | ||
|
||
import java.util.Map; | ||
import javax.naming.InitialContext; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.Endpoint; | ||
import org.apache.camel.impl.DefaultComponent; | ||
import org.kie.server.client.KieServicesConfiguration; | ||
import org.kie.server.client.KieServicesFactory; | ||
|
||
public class KieComponent extends DefaultComponent { | ||
|
||
private KieConfiguration configuration; | ||
|
||
public KieComponent() { } | ||
|
||
public KieComponent(CamelContext context) { | ||
super(context); | ||
} | ||
|
||
public KieComponent(KieConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
protected Endpoint createEndpoint( String uri, String remaining, Map<String, Object> parameters ) throws Exception { | ||
KieConfiguration kieConfiguration = getConfiguration().copy(); | ||
kieConfiguration.configure( remaining ); | ||
setProperties(kieConfiguration, parameters); | ||
|
||
KieServicesConfiguration config = remaining.startsWith( "jms" ) ? | ||
KieServicesFactory.newJMSConfiguration( (InitialContext)null, null, null ) : | ||
KieServicesFactory.newRestConfiguration( remaining, null, null ); | ||
|
||
config.setUserName( kieConfiguration.getUsername() ); | ||
config.setPassword( kieConfiguration.getPassword() ); | ||
return new KieEndpoint(uri, this, config); | ||
} | ||
|
||
public KieConfiguration getConfiguration() { | ||
if (configuration == null) { | ||
configuration = new KieConfiguration(); | ||
} | ||
return configuration; | ||
} | ||
|
||
public void setConfiguration(KieConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
kie-camel/src/main/java/org/kie/camel/KieConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2017 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.camel; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.apache.camel.RuntimeCamelException; | ||
import org.apache.camel.spi.UriParam; | ||
|
||
public class KieConfiguration implements Cloneable { | ||
|
||
@UriParam(label = "security", secret = true) | ||
private String username; | ||
|
||
@UriParam(label = "security", secret = true) | ||
private String password; | ||
|
||
public void configure(String remaining) { | ||
String userInfo = null; | ||
try { | ||
userInfo = new URI(remaining).getUserInfo(); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException( e ); | ||
} | ||
if (userInfo != null) { | ||
String[] parts = userInfo.split(":"); | ||
if (parts.length == 2) { | ||
setUsername(parts[0]); | ||
setPassword(parts[1]); | ||
} else { | ||
setUsername(userInfo); | ||
} | ||
} | ||
} | ||
|
||
public KieConfiguration copy() { | ||
try { | ||
KieConfiguration copy = (KieConfiguration) clone(); | ||
return copy; | ||
} catch (CloneNotSupportedException e) { | ||
throw new RuntimeCamelException(e); | ||
} | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername( String username ) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword( String password ) { | ||
this.password = password; | ||
} | ||
} |
Oops, something went wrong.