JBoss Community

Re: How to stop my WAR loading JBoss's provided 3rd party classes?

created by Ales Justin in JBoss Microcontainer - View the full discussion
Is there any documentation on how the jboss-classloading-domain.xml file?  I'm running into a similar situation with CXF in 6.0.0.CR1 and I'd like to give this a try.

No particular docs, as the usage is quite simple.

Simply drop properly configured jboss-classloading-domain.xml file into your app's META-INF and it should work.

 

These two code snippest show how parent policy gets created.

(which is what filters cl lookups between cl domains)

 

public ParentPolicy createParentPolicy()
   {
      if (parentPolicy == null)
      {
         if (name != null)
         {
            String upper = name.toUpperCase();
            try
            {
               Field instance = ParentPolicy.class.getField(upper);
               parentPolicy = (ParentPolicy) instance.get(null);
            }
            catch (Throwable t)
            {
               throw new RuntimeException("Cannot create parent-policy, wrong name perhaps? - " + name, t);
            }
         }
         else
         {
            ClassFilter before = (beforeFilter != null) ? beforeFilter.createFilter() : ClassFilterUtils.EVERYTHING;
            ClassFilter after = (afterFilter != null) ? afterFilter.createFilter() : ClassFilterUtils.NOTHING;
            parentPolicy = new ParentPolicy(before, after, description);
         }
      }
      return parentPolicy;
   }

 

public ClassFilter createFilter()
   {
      // perhaps it's JavaBean
      if (value instanceof ClassFilter)
      {
         return (ClassFilter) value;
      }
      else
      {
         try
         {
            Class<?> clazz = getClass().getClassLoader().loadClass(filterClassName);
            Constructor<?> ctor = (value != null) ? clazz.getDeclaredConstructor(value.getClass()) : clazz.getDeclaredConstructor();
            return (ClassFilter) ctor.newInstance(value);
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Cannot instantiate filter: " + filterClassName + " / " + value, t);
         }
      }
   }

 

By default the filterClassName is PackageClassFilter.class.getName().

 

Let me know if you need some more help.

Reply to this message by going to Community

Start a new discussion in JBoss Microcontainer at Community