1 23 24 27 28 package com.sun.enterprise.admin.target; 29 30 import java.io.Serializable ; 32 33 import com.sun.enterprise.config.ConfigContext; 35 import com.sun.enterprise.config.ConfigException; 36 37 import com.sun.enterprise.util.i18n.StringManager; 38 39 import com.sun.enterprise.config.serverbeans.Server; 40 import com.sun.enterprise.config.serverbeans.Cluster; 41 import com.sun.enterprise.config.serverbeans.Config; 42 import com.sun.enterprise.config.serverbeans.NodeAgent; 43 import com.sun.enterprise.config.serverbeans.ApplicationRef; 44 import com.sun.enterprise.config.serverbeans.ResourceRef; 45 46 public abstract class Target implements Serializable 47 { 48 51 private static final StringManager strMgr = 52 StringManager.getManager(Target.class); 53 54 private final String name; 55 private final transient ConfigContext cc; 56 57 Target(String name, ConfigContext cc) 58 { 59 checkArg(name, strMgr.getString("target.name")); 60 checkArg(cc, strMgr.getString("target.config_context")); 61 this.name = name; 62 this.cc = cc; 63 } 64 65 public String getName() 66 { 67 return name; 68 } 69 70 public abstract TargetType getType(); 71 public abstract String getConfigRef() throws ConfigException; 72 public abstract ConfigTarget getConfigTarget() throws Exception ; 73 public abstract String getTargetObjectName(String [] tokens); 74 75 public abstract Server[] getServers() throws ConfigException; 76 public abstract Cluster[] getClusters() throws ConfigException; 77 public abstract Config[] getConfigs() throws ConfigException; 78 public abstract NodeAgent[] getNodeAgents() throws ConfigException; 79 public abstract ApplicationRef[] getApplicationRefs() throws ConfigException; 80 public abstract ResourceRef[] getResourceRefs() throws ConfigException; 81 82 protected ConfigContext getConfigContext() 83 { 84 return cc; 85 } 86 87 protected void checkArg(Object o, Object name) 88 { 89 if (null == o) 90 { 91 throw new IllegalArgumentException ( 92 strMgr.getString("target.cant_be_null", name.toString())); 93 } 94 } 95 96 protected void checkTokens(String [] tokens, int minLen) 97 { 98 checkArg(tokens, name); 99 if (tokens.length < minLen) 100 { 101 throw new IllegalArgumentException ( 102 strMgr.getString("target.min_token_length", "" + minLen)); 103 } 104 } 105 } 106 | Popular Tags |