Commit e7d10d2e authored by Constantin Jucovschi's avatar Constantin Jucovschi

new updates

parent c5e831ad
......@@ -115,7 +115,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<version>1.11.2</version>
<executions>
<execution>
<goals>
......
......@@ -13,7 +13,6 @@ import java.util.UUID;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Property;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
......@@ -21,11 +20,14 @@ import org.apache.camel.spi.DataFormat;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
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.Requires;
import org.apache.felix.ipojo.annotations.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
@Component(managedservice="sallyclient")
@Provides(specifications=SallyClient.class)
@Instantiate
public class SallyClientImpl extends RouteBuilder implements SallyClient {
......@@ -36,14 +38,33 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
@Requires
CamelContextProvider camelContextProvider;
org.apache.camel.Component sallyConn;
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
public void start() throws Exception {
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.start();
}
@Invalidate
......@@ -69,10 +90,12 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
Registerdocumentresponse response = e.getIn().getBody(Registerdocumentresponse.class);
Registerdocument req = e.getProperty("origRequest", Registerdocument.class);
RoutesBuilder builder = e.getProperty("builder", RoutesBuilder.class);
CamelContext docContext = new DefaultCamelContext();
docContext.addComponent("activemq", camelContextProvider.getComponent("activemq"));
docContext.addComponent("sally", new ProducerConsumerSplitterComponent("activemq:queue:"+req.getDocumentqueue(), "activemq:queue:"+response.getSallyqueue()));
docContext.addComponent("sallyclient", sallyConn);
ProducerConsumerSplitterComponent comp = new ProducerConsumerSplitterComponent("sallyclient:queue:"+req.getDocumentqueue(), "sallyclient:queue:"+response.getSallyqueue());
comp.setCamelContext(docContext);
docContext.addComponent("sally", comp);
docContext.addRoutes(builder);
docContext.start();
}
......@@ -88,6 +111,15 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
@Override
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();
regDoc.setDocumentqueue(genUUID(docName));
regDoc.setEnvironmentid(System.getenv("SALLYENVID"));
......
Markdown is supported
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