KickJava   Java API By Example, From Geeks To Geeks.

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


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: ServerTarget.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 //jmx imports
34
import javax.management.ObjectName JavaDoc;
35 import javax.management.MalformedObjectNameException JavaDoc;
36
37 //config imports
38
import com.sun.enterprise.config.ConfigContext;
39 import com.sun.enterprise.config.ConfigException;
40
41 import com.sun.enterprise.config.serverbeans.ServerHelper;
42 import com.sun.enterprise.config.serverbeans.ClusterHelper;
43 import com.sun.enterprise.config.serverbeans.NodeAgentHelper;
44 import com.sun.enterprise.config.serverbeans.Config;
45 import com.sun.enterprise.config.serverbeans.Server;
46 import com.sun.enterprise.config.serverbeans.Cluster;
47 import com.sun.enterprise.config.serverbeans.ResourceRef;
48 import com.sun.enterprise.config.serverbeans.ApplicationRef;
49 import com.sun.enterprise.config.serverbeans.NodeAgent;
50
51 public class ServerTarget extends Target
52 {
53     protected ServerTarget(String JavaDoc name, ConfigContext cc)
54     {
55         super(name, cc);
56     }
57
58     public TargetType getType()
59     {
60         return TargetType.SERVER;
61     }
62
63     public String JavaDoc getTargetObjectName(String JavaDoc[] tokens)
64     {
65         checkTokens(tokens, 1);
66         return (tokens[0] + ":type=server,category=config,name=" + getName());
67     }
68
69     public ConfigTarget getConfigTarget() throws Exception JavaDoc
70     {
71         return new ConfigTarget(getConfigRef(), getConfigContext());
72     }
73
74     public String JavaDoc getConfigRef() throws ConfigException
75     {
76         final Config config = ServerHelper.getConfigForServer(getConfigContext(), getName());
77         return config.getName();
78     }
79     
80     /**
81      * Return all the server
82      */

83     public Server[] getServers() throws ConfigException
84     {
85         final Server[] servers = new Server[1];
86         servers[0] = ServerHelper.getServerByName(getConfigContext(), getName());
87         return servers;
88     }
89     
90     /**
91      * Return all the cluster associated with this server
92      */

93     public Cluster[] getClusters() throws ConfigException
94     {
95         //list the cluster referenced by the server
96
final Cluster[] clusters = new Cluster[1];
97         clusters[0] = ClusterHelper.getClusterForInstance(getConfigContext(), getName());
98         return clusters;
99     }
100     
101     /**
102      * Return all the configuration associated with this server
103      */

104     public Config[] getConfigs() throws ConfigException
105     {
106         final Config[] configs = new Config[1];
107         configs[0] = ServerHelper.getConfigForServer(getConfigContext(), getName());
108         return configs;
109     }
110     
111     /**
112      * Return the node agent associated with this server.
113      */

114     public NodeAgent[] getNodeAgents() throws ConfigException
115     {
116         NodeAgent[] agents = new NodeAgent[1];
117         agents[0] = NodeAgentHelper.getNodeAgentForServer(getConfigContext(), getName());
118         return agents;
119     }
120         
121     /**
122      * Return all the application refs of the server
123      */

124     public ApplicationRef[] getApplicationRefs() throws ConfigException
125     {
126         return ServerHelper.getApplicationReferences(getConfigContext(), getName());
127     }
128     
129     /**
130      * Return all the resource refs of the server
131      */

132     public ResourceRef[] getResourceRefs() throws ConfigException
133     {
134          return ServerHelper.getResourceReferences(getConfigContext(), getName());
135     }
136 }
137
Popular Tags