1 29 30 package com.caucho.config; 31 32 import com.caucho.util.L10N; 33 import com.caucho.xml.QName; 34 35 import org.w3c.dom.Node ; 36 37 import java.lang.reflect.InvocationTargetException ; 38 import java.lang.reflect.Method ; 39 40 public class ProgramAttributeStrategy extends AttributeStrategy { 41 static final L10N L = new L10N(ProgramAttributeStrategy.class); 42 43 private Method _method; 44 45 public ProgramAttributeStrategy(Method method) 46 { 47 _method = method; 48 } 49 50 53 public Method getMethod() 54 { 55 return _method; 56 } 57 58 61 public void setMethod(Method method) 62 { 63 _method = method; 64 } 65 66 69 public void configure(NodeBuilder builder, Object bean, QName name, Node node) 70 throws Exception 71 { 72 try { 73 BuilderProgram program = new NodeBuilderChildProgram(builder, node); 74 75 _method.invoke(bean, new Object [] { program }); 76 } catch (InvocationTargetException e) { 77 if (e.getCause() instanceof Exception ) 78 throw (Exception ) e.getCause(); 79 else 80 throw e; 81 } 82 } 83 } 84 | Popular Tags |