1 22 package org.jboss.mx.metadata.xb; 23 24 import org.jboss.mx.interceptor.Interceptor; 25 import org.jboss.util.NestedRuntimeException; 26 import org.jboss.xb.binding.GenericValueContainer; 27 28 import javax.xml.namespace.QName ; 29 30 36 public class InterceptorHolder 37 implements GenericValueContainer 38 { 39 private Class clazz; 40 41 public void addChild(QName name, Object value) 42 { 43 String lname = name.getLocalPart(); 44 if( lname.equals("code") ) 45 { 46 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 47 String cname = (String ) value; 48 try 49 { 50 clazz = loader.loadClass(cname); 51 } 52 catch(Throwable e) 53 { 54 throw new NestedRuntimeException("Unable to load code: "+cname, e); 55 } 56 } 57 } 58 59 public Object instantiate() 60 { 61 Interceptor i; 62 try 64 { 65 i = (Interceptor) clazz.newInstance(); 66 } 67 catch (Throwable e) 68 { 69 throw new NestedRuntimeException("Failed to instantiate interceptor", e); 70 } 71 return i; 72 } 73 74 public Class getTargetClass() 75 { 76 return Interceptor.class; 77 } 78 } 79 | Popular Tags |