001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)JSEPlatformContext.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.framework.jse;
030:
031: import com.sun.jbi.JBIProvider;
032: import com.sun.jbi.security.KeyStoreUtil;
033: import com.sun.jbi.platform.PlatformEventListener;
034:
035: import java.io.File;
036: import java.util.Set;
037: import java.util.HashSet;
038: import java.util.Map;
039: import java.util.logging.Logger;
040:
041: import javax.management.MBeanServerConnection;
042: import javax.management.MBeanServer;
043: import javax.naming.InitialContext;
044:
045: /**
046: * Implementation of PlatformContext for Java SE.
047: * @author Sun Microsystems Inc.
048: */
049: public class JSEPlatformContext implements
050: com.sun.jbi.platform.PlatformContext {
051: private String mInstanceName;
052: private String mInstanceRoot;
053: private String mInstallRoot;
054: private InitialContext mNamingContext;
055: private Logger mLog = Logger.getLogger(getClass().getPackage()
056: .getName());
057:
058: public JSEPlatformContext(String instanceName, String installRoot) {
059: mInstanceName = instanceName;
060: mInstallRoot = installRoot;
061: mInstanceRoot = installRoot + File.separator + instanceName;
062:
063: try {
064: mNamingContext = new InitialContext();
065: } catch (javax.naming.NamingException nmEx) {
066: mLog.warning(nmEx.toString());
067: }
068: }
069:
070: /**
071: * Get the TransactionManager for this implementation. The instance
072: * returned is an implementation of the standard JTS interface. If none
073: * is available, returns <CODE>null</CODE>.
074: * @return a <CODE>TransactionManager</CODE> instance.
075: * @throws Exception if a <CODE>TransactionManager</CODE> cannot be obtained.
076: */
077: public javax.transaction.TransactionManager getTransactionManager()
078: throws Exception {
079: return null;
080: }
081:
082: /**
083: * Get the MBean server connection for a particular instance.
084: * @return the <CODE>MBeanServerConnection</CODE> for the specified instance.
085: */
086: public MBeanServerConnection getMBeanServerConnection(
087: String instanceName) throws Exception {
088: return java.lang.management.ManagementFactory
089: .getPlatformMBeanServer();
090: }
091:
092: /**
093: * Get the instance name of the platform's administration server. If the
094: * platform does not provide a separate administration server, then this
095: * method returns the name of the local instance.
096: * @return instance name of the administration server
097: */
098: public String getAdminServerName() {
099: return mInstanceName;
100: }
101:
102: /**
103: * Determine whether this instance is the administration server instance.
104: * @return <CODE>true</CODE> if this instance is the administration server,
105: * <CODE>false</CODE> if not.
106: */
107: public boolean isAdminServer() {
108: return true;
109: }
110:
111: /**
112: * Get the name of this instance.
113: * @return the name of this server instance.
114: */
115: public String getInstanceName() {
116: return mInstanceName;
117: }
118:
119: /**
120: * Determine if the specified instance is up.
121: * @return true if the instance is up and running, false otherwise
122: */
123: public boolean isInstanceUp(String instanceName) {
124: return mInstanceName.equals(instanceName);
125: }
126:
127: /**
128: * Determine whether multiple servers are permitted within this AS
129: * installation.
130: * @return true if multiple servers are permitted.
131: */
132: public boolean supportsMultipleServers() {
133: return false;
134: }
135:
136: /**
137: * Get the Target Name. If the instance is not a clustered instance then
138: * the target name is the instance name. If the instance is part of a
139: * cluster then the target name is the cluster name.
140: *
141: * @return the target name.
142: */
143: public String getTargetName() {
144: return mInstanceName;
145: }
146:
147: /**
148: * Get the Target Name for a specified instance. If the instance is not
149: * clustered the instance name is returned. This operation is invoked by
150: * the JBI instance MBeans only.
151: *
152: * @return the target name.
153: */
154: public String getTargetName(String instanceName) {
155: return instanceName;
156: }
157:
158: /**
159: * Get a set of the names of all the standalone servers in the domain.
160: * @return a set of names of standalone servers in the domain.
161: */
162: public Set<String> getStandaloneServerNames() {
163: HashSet<String> names = new HashSet<String>();
164: names.add(mInstanceName);
165: return names;
166: }
167:
168: /**
169: * Get a set of the names of all the clustered servers in the domain.
170: * @return a set of names of clustered servers in the domain.
171: */
172: public Set<String> getClusteredServerNames() {
173: return new HashSet<String>();
174: }
175:
176: /**
177: * Get a set of the names of all the clusters in the domain.
178: * @return a set of names of clusters in the domain.
179: */
180: public Set<String> getClusterNames() {
181: return new HashSet<String>();
182: }
183:
184: /**
185: * Get a set of the names of all the servers in the specified cluster.
186: * @return a set of names of servers in the cluster.
187: */
188: public Set<String> getServersInCluster(String clusterName) {
189: return new HashSet<String>();
190: }
191:
192: /**
193: * Determine whether a target is a valid server or cluster name.
194: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a valid
195: * standalone server name or cluster name, <CODE>false</CODE> if not.
196: */
197: public boolean isValidTarget(String targetName) {
198: return mInstanceName.equals(targetName);
199: }
200:
201: /**
202: * Determine whether a target is a cluster.
203: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a cluster,
204: * <CODE>false</CODE> if not.
205: */
206: public boolean isCluster(String targetName) {
207: return false;
208: }
209:
210: /**
211: * Determine whether a target is a standalone server.
212: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a standalone
213: * server, <CODE>false</CODE> if not.
214: */
215: public boolean isStandaloneServer(String targetName) {
216: return mInstanceName.equals(targetName);
217: }
218:
219: /**
220: * Determine whether the target is a clustered server.
221: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a clustered
222: * server, <CODE>false</CODE> if not.
223: */
224: public boolean isClusteredServer(String targetName) {
225: return false;
226: }
227:
228: /**
229: * Determine whether or not an instance is clustered.
230: * @return <CODE>true</CODE> if the instance is clustered,
231: * <CODE>false</CODE> if not.
232: */
233: public boolean isInstanceClustered(String instanceName) {
234: return false;
235: }
236:
237: /**
238: * Get a string representation of the DAS JMX RMI connector port.
239: * @return the JMX RMI connector port as a <CODE>String</CODE>.
240: */
241: public String getJmxRmiPort() {
242: return null;
243: }
244:
245: /**
246: * Provides access to the platform's MBean server.
247: * @return platform MBean server.
248: */
249: public MBeanServer getMBeanServer() {
250: return java.lang.management.ManagementFactory
251: .getPlatformMBeanServer();
252: }
253:
254: /**
255: * Get the full path to the platform's instance root directory.
256: * @return platform instance root
257: */
258: public String getInstanceRoot() {
259: return mInstanceRoot;
260: }
261:
262: /**
263: * Get the full path to the platform's instaall root directory.
264: * @return platform install root
265: */
266: public String getInstallRoot() {
267: return mInstallRoot;
268: }
269:
270: /**
271: * Returns the provider type for this platform.
272: * @return enum value corresponding to this platform implementation.
273: */
274: public JBIProvider getProvider() {
275: return JBIProvider.JSE;
276: }
277:
278: /**
279: * Returns the KeyStoreUtil for Java SE. Currently unsupported
280: *
281: * @return a KeyStoreUtil
282: * @exception UnsupportedOperationException
283: */
284: public KeyStoreUtil getKeyStoreUtil() {
285: return null;
286: }
287:
288: /**
289: * Retrieves the naming context that should be used to locate platform
290: * resources (e.g. TransactionManager).
291: * @return naming context
292: */
293: public InitialContext getNamingContext() {
294: return mNamingContext;
295: }
296:
297: /**
298: * Get the JBI system class loader for this implementation.
299: * This is the JBI common classloader and is the parent of the JBI runtime
300: * classloader that loaded this class.
301: *
302: * @return the <CODE>ClassLoader</CODE> that is the "system" class loader
303: * from a JBI runtime perspective.
304: * @throws SecurityException if access to the class loader is denied.
305: */
306: public ClassLoader getSystemClassLoader() throws SecurityException {
307: return this .getClass().getClassLoader().getParent();
308: }
309:
310: /**
311: * Register a listener for platform events.
312: * @param listener listener implementation
313: */
314: public void addListener(PlatformEventListener listener) {
315: // NOP
316: }
317:
318: /**
319: * Remove a listener for platform events.
320: * @param listener listener implementation
321: */
322: public void removeListener(PlatformEventListener listener) {
323: // NOP
324: }
325: }
|