updated OSGi examples, removed the bridge and added reply message
This commit is contained in:
@@ -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)"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user