1 22 package org.jboss.system.metadata; 23 24 import javax.management.MalformedObjectNameException ; 25 import javax.management.ObjectName ; 26 27 import org.jboss.dependency.spi.ControllerState; 28 import org.jboss.system.microcontainer.LifecycleDependencyItem; 29 import org.jboss.system.microcontainer.ServiceControllerContext; 30 31 37 public class ServiceDependencyMetaData extends AbstractMetaDataVisitorNode 38 { 39 40 private String iDependOn; 41 42 43 private ObjectName iDependOnObjectName; 44 45 50 public String getIDependOn() 51 { 52 if (iDependOn == null) 53 return iDependOnObjectName.getCanonicalName(); 54 return iDependOn; 55 } 56 57 62 public void setIDependOn(String iDependOn) 63 { 64 if (iDependOn == null) 65 throw new IllegalArgumentException ("Null iDependOn"); 66 this.iDependOn = iDependOn; 67 this.iDependOnObjectName = null; 68 } 69 70 76 public ObjectName getIDependOnObjectName() throws MalformedObjectNameException 77 { 78 if (iDependOnObjectName == null) 79 { 80 if (iDependOn.trim().length() == 0) 81 throw new MalformedObjectNameException ("Missing object name in depends"); 82 ObjectName objectName = new ObjectName (iDependOn); 83 if (objectName.isPattern()) 84 throw new MalformedObjectNameException ("ObjectName patterns are not allowed in depends: " + iDependOn); 85 iDependOnObjectName = objectName; 86 iDependOn = null; 87 } 88 return iDependOnObjectName; 89 } 90 91 96 public void setIDependOnObjectName(ObjectName iDependOn) 97 { 98 if (iDependOn == null) 99 throw new IllegalArgumentException ("Null iDependOn"); 100 this.iDependOnObjectName = iDependOn; 101 } 102 103 public void visit(ServiceMetaDataVisitor visitor) 104 { 105 ServiceControllerContext context = visitor.getControllerContext(); 106 Object name = context.getName(); 107 Object other = iDependOn; 108 try 109 { 110 other = getIDependOnObjectName().getCanonicalName(); 111 } 112 catch (MalformedObjectNameException ignored) 113 { 114 } 115 visitor.addDependency(new LifecycleDependencyItem(name, other, ControllerState.CREATE)); 116 visitor.addDependency(new LifecycleDependencyItem(name, other, ControllerState.START)); 117 visitor.visit(this); 118 } 119 } 120 | Popular Tags |