You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/11/16 21:21:26 UTC
svn commit: r718106 - in
/mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/ftpserver/
src/main/java/org/apache/ftpserver/example/ src/mai...
Author: ngn
Date: Sun Nov 16 12:21:25 2008
New Revision: 718106
URL: http://svn.apache.org/viewvc?rev=718106&view=rev
Log:
Commiting an example of how to use FtpServer in Spring-DM (Spring and OSGi)
Added:
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/pom.xml
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.java
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.properties
Modified:
mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/ (props changed)
Propchange: mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Nov 16 12:21:25 2008
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/pom.xml
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/pom.xml?rev=718106&view=auto
==============================================================================
--- mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/pom.xml (added)
+++ mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/pom.xml Sun Nov 16 12:21:25 2008
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <description>Spring-DM based OSGi bundle that starts an FtpServer and looks for a published Ftplet service.</description>
+ <parent>
+ <artifactId>ftpserver-parent</artifactId>
+ <groupId>org.apache.ftpserver</groupId>
+ <version>1.0.0-M4-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ftpserver.examples</groupId>
+ <artifactId>ftpserver-osgi-spring-service</artifactId>
+ <name>FtpServer OSGi Spring-DM example</name>
+ <packaging>bundle</packaging>
+ <version>1.0.0-M4-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi_R4_core</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ftpserver</groupId>
+ <artifactId>ftpserver-core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName> ${artifactId}</Bundle-SymbolicName>
+ <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+ <Export-Package> org.apache.ftpserver.example.osgiservice</Export-Package>
+ <Private-Package>org.apache.ftpserver.example.osgiservice.impl</Private-Package>
+ <Import-Package>
+ org.springframework.beans.factory,
+ org.apache.ftpserver,
+ org.apache.ftpserver.ftplet
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.java?rev=718106&view=auto
==============================================================================
--- mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.java (added)
+++ mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.java Sun Nov 16 12:21:25 2008
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ftpserver.example.osgiservice.impl;
+
+import org.apache.ftpserver.FtpServer;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class FtpServerLifecycle implements InitializingBean, DisposableBean {
+
+ private FtpServer server;
+
+ public FtpServer getServer() {
+ return server;
+ }
+
+ public void setServer(FtpServer server) {
+ this.server = server;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ server.start();
+ System.out.println("Server started");
+ }
+
+ public void destroy() throws Exception {
+ server.stop();
+ System.out.println("Server stopped");
+ }
+
+}
Added: mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml?rev=718106&view=auto
==============================================================================
--- mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml (added)
+++ mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml Sun Nov 16 12:21:25 2008
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you 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.
+ -->
+<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:ftp="http://mina.apache.org/ftpserver/spring/v1"
+ 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://mina.apache.org/ftpserver/spring/v1
+ http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ ">
+ <ftp:server id="server">
+ <ftp:listeners>
+ <ftp:nio-listener name="default" port="2222" />
+ </ftp:listeners>
+ <ftp:ftplets>
+ <ftp:ftplet name="ftplet1">
+ <ref bean="ftplet" />
+ </ftp:ftplet>
+ </ftp:ftplets>
+ <ftp:file-user-manager
+ url="org/apache/ftpserver/example/osgiservice/users.properties" />
+ </ftp:server>
+
+ <osgi:service interface="org.apache.ftpserver.FtpServer"
+ ref="server">
+ </osgi:service>
+
+ <osgi:reference id="ftplet" interface="org.apache.ftpserver.ftplet.Ftplet" />
+
+ <!-- Starts and stops the bean as the context is started and stopped -->
+ <bean class="org.apache.ftpserver.example.osgiservice.impl.FtpServerLifecycle">
+ <property name="server" ref="server" />
+ </bean>
+</beans>
\ No newline at end of file
Added: mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.properties
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.properties?rev=718106&view=auto
==============================================================================
--- mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.properties (added)
+++ mina/ftpserver/trunk/examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.properties Sun Nov 16 12:21:25 2008
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+# Password is "admin"
+ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
+ftpserver.user.admin.homedirectory=/tmp
+ftpserver.user.admin.enableflag=true
+ftpserver.user.admin.writepermission=true
+ftpserver.user.admin.maxloginnumber=0
+ftpserver.user.admin.maxloginperip=0
+ftpserver.user.admin.idletime=0
+ftpserver.user.admin.uploadrate=0
+ftpserver.user.admin.downloadrate=0
+
+ftpserver.user.anonymous.userpassword=
+ftpserver.user.anonymous.homedirectory=/tmp
+ftpserver.user.anonymous.enableflag=true
+ftpserver.user.anonymous.writepermission=false
+ftpserver.user.anonymous.maxloginnumber=20
+ftpserver.user.anonymous.maxloginperip=2
+ftpserver.user.anonymous.idletime=300
+ftpserver.user.anonymous.uploadrate=4800
+ftpserver.user.anonymous.downloadrate=4800