Added OSGi version of FileCopy demo sample

This commit is contained in:
Oleg Zhurakousky
2009-07-15 20:55:39 +00:00
parent fd72745e32
commit b9d90eff7a
15 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?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

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>inbound-adapter-osgi</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

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="SpringSource dm Server v1.0"/>
<installed facet="com.springsource.server.bundle" version="1.0"/>
</faceted-project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.2.5.200906231226-RC1]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
</configs>
<configSets>
</configSets>
</beansProjectDescription>

View File

@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-Version: 1.0.3
Bundle-Name: Input_adapter_osgi
Bundle-ManifestVersion: 2
Bundle-SymbolicName: input_adapter_osgi
Import-Library: org.aspectj;version="[1.6.2.RELEASE,1.6.2.RELEASE]",
org.springframework.spring;version="[2.5.6.A,2.5.6.A]"
Import-Bundle: org.springframework.integration;version="[1.0.3.BUILD-20090711061916,1.0.3.BUILD-20090711061916]",
org.springframework.integration.file;version="[1.0.3.BUILD-20090711061916,1.0.3.BUILD-20090711061916]"

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<bean class="org.springframework.integration.samples.inbound.FileCopyDemoBootstrap"/>
<file:inbound-channel-adapter id="filesIn" directory="file:${java.io.tmpdir}/spring-integration-samples/input">
<integration:poller>
<integration:interval-trigger interval="5000"/>
</integration:poller>
</file:inbound-channel-adapter>
<osgi:service id="filesInService" ref="filesIn" interface="org.springframework.integration.channel.SubscribableChannel"/>
</beans>

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2002-2008 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.inbound;
import java.io.File;
import org.springframework.beans.factory.InitializingBean;
/**
* Common functionality for the file demo.
*
* @author Oleg Zhurakousky
*/
public class FileCopyDemoBootstrap implements InitializingBean {
public void afterPropertiesSet() throws Exception {
String tmpDirPath = System.getProperty("java.io.tmpdir");
File parentDir = new File(tmpDirPath + File.separator + "spring-integration-samples");
File inDir = new File(parentDir, "input");
if (inDir.exists() || inDir.mkdirs()) {
System.out.println("input directory is: " + inDir.getAbsolutePath());
}
else {
System.err.println("failed to create directories within tmp dir: " + tmpDirPath);
}
}
}

View File

@@ -0,0 +1,7 @@
<?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

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>outbound-adapter-osgi</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

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="SpringSource dm Server v1.0"/>
<installed facet="com.springsource.server.bundle" version="1.0"/>
</faceted-project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.2.5.200906231226-RC1]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
</configs>
<configSets>
</configSets>
</beansProjectDescription>

View File

@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-Version: 1.0.3
Bundle-Name: Outbound_adapter_osgi
Bundle-ManifestVersion: 2
Bundle-SymbolicName: outbound_adapter_osgi
Import-Library: org.aspectj;version="[1.6.2.RELEASE,1.6.2.RELEASE]",
org.springframework.spring;version="[2.5.6.A,2.5.6.A]"
Import-Bundle: org.springframework.integration;version="[1.0.3.BUILD-20090711061916,1.0.3.BUILD-20090711061916]",
org.springframework.integration.file;version="[1.0.3.BUILD-20090711061916,1.0.3.BUILD-20090711061916]"

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<bean class="org.springframework.integration.samples.filecopy.FileCopyDemoCommon"/>
<osgi:reference id="filesInService" interface="org.springframework.integration.channel.SubscribableChannel"/>
<integration:service-activator input-channel="filesInService"
output-channel="filesOut"
ref="exclaimer" method="exclaim"/>
<file:outbound-channel-adapter id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
<!-- -->
</beans>

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2002-2008 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.filecopy;
import java.io.File;
/**
* A class providing several handling methods for different types of payloads.
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
public class Exclaimer {
// public String exclaim(String input) {
// System.out.println("Copying text: " + input);
// return input.toUpperCase();
// }
public File exclaim(File input) {
System.out.println("Copying file: " + input.getAbsolutePath());
return input;
}
// public byte[] exclaim(byte[] input) {
// System.out.println("Copying " + input.length + " bytes ...");
// return new String(input).toUpperCase().getBytes();
// }
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright 2002-2008 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.filecopy;
import java.io.File;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
/**
* Common functionality for the file demo.
*
* @author Oleg Zhurakousky
*/
public class FileCopyDemoCommon implements BeanFactoryPostProcessor {
public void afterPropertiesSet() {
String tmpDirPath = System.getProperty("java.io.tmpdir");
File parentDir = new File(tmpDirPath + File.separator + "spring-integration-samples");
File outDir = new File(parentDir, "output");
if (outDir.exists() || outDir.mkdirs()) {
System.out.println("output directory is: " + outDir.getAbsolutePath());
}
else {
System.err.println("failed to create directories within tmp dir: " + tmpDirPath);
}
}
/**
* HACK!!!!!
*/
public void postProcessBeanFactory(ConfigurableListableBeanFactory arg0)
throws BeansException {
this.afterPropertiesSet();
}
}