KickJava   Java API By Example, From Geeks To Geeks.

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


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: ConfigTarget.java,v 1.3 2005/12/25 04:14:38 tcfujii Exp $
26  */

27
28 package com.sun.enterprise.admin.target;
29
30 //jdk imports
31
import java.io.Serializable JavaDoc;
32 import java.util.Set JavaDoc;
33
34 //config imports
35
import com.sun.enterprise.config.ConfigContext;
36 import com.sun.enterprise.config.ConfigException;
37
38 import com.sun.enterprise.util.i18n.StringManager;
39 import com.sun.enterprise.config.serverbeans.Config;
40 import com.sun.enterprise.config.serverbeans.Server;
41 import com.sun.enterprise.config.serverbeans.ServerHelper;
42 import com.sun.enterprise.config.serverbeans.Cluster;
43 import com.sun.enterprise.config.serverbeans.ApplicationRef;
44 import com.sun.enterprise.config.serverbeans.ResourceRef;
45 import com.sun.enterprise.config.serverbeans.NodeAgent;
46 import com.sun.enterprise.config.serverbeans.ClusterHelper;
47 import com.sun.enterprise.config.serverbeans.ConfigAPIHelper;
48
49 public class ConfigTarget extends Target
50 {
51     private static final StringManager strMgr =
52         StringManager.getManager(ConfigTarget.class);
53
54     protected ConfigTarget(String JavaDoc name, ConfigContext cc)
55     {
56         super(name, cc);
57     }
58
59     public TargetType getType()
60     {
61         return TargetType.CONFIG;
62     }
63
64     public String JavaDoc getTargetObjectName(String JavaDoc[] tokens)
65     {
66         checkTokens(tokens, 1);
67         return (tokens[0] + ":type=config,category=config,name=" + getName());
68     }
69
70     public ConfigTarget getConfigTarget() throws Exception JavaDoc
71     {
72         return this;
73     }
74
75     public String JavaDoc getConfigRef() throws ConfigException
76     {
77         return getName();
78     }
79
80     /**
81      * Return all the servers in referencing this config
82      */

83     public Server[] getServers() throws ConfigException
84     {
85         return ServerHelper.getServersReferencingConfig(getConfigContext(), getName());
86     }
87
88     /**
89      * Return all the clusters referencing this config
90      */

91     public Cluster[] getClusters() throws ConfigException
92     {
93         return ClusterHelper.getClustersReferencingConfig(getConfigContext(), getName());
94     }
95     
96     
97     /**
98      * Return the configuration
99      */

100     public Config[] getConfigs() throws ConfigException
101     {
102         Config[] configs = new Config[1];
103         configs[0] = ConfigAPIHelper.getConfigByName(getConfigContext(), getName());
104         return configs;
105     }
106
107     public NodeAgent[] getNodeAgents() throws ConfigException
108     {
109         throw new ConfigException(strMgr.getString("target.not_supported",
110             "getNodeAgents", getType().getName()));
111     }
112     
113     public ApplicationRef[] getApplicationRefs() throws ConfigException
114     {
115         throw new ConfigException(strMgr.getString("target.not_supported",
116             "getApplicationRefs", getType().getName()));
117     }
118     
119     public ResourceRef[] getResourceRefs() throws ConfigException
120     {
121         throw new ConfigException(strMgr.getString("target.not_supported",
122             "getResourceRefs", getType().getName()));
123     }
124 }
125
Popular Tags