felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject svn commit: r360481 - in /incubator/felix/sandbox/tbennett/echo-server: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/safehaus/ src/main/java/org/safehaus/osgi/ src/main/java/org/safehaus/osgi/protocols/
Date Sun, 01 Jan 2006 09:03:46 GMT
Author: tbennett
Date: Sun Jan  1 01:03:40 2006
New Revision: 360481

URL: http://svn.apache.org/viewcvs?rev=360481&view=rev
Log: (empty)

Added:
    incubator/felix/sandbox/tbennett/echo-server/
    incubator/felix/sandbox/tbennett/echo-server/pom.xml   (with props)
    incubator/felix/sandbox/tbennett/echo-server/src/
    incubator/felix/sandbox/tbennett/echo-server/src/main/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
  (with props)
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java
  (with props)

Added: incubator/felix/sandbox/tbennett/echo-server/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/echo-server/pom.xml?rev=360481&view=auto
==============================================================================
--- incubator/felix/sandbox/tbennett/echo-server/pom.xml (added)
+++ incubator/felix/sandbox/tbennett/echo-server/pom.xml Sun Jan  1 01:03:40 2006
@@ -0,0 +1,54 @@
+<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">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.safehaus.osgi</groupId>
+  <artifactId>reverse-server</artifactId>
+  <packaging>osgi-bundle</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>MINA-based Reverse Server for OSGi</name>
+  <url>http://www.safehaus.org</url>
+  <build>
+    <finalName>reverse-server</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix.plugins</groupId>
+        <artifactId>maven-osgi-plugin</artifactId>
+        <extensions>true</extensions>
+        <version>0.3.0</version>
+        <configuration>
+          <!--
+          *************************************************
+          * Uncomment to specify a manifest file to merge *
+          *************************************************
+          <manifestFile>path/to/manifest.mf</manifestFile>
+          -->
+
+          <!--
+          *******************************************************************
+          * See the following link for entry specification                  *
+          * http://docs.safehaus.org/display/OSGI/OSGi+Plugin+for+Maven+2.0 *
+          *******************************************************************
+          -->
+          <osgiManifest>
+            <bundleName>Reverse Server</bundleName>
+            <bundleActivator>org.safehaus.osgi.ReverseServerActivator</bundleActivator>
+            <bundleVendor>Safehaus</bundleVendor>
+          </osgiManifest>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi</artifactId>
+      <version>3.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.mina</groupId>
+      <artifactId>org.apache.mina</artifactId>
+      <version>0.9.1-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: incubator/felix/sandbox/tbennett/echo-server/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java?rev=360481&view=auto
==============================================================================
--- incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
(added)
+++ incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
Sun Jan  1 01:03:40 2006
@@ -0,0 +1,40 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   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.safehaus.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+import org.apache.mina.registry.Service;
+import org.apache.mina.common.TransportType;
+import org.safehaus.osgi.protocols.ReverseProtocolHandler;
+
+public class ReverseServerActivator implements BundleActivator {
+    private static final int PORT = 8192;
+
+    public void start(BundleContext bundleContext) throws Exception {
+        ServiceRegistry registry = new SimpleServiceRegistry();
+        Service service = new Service("reverse", TransportType.SOCKET, PORT);
+        registry.bind(service, new ReverseProtocolHandler());
+        System.out.println("Listening on port " + PORT);
+    }
+
+    public void stop(BundleContext bundleContext) throws Exception {
+        // Put code here to finalize your bundle...
+    }
+}

Propchange: incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java?rev=360481&view=auto
==============================================================================
--- incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java
(added)
+++ incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java
Sun Jan  1 01:03:40 2006
@@ -0,0 +1,36 @@
+package org.safehaus.osgi.protocols;
+
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
+
+public class ReverseProtocolHandler extends IoHandlerAdapter {
+    private static IoFilter LOGGING_FILTER = new LoggingFilter();
+    private static IoFilter CODEC_FILTER =
+            new ProtocolCodecFilter(new TextLineCodecFactory());
+
+    public void sessionCreated(IoSession ioSession) throws Exception {
+        ioSession.getFilterChain().addLast("logger", LOGGING_FILTER);
+        ioSession.getFilterChain().addLast("codec", CODEC_FILTER);
+    }
+
+    public void messageReceived(IoSession ioSession, Object message) throws Exception {
+        // reverse received string...
+        String s = message.toString();
+        StringBuffer buffer = new StringBuffer(s.length());
+        for (int i = s.length() - 1; i >= 0; i--) {
+            buffer.append(s.charAt(i));
+        }
+
+        // and write it back...
+        ioSession.write(buffer.toString());
+    }
+
+    public void exceptionCaught(IoSession ioSession, Throwable throwable) throws Exception
{
+        throwable.printStackTrace();
+        ioSession.close();
+    }
+}

Propchange: incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/protocols/ReverseProtocolHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message