From b9d90eff7a420e773c21e7cd34646d4d1e99751c Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 15 Jul 2009 20:55:39 +0000 Subject: [PATCH] Added OSGi version of FileCopy demo sample --- .../inbound-adapter-osgi/.classpath | 7 +++ .../inbound-adapter-osgi/.project | 30 +++++++++++ ....eclipse.wst.common.project.facet.core.xml | 5 ++ .../inbound-adapter-osgi/.springBeans | 13 +++++ .../src/META-INF/MANIFEST.MF | 10 ++++ .../src/META-INF/spring/context-osgi-in.xml | 22 ++++++++ .../inbound/FileCopyDemoBootstrap.java | 42 ++++++++++++++++ .../outbound-adapter-osgi/.classpath | 7 +++ .../outbound-adapter-osgi/.project | 30 +++++++++++ ....eclipse.wst.common.project.facet.core.xml | 5 ++ .../outbound-adapter-osgi/.springBeans | 13 +++++ .../src/META-INF/MANIFEST.MF | 10 ++++ .../src/META-INF/spring/context-osgi-out.xml | 27 ++++++++++ .../samples/filecopy/Exclaimer.java | 44 ++++++++++++++++ .../samples/filecopy/FileCopyDemoCommon.java | 50 +++++++++++++++++++ 15 files changed, 315 insertions(+) create mode 100644 spring-integration-samples/inbound-adapter-osgi/.classpath create mode 100644 spring-integration-samples/inbound-adapter-osgi/.project create mode 100644 spring-integration-samples/inbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-integration-samples/inbound-adapter-osgi/.springBeans create mode 100644 spring-integration-samples/inbound-adapter-osgi/src/META-INF/MANIFEST.MF create mode 100644 spring-integration-samples/inbound-adapter-osgi/src/META-INF/spring/context-osgi-in.xml create mode 100644 spring-integration-samples/inbound-adapter-osgi/src/org/springframework/integration/samples/inbound/FileCopyDemoBootstrap.java create mode 100644 spring-integration-samples/outbound-adapter-osgi/.classpath create mode 100644 spring-integration-samples/outbound-adapter-osgi/.project create mode 100644 spring-integration-samples/outbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-integration-samples/outbound-adapter-osgi/.springBeans create mode 100644 spring-integration-samples/outbound-adapter-osgi/src/META-INF/MANIFEST.MF create mode 100644 spring-integration-samples/outbound-adapter-osgi/src/META-INF/spring/context-osgi-out.xml create mode 100644 spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/Exclaimer.java create mode 100644 spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/FileCopyDemoCommon.java diff --git a/spring-integration-samples/inbound-adapter-osgi/.classpath b/spring-integration-samples/inbound-adapter-osgi/.classpath new file mode 100644 index 0000000000..bd5d5e5fc1 --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-integration-samples/inbound-adapter-osgi/.project b/spring-integration-samples/inbound-adapter-osgi/.project new file mode 100644 index 0000000000..4dab9a7607 --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/.project @@ -0,0 +1,30 @@ + + + inbound-adapter-osgi + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + com.springsource.server.ide.facet.core.bundlenature + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-integration-samples/inbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-integration-samples/inbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000000..75180400ad --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-integration-samples/inbound-adapter-osgi/.springBeans b/spring-integration-samples/inbound-adapter-osgi/.springBeans new file mode 100644 index 0000000000..8ce10353c2 --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + diff --git a/spring-integration-samples/inbound-adapter-osgi/src/META-INF/MANIFEST.MF b/spring-integration-samples/inbound-adapter-osgi/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..04a47b27d3 --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/src/META-INF/MANIFEST.MF @@ -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]" + diff --git a/spring-integration-samples/inbound-adapter-osgi/src/META-INF/spring/context-osgi-in.xml b/spring-integration-samples/inbound-adapter-osgi/src/META-INF/spring/context-osgi-in.xml new file mode 100644 index 0000000000..f2edab4fd1 --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/src/META-INF/spring/context-osgi-in.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/spring-integration-samples/inbound-adapter-osgi/src/org/springframework/integration/samples/inbound/FileCopyDemoBootstrap.java b/spring-integration-samples/inbound-adapter-osgi/src/org/springframework/integration/samples/inbound/FileCopyDemoBootstrap.java new file mode 100644 index 0000000000..8dc3de4d8e --- /dev/null +++ b/spring-integration-samples/inbound-adapter-osgi/src/org/springframework/integration/samples/inbound/FileCopyDemoBootstrap.java @@ -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); + } + } + +} diff --git a/spring-integration-samples/outbound-adapter-osgi/.classpath b/spring-integration-samples/outbound-adapter-osgi/.classpath new file mode 100644 index 0000000000..bd5d5e5fc1 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-integration-samples/outbound-adapter-osgi/.project b/spring-integration-samples/outbound-adapter-osgi/.project new file mode 100644 index 0000000000..d8ec1a82b1 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/.project @@ -0,0 +1,30 @@ + + + outbound-adapter-osgi + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + com.springsource.server.ide.facet.core.bundlenature + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-integration-samples/outbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-integration-samples/outbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000000..75180400ad --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-integration-samples/outbound-adapter-osgi/.springBeans b/spring-integration-samples/outbound-adapter-osgi/.springBeans new file mode 100644 index 0000000000..8ce10353c2 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + diff --git a/spring-integration-samples/outbound-adapter-osgi/src/META-INF/MANIFEST.MF b/spring-integration-samples/outbound-adapter-osgi/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..accc1bdcc3 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/src/META-INF/MANIFEST.MF @@ -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]" + diff --git a/spring-integration-samples/outbound-adapter-osgi/src/META-INF/spring/context-osgi-out.xml b/spring-integration-samples/outbound-adapter-osgi/src/META-INF/spring/context-osgi-out.xml new file mode 100644 index 0000000000..0cd22ffa10 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/src/META-INF/spring/context-osgi-out.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + diff --git a/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/Exclaimer.java b/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/Exclaimer.java new file mode 100644 index 0000000000..08963c6507 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/Exclaimer.java @@ -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(); +// } + +} diff --git a/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/FileCopyDemoCommon.java b/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/FileCopyDemoCommon.java new file mode 100644 index 0000000000..5b5a2f0072 --- /dev/null +++ b/spring-integration-samples/outbound-adapter-osgi/src/org/springframework/integration/samples/filecopy/FileCopyDemoCommon.java @@ -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(); + } +}