cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r382570 - in /cocoon/trunk/cocoon-blocks-fw: cocoon-blocks-fw-impl/META-INF/ cocoon-blocks-fw-osgi-impl/META-INF/ cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/
Date Thu, 02 Mar 2006 23:51:11 GMT
Author: danielf
Date: Thu Mar  2 15:51:09 2006
New Revision: 382570

URL: http://svn.apache.org/viewcvs?rev=382570&view=rev
Log:
Starting to get the blocks fw to work in OSGi.

Added:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/META-INF/
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/META-INF/MANIFEST.MF   (with props)
Modified:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
    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-impl/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/META-INF/MANIFEST.MF?rev=382570&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/META-INF/MANIFEST.MF (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/META-INF/MANIFEST.MF Thu Mar  2 15:51:09
2006
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: cocoon-blocks-fw-impl
+Bundle-SymbolicName: org.apache.cocoon.blocks
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Import-Package: javax.servlet;version="2.3.0",
+ javax.servlet.http
+Export-Package: org.apache.cocoon.blocks,
+ org.apache.cocoon.blocks.util

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

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

Modified: 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=382570&r1=382569&r2=382570&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF (original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/MANIFEST.MF Thu Mar
 2 15:51:09 2006
@@ -7,6 +7,8 @@
 Bundle-Localization: plugin
 Import-Package: javax.servlet,
  javax.servlet.http,
+ org.apache.cocoon.blocks,
+ org.apache.cocoon.blocks.util,
  org.osgi.framework;version="1.3.0",
  org.osgi.service.component;version="1.0.0",
  org.osgi.service.http,

Modified: 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=382570&r1=382569&r2=382570&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml (original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml Thu Mar
 2 15:51:09 2006
@@ -16,12 +16,26 @@
                    unbind="unsetServlet"/>
   </scr:component>
   
+  <scr:component name="cocoon.blockServlet1">
+    <scr:implementation class="org.apache.cocoon.blocks.osgi.BlockServlet"/>
+    <scr:service>
+      <scr:provide interface="javax.servlet.Servlet"/>
+	</scr:service>
+	<scr:property name="path" value="/test1"/>
+	<scr:property name="attr" value="foo"/>
+    <scr:reference name="Servlet"
+                   interface="javax.servlet.Servlet"
+                   target="(component.name=cocoon.servlet1)"
+                   bind="setServlet"/>
+  </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">

Modified: 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=382570&r1=382569&r2=382570&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/Activator.java
Thu Mar  2 15:51:09 2006
@@ -28,9 +28,11 @@
  * @version $Id$
  */
 public class Activator {
-    
+
     private LogService log;
+
     private HttpService httpService;
+
     private ComponentContext context;
 
     protected void setLog(LogService logService) {
@@ -43,17 +45,23 @@
         System.out.println("Got http service");
     }
 
-    protected void setServlet(ServiceReference reference) throws ServletException, NamespaceException
{
+    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);
+        if (path != null) {
+            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);
+        if (path != null) {
+            this.httpService.unregister(path);
+            this.log.log(LogService.LOG_DEBUG, "Unregister Servlet at " + path);
+        }
     }
 
     protected void activate(ComponentContext context) {
@@ -65,5 +73,5 @@
     protected void deactivate(ComponentContext context) {
         System.out.println("Cocoon Stop");
         this.log.log(LogService.LOG_DEBUG, "Cocoon stop");
-    }    
+    }
 }

Modified: 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=382570&r1=382569&r2=382570&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet.java
Thu Mar  2 15:51:09 2006
@@ -29,7 +29,8 @@
 
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         response.setContentType("text/plain");
-        response.getWriter().println("Test!");
+        String attr = this.getInitParameter("attr");
+        response.getWriter().println("Test! " + attr);
     }
 
 }



Mime
View raw message