1 22 package org.jboss.ejb3; 23 24 import java.util.Collection ; 25 import java.util.HashSet ; 26 import javax.management.MalformedObjectNameException ; 27 import javax.management.ObjectName ; 28 29 35 public class JmxDependencyPolicy implements DependencyPolicy 36 { 37 protected HashSet <ObjectName > dependencies = new HashSet <ObjectName >(); 38 39 public void addDependency(String dependency) 40 { 41 ObjectName on = null; 42 try 43 { 44 on = new ObjectName (dependency); 45 } 46 catch (MalformedObjectNameException e) 47 { 48 throw new RuntimeException (dependency, e); 49 } 50 dependencies.add(on); 51 } 52 53 public Collection getDependencies() 54 { 55 return dependencies; 56 } 57 58 public Collection getDependencies(Collection currentDependencies) 59 { 60 dependencies.addAll(currentDependencies); 61 return dependencies; 62 } 63 64 public void addDatasource(String jndiName) 65 { 66 String ds = jndiName; 67 if (ds.startsWith("java:/")) 68 { 69 ds = ds.substring(6); 70 71 } 72 else if (ds.startsWith("java:")) 73 { 74 ds = ds.substring(5); 75 } 76 String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding"; 78 79 try 80 { 81 dependencies.add(new ObjectName (onStr)); 82 } 83 catch (MalformedObjectNameException e) 84 { 85 throw new RuntimeException (e); 86 } 87 } 88 89 } 90 | Popular Tags |