public class ResinBeanContainer
extends java.lang.Object
ResinEmbed
should be used.
static void main(String []args)
{
ResinBeanContainer beans = new ResinBeanContainer();
beans.addModule("test.jar");
beans.start();
RequestContext req = beans.beginRequest();
try {
MyMain main = beans.getInstance(MyMain.class);
main.main(args);
} finally {
req.close();
}
beans.close();
}
<beans xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">
<resin:import path="${__DIR__}/my-include.xml"/>
<database name="my-database">
<driver ...>
...
</driver>
</database>
<mypkg:MyBean xmlns:mypkg="urn:java:com.mycom.mypkg">
<my-property>my-data</my-property>
</mypkg:MyBean>
</beans>
Constructor and Description |
---|
ResinBeanContainer()
Creates a new Resin context.
|
Modifier and Type | Method and Description |
---|---|
void |
addBeansXml(java.lang.String pathName)
Adds a Resin beans configuration file, allowing creation of databases or
bean configuration.
|
void |
addClassPath(java.lang.String classPath)
Adds a new module (jar or exploded classes directory)
|
void |
addPackageModule(java.lang.String packageName)
Adds a package in the classpath as module root.
|
void |
addPackageModule(java.lang.String modulePath,
java.lang.String packageName)
Adds a package as module root.
|
void |
addResourceRoot(Path path) |
BeanContainerRequest |
beginRequest()
Enters the Resin context and begins a new request on the thread.
|
void |
close()
Shuts the context down.
|
void |
completeRequest(BeanContainerRequest context)
Completes the thread's request and exits the Resin context.
|
java.lang.Object |
getBeanByName(java.lang.String name)
Returns an instance of the bean with the given name.
|
InjectManager |
getCdiManager() |
java.lang.ClassLoader |
getClassLoader() |
<T> T |
getInstance(java.lang.Class<T> type,
java.lang.annotation.Annotation... qualifiers)
Returns a new instance of the given type with optional qualifiers.
|
java.lang.Object |
getInstance(java.lang.String className,
java.lang.annotation.Annotation... qualifiers)
Returns a new instance of the given type with optional bindings.
|
void |
request(java.lang.Runnable runnable)
Executes code in the Resin bean classloader and creates a request scope.
|
void |
setId(java.lang.String id) |
void |
setModule(java.lang.String modulePath) |
void |
setWorkDirectory(java.lang.String path)
Sets the work directory for Resin to use when generating temporary files.
|
void |
start()
Initializes the context.
|
java.lang.String |
toString() |
public void setId(java.lang.String id)
public InjectManager getCdiManager()
public void setModule(java.lang.String modulePath)
public void addClassPath(java.lang.String classPath)
public void addPackageModule(java.lang.String modulePath, java.lang.String packageName)
packageName
- the name of the package to be treated as a virtual module root.public void addPackageModule(java.lang.String packageName)
packageName
- the name of the package to be treated as a virtual module root.public void addBeansXml(java.lang.String pathName)
pathName
- URL/path to the configuration filepublic void addResourceRoot(Path path)
public void setWorkDirectory(java.lang.String path)
public void start()
public java.lang.Object getInstance(java.lang.String className, java.lang.annotation.Annotation... qualifiers)
className
- the className of the bean to instantiatequalifier
- optional @Qualifier annotations to select the beanpublic <T> T getInstance(java.lang.Class<T> type, java.lang.annotation.Annotation... qualifiers)
public java.lang.Object getBeanByName(java.lang.String name)
name
- the @Named of the bean to instantiatepublic void request(java.lang.Runnable runnable)
resinBean.request (new Runnable() {
doMyCode();
});
public BeanContainerRequest beginRequest()
ResinContext resinContext = ...;
RequestContext cxt = resinContext.beginRequest();
try {
// ... actions inside the Resin request context
} finally {
resinContext.completeRequest(cxt);
}
completeContext
public void completeRequest(BeanContainerRequest context)
public void close()
public java.lang.ClassLoader getClassLoader()
public java.lang.String toString()
toString
in class java.lang.Object