Commit e7d10d2e authored by Constantin Jucovschi's avatar Constantin Jucovschi
Browse files

new updates

parent c5e831ad
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId> <artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version> <version>1.11.2</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
......
...@@ -13,7 +13,6 @@ import java.util.UUID; ...@@ -13,7 +13,6 @@ import java.util.UUID;
import org.apache.camel.CamelContext; import org.apache.camel.CamelContext;
import org.apache.camel.Exchange; import org.apache.camel.Exchange;
import org.apache.camel.Property;
import org.apache.camel.RoutesBuilder; import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder; import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultCamelContext;
...@@ -21,11 +20,14 @@ import org.apache.camel.spi.DataFormat; ...@@ -21,11 +20,14 @@ import org.apache.camel.spi.DataFormat;
import org.apache.felix.ipojo.annotations.Component; import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate; import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Invalidate; import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Property;
import org.apache.felix.ipojo.annotations.Provides; import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.Requires; import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Validate; import org.apache.felix.ipojo.annotations.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component @Component(managedservice="sallyclient")
@Provides(specifications=SallyClient.class) @Provides(specifications=SallyClient.class)
@Instantiate @Instantiate
public class SallyClientImpl extends RouteBuilder implements SallyClient { public class SallyClientImpl extends RouteBuilder implements SallyClient {
...@@ -36,14 +38,33 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient { ...@@ -36,14 +38,33 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
@Requires @Requires
CamelContextProvider camelContextProvider; CamelContextProvider camelContextProvider;
org.apache.camel.Component sallyConn;
CamelContext context; CamelContext context;
@Property(name="SallyHost")
String sallyHost;
@Property(name="SallyUser")
String sallyUser;
@Property(name="SallyPassword")
String sallyPassword;
boolean started = false;
Logger log = LoggerFactory.getLogger(getClass());
@Validate @Validate
public void start() throws Exception { public void start() throws Exception {
context = new DefaultCamelContext(); context = new DefaultCamelContext();
context.addComponent("activemq", camelContextProvider.getComponent("activemq")); if (sallyHost == null) {
sallyConn = camelContextProvider.getComponent("activemq");
} else {
sallyConn = activeMQ.createActiveMQConnection(sallyHost, sallyUser, sallyPassword);
}
context.addComponent("activemq", sallyConn);
context.addRoutes(this); context.addRoutes(this);
context.start();
} }
@Invalidate @Invalidate
...@@ -69,10 +90,12 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient { ...@@ -69,10 +90,12 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
Registerdocumentresponse response = e.getIn().getBody(Registerdocumentresponse.class); Registerdocumentresponse response = e.getIn().getBody(Registerdocumentresponse.class);
Registerdocument req = e.getProperty("origRequest", Registerdocument.class); Registerdocument req = e.getProperty("origRequest", Registerdocument.class);
RoutesBuilder builder = e.getProperty("builder", RoutesBuilder.class); RoutesBuilder builder = e.getProperty("builder", RoutesBuilder.class);
CamelContext docContext = new DefaultCamelContext(); CamelContext docContext = new DefaultCamelContext();
docContext.addComponent("activemq", camelContextProvider.getComponent("activemq")); docContext.addComponent("sallyclient", sallyConn);
docContext.addComponent("sally", new ProducerConsumerSplitterComponent("activemq:queue:"+req.getDocumentqueue(), "activemq:queue:"+response.getSallyqueue())); ProducerConsumerSplitterComponent comp = new ProducerConsumerSplitterComponent("sallyclient:queue:"+req.getDocumentqueue(), "sallyclient:queue:"+response.getSallyqueue());
comp.setCamelContext(docContext);
docContext.addComponent("sally", comp);
docContext.addRoutes(builder); docContext.addRoutes(builder);
docContext.start(); docContext.start();
} }
...@@ -88,6 +111,15 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient { ...@@ -88,6 +111,15 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
@Override @Override
public void registerDocument(String docName, String[] interfaces, RoutesBuilder builder) { public void registerDocument(String docName, String[] interfaces, RoutesBuilder builder) {
if (!started) {
try {
context.start();
started = true;
} catch (Exception e) {
e.printStackTrace();
return;
}
}
Registerdocument regDoc = new Registerdocument(); Registerdocument regDoc = new Registerdocument();
regDoc.setDocumentqueue(genUUID(docName)); regDoc.setDocumentqueue(genUUID(docName));
regDoc.setEnvironmentid(System.getenv("SALLYENVID")); regDoc.setEnvironmentid(System.getenv("SALLYENVID"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment