KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > target > Target


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * $Id: Target.java,v 1.3 2005/12/25 04:14:39 tcfujii Exp $
26  */

27
28 package com.sun.enterprise.admin.target;
29
30 //jdk imports
31
import java.io.Serializable JavaDoc;
32
33 //config imports
34
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 JavaDoc
47 {
48     /**
49      * i18n strings manager object
50      */

51     private static final StringManager strMgr =
52         StringManager.getManager(Target.class);
53
54     private final String JavaDoc name;
55     private final transient ConfigContext cc;
56
57     Target(String JavaDoc 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 JavaDoc getName()
66     {
67         return name;
68     }
69
70     public abstract TargetType getType();
71     public abstract String JavaDoc getConfigRef() throws ConfigException;
72     public abstract ConfigTarget getConfigTarget() throws Exception JavaDoc;
73     public abstract String JavaDoc getTargetObjectName(String JavaDoc[] 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 JavaDoc o, Object JavaDoc name)
88     {
89         if (null == o)
90         {
91             throw new IllegalArgumentException JavaDoc(
92                 strMgr.getString("target.cant_be_null", name.toString()));
93         }
94     }
95
96     protected void checkTokens(String JavaDoc[] tokens, int minLen)
97     {
98         checkArg(tokens, name);
99         if (tokens.length < minLen)
100         {
101             throw new IllegalArgumentException JavaDoc(
102                 strMgr.getString("target.min_token_length", "" + minLen));
103         }
104     }
105 }
106
Popular Tags