I think we should be using something like the more flexible like the
java service provider notion used by jaxp and others as the env aware
factory bootstrap:
http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Service Provider

A simple example test driver:

package util.jar;

import java.util.Iterator;

/**
 * @author [EMAIL PROTECTED]
 * @version $Revision:$
 */
public class TestServiceProvider
{
   static IByteCodeThing getThing()
   {
      IByteCodeThing thing = null;
      // Bad dependency on sun.misc that we can easily replace with our
own impl
      Iterator ps =
sun.misc.Service.providers(IByteCodeThingFactory.class);
      while (ps.hasNext())
      {
         IByteCodeThingFactory factory = (IByteCodeThingFactory)
ps.next();
         try
         {
            thing = factory.getThing();
         }
         catch (Exception e)
         {
            // go onto the next provider
            System.out.println("Failed to load instance from factory: "
+ factory + ", msg=" + e.getMessage());
         }
      }
      return thing;
   }

   public static void main(String[] args)
   {
      IByteCodeThing thing = getThing();
      System.out.println("Found thing: " + thing);
      thing.doSomething();
   }
}

Simple ant fragments that create a bytecodething.jar with a
META-INF/services/util.jar.IByteCodeThingFactory entry describing a
cglib/javassist based implementation of the
util.jar.IByteCodeThingFactory interface:

  <target name="bytecodething.jar">
    <echo file="lib/IByteCodeThingFactory">
util.jar.javassit.ByteCodeThingFactory
util.jar.cglib.ByteCodeThingFactory
    </echo>
    <jar destfile="lib/bytecodething.jar">
      <zipfileset
fullpath="META-INF/services/util.jar.IByteCodeThingFactory"
        file="lib/IByteCodeThingFactory" />
      <fileset dir="classes">
        <include name="util/jar/**" />
      </fileset>
    </jar>
  </target>
  <target name="test-bytecodething" depends="bytecodething.jar">
    <java classname="util.jar.TestServiceProvider">
      <classpath path="lib/bytecodething.jar" />
    </java>
  </target>

Running the test driver:

[EMAIL PROTECTED] java5]$ ant test-bytecodething
Buildfile: build.xml

bytecodething.jar:
      [jar] Building jar: C:\usr\local\java5\lib\bytecodething.jar

test-bytecodething:
     [java] Failed to load instance from factory:
[EMAIL PROTECTED], msg=no cglib available
     [java] Found thing: [EMAIL PROTECTED]
     [java] Doing javassit bytecode thing

The util.jar.cglib.ByteCodeThingFactory simply throws a
ClassNotFoundException("no cglib available") as an example of how this
could be selected based on class visibility.

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Steve Ebersole
> Sent: Wednesday, April 26, 2006 9:41 AM
> To: jboss-development@lists.sourceforge.net
> Subject: RE: [JBoss-dev] Upgrading cglib dependency to 
> version 2.1.3 in 4.0branch
> 
> Right, that's the other part to this.  I'd need to change the 
> hibernate-int module to depend on this new hibernate 
> "release".  Then it is a matter of specifying to use 
> javassist over cglib as a config parameter.  The interesting 
> thing here, though, is that this setting is global to a 
> classloader (scoped by a static variable).  Should this be 
> something we make a JBoss config option?  Otherwise, I could 
> just set a system property when the MBean first starts up and 
> hope that no one has yet loaded that particular class.
> 
> Bill/Emmanuel, will need to do the similiar for the ejb3 module.
> 
> BTW, anyone have intellij projects files for 4x and head they 
> would share?


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to