LwContainerComponent component = new LwContainerComponent();
container.activateComponent(component, "#ServiceMixComponent#");
URL url = getClass().getResource("su1-src/servicemix.xml");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
ServiceMixClient client = new DefaultServiceMixClient(container);
for (int i = 0; i < 2; i++) {
// Deploy and start su
component.getServiceUnitManager().deploy("su1", path.getAbsolutePath());
component.getServiceUnitManager().init("su1", path.getAbsolutePath());
component.getServiceUnitManager().start("su1");
// Send message
InOut inout = client.createInOutExchange();
inout.setService(new QName("http://servicemix.apache.org/demo/", "chained"));
client.send(inout);
// Stop and undeploy
component.getServiceUnitManager().stop("su1");
component.getServiceUnitManager().shutDown("su1");
component.getServiceUnitManager().undeploy("su1", path.getAbsolutePath());
// Send message
inout = client.createInOutExchange();
inout.setService(new QName("http://servicemix.apache.org/demo/", "chained"));
try {
client.send(inout);
} catch (MessagingException e) {
// Ok, the lw component is undeployed
}
}