updated OSGi examples, removed the bridge and added reply message

This commit is contained in:
Oleg Zhurakousky
2009-07-17 00:18:34 +00:00
parent 1be9b86a59
commit 64031c05ea
5 changed files with 13 additions and 15 deletions

View File

@@ -11,5 +11,4 @@ Import-Package: org.eclipse.osgi.framework.console;version="1.0.0",
Import-Library: org.aspectj;version="[1.6.2, 2.0.0)",
org.springframework.spring;version="[2.5.6.A, 3.1.0)"
Import-Bundle: org.springframework.integration;version="[1.0.3,1.0.4)",
org.springframework.integration.file;version="[1.0.3,1.0.4)"
org.springframework.integration.file;version="[1.0.3,1.0.4)"

View File

@@ -11,11 +11,11 @@
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file">
<integration:gateway id="inboundGateway" service-interface="org.springframework.integration.samples.inbound.InboundGateway"
default-request-channel="inChannel"/>
<integration:publish-subscribe-channel id="inChannel"/>
<osgi:service id="inboundService" ref="inChannel" interface="org.springframework.integration.channel.SubscribableChannel"/>
</beans>
<osgi:service id="inboundService" ref="inChannel" interface="org.springframework.integration.channel.SubscribableChannel" />
</beans>

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.integration.samples.inbound;
import java.io.File;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -77,8 +78,8 @@ public class InboundDemoBundleActivator implements BundleActivator, CommandProvi
Assert.notNull(message, "You must provide message as first argument");
Assert.notNull(fileName, "You must proivi a file name as second argument");
ci.println("Sending message: '" + message + "'");
gateway.sendMessage(message, fileName);
ci.println("Message sent!");
File file = gateway.sendMessage(message, fileName);
ci.println("Message sent and its contents are written to: " + file.getAbsolutePath());
}
}

View File

@@ -15,15 +15,15 @@
*/
package org.springframework.integration.samples.inbound;
import java.io.File;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.file.FileHeaders;
/**
* Simple BundleActivator which will register ServiceListener which will listen for
* ApplicationContext published event. Once event is received, HelloWorldDemo will be executed.
*
* @author Oleg Zhurakousky
*/
public interface InboundGateway {
public void sendMessage(String message, @Header(FileHeaders.FILENAME)String fileName);
public File sendMessage(String message, @Header(FileHeaders.FILENAME)String fileName);
}

View File

@@ -12,10 +12,8 @@
xmlns:file="http://www.springframework.org/schema/integration/file">
<osgi:reference id="filesInService" interface="org.springframework.integration.channel.SubscribableChannel"/>
<integration:bridge input-channel="filesInService" output-channel="filesOut"/>
<osgi:reference id="filesInService" interface="org.springframework.integration.channel.SubscribableChannel" cardinality="0..1"/>
<file:outbound-channel-adapter id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output" delete-source-files="true" />
<file:outbound-gateway request-channel="filesInService" id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output" delete-source-files="true" />
</beans>