cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r378111 - in /cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cocoon/ src/main/java/org/apache/cocoon/blocks/ src/mai...
Date Wed, 15 Feb 2006 22:58:59 GMT
Author: danielf
Date: Wed Feb 15 14:58:57 2006
New Revision: 378111

URL: http://svn.apache.org/viewcvs?rev=378111&view=rev
Log:
Initial experiments for using OSGi for the blocks fw. Especially I test how to use the declarative
services.
No Maven build yet. Check the README for how to test it.

Added:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/   (with props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF   (with
props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml   (with
props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt   (with props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml   (with props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
  (with props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
  (with props)
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
  (with props)

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb 15 14:58:57 2006
@@ -0,0 +1,7 @@
+build.properties
+.classpath
+.project
+.wtpmodules
+.deployables
+.settings
+target

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF Wed Feb
15 14:58:57 2006
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: cocoon-blocks-fw-osgi-impl
+Bundle-SymbolicName: org.apache.cocoon.blocks.osgi
+Bundle-Version: 1.0.0
+Service-Component: META-INF/components.xml
+Bundle-Localization: plugin
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.component;version="1.0.0",
+ org.osgi.service.http,
+ org.osgi.service.log

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml Wed Feb
15 14:58:57 2006
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+  <scr:component name="cocoon.activator">
+    <scr:implementation class="org.apache.cocoon.blocks.osgi.Activator"/>
+    <scr:reference name="LOG"
+                   interface="org.osgi.service.log.LogService"
+                   bind="setLog"/>
+    <scr:reference name="HTTP"
+                   interface="org.osgi.service.http.HttpService"
+                   bind="setHttpService"/>
+    <scr:reference name="Servlet"
+                   interface="javax.servlet.Servlet"
+                   cardinality="0..n"
+                   policy="dynamic"
+                   bind="setServlet"
+                   unbind="unsetServlet"/>
+  </scr:component>
+  
+  <scr:component name="cocoon.servlet1">
+    <scr:implementation class="org.apache.cocoon.blocks.osgi.TestServlet"/>
+    <scr:service>
+      <scr:provide interface="javax.servlet.Servlet"/>
+	</scr:service>
+	<scr:property name="path" value="/test1"/>
+  </scr:component>
+  
+  <scr:component name="cocoon.servlet2">
+    <scr:implementation class="org.apache.cocoon.blocks.osgi.TestServlet"/>
+    <scr:service>
+      <scr:provide interface="javax.servlet.Servlet"/>
+	</scr:service>
+	<scr:property name="path" value="/test2"/>
+  </scr:component>
+</components>
\ No newline at end of file

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt Wed Feb 15 14:58:57
2006
@@ -0,0 +1,55 @@
+OSGi Blocks Framework
+=====================
+
+This far this project only contain some preliminary OSGi experimentation.
+Specifically I experimenting with how to use the declarative services for
+wiring and mounting some servlets.
+
+The project does not use Maven yet, I don't know how to build it with Maven
+in a convenient way, suggestions are welcome.
+
+I run it within Eclipse, and use 3.2M4 as it has better support for developing
+and executing OSGi bundles than 3.1. Getting some knowledge about Eclipse RCP 
+or at least about plugin development doesn't hurt.
+
+Create a platform
+-----------------
+
+First one need to create a "platform" consisting of the basic OSGi framework
+and service bundles. Get the latest Eclipse-Equinox-SDK and launcher (for your OS),
+from the stream integration builds at http://download.eclipse.org/eclipse/equinox/.
+Unpack the SDK at some appropriate place and then unpack the launcher in the top
+directory of the SDK.
+
+Choose the platform as target platform:
+Window -> Preferences ... -> Plug-in development -> Target platform
+
+Plugin development
+------------------
+
+Import the this project into Eclipse and make it a plugin:
+Right click the project -> PDE Tools -> Convert project to plug-in projects ...
+
+Running the platform
+--------------------
+
+Start the framework:
+Run -> Run ... -> Equinox OSGi Framework -> New
+Make shure that this project and all the bundles in the target platform are chosen
+in the Plug-ins tab and that -console is given as program argument.
+
+When the platform is started you get a OSGi console in the console view in Eclipse.
+Type "help" to see what commands are available. Take a look in META-INF/components.xml
+and the use "services" to see that the services are started and connected. Type
+"bundles" to see what bundles there are, "log" for the log messages.
+
+Test to stop, update, refresh and start this bundle and take a look at the log between
+the steps to see how the services are connected.
+
+Open a browser and test http://localhost/test1 and http://localhost/test2.
+
+At last
+-------
+
+I have probably missed some information. Ask, update this document or better
+make it work with Maven.

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/README.txt
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml Wed Feb 15 14:58:57 2006
@@ -0,0 +1,22 @@
+<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">
+  <parent>
+    <artifactId>cocoon-blocks-fw</artifactId>
+    <groupId>org.apache.cocoon</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cocoon</groupId>
+  <artifactId>cocoon-blocks-fw-osgi-impl</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>Blocks Framework OSGi</name>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
(added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
Wed Feb 15 14:58:57 2006
@@ -0,0 +1,51 @@
+package org.apache.cocoon.blocks.osgi;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+import org.osgi.service.log.LogService;
+
+public class Activator {
+    
+    private LogService log;
+    private HttpService httpService;
+    private ComponentContext context;
+
+    protected void setLog(LogService logService) {
+        this.log = logService;
+        System.out.println("Got log");
+    }
+
+    protected void setHttpService(HttpService httpService) {
+        this.httpService = httpService;
+        System.out.println("Got http service");
+    }
+
+    protected void setServlet(ServiceReference reference) throws ServletException, NamespaceException
{
+        String path = (String) reference.getProperty("path");
+        Servlet servlet = (Servlet) this.context.locateService("Servlet", reference);
+        this.httpService.registerServlet(path, servlet, null, null);
+        this.log.log(LogService.LOG_DEBUG, "Register Servlet at " + path);
+    }
+
+    protected void unsetServlet(ServiceReference reference) {
+        String path = (String) reference.getProperty("path");
+        this.httpService.unregister(path);
+        this.log.log(LogService.LOG_DEBUG, "Unregister Servlet at " + path);
+    }
+
+    protected void activate(ComponentContext context) {
+        this.context = context;
+        System.out.println("Cocoon Start");
+        this.log.log(LogService.LOG_DEBUG, "Cocoon start");
+    }
+
+    protected void deactivate(ComponentContext context) {
+        System.out.println("Cocoon Stop");
+        this.log.log(LogService.LOG_DEBUG, "Cocoon stop");
+    }    
+}

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
(added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
Wed Feb 15 14:58:57 2006
@@ -0,0 +1,17 @@
+package org.apache.cocoon.blocks.osgi;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TestServlet extends HttpServlet {
+
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        response.setContentType("text/plain");
+        response.getWriter().println("Test!");
+    }
+
+}

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java?rev=378111&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
(added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
Wed Feb 15 14:58:57 2006
@@ -0,0 +1,38 @@
+package org.apache.cocoon;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/test/java/org/apache/cocoon/AppTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message