forked from openkylin/plexus-bsh-factory
Import Upstream version 1.0~alpha7
This commit is contained in:
commit
9bba180a10
|
@ -0,0 +1 @@
|
|||
debian/patches
|
|
@ -0,0 +1 @@
|
|||
series
|
|
@ -0,0 +1 @@
|
|||
2
|
|
@ -0,0 +1,18 @@
|
|||
<project>
|
||||
<parent>
|
||||
<artifactId>plexus-component-factories</artifactId>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<version>1.0-alpha-5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>plexus-bsh-factory</artifactId>
|
||||
<name>Plexus BSH Factory</name>
|
||||
<version>1.0-alpha-7</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>bsh</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,99 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import bsh.EvalError;
|
||||
import bsh.Interpreter;
|
||||
import bsh.UtilEvalError;
|
||||
import org.codehaus.classworlds.ClassRealm;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.factory.AbstractComponentFactory;
|
||||
import org.codehaus.plexus.component.factory.ComponentInstantiationException;
|
||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* BeanShell component factory.
|
||||
*
|
||||
* @author <a href="mailto:jason@maven.org">Jason Van Zyl</a>
|
||||
* @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
|
||||
*/
|
||||
public class BshComponentFactory
|
||||
extends AbstractComponentFactory
|
||||
{
|
||||
public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm containerRealm,
|
||||
PlexusContainer container )
|
||||
throws ComponentInstantiationException
|
||||
{
|
||||
String impl = componentDescriptor.getImplementation();
|
||||
if ( !impl.startsWith( "/" ) )
|
||||
{
|
||||
impl = "/" + impl;
|
||||
}
|
||||
|
||||
URL scriptLocation = containerRealm.getResource( impl );
|
||||
|
||||
if ( scriptLocation == null )
|
||||
{
|
||||
StringBuffer buf = new StringBuffer( "Cannot find: " + impl + " in classpath:" );
|
||||
for ( int i = 0; i < containerRealm.getConstituents().length; i++ )
|
||||
{
|
||||
URL constituent = containerRealm.getConstituents()[i];
|
||||
buf.append( "\n [" + i + "] " + constituent );
|
||||
}
|
||||
throw new ComponentInstantiationException( buf.toString() );
|
||||
}
|
||||
|
||||
Object result = null;
|
||||
Reader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
Interpreter interp = new Interpreter();
|
||||
|
||||
reader = new InputStreamReader( scriptLocation.openStream() );
|
||||
|
||||
// TODO
|
||||
// BeanShell honours the context classloader, which something is setting (erroneously?)
|
||||
// interp.setClassLoader( containerRealm.getClassLoader() );
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader( containerRealm.getClassLoader() );
|
||||
result = interp.eval( reader );
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
}
|
||||
catch ( EvalError evalError )
|
||||
{
|
||||
containerRealm.display();
|
||||
|
||||
container.getLogger().info( "Error text: " + evalError.getErrorText() );
|
||||
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getComponentKey() +
|
||||
"; unable to read BeanShell script", evalError );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
containerRealm.display();
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getComponentKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getComponentKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
public class BshComponentFactoryTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
public BshComponentFactoryTest()
|
||||
{
|
||||
}
|
||||
|
||||
public void testComponent()
|
||||
throws Exception
|
||||
{
|
||||
Hello hello = (Hello) lookup( Hello.ROLE );
|
||||
|
||||
assertNotNull( hello );
|
||||
|
||||
hello.initialize();
|
||||
|
||||
hello.start();
|
||||
|
||||
hello.hello();
|
||||
|
||||
hello.dispose();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<project>
|
||||
<parent>
|
||||
<artifactId>plexus-component-factories</artifactId>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<version>1.0-alpha-5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>plexus-bsh-factory</artifactId>
|
||||
<name>Plexus BSH Factory</name>
|
||||
<version>1.0-alpha-7</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>bsh</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-9-stable-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
01-add-missing-dependencies.patch
|
||||
02-plexus-containers-compatibility.patch
|
||||
03-junit-dependency.patch
|
|
@ -0,0 +1,63 @@
|
|||
plexus-bsh-factory (1.0~alpha7-5) unstable; urgency=medium
|
||||
|
||||
* Update Uploaders field (Closes: #889420)
|
||||
* Update build-dep on libplexus-container-default-java (Closes: #1020427)
|
||||
* Use debhelper-compat 13
|
||||
* Remove get-orig-source target from debian/rules
|
||||
* Bump Standards-Version to 4.6.1
|
||||
* Freshen years in debian/copyright
|
||||
|
||||
-- tony mancill <tmancill@debian.org> Fri, 23 Sep 2022 08:15:07 -0700
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-4.1) unstable; urgency=medium
|
||||
|
||||
* Non maintainer upload by the Reproducible Builds team.
|
||||
* No source change upload to rebuild on buildd with .buildinfo files.
|
||||
|
||||
-- Holger Levsen <holger@debian.org> Mon, 28 Dec 2020 13:14:33 +0100
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-4) unstable; urgency=medium
|
||||
|
||||
* Team upload.
|
||||
* Depend on libplexus-container-default1.5-java
|
||||
instead of libplexus-container-default-java
|
||||
* Standards-Version updated to 4.1.0
|
||||
* Switch to debhelper level 10
|
||||
|
||||
-- Emmanuel Bourg <ebourg@apache.org> Fri, 08 Sep 2017 09:43:49 +0200
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-3.1) unstable; urgency=medium
|
||||
|
||||
* Non-maintainer upload.
|
||||
* Build with maven-debian-helper
|
||||
* Depend on libbsh-java instead of bsh
|
||||
* Moved the package to Git
|
||||
* Standards-Version updated to 3.9.7 (no changes)
|
||||
* Switch to debhelper level 9
|
||||
* Converted debian/copyright to the Copyright Format 1.0
|
||||
|
||||
-- Emmanuel Bourg <ebourg@apache.org> Fri, 19 Feb 2016 16:57:41 +0100
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-3) unstable; urgency=low
|
||||
|
||||
* Add myself to Uploaders.
|
||||
* Bump Standards-Version to 3.9.2: no changes needed.
|
||||
* Fix FTBFS: remove version param (deprecated in debian-ant-helper)
|
||||
and use POM version (Closes: #628345).
|
||||
* Use mh_clean in clean rule.
|
||||
* Bump to debhelper 7 compat level.
|
||||
* Switch to source format 3.0 (quilt).
|
||||
|
||||
-- Damien Raude-Morvan <drazzib@debian.org> Sun, 29 May 2011 13:33:35 +0200
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-2) unstable; urgency=low
|
||||
|
||||
* Switch to the new plexus-container package.
|
||||
|
||||
-- Torsten Werner <twerner@debian.org> Mon, 13 Jul 2009 21:22:01 +0200
|
||||
|
||||
plexus-bsh-factory (1.0~alpha7-1) unstable; urgency=low
|
||||
|
||||
* Initial release. (Closes: #535021)
|
||||
|
||||
-- Ludovic Claude <ludovic.claude@laposte.net> Sat, 28 Mar 2009 22:01:14 +0000
|
|
@ -0,0 +1,27 @@
|
|||
Source: plexus-bsh-factory
|
||||
Section: java
|
||||
Priority: optional
|
||||
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
|
||||
Uploaders: Ludovic Claude <ludovic.claude@laposte.net>,
|
||||
tony mancill <tmancill@debian.org>
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
default-jdk,
|
||||
junit4,
|
||||
libbsh-java,
|
||||
libplexus-container-default-java,
|
||||
maven-debian-helper,
|
||||
Standards-Version: 4.6.1
|
||||
Vcs-Git: https://salsa.debian.org/java-team/plexus-bsh-factory.git
|
||||
Vcs-Browser: https://salsa.debian.org/java-team/plexus-bsh-factory
|
||||
Homepage: http://plexus.codehaus.org/
|
||||
|
||||
Package: libplexus-bsh-factory-java
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, libplexus-container-default1.5-java, libbsh-java
|
||||
Description: Plexus Beanshell Factory
|
||||
The Plexus project provides a full software stack for creating and
|
||||
executing software projects. Based on the Plexus container, the applications
|
||||
can utilise component-oriented programming to build modular, reusable
|
||||
components that can easily be assembled and reused.
|
||||
.
|
||||
This package provides a factory for instantiating BeanShell with Plexus.
|
|
@ -0,0 +1,16 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Plexus BeanShell Factory
|
||||
Source: http://plexus.codehaus.org
|
||||
|
||||
Files: *
|
||||
Copyright: 2001-2009, Codehaus Foundation.
|
||||
License: Apache-2.0
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2009-2022, Ludovic Claude <ludovic.claude@laposte.net>
|
||||
2022 tony mancill <tmancill@debian.org>
|
||||
License: Apache-2.0
|
||||
|
||||
License: Apache-2.0
|
||||
On Debian systems, the full text of the Apache-2.0 license
|
||||
can be found in the file '/usr/share/common-licenses/Apache-2.0'
|
|
@ -0,0 +1,2 @@
|
|||
pom.xml --no-parent
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
javadoc.dir=build/api
|
||||
maven.test.skip=true
|
|
@ -0,0 +1,3 @@
|
|||
junit junit * s/.*/4.x/ * *
|
||||
s/bsh/org.beanshell/ bsh jar s/.*/debian/
|
||||
org.codehaus.plexus plexus-container-default * s/.*/1.5.5/ * *
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
VERSION=$2
|
||||
TAR=../plexus-bsh-factory_$VERSION.orig.tar.gz
|
||||
DIR=plexus-bsh-factory-$VERSION
|
||||
TAG=$(echo "plexus-bsh-factory-$VERSION" | sed 's,~\(alpha\|beta\),-\1-,' | sed 's/alpha-7/alpha-7-SNAPSHOT/')
|
||||
|
||||
svn export http://svn.codehaus.org/plexus/tags/$TAG/ $DIR
|
||||
tar -c -z -f $TAR $DIR
|
||||
rm -rf $DIR ../$TAG
|
||||
|
||||
# move to directory 'tarballs'
|
||||
if [ -r .svn/deb-layout ]; then
|
||||
. .svn/deb-layout
|
||||
mv $TAR $origDir
|
||||
echo "moved $TAR to $origDir"
|
||||
fi
|
|
@ -0,0 +1,19 @@
|
|||
Description: Adds the missing dependency on junit
|
||||
Author: Emmanuel Bourg <ebourg@apache.org>
|
||||
Forwarded: no
|
||||
--- a/pom.xml
|
||||
+++ b/pom.xml
|
||||
@@ -14,5 +14,11 @@
|
||||
<artifactId>bsh</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
+ <dependency>
|
||||
+ <groupId>org.codehaus.plexus</groupId>
|
||||
+ <artifactId>plexus-container-default</artifactId>
|
||||
+ <version>1.0-alpha-9-stable-1</version>
|
||||
+ <scope>provided</scope>
|
||||
+ </dependency>
|
||||
</dependencies>
|
||||
-</project>
|
||||
\ No newline at end of file
|
||||
+</project>
|
|
@ -0,0 +1,56 @@
|
|||
Description: Fixes the compatibility with the version of plexus-container-default in Debian
|
||||
Author: Emmanuel Bourg <ebourg@apache.org>
|
||||
Forwarded: no
|
||||
--- a/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactory.java
|
||||
+++ b/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactory.java
|
||||
@@ -25,6 +25,11 @@
|
||||
public class BshComponentFactory
|
||||
extends AbstractComponentFactory
|
||||
{
|
||||
+ public String getId()
|
||||
+ {
|
||||
+ return "bsh";
|
||||
+ }
|
||||
+
|
||||
public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm containerRealm,
|
||||
PlexusContainer container )
|
||||
throws ComponentInstantiationException
|
||||
@@ -69,23 +74,23 @@
|
||||
{
|
||||
containerRealm.display();
|
||||
|
||||
- container.getLogger().info( "Error text: " + evalError.getErrorText() );
|
||||
+ ((org.codehaus.plexus.DefaultPlexusContainer) container).getLogger().info( "Error text: " + evalError.getErrorText() );
|
||||
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
- componentDescriptor.getComponentKey() +
|
||||
+ componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", evalError );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
containerRealm.display();
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
- componentDescriptor.getComponentKey() +
|
||||
+ componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
- componentDescriptor.getComponentKey() +
|
||||
+ componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
finally
|
||||
--- a/src/test/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactoryTest.java
|
||||
+++ b/src/test/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactoryTest.java
|
||||
@@ -12,7 +12,7 @@
|
||||
public void testComponent()
|
||||
throws Exception
|
||||
{
|
||||
- Hello hello = (Hello) lookup( Hello.ROLE );
|
||||
+ Hello hello = (Hello) lookup( Hello.class );
|
||||
|
||||
assertNotNull( hello );
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
--- a/pom.xml
|
||||
+++ b/pom.xml
|
||||
@@ -20,5 +20,10 @@
|
||||
<version>1.0-alpha-9-stable-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
+ <dependency>
|
||||
+ <groupId>junit</groupId>
|
||||
+ <artifactId>junit</artifactId>
|
||||
+ <version>4.12</version>
|
||||
+ </dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
01-add-missing-dependencies.patch
|
||||
02-plexus-containers-compatibility.patch
|
||||
03-junit-dependency.patch
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@
|
|
@ -0,0 +1 @@
|
|||
3.0 (quilt)
|
|
@ -0,0 +1,5 @@
|
|||
version=3
|
||||
opts="uversionmangle=s/alpha-7-SNAPSHOT/alpha-7/;s/-(alpha|beta)-/~$1/" \
|
||||
http://svn.codehaus.org/plexus/tags/ \
|
||||
plexus-bsh-factory-([0-9].*)/ debian debian/orig-tar.sh
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<project>
|
||||
<parent>
|
||||
<artifactId>plexus-component-factories</artifactId>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<version>1.0-alpha-5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>plexus-bsh-factory</artifactId>
|
||||
<name>Plexus BSH Factory</name>
|
||||
<version>1.0-alpha-7</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>bsh</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-9-stable-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,248 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-bsh-factory</artifactId>
|
||||
<name>Plexus BSH Factory</name>
|
||||
<version>1.0-alpha-7</version>
|
||||
<ciManagement>
|
||||
<notifiers>
|
||||
<notifier>
|
||||
<configuration>
|
||||
<address>dev@plexus.codehaus.org</address>
|
||||
</configuration>
|
||||
</notifier>
|
||||
<notifier>
|
||||
<type>irc</type>
|
||||
<configuration>
|
||||
<port>6667</port>
|
||||
<host>irc.codehaus.org</host>
|
||||
<channel>#plexus</channel>
|
||||
</configuration>
|
||||
</notifier>
|
||||
</notifiers>
|
||||
</ciManagement>
|
||||
<inceptionYear>2001</inceptionYear>
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>Plexus Developer List</name>
|
||||
<subscribe>http://lists.codehaus.org/mailman/listinfo/plexus-dev</subscribe>
|
||||
<unsubscribe>http://lists.codehaus.org/mailman/listinfo/plexus-dev</unsubscribe>
|
||||
<archive>http://lists.codehaus.org/pipermail/plexus-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>jvanzyl</id>
|
||||
<name>Jason van Zyl</name>
|
||||
<email>jason@zenplex.com</email>
|
||||
<organization>Zenplex</organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
<role>Release Manager</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>kaz</id>
|
||||
<name>Pete Kazmier</name>
|
||||
<email></email>
|
||||
<organization></organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jtaylor</id>
|
||||
<name>James Taylor</name>
|
||||
<email>james@jamestaylor.org</email>
|
||||
<organization></organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>dandiep</id>
|
||||
<name>Dan Diephouse</name>
|
||||
<email>dan@envoisolutions.com</email>
|
||||
<organization>Envoi solutions</organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>kasper</id>
|
||||
<name>Kasper Nielsen</name>
|
||||
<email>apache@kav.dk</email>
|
||||
<organization></organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>bwalding</id>
|
||||
<name>Ben Walding</name>
|
||||
<email>bwalding@codehaus.org</email>
|
||||
<organization>Walding Consulting Services</organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mhw</id>
|
||||
<name>Mark Wilkinson</name>
|
||||
<email>mhw@kremvax.net</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>michal</id>
|
||||
<name>Michal Maczka</name>
|
||||
<email>mmaczka@interia.pl</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>evenisse</id>
|
||||
<name>Emmanuel Venisse</name>
|
||||
<email>evenisse@codehaus.org</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>trygvis</id>
|
||||
<name>Trygve Laugstøl</name>
|
||||
<email>trygvis@codehaus.org</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>kenney</id>
|
||||
<name>Kenney Westerhof</name>
|
||||
<email>kenney@codehaus.org</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:svn:svn://svn.codehaus.org/plexus/scm/trunk/plexus-component-factories/plexus-bsh-factory</connection>
|
||||
<developerConnection>scm:svn:https://svn.codehaus.org/plexus/trunk/plexus-component-factories/plexus-bsh-factory</developerConnection>
|
||||
</scm>
|
||||
<organization>
|
||||
<name>Codehaus</name>
|
||||
<url>http://www.codehaus.org/</url>
|
||||
</organization>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
<outputDirectory>target/classes</outputDirectory>
|
||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<directory>target</directory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.0-beta-3-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<tagBase>https://svn.codehaus.org/plexus/tags</tagBase>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Snapshot Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<name>Maven Repository Switchboard</name>
|
||||
<url>http://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<id>snapshots-plugins</id>
|
||||
<name>Maven Snapshot Plugins Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<name>Maven Plugin Repository</name>
|
||||
<url>http://repo1.maven.org/maven2</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>classworlds</groupId>
|
||||
<artifactId>classworlds</artifactId>
|
||||
<version>1.1-alpha-2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>bsh</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reporting>
|
||||
<outputDirectory>target/site</outputDirectory>
|
||||
</reporting>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>repo1</id>
|
||||
<name>Maven Central Repository</name>
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Development Repository</name>
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import bsh.Interpreter;
|
||||
|
||||
/**
|
||||
* Beanshell components must implement this to be able to provide the interpreter.
|
||||
* @todo This may not be needed if the creation and configuration is done in one step, or there is some other way
|
||||
* of getting back the interpreter from the created component
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id: BshComponent.java 1817 2005-05-17 08:08:08Z brett $
|
||||
*/
|
||||
public interface BshComponent
|
||||
{
|
||||
Interpreter getInterpreter();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import bsh.EvalError;
|
||||
import bsh.Interpreter;
|
||||
|
||||
import org.codehaus.classworlds.ClassRealm;
|
||||
import org.codehaus.plexus.component.configurator.AbstractComponentConfigurator;
|
||||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
||||
import org.codehaus.plexus.component.configurator.ConfigurationListener;
|
||||
import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
||||
/**
|
||||
* @todo not happy that this has to be different to the object with fields configurator - should only need to redefine the "setValue" method
|
||||
*/
|
||||
public class BshComponentConfigurator
|
||||
extends AbstractComponentConfigurator
|
||||
{
|
||||
|
||||
public void configureComponent( Object component, PlexusConfiguration configuration,
|
||||
ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm,
|
||||
ConfigurationListener listener )
|
||||
throws ComponentConfigurationException
|
||||
{
|
||||
Interpreter interpreter = ( (BshComponent) component ).getInterpreter();
|
||||
|
||||
int items = configuration.getChildCount();
|
||||
|
||||
for ( int i = 0; i < items; i++ )
|
||||
{
|
||||
PlexusConfiguration childConfiguration = configuration.getChild( i );
|
||||
|
||||
String elementName = childConfiguration.getName();
|
||||
|
||||
Class type = Object.class;
|
||||
|
||||
String implementation = childConfiguration.getAttribute( "implementation", null );
|
||||
|
||||
if ( implementation != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
type = containerRealm.loadClass( implementation );
|
||||
|
||||
}
|
||||
catch ( ClassNotFoundException e )
|
||||
{
|
||||
String msg = "Class name which was explicitly given in configuration using 'implementation' attribute: '" +
|
||||
implementation + "' cannot be loaded";
|
||||
|
||||
throw new ComponentConfigurationException( msg, e );
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationConverter converter = converterLookup.lookupConverterForType( type );
|
||||
|
||||
Object value = converter.fromConfiguration( converterLookup, childConfiguration, type, component.getClass(),
|
||||
containerRealm.getClassLoader(), expressionEvaluator, listener );
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
interpreter.set( elementName, value );
|
||||
}
|
||||
catch ( EvalError evalError )
|
||||
{
|
||||
throw new ComponentConfigurationException( "Unable to evaluate beanshell", evalError );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import bsh.EvalError;
|
||||
import bsh.Interpreter;
|
||||
import bsh.UtilEvalError;
|
||||
import org.codehaus.classworlds.ClassRealm;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.factory.AbstractComponentFactory;
|
||||
import org.codehaus.plexus.component.factory.ComponentInstantiationException;
|
||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* BeanShell component factory.
|
||||
*
|
||||
* @author <a href="mailto:jason@maven.org">Jason Van Zyl</a>
|
||||
* @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
|
||||
*/
|
||||
public class BshComponentFactory
|
||||
extends AbstractComponentFactory
|
||||
{
|
||||
public String getId()
|
||||
{
|
||||
return "bsh";
|
||||
}
|
||||
|
||||
public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm containerRealm,
|
||||
PlexusContainer container )
|
||||
throws ComponentInstantiationException
|
||||
{
|
||||
String impl = componentDescriptor.getImplementation();
|
||||
if ( !impl.startsWith( "/" ) )
|
||||
{
|
||||
impl = "/" + impl;
|
||||
}
|
||||
|
||||
URL scriptLocation = containerRealm.getResource( impl );
|
||||
|
||||
if ( scriptLocation == null )
|
||||
{
|
||||
StringBuffer buf = new StringBuffer( "Cannot find: " + impl + " in classpath:" );
|
||||
for ( int i = 0; i < containerRealm.getConstituents().length; i++ )
|
||||
{
|
||||
URL constituent = containerRealm.getConstituents()[i];
|
||||
buf.append( "\n [" + i + "] " + constituent );
|
||||
}
|
||||
throw new ComponentInstantiationException( buf.toString() );
|
||||
}
|
||||
|
||||
Object result = null;
|
||||
Reader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
Interpreter interp = new Interpreter();
|
||||
|
||||
reader = new InputStreamReader( scriptLocation.openStream() );
|
||||
|
||||
// TODO
|
||||
// BeanShell honours the context classloader, which something is setting (erroneously?)
|
||||
// interp.setClassLoader( containerRealm.getClassLoader() );
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader( containerRealm.getClassLoader() );
|
||||
result = interp.eval( reader );
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
}
|
||||
catch ( EvalError evalError )
|
||||
{
|
||||
containerRealm.display();
|
||||
|
||||
((org.codehaus.plexus.DefaultPlexusContainer) container).getLogger().info( "Error text: " + evalError.getErrorText() );
|
||||
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", evalError );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
containerRealm.display();
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ComponentInstantiationException( "Cannot build component for: " +
|
||||
componentDescriptor.getHumanReadableKey() +
|
||||
"; unable to read BeanShell script", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.component.factory.ComponentFactory</role>
|
||||
<implementation>org.codehaus.plexus.component.factory.bsh.BshComponentFactory</implementation>
|
||||
<role-hint>bsh</role-hint>
|
||||
<configuration>
|
||||
<id>bsh</id>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.component.configurator.ComponentConfigurator</role>
|
||||
<implementation>org.codehaus.plexus.component.factory.bsh.BshComponentConfigurator</implementation>
|
||||
<role-hint>bsh</role-hint>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -0,0 +1,27 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
public class BshComponentFactoryTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
public BshComponentFactoryTest()
|
||||
{
|
||||
}
|
||||
|
||||
public void testComponent()
|
||||
throws Exception
|
||||
{
|
||||
Hello hello = (Hello) lookup( Hello.class );
|
||||
|
||||
assertNotNull( hello );
|
||||
|
||||
hello.initialize();
|
||||
|
||||
hello.start();
|
||||
|
||||
hello.hello();
|
||||
|
||||
hello.dispose();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.codehaus.plexus.component.factory.bsh;
|
||||
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
|
||||
|
||||
public interface Hello
|
||||
extends Initializable, Startable, Disposable
|
||||
{
|
||||
static String ROLE = Hello.class.getName();
|
||||
|
||||
void hello();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import org.codehaus.plexus.component.factory.bsh.Hello;
|
||||
|
||||
contextualize( context )
|
||||
{
|
||||
System.out.println( "contextualize(context): " + context );
|
||||
}
|
||||
|
||||
initialize()
|
||||
{
|
||||
System.out.println( "initialize()" );
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
System.out.println( "start()" );
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
System.out.println( "stop()" );
|
||||
}
|
||||
|
||||
dispose()
|
||||
{
|
||||
System.out.println( "dispose()" );
|
||||
}
|
||||
|
||||
hello()
|
||||
{
|
||||
System.out.println( "hello!" );
|
||||
}
|
||||
|
||||
return (Hello)this;
|
|
@ -0,0 +1,18 @@
|
|||
<plexus>
|
||||
<!-- component-factory-manager implementation="org.codehaus.plexus.component.factory.DefaultComponentFactoryManager">
|
||||
<component-factories>
|
||||
<component-factory implementation="org.codehaus.plexus.component.factory.bsh.BshComponentFactory">
|
||||
<id>bsh</id>
|
||||
<bsh-home>${basedir}/target</bsh-home>
|
||||
<bsh-path>${basedir}/src/bsh</bsh-path>
|
||||
</component-factory>
|
||||
</component-factories>
|
||||
</component-factory-manager -->
|
||||
<components>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.component.factory.bsh.Hello</role>
|
||||
<implementation>/DefaultHello.bsh</implementation>
|
||||
<component-factory>bsh</component-factory>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
Loading…
Reference in New Issue