KickJava   Java API By Example, From Geeks To Geeks.

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


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: ClusterTarget.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
33 //config imports
34
import com.sun.enterprise.config.ConfigContext;
35 import com.sun.enterprise.config.ConfigException;
36
37 import com.sun.enterprise.config.serverbeans.ClusterHelper;
38 import com.sun.enterprise.config.serverbeans.ServerHelper;
39 import com.sun.enterprise.config.serverbeans.NodeAgentHelper;
40 import com.sun.enterprise.config.serverbeans.Config;
41 import com.sun.enterprise.config.serverbeans.Server;
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
47 public class ClusterTarget extends Target
48 {
49     protected ClusterTarget(String JavaDoc name, ConfigContext cc)
50     {
51         super(name, cc);
52     }
53
54     public TargetType getType()
55     {
56         return TargetType.CLUSTER;
57     }
58
59     public String JavaDoc getTargetObjectName(String JavaDoc[] tokens)
60     {
61         checkTokens(tokens, 1);
62         return (tokens[0] + ":type=cluster,category=config,name=" + getName());
63     }
64
65     public ConfigTarget getConfigTarget() throws Exception JavaDoc
66     {
67         return new ConfigTarget(getConfigRef(), getConfigContext());
68     }
69
70     public String JavaDoc getConfigRef() throws ConfigException
71     {
72         final Config config = ClusterHelper.getConfigForCluster(getConfigContext(), getName());
73         return config.getName();
74     }
75     
76     /**
77      * Return all the servers in the cluster
78      */

79     public Server[] getServers() throws ConfigException
80     {
81         return ServerHelper.getServersInCluster(getConfigContext(), getName());
82     }
83     
84     /**
85      * Return the cluster
86      */

87     public Cluster[] getClusters() throws ConfigException
88     {
89         final Cluster[] clusters = new Cluster[1];
90         clusters[0] = ClusterHelper.getClusterByName(getConfigContext(), getName());
91         return clusters;
92     }
93     
94     /**
95      * Return the configuration referenced by the cluster
96      */

97     public Config[] getConfigs() throws ConfigException
98     {
99         final Config[] configs = new Config[1];
100         configs[0] = ClusterHelper.getConfigForCluster(getConfigContext(), getName());
101         return configs;
102     }
103     
104     /**
105      * Return all the node agents that have instances that are part of the cluster
106      */

107     public NodeAgent[] getNodeAgents() throws ConfigException
108     {
109         return NodeAgentHelper.getNodeAgentsForCluster(getConfigContext(), getName());
110     }
111     
112     /**
113      * Return all the application refs of the cluster
114      */

115     public ApplicationRef[] getApplicationRefs() throws ConfigException
116     {
117         return ClusterHelper.getApplicationReferences(getConfigContext(), getName());
118     }
119     
120     /**
121      * Return all the resource refs of the cluster
122      */

123     public ResourceRef[] getResourceRefs() throws ConfigException
124     {
125         return ClusterHelper.getResourceReferences(getConfigContext(), getName());
126     }
127 }
128
Popular Tags