diff --git a/spring-integration-samples/cafe/src/main/java/log4j.xml b/spring-integration-samples/cafe/src/main/java/log4j.xml new file mode 100644 index 0000000000..a01d5446a0 --- /dev/null +++ b/spring-integration-samples/cafe/src/main/java/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/annotation/CafeDemo.java b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/annotation/CafeDemo.java index 07bf600f5b..ad875bc2de 100644 --- a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/annotation/CafeDemo.java +++ b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/annotation/CafeDemo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/xml/CafeDemo.java b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/xml/CafeDemo.java index 54db622fe4..dc022e9559 100644 --- a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/xml/CafeDemo.java +++ b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/cafe/xml/CafeDemo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package org.springframework.integration.samples.cafe.xml; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.integration.samples.cafe.Cafe; import org.springframework.integration.samples.cafe.DrinkType; import org.springframework.integration.samples.cafe.Order; @@ -29,8 +28,9 @@ import org.springframework.integration.samples.cafe.Order; * order is placed, the Cafe will send that order to the "orders" channel. * The relevant components are defined within the configuration file * ("cafeDemo.xml"). - * If deployed in SpringSource dmServer the ApplicationContext configuration is in - * META-INF/spring directory + *

+ * If deploying in SpringSource dmServer, the relevant ApplicationContext + * configuration is in the META-INF/spring directory instead. * * @author Mark Fisher * @author Marius Bogoevici @@ -40,17 +40,12 @@ public class CafeDemo { public static void main(String[] args) { CafeDemo demo = new CafeDemo(); - AbstractApplicationContext applicationContext = null; - if(args.length > 0) { - applicationContext = new FileSystemXmlApplicationContext(args); - } - else { - applicationContext = new ClassPathXmlApplicationContext("cafeDemo.xml", CafeDemo.class); - } - demo.performDemo(applicationContext, 100); + AbstractApplicationContext context = new ClassPathXmlApplicationContext("cafeDemo.xml", CafeDemo.class); + demo.performDemo(context, 100); } - public void performDemo(ApplicationContext applicationContext, int iterations){ + + public void performDemo(ApplicationContext applicationContext, int iterations) { Cafe cafe = (Cafe) applicationContext.getBean("cafe"); for (int i = 1; i <= iterations; i++) { Order order = new Order(i); @@ -59,4 +54,5 @@ public class CafeDemo { cafe.placeOrder(order); } } + } diff --git a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/osgi/cafe/CafeBundleActivator.java b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/osgi/cafe/CafeBundleActivator.java index 0cc8023085..1eabec1cb0 100644 --- a/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/osgi/cafe/CafeBundleActivator.java +++ b/spring-integration-samples/cafe/src/main/java/org/springframework/integration/samples/osgi/cafe/CafeBundleActivator.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.samples.osgi.cafe; import java.util.concurrent.ExecutorService; @@ -28,30 +29,27 @@ import org.springframework.context.ApplicationContext; import org.springframework.integration.samples.cafe.xml.CafeDemo; /** - * Simple BundleActivator which will register ServiceListener which will listen for - * ApplicationContext published event. Once event is received, CafeDemo will be executed. + * An OSGi BundleActivator which will register a ServiceListener to listen for + * an ApplicationContext published event. Once the event is received, the + * CafeDemo will be executed. * * @author Oleg Zhurakousky + * @since 1.0.3 */ public class CafeBundleActivator implements BundleActivator, ServiceListener{ + private BundleContext context; - /** - * - */ + public void start(BundleContext context) throws Exception { this.context = context; context.addServiceListener(this); } - /** - * - */ + public void stop(BundleContext context) throws Exception {} - /** - * - */ + public void serviceChanged(ServiceEvent serviceEvent) { ServiceReference sr = serviceEvent.getServiceReference(); - if (context.getBundle().getSymbolicName().equals(sr.getProperty(Constants.BUNDLE_SYMBOLICNAME))){ + if (context.getBundle().getSymbolicName().equals(sr.getProperty(Constants.BUNDLE_SYMBOLICNAME))) { final ApplicationContext applicationContext = (ApplicationContext) context.getService(sr); ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new Runnable() { @@ -61,4 +59,5 @@ public class CafeBundleActivator implements BundleActivator, ServiceListener{ }); } } + }