You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/11/02 22:51:28 UTC
cvs commit: jakarta-turbine-2/conf/test/merlin kernel.xml
epugh 2003/11/02 13:51:28
Modified: . project.xml project.properties
xdocs changes.xml
Added: conf/test MerlinComponentServiceTest.properties
src/java/org/apache/turbine/services/avaloncomponent
TurbineMerlinComponentService.java
src/test/org/apache/turbine/services/avaloncomponent
MerlinComponentServiceTest.java
conf/test/merlin/BLOCK-INF block.xml
conf/test/merlin kernel.xml
Log:
Merlin based Component Service. Thanks to Peter. Plus a unit test. I will be going
through the project.xml list of dependencies once I understand better which are
required and which are not.
Revision Changes Path
1.1 jakarta-turbine-2/conf/test/MerlinComponentServiceTest.properties
Index: MerlinComponentServiceTest.properties
===================================================================
# -------------------------------------------------------------------
# $Id: MerlinComponentServiceTest.properties,v 1.1 2003/11/02 21:51:28 epugh Exp $
#
# This is the configuration file for the Torque Load tests of the
# Turbine 2 project. Do not remove!
#
# -------------------------------------------------------------------
log4j.file = /conf/test/Log4j.properties
services.FactoryService.classname=org.apache.turbine.services.factory.TurbineFactoryService
services.PoolService.classname=org.apache.turbine.services.pool.TurbinePoolService
services.RunDataService.classname=org.apache.turbine.services.rundata.TurbineRunDataService
services.ServletService.classname=org.apache.turbine.services.servlet.TurbineServletService
services.AssemblerBrokerService.classname=org.apache.turbine.services.assemblerbroker.TurbineAssemblerBrokerService
services.GlobalCacheService.classname=org.apache.turbine.services.cache.TurbineGlobalCacheService
services.TemplateService.classname=org.apache.turbine.services.template.TurbineTemplateService
services.MerlinComponentService.classname=org.apache.turbine.services.avaloncomponent.TurbineMerlinComponentService
services.MerlinComponentService.earlyInit=true
services.MerlinComponentService.block.path=conf/test/merlin
services.MerlinComponentService.kernel=conf/test/merlin/kernel.xml
1.144 +153 -16 jakarta-turbine-2/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -r1.143 -r1.144
--- project.xml 29 Oct 2003 04:50:53 -0000 1.143
+++ project.xml 2 Nov 2003 21:51:28 -0000 1.144
@@ -310,11 +310,144 @@
<dependencies>
<dependency>
- <id>avalon-framework</id>
- <version>4.1.4</version>
- <url>http://jakarta.apache.org/avalon/</url>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j-jmx</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j-tools</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework-api</artifactId>
+ <version>4.1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework-impl</artifactId>
+ <version>4.1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>merlin</groupId>
+ <artifactId>merlin-kernel-spi</artifactId>
+ <version>3.2-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>merlin</groupId>
+ <artifactId>merlin-kernel-impl</artifactId>
+ <version>3.2-dev</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-activation</groupId>
+ <artifactId>avalon-activation-api</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-activation</groupId>
+ <artifactId>avalon-activation-spi</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-activation</groupId>
+ <artifactId>avalon-activation-impl</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-composition</groupId>
+ <artifactId>avalon-composition-api</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-composition</groupId>
+ <artifactId>avalon-composition-spi</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-composition</groupId>
+ <artifactId>avalon-composition-impl</artifactId>
+ <version>1.2-dev</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-extension</groupId>
+ <artifactId>avalon-extension-spi</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-extension</groupId>
+ <artifactId>avalon-extension-impl</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-meta</groupId>
+ <artifactId>avalon-meta-api</artifactId>
+ <version>1.2.1-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-meta</groupId>
+ <artifactId>avalon-meta-spi</artifactId>
+ <version>1.2.1-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-meta</groupId>
+ <artifactId>avalon-meta-impl</artifactId>
+ <version>1.2.1-dev</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-repository</groupId>
+ <artifactId>avalon-repository-spi</artifactId>
+ <version>1.0b1</version>
</dependency>
<dependency>
+ <groupId>avalon-repository</groupId>
+ <artifactId>avalon-repository-impl</artifactId>
+ <version>1.0b1</version>
+ </dependency>
+ <dependency>
+ <id>logkit</id>
+ <version>1.2</version>
+ <url>http://jakarta.apache.org/avalon/logkit/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>excalibur-lifecycle</groupId>
+ <artifactId>excalibur-lifecycle-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <id>excalibur-i18n</id>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <id>excalibur-thread</id>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <id>excalibur-event</id>
+ <version>1.0.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>excalibur</groupId>
+ <artifactId>excalibur-util-concurrent</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <id>excalibur-configuration</id>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
<id>commons-beanutils</id>
<version>1.6.1</version>
<url>http://jakarta.apache.org/commons/beanutils.html</url>
@@ -495,11 +628,6 @@
<url>http://jakarta.apache.org/log4j/</url>
</dependency>
<dependency>
- <id>logkit</id>
- <version>1.0.1</version>
- <url>http://jakarta.apache.org/avalon/logkit/</url>
- </dependency>
- <dependency>
<id>servletapi</id>
<version>2.3</version>
<url>http://java.sun.com/products/servlet/</url>
@@ -562,7 +690,14 @@
<groupId>mockobjects</groupId>
<artifactId>mockobjects-core</artifactId>
<version>0.09</version>
- </dependency>
+ </dependency>
+
+ <!-- Needed for testing -->
+ <!--dependency>
+ <groupId>merlin</groupId>
+ <artifactId>merlin-hello-tutorial</artifactId>
+ <version>1.0</version>
+ </dependency-->
</dependencies>
<build>
@@ -578,22 +713,24 @@
<aspectSourceDirectory/>
</build>
- <reports>
- <!--
- <report>maven-jdepend-plugin</report>
- -->
+ <reports>
+ <report>maven-jdepend-plugin</report>
<report>maven-checkstyle-plugin</report>
<report>maven-changelog-plugin</report>
<report>maven-developer-activity-plugin</report>
<report>maven-file-activity-plugin</report>
- <!-- <report>maven-javadoc-plugin</report>-->
+ <!--<report>maven-javadoc-plugin</report>-->
<report>maven-jxr-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-multiproject-plugin</report>
+ <report>maven-junit-report-plugin</report>
<!--
- <report>maven-junit-report-plugin</report>
<report>maven-linkcheck-plugin</report>
-->
<report>maven-tasklist-plugin</report>
- <report>maven-jcoverage-plugin</report>
+
</reports>
1.26 +2 -2 jakarta-turbine-2/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/project.properties,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- project.properties 24 Oct 2003 15:15:08 -0000 1.25
+++ project.properties 2 Nov 2003 21:51:28 -0000 1.26
@@ -14,7 +14,7 @@
# contain all the jars needed to build Turbine, even if a jar
# is missing on ibiblio
#========================================================================
-#maven.repo.remote=http://www.ibiblio.org/maven/,http://jakarta.apache.org/turbine/repo
+maven.repo.remote=http://www.ibiblio.org/maven/,http://jakarta.apache.org/turbine/repo,http://dpml.net/
maven.checkstyle.format = turbine
#maven.home = ${user.home}/maven
1.1 jakarta-turbine-2/src/java/org/apache/turbine/services/avaloncomponent/TurbineMerlinComponentService.java
Index: TurbineMerlinComponentService.java
===================================================================
package org.apache.turbine.services.avaloncomponent;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import java.net.URL;
import org.apache.avalon.activation.appliance.Block;
import org.apache.avalon.composition.util.ExceptionHelper;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
import org.apache.avalon.merlin.kernel.impl.DefaultKernelContext;
import org.apache.avalon.repository.impl.DefaultFileRepository;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.turbine.Turbine;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.TurbineBaseService;
/**
* An implementation of AvalonComponentService based on the avalon Merlin 3.2 container.
*
* @author <a mailto="peter@courcoux.biz">Peter Courcoux</a>
* @author <a mailto="epugh@upstate.com">Eric Pugh</a>
*/
public class TurbineMerlinComponentService
extends TurbineBaseService
implements MerlinComponentService, Initializable, Disposable
{
/** Logging */
private static Log log = LogFactory.getLog(TurbineMerlinComponentService.class);
/** Merlin kernel */
private DefaultKernel m_kernel = null;
// -------------------------------------------------------------
// Service initialization
// -------------------------------------------------------------
/**
* Load all configured components and initialize them. This is a zero parameter variant which
* queries the Turbine Servlet for its config.
*
* @throws InitializationException Something went wrong in the init stage
*/
public void init() throws InitializationException
{
try
{
initialize();
setInit(true);
}
catch (Exception e)
{
log.error("Exception caught initialising service: ", e);
throw new InitializationException("init failed", e);
}
}
/**
* Shuts the Component Service down, calls dispose on the components that implement this
* interface
*
*/
public void shutdown()
{
dispose();
setInit(false);
}
// -------------------------------------------------------------
// Avalon lifecycle interfaces
// -------------------------------------------------------------
/**
* Initializes the container
*
* @throws Exception generic exception
*/
public void initialize() throws Exception
{
org.apache.commons.configuration.Configuration conf
= getConfiguration();
String homePath = Turbine.getApplicationRoot();
File home = new File(homePath);
// Eric. The next thing to do is to decide how to create the blocks array.
// Steve suggested listing all the block URL's in WEB.xml as initialisation params.
// I think it needs to come from some local config. while we are keeping everything
// in the webapp context.
String blockPath = Turbine.getRealPath(
conf.getString(BLOCK_CONFIG_KEY, BLOCK_CONFIG_PATH));
File kernal = new File(Turbine.getRealPath(
conf.getString(KERNAL_CONFIG_KEY, KERNAL_CONFIG_PATH)));
//File userDir = new File(Turbine.getRealPath("target/test-classes"));
if(!kernal.exists()){
throw new Exception("Kernal file " + kernal + " doesn't exist. You must provide a " +
"valid kernal file.");
}
URL block = new File(blockPath).toURL();
URL[] blocks = new URL[1];
blocks[0] = block;
// Create the kernel context
try
{
DefaultKernelContext context =
new DefaultKernelContext(
new DefaultFileRepository(new File(Turbine.getRealPath("merlin/dud"))),
// system repo
null, //new File( Turbine.getRealPath("merlin/repository")), // user repo directory
null, //new File( Turbine.getRealPath("merlin/ext")), // ext directory
home, // home
kernal.toURL(), // kernel config
blocks, // block urls
null, // config override
true, // server
true, // info
true // debug
);
m_kernel = new DefaultKernel(context);
m_kernel.startup();
log.info("kernel established");
log.info("Application Root is " + homePath);
}
catch (Exception e)
{
final String message = "Turbine/Merlin problem.";
final String error = ExceptionHelper.packException(message, e, true);
log.info(error);
System.out.println(error);
}
}
/**
* Disposes of the container and releases resources
*/
public void dispose()
{
if (m_kernel != null)
{
m_kernel.shutdown();
m_kernel = null;
}
}
/**
* Returns an instance of the named component
*
* @param roleName Name of the role the component fills.
* @return an instance of the named component
* @throws Exception generic exception
*/
public Object lookup(String path) throws Exception
{
Block root = m_kernel.getRootBlock();
return root.locate(path);
}
/**
* Releases the component
*
* @param source. The path to the handler for this component For example, if the object is a
* java.sql.Connection object sourced from the "/turbine-merlin/datasource"
* component, the call would be :- release("/turbine-merlin/datasource", conn);
* @param component the component to release
*/
public void release(Object component)
{
Block root = m_kernel.getRootBlock();
root.release(component);
}
}
1.76 +4 -0 jakarta-turbine-2/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/xdocs/changes.xml,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- changes.xml 31 Oct 2003 01:22:28 -0000 1.75
+++ changes.xml 2 Nov 2003 21:51:28 -0000 1.76
@@ -63,6 +63,10 @@
<p>
<ul>
<li>
+ Added first cut of the MerlinComponentService which uses the Avalon Merlin
+ container. Merlin has many many features to help with dealing with components. Thanks to Peter for this!
+ </li>
+ <li>
The cache, crypto, mimetype services have now been deprecated in favor
of the Fulcrum versions as well. Turbine security now uses the Fulcrum
crypto component.
1.1 jakarta-turbine-2/src/test/org/apache/turbine/services/avaloncomponent/MerlinComponentServiceTest.java
Index: MerlinComponentServiceTest.java
===================================================================
package org.apache.turbine.services.avaloncomponent;
/*
* ==================================================================== The Apache Software
* License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met: 1. Redistributions of source code must retain
* the above copyright notice, this list of conditions and the following disclaimer. 2.
* Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution. 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may
* appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4.
* The names "Apache" and "Apache Software Foundation" and "Apache Turbine" must not be used to
* endorse or promote products derived from this software without prior written permission. For
* written permission, please contact apache@apache.org. 5. Products derived from this software may
* not be called "Apache", "Apache Turbine", nor may "Apache" appear in their name, without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals on behalf of the
* Apache Software Foundation. For more information on the Apache Software Foundation, please see
* <http://www.apache.org/> .
*/
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.test.BaseTestCase;
import org.apache.turbine.util.TurbineConfig;
/**
* Simple test to make sure that the AvalonComponentService can be initialized.
*
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: MerlinComponentServiceTest.java,v 1.1 2003/11/02 21:51:28 epugh Exp $
*/
public class MerlinComponentServiceTest extends BaseTestCase
{
private static final Log log = LogFactory.getLog(MerlinComponentServiceTest.class);
public MerlinComponentServiceTest(String name) throws Exception
{
super(name);
}
private MerlinComponentService getService()
{
return (MerlinComponentService) TurbineServices.getInstance().getService(
MerlinComponentService.SERVICE_NAME);
}
/**
* Test that we successfully download and install the HelloComponent form the
* Merlin tutorial. Currently pulling from http://jakarta.apache.org/turbine/repo/merlin
* @throws Exception
*/
public void testMerlinWithHelloComponent() throws Exception
{
TurbineConfig tc =
new TurbineConfig(".", "/conf/test/MerlinComponentServiceTest.properties");
try
{
tc.initialize();
Object appliance = getService().lookup("/tutorial/hello"); // just to test
assertNotNull(appliance);
assertEquals("appliance:/tutorial/hello", appliance.toString());
log.info("Looked up appliance: " + appliance.toString());
getService().release(appliance);
}
catch (Exception e)
{
throw e;
}
finally
{
tc.dispose();
}
}
/**
* Test that a locally compiled component can be loaded and used. Currently not
* working because the org.apache.turbine.test.TestComponent is in this classloader,
* not in a downloaded jar.
* @throws Exception
*/
public void OFF_testMerlinWithTestComponent() throws Exception
{
TurbineConfig tc =
new TurbineConfig(".", "/conf/test/MerlinComponentServiceTest.properties");
try
{
tc.initialize();
Object appliance = getService().lookup("/local/testcomponent"); // just to test
assertNotNull(appliance);
assertEquals("appliance:/local/testcomponent", appliance.toString());
log.info("Looked up appliance: " + appliance.toString());
getService().release(appliance);
}
catch (Exception e)
{
throw e;
}
finally
{
tc.dispose();
}
}
}
1.1 jakarta-turbine-2/conf/test/merlin/BLOCK-INF/block.xml
Index: block.xml
===================================================================
<container name="tutorial">
<classloader>
<classpath>
<repository>
<resource id="merlin:merlin-hello-tutorial" version="1.0"/>
</repository>
</classpath>
</classloader>
<component name="hello" class="tutorial.HelloComponent"/>
</container>
<!-- Not working, dont' know how to load wit local path...
<container name="local">
<component name="testcomponent" class="org.apache.turbine.test.TestComponent"/>
</container>
-->
1.1 jakarta-turbine-2/conf/test/merlin/kernel.xml
Index: kernel.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<kernel>
<logging priority="INFO" name="kernel">
<category name="/logger" priority="WARN"/>
</logging>
<repository>
<hosts>
<host path="http://jakarta.apache.org/turbine/repo/"/>
<host path="http://dpml.net/"/>
<host path="http://www.ibiblio.org/maven/"/>
</hosts>
</repository>
</kernel>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org