[Design of JBoss jBPM] - Re: jBPM Classloading
by bwand
Hi, I have refactored the code. Now it uses the JbpmConfiguration.Configs class to get the properties. I paste the complete ClassLoaderUtil class.
|
| package org.jbpm.util;
|
| import java.io.IOException;
| import java.io.InputStream;
| import java.util.Properties;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmException;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.instantiation.ProcessClassLoader;
|
| /**
| * provides centralized classloader lookup.
| */
| public class ClassLoaderUtil {
| private static Log log = LogFactory.getLog(ClassLoaderUtil.class);
|
| public static Class loadClass(String className) {
| try {
| return getClassLoader().loadClass(className);
| } catch (ClassNotFoundException e) {
| throw new JbpmException("class not found '" + className + "'", e);
| }
| }
|
| public static ClassLoader getClassLoader() {
| if (JbpmConfiguration.Configs.hasObject("jbpm.classloader")) {
| String jbpmClassloader = JbpmConfiguration.Configs.getString("jbpm.classloader");
| String jbpmClassloaderClassname = JbpmConfiguration.Configs.getString("jbpm.classloader.classname");
|
| if (jbpmClassloader.equals("jbpm")) {
| return ClassLoaderUtil.class.getClassLoader();
| } else if (jbpmClassloader.equals("context")) {
| return Thread.currentThread().getContextClassLoader();
| } else if (jbpmClassloader.equals("custom")) {
| try {
| if (jbpmClassloaderClassname == null) {
| throw new JbpmException(
| "'jbpm.classloader' property set to 'custom' but 'jbpm.classloader.classname' is empty!");
| }
| return (ClassLoader) Thread.currentThread().getContextClassLoader().loadClass(
| jbpmClassloaderClassname).newInstance();
| } catch (InstantiationException e) {
| throw new JbpmException("Error instantiating custom classloader " + jbpmClassloaderClassname, e);
| } catch (IllegalAccessException e) {
| throw new JbpmException("Error accessing custom classloader " + jbpmClassloaderClassname, e);
| } catch (ClassNotFoundException e) {
| throw new JbpmException("Custom classloader " + jbpmClassloaderClassname + " not found ", e);
| }
| } else {
| throw new JbpmException("'jbpm.classloader' property set to '" + jbpmClassloader
| + "' but only the values 'jbpm'/'context'/'custom' are supported!");
| }
| } else {
| return ClassLoaderUtil.class.getClassLoader();
| }
| }
|
| public static InputStream getStream(String resource) {
| return getClassLoader().getResourceAsStream(resource);
| }
|
| public static Properties getProperties(String resource) {
| Properties properties = new Properties();
| try {
| properties.load(getStream(resource));
| } catch (IOException e) {
| throw new JbpmException("couldn't load properties file '" + resource + "'", e);
| }
| return properties;
| }
|
| /**
| * searches the given resource, first on the root of the classpath and if
| * not not found there, in the given directory. public static InputStream
| * getStream(String resource, String directory) { InputStream is =
| * getClassLoader().getResourceAsStream(resource); if (is==null) { is =
| * getClassLoader().getResourceAsStream(directory+"/"+resource); } return
| * is; }
| *
| * public static Properties getProperties(String resource, String directory) {
| * Properties properties = new Properties(); try {
| * properties.load(getStream(resource, directory)); } catch (IOException e) {
| * throw new JbpmException("couldn't load properties file '"+resource+"'",
| * e); } return properties; }
| */
|
| public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
| return new ProcessClassLoader(getClassLoader(), processDefinition);
| }
|
| }
|
Since this is my only patch I will not need committers access. Koen you will take care of this patch? Does this match your expectations?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136377#4136377
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136377
18 years
[Design of AOP on JBoss (Aspects/JBoss)] - Not very useful error message
by adrian@jboss.org
I'm getting the following error message during shutdown of the AS
with the new Microcontainer code.
As you can see it is not very useful in terms of telling me what is wrong. ;-)
| 2008-03-13 16:42:00,219 DEBUG [org.jboss.aop.deployers.AspectDeployer] (JBoss Shutdown Hook) undeploying: vfsfile:/home/ejort/jboss-head/build/output/jboss-5.0.0.CR1/s
| erver/all/deploy/ejb3-interceptors-aop.xml from org.jboss.aop.asintegration.jboss5.ScopedVFSClassLoaderDomain@1576367
| 2008-03-13 16:42:00,230 WARN [org.jboss.aop.deployers.AspectDeployer] (JBoss Shutdown Hook) Error undeploying xml ejb3-interceptors-aop.xml from org.jboss.aop.asinteg
| ration.jboss5.ScopedVFSClassLoaderDomain@1576367
| java.lang.RuntimeException: Unable to undeploy container: Intercepted Bean
| at org.jboss.aop.AspectXmlLoader.undeployDomain(AspectXmlLoader.java:1071)
| at org.jboss.aop.AspectXmlLoader.undeployTopElements(AspectXmlLoader.java:1297)
| at org.jboss.aop.AspectXmlLoader.undeployXML(AspectXmlLoader.java:1201)
| at org.jboss.aop.deployers.AspectDeployer.undeployXml(AspectDeployer.java:205)
| at org.jboss.aop.deployers.AspectDeployer.undeployXml(AspectDeployer.java:189)
| at org.jboss.aop.deployers.AspectDeployer.undeploy(AspectDeployer.java:134)
| at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalUndeploy(AbstractVFSRealDeployer.java:54)
| at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.undeploy(AbstractRealDeployer.java:112)
| at org.jboss.deployers.plugins.deployers.DeployerWrapper.undeploy(DeployerWrapper.java:197)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1140)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.uninstall(DeployersImpl.java:1095)
| at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:333)
| at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1330)
| at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1009)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:627)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:411)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:471)
| at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:539)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.unload(ProfileServiceBootstrap.java:360)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.unloadProfile(ProfileServiceBootstrap.java:321)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.shutdown(ProfileServiceBootstrap.java:149)
| at org.jboss.bootstrap.AbstractServerImpl.shutdownServer(AbstractServerImpl.java:505)
| at org.jboss.bootstrap.AbstractServerImpl$ShutdownHook.run(AbstractServerImpl.java:824)
|
Can we fix it to give a reasonable error message?
Also does this still parse the xml at undeployment? :-(
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136360#4136360
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136360
18 years
[Design the new POJO MicroContainer] - Re: Field injection
by adrian@jboss.org
"alesj" wrote : "adrian(a)jboss.org" wrote :
| | i.e. the property has the same name as the field and the
| | get/set operations work on the field joinpoints.
| | But only if the property has no relevant getter/setter.
| |
| How should we pass in the 'AccessType' info/param to this?
| e.g.
| I only allow strict property access, so I don't want the BeanInfo abstract to failover to fields on not found property.
|
| And another access issue.
| Should I allow mixing the usage of properties and fields with JBMICROCONT-220?
It's just a case of extending the BeanInfoFactory abstraction to add an enum or something
which is configured as an attribute on our BeanMetaData.
| // Old method for backwards compatibility
| public BeanInfo getBeanInfo(Class<?> clazz)
| {
| return getBeanInfo(clazz, BeanModel.STANDARD);
| }
|
| public BeanInfo getBeanInfo(Class<?> clazz, BeanMode mode)
| {
| // Cache different versions based on the enum
| }
|
| public enum BeanMode
| {
| STANDARD, // Getters and Setters
| FIELDS, // Getters/Setters and fields without getters and setters
| ALL // As above but with non public fields included,
| }
|
The rest is just implementation detail.
One possible implementation would be to create a lightweight "filter"
BeanInfo impl over the ALL model for the other models?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136349#4136349
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136349
18 years