cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r293177 - in /cocoon/trunk/src: java/ java/org/apache/cocoon/core/container/ java/org/apache/cocoon/core/osgi/ osgi-servlet/org/apache/cocoon/service/servlet/impl/ webapp/ webapp/WEB-INF/ webapp/WEB-INF/xconf/
Date Sun, 02 Oct 2005 22:08:29 GMT
Author: danielf
Date: Sun Oct  2 15:08:09 2005
New Revision: 293177

URL: http://svn.apache.org/viewcvs?rev=293177&view=rev
Log:
Exposing components as OSGi services. Handle poolable with thread safe proxy as well as singletons.
Read component configurations from block.xml. Updated mainifests. Can't expose single threaded
components as services yet, flowscript, the output modules and the part source are marked
as exported="false" because of that.

Modified:
    cocoon/trunk/src/java/Manifest.mf
    cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
    cocoon/trunk/src/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java
    cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java
    cocoon/trunk/src/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java
    cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java
    cocoon/trunk/src/webapp/Manifest.mf
    cocoon/trunk/src/webapp/WEB-INF/block.xml
    cocoon/trunk/src/webapp/WEB-INF/xconf/cocoon-core.xconf

Modified: cocoon/trunk/src/java/Manifest.mf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/Manifest.mf?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/java/Manifest.mf (original)
+++ cocoon/trunk/src/java/Manifest.mf Sun Oct  2 15:08:09 2005
@@ -109,8 +109,9 @@
  org.apache.excalibur.source,
  org.apache.excalibur.source.impl,
  org.apache.excalibur.store,
+ org.apache.excalibur.xml,
  org.apache.excalibur.xml.impl,
- org.apache.excalibur.xml.sax,   
+ org.apache.excalibur.xml.sax,
  org.apache.excalibur.xml.xpath,
  org.apache.excalibur.xml.xslt,
  org.apache.excalibur.xmlizer,

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java Sun Oct
 2 15:08:09 2005
@@ -97,7 +97,7 @@
     /** LoggerManager. */
     protected LoggerManager loggerManager;
 
-    private ComponentEnvironment componentEnv;
+    protected ComponentEnvironment componentEnv;
 
     /** The settings */
     private Settings settings;

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java Sun Oct  2 15:08:09
2005
@@ -21,6 +21,7 @@
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.Cocoon;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.core.BootstrapEnvironment;
 import org.apache.cocoon.core.Core;
@@ -58,10 +59,10 @@
      * This method may be overwritten by subclasses to provide an own
      * configuration
      */
-    protected Configuration getConfiguration() {
-        DefaultConfiguration config = new DefaultConfiguration("cocoon", "CoreBlockActivator");
-        return config;
-    }
+//     protected Configuration getConfiguration() {
+//         DefaultConfiguration config = new DefaultConfiguration("cocoon", "CoreBlockActivator");
+//         return config;
+//     }
 
     /**
      * This method may be overwritten by subclasses to add aditional
@@ -70,6 +71,6 @@
     protected void addComponents(CoreServiceManager manager) 
     throws ServiceException, ConfigurationException {
         manager.addInstance(Core.ROLE, this.core);
-        manager.addInstance(Processor.ROLE, this.processor);
+        manager.addInstance(Cocoon.class.getName(), this.processor);
     }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java Sun Oct
 2 15:08:09 2005
@@ -25,7 +25,9 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.components.ComponentInfo;
 import org.apache.cocoon.core.container.CoreServiceManager;
+import org.apache.cocoon.core.container.DefaultServiceSelector;
 import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.core.container.handler.PoolableComponentHandler;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceFactory;
@@ -59,13 +61,29 @@
      */
     public void addComponent(String role, String className, Configuration configuration,
ComponentInfo info) throws ConfigurationException {
         super.addComponent(role, className, configuration, info);
+
+        Class clazz;
+        try {
+            clazz = this.componentEnv.loadClass(className);
+        } catch(ClassNotFoundException cnfe) {
+            throw new ConfigurationException("Cannot load class " + className + " for component
at " +
+                                             configuration.getLocation(), cnfe);
+        }
+
+        // The DefaultServiceSelector just add its children, no need to add it as a service
+        if (DefaultServiceSelector.class.isAssignableFrom(clazz))
+            return;
         if (configuration.getAttributeAsBoolean("exported", true)) {
             ComponentHandler handler = (ComponentHandler)super.componentHandlers.get(role);
-            if (!handler.isSingleton()) {
-                throw new ConfigurationException("Only singleton services can be exported
as OSGi services, at " +
-                                                 configuration.getLocation());
+            // Shouldn't PoolableComponentHandler be marked as a singleton?
+            if (handler.isSingleton() ||
+                handler instanceof PoolableComponentHandler) {
+                this.addService(role, handler);
+            } else {
+                throw new ConfigurationException("Only singleton services and thread safe
pool proxies can be exported as OSGi services, at " +
+                                                 configuration.getLocation() +
+                                                 " handler=" + handler);
             }
-            this.addService(role, handler);
         }
     }
     
@@ -75,10 +93,6 @@
     public void addInstance(String role, Object instance) throws ServiceException {
         super.addInstance(role, instance);
         ComponentHandler handler = (ComponentHandler)super.componentHandlers.get(role);
-        if (!handler.isSingleton()) {
-            throw new ServiceException("Only singleton services can be exported as OSGi services,
at " +
-                                       instance.toString());
-        }
         this.addService(role, handler);
     }
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java Sun Oct
 2 15:08:09 2005
@@ -21,7 +21,7 @@
 import org.apache.avalon.excalibur.logger.LoggerManager;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
@@ -82,7 +82,7 @@
         this.manager.setRoleManager(null);
         
         //---- Configurable
-        this.manager.configure(this.getConfiguration());
+        this.manager.configure(this.getConfiguration(ctx));
         this.addComponents(this.manager);
         
         //---- Initializable
@@ -104,15 +104,13 @@
      * This method may be overwritten by subclasses to provide an own
      * configuration
      */
-    protected Configuration getConfiguration() {
-        // Create a configuration object with one include directive. ECM++ will do the rest!
-        DefaultConfiguration config = new DefaultConfiguration("cocoon", "ServiceManagerActivator");
-//         DefaultConfiguration include = new DefaultConfiguration("include");
-//         URL confURL = ctx.getBundle().getResource("/BLOCK-INF/block.xconf");
-//         include.setAttribute("src", confURL.toExternalForm());
-//         config.addChild(include);
+    protected Configuration getConfiguration(BundleContext ctx) throws Exception {
+	URL confURL = ctx.getBundle().getResource("/WEB-INF/block.xml");
+	DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+	Configuration block = builder.build(confURL.openStream());
+	Configuration components = block.getChild("components");
 
-        return config;
+        return components;
     }
 
     /**

Modified: cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java (original)
+++ cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java Sun
Oct  2 15:08:09 2005
@@ -19,6 +19,7 @@
 
 import org.apache.avalon.excalibur.logger.LoggerManager;
 import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.Cocoon;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.core.Core;
 import org.apache.cocoon.core.osgi.OSGiLoggerManager;
@@ -55,7 +56,7 @@
 
         OSGiServiceManager manager = new OSGiServiceManager(Activator.bc);
         this.core = (Core)manager.lookup(Core.ROLE);
-        this.processor = (Processor)manager.lookup(Processor.ROLE);
+        this.processor = (Processor)manager.lookup(Cocoon.class.getName());
 
         ServiceListener listener = new ServiceListener() {
                 public void serviceChanged(ServiceEvent ev) {

Modified: cocoon/trunk/src/webapp/Manifest.mf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/Manifest.mf?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/webapp/Manifest.mf (original)
+++ cocoon/trunk/src/webapp/Manifest.mf Sun Oct  2 15:08:09 2005
@@ -12,6 +12,13 @@
 Bundle-Category: sitemap
 Import-Package: 
  org.osgi.framework,
- org.apache.cocoon
+ org.apache.cocoon,
+ org.apache.excalibur.source,
+ org.apache.excalibur.store,
+ org.apache.excalibur.xml,
+ org.apache.excalibur.xml.sax,
+ org.apache.excalibur.xml.xpath,
+ org.apache.excalibur.xml.xslt,
+ org.apache.excalibur.xmlizer
 DynamicImport-Package: org.apache.cocoon.*
 Bundle-UUID: org.apache.cocoon:cocoon_webapp:1.0.0:impl

Modified: cocoon/trunk/src/webapp/WEB-INF/block.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/block.xml?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/block.xml (original)
+++ cocoon/trunk/src/webapp/WEB-INF/block.xml Sun Oct  2 15:08:09 2005
@@ -28,5 +28,8 @@
          implementation="unstable"/>
   <license href="http://www.apache.org/licenses/">Apache License 2.0</license>
   <author href="http://cocoon.apache.org">Apache Cocoon community</author>
+  <components>
+    <include src="context://WEB-INF/xconf/cocoon-core.xconf"/>
+  </components>
   <sitemap src="sitemap.xmap"/>
 </block>

Modified: cocoon/trunk/src/webapp/WEB-INF/xconf/cocoon-core.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/xconf/cocoon-core.xconf?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/xconf/cocoon-core.xconf (original)
+++ cocoon/trunk/src/webapp/WEB-INF/xconf/cocoon-core.xconf Sun Oct  2 15:08:09 2005
@@ -92,7 +92,7 @@
       +-->
   <flow-interpreters default="javascript" logger="flow">
     <!-- FOM (Flow Object Model) -->
-    <component-instance name="javascript" class="org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter">
+    <component-instance exported="false" name="javascript" class="org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter">
       <load-on-startup>resource://org/apache/cocoon/components/flow/javascript/fom/fom_system.js</load-on-startup>
       <reload-scripts>true</reload-scripts>
       <check-time>4000</check-time>
@@ -244,9 +244,9 @@
       | and transformers.
       +-->
   <output-modules>
-    <component-instance logger="core.modules.output" name="request-attr" class="org.apache.cocoon.components.modules.output.RequestAttributeOutputModule"/>
-    <component-instance logger="core.modules.output" name="request-attr-map" class="org.apache.cocoon.components.modules.output.RequestAttributeMap"/>
-    <component-instance logger="core.modules.output" name="session-attr" class="org.apache.cocoon.components.modules.output.SessionAttributeOutputModule"/>
+    <component-instance exported="false" logger="core.modules.output" name="request-attr"
class="org.apache.cocoon.components.modules.output.RequestAttributeOutputModule"/>
+    <component-instance exported="false" logger="core.modules.output" name="request-attr-map"
class="org.apache.cocoon.components.modules.output.RequestAttributeMap"/>
+    <component-instance exported="false" logger="core.modules.output" name="session-attr"
class="org.apache.cocoon.components.modules.output.SessionAttributeOutputModule"/>
   </output-modules>
 
 <!-- ================================= XML ================================ -->
@@ -536,7 +536,7 @@
         | traversable (directory structures can be crawled).
         +-->
     <component-instance name="file" class="org.apache.excalibur.source.impl.FileSourceFactory"/>
-    <component-instance name="upload" class="org.apache.cocoon.components.source.impl.PartSourceFactory"/>
+    <component-instance exported="false" name="upload" class="org.apache.cocoon.components.source.impl.PartSourceFactory"/>
     <component-instance name="module" class="org.apache.cocoon.components.source.impl.ModuleSourceFactory"/>
     <component-instance name="xmodule" class="org.apache.cocoon.components.source.impl.XModuleSourceFactory"/>
     <component-instance name="empty" class="org.apache.cocoon.components.source.impl.EmptySourceFactory"/>



Mime
View raw message