org.codehaus.plexus.embed
Class Embedder
java.lang.Object
org.codehaus.plexus.embed.Embedder
- public class Embedder
- extends java.lang.Object
Embedder enables a client to embed Plexus into their
application with a minimal amount of work. The basic usage is
as follows:
Embedder embedder = new Embedder();
embedder.setConfiguration("/plexus.xml");
embedder.addContextValue("plexus.home", ".");
embedder.start();
PlexusContainer container = embedder.getContainer();
[do stuff with container]
embedder.stop();
- Version:
- $Id: Embedder.java,v 1.18 2004/01/17 17:58:43 jvanzyl Exp $
- Author:
- Jason van Zyl, Pete Kazmier
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
configuration
private java.lang.String configuration
configurationURL
private volatile java.net.URL configurationURL
container
private final DefaultPlexusContainer container
embedderStarted
private volatile boolean embedderStarted
embedderStopped
private volatile boolean embedderStopped
Embedder
public Embedder()
getContainer
public PlexusContainer getContainer()
lookup
public java.lang.Object lookup(java.lang.String role)
throws ComponentLookupException
- Throws:
ComponentLookupException
lookup
public java.lang.Object lookup(java.lang.String role,
java.lang.String id)
throws ComponentLookupException
- Throws:
ComponentLookupException
hasService
public boolean hasService(java.lang.String role)
hasService
public boolean hasService(java.lang.String role,
java.lang.String id)
release
public void release(java.lang.Object service)
setClassLoader
public void setClassLoader(java.lang.ClassLoader classLoader)
setConfiguration
public void setConfiguration(java.lang.String configuration)
setConfiguration
public void setConfiguration(java.net.URL configuration)
addContextValue
public void addContextValue(java.lang.Object key,
java.lang.Object value)
start
public void start()
throws java.lang.Exception
- Throws:
java.lang.Exception
stop
public void stop()
throws java.lang.Exception
- Throws:
java.lang.Exception
findConfigurationInputStream
private java.io.InputStream findConfigurationInputStream()
- Tries a variety of methods to find the configuration resource.
BRW - I see this as fairly pointless as putting your config into the Embedder.class package
will be annoying. Far better to just force the end user to provide a URL and remove
all this logic.
JVZ - What about uberjar applications?
BRW - If it doesn't work in uberjar, then we'll have a good test case and I'll fix classworlds.
- Returns:
- the stream containing the configuration
- Throws:
java.lang.RuntimeException
- when the configuration can not be found / opened