Author: ngn
Date: Sun Nov 16 12:19:00 2008
New Revision: 718104
URL: http://svn.apache.org/viewvc?rev=718104&view=rev
Log:
Commiting an example of publishing an Ftplet as an OSGi service
Added:
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/pom.xml
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.java
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.java
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/resources/
Modified:
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/ (props
changed)
Propchange: mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Nov 16 12:19:00 2008
@@ -0,0 +1,5 @@
+.settings
+bin
+target
+.classpath
+.project
Added: mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/pom.xml
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/pom.xml?rev=718104&view=auto
==============================================================================
--- mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/pom.xml (added)
+++ mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/pom.xml Sun Nov
16 12:19:00 2008
@@ -0,0 +1,75 @@
+<?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>Simple example where an Ftplet is published as a OSGi
service. Another bundle, using the white-board pattern can locate this and plug
it into a running server.</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-ftplet-service</artifactId>
+ <name>FtpServer OSGi Ftplet service example</name>
+ <packaging>bundle</packaging>
+ <version>1.0.0-M4-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ftpserver</groupId>
+ <artifactId>ftplet-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi_R4_core</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </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.ftpletservice</Export-Package>
+ <Private-Package>
org.apache.ftpserver.example.ftpletservice.impl</Private-Package>
+
<Bundle-Activator>org.apache.ftpserver.example.ftpletservice.impl.Activator</Bundle-Activator>
+ <Import-Package>
+ org.apache.ftpserver.ftplet,
+ org.osgi.framework
+ </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-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.java?rev=718104&view=auto
==============================================================================
---
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.java
(added)
+++
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.java
Sun Nov 16 12:19:00 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.ftpletservice;
+
+import java.io.IOException;
+
+import org.apache.ftpserver.ftplet.DefaultFtplet;
+import org.apache.ftpserver.ftplet.FtpException;
+import org.apache.ftpserver.ftplet.FtpSession;
+import org.apache.ftpserver.ftplet.FtpletResult;
+
+public class MyFtplet extends DefaultFtplet {
+
+ @Override
+ public FtpletResult onConnect(FtpSession session) throws FtpException,
+ IOException {
+ System.out.println("User connected to FtpServer");
+
+ return super.onConnect(session);
+ }
+
+ @Override
+ public FtpletResult onDisconnect(FtpSession session) throws FtpException,
+ IOException {
+ System.out.println("User connected to FtpServer");
+
+ return super.onDisconnect(session);
+ }
+
+
+
+}
Added:
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.java?rev=718104&view=auto
==============================================================================
---
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.java
(added)
+++
mina/ftpserver/trunk/examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.java
Sun Nov 16 12:19:00 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.ftpletservice.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.ftpserver.example.ftpletservice.MyFtplet;
+import org.apache.ftpserver.ftplet.Ftplet;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ Dictionary<String, String> properties = new Hashtable<String,
String>();
+ properties.put("name", "myftplet");
+
+ context.registerService(Ftplet.class.getName(), new MyFtplet(),
properties);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // do nothing
+ }
+
+}