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: * @(#)ScaffoldPlatformContext.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.messaging;
030:
031: import com.sun.jbi.JBIProvider;
032: import com.sun.jbi.platform.PlatformContext;
033: import com.sun.jbi.platform.PlatformEventListener;
034: import com.sun.jbi.security.KeyStoreUtil;
035: import java.util.HashSet;
036: import java.util.Set;
037: import javax.management.MBeanServer;
038: import javax.management.MBeanServerConnection;
039: import javax.naming.InitialContext;
040:
041: /**
042: * This is a test class to provide a simple PlatformContext implementation
043: * for use by the TestEnvironmentContext class.
044: *
045: * @author Sun Microsystems, Inc.
046: */
047: public class ScaffoldPlatformContext implements PlatformContext {
048: private String mInstanceRoot;
049: private String mInstallRoot;
050:
051: /** Create a new PlatformContextImpl. */
052: public ScaffoldPlatformContext() {
053: mInstallRoot = System.getProperty("java.io.tmpdir");
054: mInstanceRoot = System.getProperty("java.io.tmpdir");
055: }
056:
057: /**
058: * Get the TransactionManager for this implementation. The instance
059: * returned is an implementation of the standard JTS interface. If none
060: * is available, returns null.
061: * @return A TransactionManager instance.
062: * @throws Exception if a TransactionManager cannot be obtained.
063: */
064: public javax.transaction.TransactionManager getTransactionManager()
065: throws Exception {
066: javax.naming.InitialContext ctx = new javax.naming.InitialContext();
067: javax.transaction.TransactionManager transactionManager = (javax.transaction.TransactionManager) ctx
068: .lookup("java:appserver/TransactionManager");
069: return transactionManager;
070: }
071:
072: /**
073: * Get the MBean server connection for a particular instance.
074: * @return the <CODE>MBeanServerConnection</CODE> for the specified instance.
075: */
076: public MBeanServerConnection getMBeanServerConnection(
077: String instanceName) {
078: return java.lang.management.ManagementFactory
079: .getPlatformMBeanServer();
080: }
081:
082: /**
083: * Get the instance name of the platform's administration server. If the
084: * platform does not provide a separate administration server, then this
085: * method returns the name of the local instance.
086: * @return instance name of the administration server
087: */
088: public String getAdminServerName() {
089: return getInstanceName();
090: }
091:
092: /**
093: * Determine whether this instance is the administration server instance.
094: * @return <CODE>true</CODE> if this instance is the administration server,
095: * <CODE>false</CODE> if not.
096: */
097: public boolean isAdminServer() {
098: return true;
099: }
100:
101: /**
102: * Get the name of this instance.
103: * @return the name of this server instance.
104: */
105: public String getInstanceName() {
106: return "server";
107: }
108:
109: /**
110: * @return true if the instance is up and running, false otherwise
111: */
112: public boolean isInstanceUp(String instanceName) {
113: return true;
114: }
115:
116: /**
117: * Determine whether multiple servers are permitted within this AS
118: * installation.
119: * @return true if multiple servers are permitted.
120: */
121: public boolean supportsMultipleServers() {
122: return false;
123: }
124:
125: /**
126: * Get the Target Name. If the instance is not a clustered instance then
127: * the target name is the instance name. If the instance is part of a
128: * cluster then the target name is the cluster name.
129: *
130: * @return the target name.
131: */
132: public String getTargetName() {
133: return "server";
134: }
135:
136: /**
137: * Get the Target Name for a specified instance. If the instance is not
138: * clustered the instance name is returned. This operation is invoked by
139: * the JBI instance MBeans only.
140: *
141: * @return the target name.
142: */
143: public String getTargetName(String instanceName) {
144: return "server";
145: }
146:
147: /**
148: * Get a set of the names of all the standalone servers in the domain.
149: * @return a set of names of standalone servers in the domain.
150: */
151: public Set<String> getStandaloneServerNames() {
152: return new HashSet<String>();
153: }
154:
155: /**
156: * Get a set of the names of all the clustered servers in the domain.
157: * @return a set of names of clustered servers in the domain.
158: */
159: public Set<String> getClusteredServerNames() {
160: return new HashSet<String>();
161: }
162:
163: /**
164: * Get a set of the names of all the clusters in the domain.
165: * @return a set of names of clusters in the domain.
166: */
167: public Set<String> getClusterNames() {
168: return new HashSet<String>();
169: }
170:
171: /**
172: * Get a set of the names of all the servers in the specified cluster.
173: * @return a set of names of servers in the cluster.
174: */
175: public Set<String> getServersInCluster(String clusterName) {
176: return new HashSet<String>();
177: }
178:
179: /**
180: * Determine whether a target is a valid server or cluster name.
181: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a valid
182: * standalone server name or cluster name, <CODE>false</CODE> if not.
183: */
184: public boolean isValidTarget(String targetName) {
185: return true;
186: }
187:
188: /**
189: * Determine whether a target is a cluster.
190: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a cluster,
191: * <CODE>false</CODE> if not.
192: */
193: public boolean isCluster(String targetName) {
194: return false;
195: }
196:
197: /**
198: * Determine whether a target is a standalone server.
199: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a standalone
200: * server, <CODE>false</CODE> if not.
201: */
202: public boolean isStandaloneServer(String targetName) {
203: return true;
204: }
205:
206: /**
207: * Determine whether the target is a clustered server.
208: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a clustered
209: * server, <CODE>false</CODE> if not.
210: */
211: public boolean isClusteredServer(String targetName) {
212: return false;
213: }
214:
215: /**
216: * Determine whether or not an instance is clustered.
217: * @return <CODE>true</CODE> if the instance is clustered,
218: * <CODE>false</CODE> if not.
219: */
220: public boolean isInstanceClustered(String instanceName) {
221: return false;
222: }
223:
224: /**
225: * Get a string representation of the DAS JMX RMI connector port.
226: * @return the JMX RMI connector port as a (CODE>String</CODE>.
227: */
228: public String getJmxRmiPort() {
229: return null;
230: }
231:
232: /**
233: * Provides access to the platform's MBean server.
234: * @return platform MBean server.
235: */
236: public MBeanServer getMBeanServer() {
237: return java.lang.management.ManagementFactory
238: .getPlatformMBeanServer();
239: }
240:
241: /**
242: * Get the full path to the platform's instance root directory.
243: * @return platform instance root
244: */
245: public String getInstanceRoot() {
246: return mInstanceRoot;
247: }
248:
249: /**
250: * Get the full path to the platform's instaall root directory.
251: * @return platform install root
252: */
253: public String getInstallRoot() {
254: return mInstallRoot;
255: }
256:
257: /**
258: * Set the full path to the platform's instance root directory.
259: * @param instanceRoot platform instance root
260: */
261: public void setInstanceRoot(String instanceRoot) {
262: mInstanceRoot = instanceRoot;
263: }
264:
265: /**
266: * Set the full path to the platform's install root directory.
267: * @param install platform install root
268: */
269: public void setInstallRoot(String installRoot) {
270: mInstallRoot = installRoot;
271: }
272:
273: /**
274: * Returns the provider type for this platform.
275: * @return enum value corresponding to this platform implementation.
276: */
277: public JBIProvider getProvider() {
278: return JBIProvider.OTHER;
279: }
280:
281: /**
282: * Returns the KeyStoreUtil for Java SE. Currently unsupported
283: *
284: * @return a KeyStoreUtil
285: * @exception UnsupportedOperationException
286: */
287: public KeyStoreUtil getKeyStoreUtil() {
288: throw new UnsupportedOperationException();
289: }
290:
291: /**
292: * Retrieves the naming context that should be used to locate platform
293: * resources (e.g. TransactionManager).
294: * @return naming context
295: */
296: public InitialContext getNamingContext() {
297: return null;
298: }
299:
300: /**
301: * Get the JBI system class loader for this implementation.
302: *
303: * @return the <CODE>ClassLoader</CODE> that is the "system" class loader
304: * from a JBI runtime perspective.
305: * @throws SecurityException if access to the class loader is denied.
306: */
307: public ClassLoader getSystemClassLoader() throws SecurityException {
308: return this .getClass().getClassLoader();
309: }
310:
311: /**
312: * Register a listener for platform events.
313: * @param listener listener implementation
314: */
315: public void addListener(PlatformEventListener listener) {
316:
317: }
318:
319: /**
320: * Remove a listener for platform events.
321: * @param listener listener implementation
322: */
323: public void removeListener(PlatformEventListener listener) {
324:
325: }
326: }
|