1 23 24 27 28 package com.sun.enterprise.admin.target; 29 30 import java.io.Serializable ; 32 33 import javax.management.ObjectName ; 35 import javax.management.MalformedObjectNameException ; 36 37 import com.sun.enterprise.config.ConfigContext; 39 import com.sun.enterprise.config.ConfigException; 40 41 import com.sun.enterprise.config.serverbeans.ServerHelper; 42 import com.sun.enterprise.config.serverbeans.ClusterHelper; 43 import com.sun.enterprise.config.serverbeans.NodeAgentHelper; 44 import com.sun.enterprise.config.serverbeans.Config; 45 import com.sun.enterprise.config.serverbeans.Server; 46 import com.sun.enterprise.config.serverbeans.Cluster; 47 import com.sun.enterprise.config.serverbeans.ResourceRef; 48 import com.sun.enterprise.config.serverbeans.ApplicationRef; 49 import com.sun.enterprise.config.serverbeans.NodeAgent; 50 51 public class ServerTarget extends Target 52 { 53 protected ServerTarget(String name, ConfigContext cc) 54 { 55 super(name, cc); 56 } 57 58 public TargetType getType() 59 { 60 return TargetType.SERVER; 61 } 62 63 public String getTargetObjectName(String [] tokens) 64 { 65 checkTokens(tokens, 1); 66 return (tokens[0] + ":type=server,category=config,name=" + getName()); 67 } 68 69 public ConfigTarget getConfigTarget() throws Exception 70 { 71 return new ConfigTarget(getConfigRef(), getConfigContext()); 72 } 73 74 public String getConfigRef() throws ConfigException 75 { 76 final Config config = ServerHelper.getConfigForServer(getConfigContext(), getName()); 77 return config.getName(); 78 } 79 80 83 public Server[] getServers() throws ConfigException 84 { 85 final Server[] servers = new Server[1]; 86 servers[0] = ServerHelper.getServerByName(getConfigContext(), getName()); 87 return servers; 88 } 89 90 93 public Cluster[] getClusters() throws ConfigException 94 { 95 final Cluster[] clusters = new Cluster[1]; 97 clusters[0] = ClusterHelper.getClusterForInstance(getConfigContext(), getName()); 98 return clusters; 99 } 100 101 104 public Config[] getConfigs() throws ConfigException 105 { 106 final Config[] configs = new Config[1]; 107 configs[0] = ServerHelper.getConfigForServer(getConfigContext(), getName()); 108 return configs; 109 } 110 111 114 public NodeAgent[] getNodeAgents() throws ConfigException 115 { 116 NodeAgent[] agents = new NodeAgent[1]; 117 agents[0] = NodeAgentHelper.getNodeAgentForServer(getConfigContext(), getName()); 118 return agents; 119 } 120 121 124 public ApplicationRef[] getApplicationRefs() throws ConfigException 125 { 126 return ServerHelper.getApplicationReferences(getConfigContext(), getName()); 127 } 128 129 132 public ResourceRef[] getResourceRefs() throws ConfigException 133 { 134 return ServerHelper.getResourceReferences(getConfigContext(), getName()); 135 } 136 } 137 | Popular Tags |