Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 97812 invoked from network); 2 Oct 2005 22:08:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Oct 2005 22:08:53 -0000 Received: (qmail 76435 invoked by uid 500); 2 Oct 2005 22:08:52 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 76300 invoked by uid 500); 2 Oct 2005 22:08:52 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 76288 invoked by uid 99); 2 Oct 2005 22:08:51 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 02 Oct 2005 15:08:51 -0700 Received: (qmail 97733 invoked by uid 65534); 2 Oct 2005 22:08:31 -0000 Message-ID: <20051002220831.97732.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: cvs@cocoon.apache.org From: danielf@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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"/> Apache License 2.0 Apache Cocoon community + + + 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 @@ +--> - + resource://org/apache/cocoon/components/flow/javascript/fom/fom_system.js true 4000 @@ -244,9 +244,9 @@ | and transformers. +--> - - - + + + @@ -536,7 +536,7 @@ | traversable (directory structures can be crawled). +--> - +