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: * @(#)ScaffoldedEnvironmentContext.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * SampleEnvironmentContext.java
031: *
032: * SUN PROPRIETARY/CONFIDENTIAL.
033: * This software is the proprietary information of Sun Microsystems, Inc.
034: * Use is subject to license terms.
035: *
036: * Created on December 19, 2004, 12:48 PM
037: */package com.sun.jbi.management.system;
038:
039: import com.sun.jbi.JBIProvider;
040: import com.sun.jbi.management.MBeanNames;
041: import com.sun.jbi.management.support.MBeanNamesImpl;
042:
043: import java.util.Properties;
044: import javax.management.MBeanServer;
045: import javax.management.MBeanServerFactory;
046:
047: /**
048: *
049: * @author Sun Microsystems, Inc.
050: */
051: public class ScaffoldedEnvironmentContext implements
052: com.sun.jbi.EnvironmentContext {
053: /** App Server Install Root. */
054: private String mAsInstRoot;
055: private String mJbiInstallRoot;
056: private String mJbiInstanceRoot;
057: private MBeanNames mMBeanNames;
058: private MBeanServer mMBeanServer;
059: private Properties mProps;
060: private ScaffoldPlatformContext mPlatform;
061:
062: /** Creates a new instance of SampleEnvironmentContext */
063: public ScaffoldedEnvironmentContext() {
064: mMBeanNames = new com.sun.jbi.management.support.MBeanNamesImpl(
065: "com.sun.jbi", "NULL_INSTANCE");
066:
067: mPlatform = new ScaffoldPlatformContext();
068: mMBeanServer = java.lang.management.ManagementFactory
069: .getPlatformMBeanServer();
070: }
071:
072: /** Creates a new instance of SampleEnvironmentContext */
073: public ScaffoldedEnvironmentContext(String jbiInstallRoot)
074: throws Exception {
075: mMBeanNames = new com.sun.jbi.management.support.MBeanNamesImpl(
076: "com.sun.jbi", "NULL_INSTANCE");
077:
078: mMBeanServer = java.lang.management.ManagementFactory
079: .getPlatformMBeanServer();
080: setJbiInstanceRoot(jbiInstallRoot);
081: setAppServerInstanceRoot(jbiInstallRoot);
082: setProperty("com.sun.jbi.home", jbiInstallRoot);
083: createRegistry();
084:
085: }
086:
087: /**
088: * Get the platform-specific context for this implementation.
089: * @return The PlatformContext.
090: */
091: public com.sun.jbi.platform.PlatformContext getPlatformContext() {
092: return mPlatform;
093: }
094:
095: /**
096: * Get a reference to the persisted JBI registry.
097: * @return Registry instance
098: */
099: public com.sun.jbi.registry.Registry getRegistry() {
100: return null;
101: }
102:
103: /**
104: * Get a read-only reference to the persisted JBI Registry. A DOM registry document
105: * object is returned.
106: * @return the registry document
107: */
108: public org.w3c.dom.Document getReadOnlyRegistry() {
109: // return null, if the DOM registry is needed then more stuff goes here
110: return null;
111: }
112:
113: /**
114: * Indicates whether or not the JBI framework has been fully started. This
115: * method provides clients with a way of determining if the JBI framework
116: * started up in passive mode as a result of on-demand initialization.
117: * The 'start' parameter instructs the framework to
118: * start completely if it has not already done so. If the framework has
119: * already been started, the request to start again is ignored.
120: * @param start requests that the framework start completely before
121: * returning.
122: * @return true if the framework is completely started, false otherwise.
123: */
124: public boolean isFrameworkReady(boolean start) {
125: return true;
126: }
127:
128: public JBIProvider getProvider() {
129: return JBIProvider.OTHER;
130: }
131:
132: public String getAppServerInstallRoot() {
133: return mAsInstRoot;
134: }
135:
136: public void setAppServerInstallRoot(String root) {
137: mAsInstRoot = root;
138: }
139:
140: public String getAppServerInstanceRoot() {
141: return mAsInstRoot;
142: }
143:
144: public void setAppServerInstanceRoot(String root) {
145: mAsInstRoot = root;
146: }
147:
148: public com.sun.jbi.ComponentManager getComponentManager() {
149: return null;
150: }
151:
152: public String getComponentId() {
153: return "";
154: }
155:
156: public String getComponentName() {
157: return "notNeeded";
158: }
159:
160: public com.sun.jbi.ComponentQuery getComponentQuery() {
161: return null;
162: }
163:
164: public com.sun.jbi.ComponentQuery getComponentQuery(
165: String targetName) {
166: return null;
167: }
168:
169: public String getComponentRoot() {
170: return null;
171: }
172:
173: public com.sun.jbi.messaging.ConnectionManager getConnectionManager() {
174: return null;
175: }
176:
177: public java.util.Properties getInitialProperties() {
178: if (mProps == null) {
179: mProps = new Properties();
180: }
181: return mProps;
182: }
183:
184: public void setProperty(String key, String value) {
185: getInitialProperties().setProperty(key, value);
186: }
187:
188: public String getJbiInstallRoot() {
189: return mJbiInstallRoot;
190: }
191:
192: public void setJbiInstallRoot(String jbiRoot) {
193: mJbiInstallRoot = jbiRoot;
194: }
195:
196: public String getJbiInstanceRoot() {
197: return mJbiInstanceRoot;
198: }
199:
200: public void setJbiInstanceRoot(String jbiRoot) {
201: mJbiInstanceRoot = jbiRoot;
202: }
203:
204: public com.sun.jbi.management.MBeanHelper getMBeanHelper() {
205: return null;
206: }
207:
208: public com.sun.jbi.management.MBeanNames getMBeanNames() {
209: return mMBeanNames;
210: }
211:
212: public javax.management.MBeanServer getMBeanServer() {
213: return mMBeanServer;
214: }
215:
216: public Object getManagementClass(String aServiceName) {
217: return null;
218: }
219:
220: public com.sun.jbi.management.ManagementMessageFactory getManagementMessageFactory() {
221: return null;
222: }
223:
224: public javax.naming.InitialContext getNamingContext() {
225: return null;
226: }
227:
228: /**
229: * Get the Event Notifier instance.
230: * @return The EventNotifer instance.
231: */
232: public com.sun.jbi.framework.EventNotifierCommon getNotifier() {
233: return null;
234: }
235:
236: public com.sun.jbi.ServiceUnitRegistration getServiceUnitRegistration() {
237: return null;
238: }
239:
240: public com.sun.jbi.StringTranslator getStringTranslator(
241: String packageName) {
242: return Util.getStringTranslator(packageName);
243: }
244:
245: public com.sun.jbi.StringTranslator getStringTranslatorFor(
246: Object object) {
247: return Util.getStringTranslator(object.getClass().getPackage()
248: .getName());
249: }
250:
251: /**
252: * Get the VersionInfo for this runtime.
253: * @return The VersionInfo instance.
254: */
255: public com.sun.jbi.VersionInfo getVersionInfo() {
256: return (com.sun.jbi.VersionInfo) this ;
257: }
258:
259: /**
260: * Get a TransactionManager from the AppServer.
261: * @return A TransactionManager instance.
262: */
263: public javax.transaction.TransactionManager getTransactionManager() {
264: return null;
265: }
266:
267: /**
268: * Gets a Wsdl factory.
269: * @return wsdl factory.
270: */
271:
272: public com.sun.jbi.wsdl2.WsdlFactory getWsdlFactory()
273: throws com.sun.jbi.wsdl2.WsdlException {
274: return null;
275: }
276:
277: /**
278: * Create a Registry Instance.
279: *
280: * @return a Registry Instance
281: * @throws Exception if an unexpected error occurs
282: */
283: public com.sun.jbi.management.registry.Registry createRegistry()
284: throws Exception {
285: com.sun.jbi.management.registry.Registry registry = null;
286: try {
287: String regFolder = getJbiInstanceRoot()
288: + java.io.File.separator + "config";
289:
290: // -- Create a XML Registry Spec.
291: java.util.Properties props = new java.util.Properties();
292: props
293: .setProperty(
294: com.sun.jbi.management.registry.Registry.REGISTRY_FOLDER_PROPERTY,
295: regFolder);
296:
297: com.sun.jbi.management.system.ManagementContext mgtCtx = new com.sun.jbi.management.system.ManagementContext(
298: this );
299:
300: com.sun.jbi.management.repository.Repository repository = new com.sun.jbi.management.repository.Repository(
301: mgtCtx);
302:
303: mgtCtx.setRepository(repository);
304: registry = com.sun.jbi.management.registry.RegistryBuilder
305: .buildRegistry(new com.sun.jbi.management.registry.RegistrySpecImpl(
306: com.sun.jbi.management.registry.RegistryType.XML,
307: props, mgtCtx));
308:
309: java.util.List<String> servers = registry.getGenericQuery()
310: .getServers();
311: if (!servers.contains("server")) {
312: registry.getUpdater().addServer("server");
313: }
314:
315: } catch (Exception aEx) {
316: aEx.printStackTrace();
317: throw aEx;
318: }
319: return registry;
320: }
321:
322: /**
323: * This method is used to scaffold EnvironmentContext.isStartOnDeployEnabled()
324: * and always returns true
325: */
326: public boolean isStartOnDeployEnabled() {
327: return true;
328: }
329:
330: /**
331: * This method is used to find out if start-onverify is enabled.
332: * When this is enabled components are started automatically when
333: * an application has to be verified for them
334: * This is controlled by the property com.sun.jbi.startOnVerify.
335: * By default start-on-verify is enabled.
336: * It is disabled only if com.sun.jbi.startOnVerify=false.
337: */
338: public boolean isStartOnVerifyEnabled() {
339: return true;
340: }
341:
342: }
|