[jboss-dev-forums] [Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149

anil.saldhana@jboss.com do-not-reply at jboss.com
Tue Nov 11 11:04:48 EST 2008


"alesj" wrote : 
  | As you could probably also see, I've rolled back your CL changes as well.
  | Using System property in such way w/o discussing it before is a huge no-no.
  | If you really needed that you could either 
  |  - make it true by default (as it is now)
  |  - created few new classes in jbossas: deployer + policy combination that sets that flag to true
  | 

AS5 today is booting with the VFSClassloader system via the system property?  Then why don't you fix that (by making things injectable) first rather than preach here about using a system property (in fact the vfs project has a lot of system properties)?  Here let me show you.


  | conf/classloader.xml
  | 
  |  <!--
  |       The classloader implementation
  |    -->
  |    <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
  |       <classloader><null/></classloader>
  |       <constructor factoryClass="org.jboss.classloader.spi.ClassLoaderSystem" factoryMethod="getInstance"/>
  |    </bean>
  | 
  | 

Now let us look at the code.

  | 
  | ClassLoaderSystem.java
  | -----------------------------
  |  /** The class loading system builder */
  |    private static final ClassLoaderSystemBuilder builder = new ClassLoaderSystemBuilder();
  | 
  | public static final ClassLoaderSystem getInstance()
  |    {
  |       SecurityManager sm = System.getSecurityManager();
  |       if (sm != null)
  |          sm.checkCreateClassLoader();
  |       return builder.get();
  |    }
  | 
  | 
  | public class ClassLoaderSystemBuilder
  | {
  |    /** The singleton */
  |    private static final ClassLoaderSystem singleton;
  | 
  |    static
  |    {
  |       singleton = AccessController.doPrivileged(new PrivilegedAction<ClassLoaderSystem>()
  |       {
  |          public ClassLoaderSystem run()
  |          {
  |             String className = System.getProperty(ClassLoaderSystem.class.getName(), DefaultClassLoaderSystem.class.getName());
  |             try
  |             {
  |                Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
  |                Object result = clazz.newInstance();
  |                return ClassLoaderSystem.class.cast(result);
  |             }
  |             catch (RuntimeException e)
  |             {
  |                throw e;
  |             }
  |             catch (Exception e)
  |             {
  |                throw new Error("Unexpected error loading ClassLoaderSystem " + className, e);
  |             }
  |          }
  |       });
  |  
  |    public static ClassLoaderSystem get()
  |    {
  |       return singleton;
  |    }
  |    }
  | 
  | 
  | DefaultClassLoaderSystem.java
  | -------------------------------------
  | public class DefaultClassLoaderSystem extends ClassLoaderSystem
  | {
  |    @Override
  |    protected ClassLoaderDomain createDomain(String name)
  |    {
  |       return new ClassLoaderDomain(name);
  |    }
  | }
  | 
  | and so on.
  | 
  | 

There, there is no easy way to get to VFSClassloaderPolicy at the moment for configuration.  If it was provided, then it would have been easier. :)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188506#4188506

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188506



More information about the jboss-dev-forums mailing list