1 27 package org.objectweb.jonas_ejb.deployment.rules; 28 29 import java.lang.reflect.Method ; 30 31 import org.apache.commons.digester.Digester; 32 import org.apache.commons.digester.Rule; 33 import org.objectweb.jonas_lib.deployment.rules.JRuleSetBase; 34 import org.xml.sax.Attributes ; 35 36 41 42 public class EjbJarRuleSet extends JRuleSetBase { 43 44 47 public EjbJarRuleSet() { 48 super("ejb-jar/"); 49 } 50 51 56 57 public void addRuleInstances(Digester digester) { 58 digester.addRule("ejb-jar", new SetPublicIdRule("setPublicId")); 59 digester.addSetProperties("ejb-jar"); 60 digester.addCallMethod(prefix + "description", "setDescription", 0); 61 digester.addCallMethod(prefix + "display-name", "setDisplayName", 0); 62 digester.addCallMethod(prefix + "small-icon", "setSmallIcon", 0); 63 digester.addCallMethod(prefix + "large-icon", "setLargeIcon", 0); 64 digester.addRuleSet(new EnterpriseBeansRuleSet(prefix)); 65 digester.addRuleSet(new RelationshipsRuleSet(prefix)); 66 digester.addRuleSet(new AssemblyDescriptorRuleSet(prefix)); 67 digester.addCallMethod(prefix + "ejb-client-jar", "setEjbClientJar", 0); 68 } 69 70 74 75 private final class SetPublicIdRule extends Rule { 76 77 82 public SetPublicIdRule(String method) { 83 this.method = method; 84 } 85 86 89 private String method = null; 90 91 98 public void begin(Attributes attributes) throws Exception { 99 Object top = digester.peek(); 100 Class [] paramClasses = new Class [1]; 101 paramClasses[0] = "String".getClass(); 102 String [] paramValues = new String [1]; 103 paramValues[0] = digester.getPublicId(); 104 105 Method m = null; 106 try { 107 m = top.getClass().getMethod(method, paramClasses); 108 } catch (NoSuchMethodException e) { 109 System.out.println("Can't find method " + method + " in " + top + " CLASS " + top.getClass()); 110 return; 111 } 112 113 m.invoke(top, (Object []) paramValues); 114 115 } 116 117 } 118 } | Popular Tags |