INT-996 moving osgi samples to sandbox for now

This commit is contained in:
Mark Fisher
2010-03-11 18:19:41 +00:00
parent ab18ddd199
commit 0a3a1d4fed
13 changed files with 0 additions and 293 deletions

View File

@@ -56,35 +56,4 @@ Open any project and you will see the 'lib' directory with all of the JARs
required to run the demos. Now you can configure your IDE to point to those
directories.
===============================================================================
OSGi Samples
------------
The Hello World and Cafe samples listed above are both OSGi-enabled. Instead
of running those as standalone applications via their main() methods, you can
deploy them to an OSGi runtime and rely on the included BundleActivators.
Before running those or any other OSGi-based applications that rely on Spring
Integration, you will need to deploy the necessary Spring Integration bundles
into the OSGi deployment environment (you can just copy all of the JARs within
the 'dist' directory of the distribution). You may also need some of the other
dependencies that are located within the 'lib' directory of the distribution.
For the detailed instructions, refer to the "Samples" Appendix of the Spring
Integration Reference Manual.
This release also includes two new samples that are dedicated to showcasing
capabilities of the Spring Integration and OSGi combination. They form a
producer/consumer pair: osgi-inbound and osgi-outbound. Unlike the others,
they are not Maven-enabled, but instead they are ready to run directly within
SpringSource dm Server, and with the SpringSource Tool Suite support, this
requires only an import, adding "OSGi Bundle Project Nature" via the 'Spring
Tools' context menu, and deploying to a dm server instance as the project's
targeted runtime. A comprehensive overview of those OSGi samples is included
in the "Samples" Appendix of the Spring Integration Reference Manual.
NOTE: Starting dmServer v2.0.M5 OSGi console is not available by default in
favor of dmShell. However you can re-enable the OSGi console by going to
{dm_home}/lib and adding osgi.console=<port> to the
com.springsource.kernel.launch.properties file.
Happy integration :-)

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="com.springsource.server.ide.jdt.core.MANIFEST_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>osgi-inbound</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.springsource.server.ide.facet.core.bundlenature</nature>
<nature>org.springframework.ide.eclipse.core.springnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="osgi-inbound" default="jar">
<target name="jar">
<jar manifest="src/META-INF/MANIFEST.MF" destfile="osgi-inbound-2.0.0.BUILD-SNAPSHOT.jar" basedir="bin"/>
</target>
</project>

View File

@@ -1,13 +0,0 @@
Manifest-Version: 1.0
Bundle-Version: 2.0.0.BUILD-SNAPSHOT
Bundle-Name: org.springframework.integration.samples.osgi.inbound
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.springframework.integration.samples.osgi.inbound
Bundle-Activator: org.springframework.integration.samples.osgi.inbound.InboundDemoBundleActivator
Import-Package: org.eclipse.osgi.framework.console;version="1.0.0",
org.osgi.framework;version="1.4.0",
org.osgi.service.packageadmin;version="1.2.0",
org.eclipse.osgi.util
Import-Library: org.springframework.spring;version="[3.0.0, 3.1.0)"
Import-Bundle: org.springframework.integration;version="[2.0.0, 2.1.0)",
org.springframework.integration.file;version="[2.0.0, 2.1.0)"

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:integration="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<osgi:service id="inboundService" ref="inboundChannel"
interface="org.springframework.integration.channel.SubscribableChannel"/>
<integration:publish-subscribe-channel id="inboundChannel"/>
<integration:gateway id="inboundGateway"
service-interface="org.springframework.integration.samples.osgi.inbound.InboundGateway"
default-request-channel="inboundChannel"/>
</beans>

View File

@@ -1,83 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.osgi.inbound;
import java.io.File;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
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.util.Assert;
/**
* Simple BundleActivator which will register a ServiceListener and serve as a
* CommandProvider for interpreting the 'siSend' command. It invokes a Spring
* Integration Gateway proxy when the command is invoked.
*
* @author Oleg Zhurakousky
* @since 1.0.3
*/
public class InboundDemoBundleActivator implements BundleActivator, CommandProvider, ServiceListener {
private BundleContext context;
private InboundGateway gateway;
@SuppressWarnings("unchecked")
public void start(BundleContext context) throws Exception {
this.context = context;
this.context.addServiceListener(this);
Dictionary props = new Hashtable();
context.registerService(CommandProvider.class.getName(), this, props);
}
public void stop(BundleContext arg0) throws Exception {}
public String getHelp() {
return "\n---Spring Integration CLI-based OSGi Demo---\n\t" +
"siSend <message> <filename> - send text to be written to a file\n";
}
public void serviceChanged(ServiceEvent serviceEvent) {
ServiceReference sr = serviceEvent.getServiceReference();
if (context.getBundle().getSymbolicName().equals(sr.getProperty(Constants.BUNDLE_SYMBOLICNAME))) {
ApplicationContext applicationContext = (ApplicationContext) context.getService(sr);
gateway = (InboundGateway) applicationContext.getBean("inboundGateway");
}
}
public void _siSend(CommandInterpreter ci){
String message = ci.nextArgument();
String filename = ci.nextArgument();
Assert.notNull(message, "You must provide message as the first argument.");
Assert.notNull(filename, "You must provide a filename as the second argument.");
ci.println("Sending message: '" + message + "'");
File file = gateway.sendMessage(message, filename);
ci.println("Message sent and its contents were written to: " + file.getAbsolutePath());
}
}

View File

@@ -1,31 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.osgi.inbound;
import java.io.File;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.file.FileHeaders;
/**
* @author Oleg Zhurakousky
*/
public interface InboundGateway {
public File sendMessage(String message, @Header(FileHeaders.FILENAME) String filename);
}

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="com.springsource.server.ide.jdt.core.MANIFEST_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>osgi-outbound</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.springsource.server.ide.facet.core.bundlenature</nature>
<nature>org.springframework.ide.eclipse.core.springnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="osgi-outbound" default="jar">
<target name="jar">
<jar manifest="src/META-INF/MANIFEST.MF" destfile="osgi-outbound-2.0.0.BUILD-SNAPSHOT.jar" basedir="bin"/>
</target>
</project>

View File

@@ -1,8 +0,0 @@
Manifest-Version: 1.0
Bundle-Version: 2.0.0.BUILD-SNAPSHOT
Bundle-Name: org.springframework.integration.samples.osgi.outbound
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.springframework.integration.samples.osgi.outbound
Import-Bundle: org.springframework.integration;version="[2.0.0, 2.1.0)",
org.springframework.integration.file;version="[2.0.0, 2.1.0)"
Import-Library: org.springframework.spring;version="[3.0.0, 3.1.0)"

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
<osgi:reference id="filesIn"
interface="org.springframework.integration.channel.SubscribableChannel"/>
<file:outbound-gateway id="filesOut"
request-channel="filesIn"
directory="${java.io.tmpdir}/spring-integration-samples/output"
delete-source-files="true"/>
</beans>