KickJava   Java API By Example, From Geeks To Geeks.

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


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: NodeAgentTarget.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 import com.sun.enterprise.config.serverbeans.Server;
39 import com.sun.enterprise.config.serverbeans.ServerHelper;
40 import com.sun.enterprise.config.serverbeans.Cluster;
41 import com.sun.enterprise.config.serverbeans.ClusterHelper;
42 import com.sun.enterprise.config.serverbeans.Config;
43 import com.sun.enterprise.config.serverbeans.NodeAgentHelper;
44 import com.sun.enterprise.config.serverbeans.NodeAgent;
45 import com.sun.enterprise.config.serverbeans.ApplicationRef;
46 import com.sun.enterprise.config.serverbeans.ResourceRef;
47
48 public class NodeAgentTarget extends Target
49 {
50     /**
51      * i18n strings manager object
52      */

53     private static final StringManager strMgr =
54         StringManager.getManager(NodeAgentTarget.class);
55
56     protected NodeAgentTarget(String JavaDoc name, ConfigContext cc)
57     {
58         super(name, cc);
59     }
60
61     public TargetType getType()
62     {
63         return TargetType.NODE_AGENT;
64     }
65
66     public String JavaDoc getTargetObjectName(String JavaDoc[] tokens)
67     {
68         checkTokens(tokens, 1);
69         return (tokens[0] + ":type=node-agent,category=config,name=" + getName());
70     }
71
72     public ConfigTarget getConfigTarget() throws Exception JavaDoc
73     {
74         throw new ConfigException(strMgr.getString(
75             "target.no_config_for_node_agent"));
76     }
77
78     public String JavaDoc getConfigRef() throws ConfigException
79     {
80         return null;
81     }
82     
83     /**
84      * Return all the servers managed by the node agent
85      */

86     public Server[] getServers() throws ConfigException
87     {
88         return ServerHelper.getServersOfANodeAgent(getConfigContext(), getName());
89     }
90     
91     /**
92      * Return all the clusters who contain instances managed by this node agent
93      */

94     public Cluster[] getClusters() throws ConfigException
95     {
96         return ClusterHelper.getClustersForNodeAgent(getConfigContext(), getName());
97     }
98     
99     /**
100      * Return the configuration associated with this Node Agent.
101      */

102     public Config[] getConfigs() throws ConfigException
103     {
104         throw new ConfigException(strMgr.getString("target.not_supported",
105             "getConfigs", getType().getName()));
106     }
107     
108     public ApplicationRef[] getApplicationRefs() throws ConfigException
109     {
110         throw new ConfigException(strMgr.getString("target.not_supported",
111             "getApplicationRefs", getType().getName()));
112     }
113     
114     public ResourceRef[] getResourceRefs() throws ConfigException
115     {
116         throw new ConfigException(strMgr.getString("target.not_supported",
117             "getResourceRefs", getType().getName()));
118     }
119
120     /**
121      * Return the node agent
122      */

123     public NodeAgent[] getNodeAgents() throws ConfigException
124     {
125         NodeAgent[] agents = new NodeAgent[1];
126         agents[0] = NodeAgentHelper.getNodeAgentByName(getConfigContext(), getName());
127         return agents;
128     }
129 }
130
Popular Tags