plexus-bsh-factory-1.0~alpha7/0000755000175000017500000000000011224731165016344 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/release-pom.xml0000644000175000017500000001606410323253736021310 0ustar twernertwerner 4.0.0 org.codehaus.plexus plexus-bsh-factory Plexus BSH Factory 1.0-alpha-7
dev@plexus.codehaus.org
irc 6667 irc.codehaus.org #plexus
2001 Plexus Developer List http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/pipermail/plexus-dev/ jvanzyl Jason van Zyl jason@zenplex.com Zenplex Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer trygvis Trygve Laugstøl trygvis@codehaus.org Developer kenney Kenney Westerhof kenney@codehaus.org Developer scm:svn:svn://svn.codehaus.org/plexus/scm/trunk/plexus-component-factories/plexus-bsh-factory scm:svn:https://svn.codehaus.org/plexus/trunk/plexus-component-factories/plexus-bsh-factory Codehaus http://www.codehaus.org/ src/main/java src/main/scripts src/test/java target/classes target/test-classes src/main/resources src/test/resources target maven-release-plugin 2.0-beta-3-SNAPSHOT https://svn.codehaus.org/plexus/tags false snapshots Maven Snapshot Development Repository http://snapshots.maven.codehaus.org/maven2 false central Maven Repository Switchboard http://repo1.maven.org/maven2 false snapshots-plugins Maven Snapshot Plugins Development Repository http://snapshots.maven.codehaus.org/maven2 false central Maven Plugin Repository http://repo1.maven.org/maven2 org.codehaus.plexus plexus-utils 1.0.4 compile junit junit 3.8.1 test org.codehaus.plexus plexus-container-default 1.0-alpha-8 compile classworlds classworlds 1.1-alpha-2 compile bsh bsh 1.3.0 compile target/site repo1 Maven Central Repository scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2 snapshots Maven Central Development Repository scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2
plexus-bsh-factory-1.0~alpha7/src/0000755000175000017500000000000011224731164017132 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/0000755000175000017500000000000011224731164020111 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/0000755000175000017500000000000011224731164022123 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/DefaultHello.bsh0000644000175000017500000000066010242260447025173 0ustar twernertwernerimport 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; plexus-bsh-factory-1.0~alpha7/src/test/resources/org/0000755000175000017500000000000011224731164022712 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/0000755000175000017500000000000011224731164024505 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/0000755000175000017500000000000011224731164026025 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/component/0000755000175000017500000000000011224731164030027 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/component/factory/0000755000175000017500000000000011224731164031476 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/component/factory/bsh/0000755000175000017500000000000011224731164032252 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/component/factory/bsh/BshComponentFactoryTest.xmlplexus-bsh-factory-1.0~alpha7/src/test/resources/org/codehaus/plexus/component/factory/bsh/BshCompon0000644000175000017500000000130710242264477034075 0ustar twernertwerner org.codehaus.plexus.component.factory.bsh.Hello /DefaultHello.bsh bsh plexus-bsh-factory-1.0~alpha7/src/test/java/0000755000175000017500000000000011224731164021032 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/0000755000175000017500000000000011224731164021621 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/0000755000175000017500000000000011224731164023414 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/0000755000175000017500000000000011224731164024734 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/0000755000175000017500000000000011224731164026736 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/factory/0000755000175000017500000000000011224731164030405 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/factory/bsh/0000755000175000017500000000000011224731164031161 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactoryTest.javaplexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/factory/bsh/BshComponentFa0000644000175000017500000000072710227637030033757 0ustar twernertwernerpackage 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(); } } plexus-bsh-factory-1.0~alpha7/src/test/java/org/codehaus/plexus/component/factory/bsh/Hello.java0000644000175000017500000000064410064721627033077 0ustar twernertwernerpackage 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(); } plexus-bsh-factory-1.0~alpha7/src/main/0000755000175000017500000000000011224731165020057 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/resources/0000755000175000017500000000000011224731165022071 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/resources/META-INF/0000755000175000017500000000000011224731165023231 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/resources/META-INF/plexus/0000755000175000017500000000000011224731165024551 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000116310242323150027447 0ustar twernertwerner org.codehaus.plexus.component.factory.ComponentFactory org.codehaus.plexus.component.factory.bsh.BshComponentFactory bsh bsh org.codehaus.plexus.component.configurator.ComponentConfigurator org.codehaus.plexus.component.factory.bsh.BshComponentConfigurator bsh plexus-bsh-factory-1.0~alpha7/src/main/java/0000755000175000017500000000000011224731165021000 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/0000755000175000017500000000000011224731165021567 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/0000755000175000017500000000000011224731165023362 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/0000755000175000017500000000000011224731165024702 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/0000755000175000017500000000000011224731165026704 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/0000755000175000017500000000000011224731165030353 5ustar twernertwernerplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/0000755000175000017500000000000011224731165031127 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentConfigurator.javaplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentCo0000755000175000017500000000553010323253736033743 0ustar twernertwernerpackage 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 ); } } } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponent.javaplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponent.j0000755000175000017500000000104210242323150033667 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: BshComponent.java 1817 2005-05-17 08:08:08Z brett $ */ public interface BshComponent { Interpreter getInterpreter(); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentFactory.javaplexus-bsh-factory-1.0~alpha7/src/main/java/org/codehaus/plexus/component/factory/bsh/BshComponentFa0000644000175000017500000000731310251212037033713 0ustar twernertwernerpackage 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 Jason Van Zyl * @author Brett Porter */ 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; } } plexus-bsh-factory-1.0~alpha7/pom.xml0000644000175000017500000000075410323253736017671 0ustar twernertwerner plexus-component-factories org.codehaus.plexus 1.0-alpha-5 4.0.0 plexus-bsh-factory Plexus BSH Factory 1.0-alpha-7 bsh bsh 1.3.0