diff --git a/spring-integration-samples/helloworld/src/main/java/log4j.xml b/spring-integration-samples/helloworld/src/main/java/log4j.xml new file mode 100644 index 0000000000..3865c97d90 --- /dev/null +++ b/spring-integration-samples/helloworld/src/main/java/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java index e124c5c35b..e7029dfccf 100644 --- a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java +++ b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java @@ -17,6 +17,8 @@ package org.springframework.integration.samples.helloworld; /** + * Simple POJO to be referenced from a Service Activator. + * * @author Mark Fisher */ public class HelloService { diff --git a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java index 86cad505d9..2d58829cb3 100644 --- a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java +++ b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java @@ -48,12 +48,14 @@ public class HelloWorldDemo { demo.performDemo(applicationContext); applicationContext.stop(); } - - public void performDemo(ApplicationContext applicationContext){ + + + public void performDemo(ApplicationContext applicationContext) { ChannelResolver channelResolver = new BeanFactoryChannelResolver(applicationContext); MessageChannel inputChannel = channelResolver.resolveChannelName("inputChannel"); PollableChannel outputChannel = (PollableChannel) channelResolver.resolveChannelName("outputChannel"); inputChannel.send(new StringMessage("World")); System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); } + } diff --git a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/osgi/helloworld/HelloWorldBundleActivator.java b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/osgi/helloworld/HelloWorldBundleActivator.java index 6ca3bd9f55..15d104ba44 100644 --- a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/osgi/helloworld/HelloWorldBundleActivator.java +++ b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/osgi/helloworld/HelloWorldBundleActivator.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.helloworld; import org.osgi.framework.BundleActivator; @@ -21,35 +22,35 @@ import org.osgi.framework.Constants; import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; + import org.springframework.context.ApplicationContext; import org.springframework.integration.samples.helloworld.HelloWorldDemo; + /** - * Simple BundleActivator which will register ServiceListener which will listen for - * ApplicationContext published event. Once event is received, HelloWorldDemo will be executed. + * An OSGi BundleActivator which will register a ServiceListener to listen + * for an ApplicationContext published event. Once the event is received, + * the HelloWorldDemo will be executed. * * @author Oleg Zhurakousky + * @since 1.0.3 */ public class HelloWorldBundleActivator 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))) { ApplicationContext applicationContext = (ApplicationContext) context.getService(sr); new HelloWorldDemo().performDemo(applicationContext); - } + } } + }