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: * @(#)NMRContext.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.ComponentManager;
032: import com.sun.jbi.ComponentType;
033: import com.sun.jbi.ComponentState;
034: import com.sun.jbi.EnvironmentContext;
035: import com.sun.jbi.util.EnvironmentAccess;
036:
037: import com.sun.jbi.JBIProvider;
038: import com.sun.jbi.StringTranslator;
039:
040: import com.sun.jbi.wsdl2.WsdlException;
041: import com.sun.jbi.wsdl2.WsdlFactory;
042:
043: import java.util.List;
044: import java.util.HashMap;
045: import java.util.Vector;
046: import javax.management.MBeanServerFactory;
047:
048: import javax.jbi.component.Component;
049: import javax.jbi.component.ComponentContext;
050: import javax.jbi.servicedesc.ServiceEndpoint;
051:
052: import javax.xml.namespace.QName;
053:
054: /** Simple NMR implementation of Framework contexts.
055: * @author Sun Microsystems, Inc.
056: */
057: public class NMRContext implements EnvironmentContext,
058: ComponentManager, StringTranslator {
059: public static final String ROOT_PATH = "bld";
060:
061: private HashMap mComponents;
062: private HashMap mContexts;
063: private MessageService mMsgSvc;
064: private Vector mEmptyVec;
065: private ScaffoldPlatformContext mPlatform;
066:
067: public NMRContext(MessageService msgSvc) {
068: EnvironmentAccess.setContext(this );
069: mPlatform = new ScaffoldPlatformContext();
070: mComponents = new HashMap();
071: mContexts = new HashMap();
072: mEmptyVec = new Vector();
073: mMsgSvc = msgSvc;
074: }
075:
076: public JBIProvider getProvider() {
077: return JBIProvider.OTHER;
078: }
079:
080: /**
081: * Get the platform-specific context for this implementation.
082: * @return The PlatformContext.
083: */
084: public com.sun.jbi.platform.PlatformContext getPlatformContext() {
085: return mPlatform;
086: }
087:
088: public void reset() {
089: mComponents.clear();
090: mContexts.clear();
091: }
092:
093: public ComponentContext getComponentContext(String componentId) {
094: return (ComponentContext) mContexts.get(componentId);
095: }
096:
097: /*******************************************************************
098: * ComponentManager Methods
099: ******************************************************************/
100:
101: public void addComponentInstance(String id, Component component)
102: throws Exception {
103: DeliveryChannelImpl channel;
104:
105: mComponents.put(id, component);
106: mContexts.put(id, new ComponentContextImpl(mMsgSvc
107: .activateChannel(id, null)));
108: }
109:
110: public void installSharedLibrary(String name, String description,
111: String componentRoot, boolean isSelfFirst, List elements)
112: throws javax.jbi.JBIException {
113:
114: }
115:
116: public javax.management.ObjectName loadBootstrap(
117: com.sun.jbi.component.InstallationContext installContext,
118: String bootClassName, List bootClassPathElements,
119: List sharedLibraryList) throws javax.jbi.JBIException {
120: return null;
121: }
122:
123: public void uninstallSharedLibrary(String id)
124: throws javax.jbi.JBIException {
125:
126: }
127:
128: public void unloadBootstrap(String componentName)
129: throws javax.jbi.JBIException {
130:
131: }
132:
133: public Component getComponentInstance(String str) {
134: return (Component) mComponents.get(str);
135: }
136:
137: /**
138: * Get the com.sun.jbi.framework.DeployerMBean instance.
139: * @param name - the unique name of the component.
140: * @return The instance for the requested component or null if the
141: * component is not registered or not active.
142: */
143: public com.sun.jbi.framework.DeployerMBean getDeployerInstance(
144: String name) {
145: return null;
146: }
147:
148: public void cancelComponentUpdate(String componentName)
149: throws javax.jbi.JBIException {
150: }
151:
152: public void updateComponent(
153: com.sun.jbi.component.InstallationContext installContext,
154: List bootClassPathElements) throws javax.jbi.JBIException {
155: }
156:
157: public void validateComponentForUpdate(
158: com.sun.jbi.component.InstallationContext installContext,
159: List bootClassPathElements) throws javax.jbi.JBIException {
160: }
161:
162: public void cancelComponentUpgrade(String componentName)
163: throws javax.jbi.JBIException {
164: }
165:
166: public void upgradeComponent(
167: com.sun.jbi.component.InstallationContext installContext,
168: String bootClassName, List bootClassPathElements,
169: List sharedLibraryNames) throws javax.jbi.JBIException {
170: }
171:
172: public boolean validateComponentForUpgrade(
173: com.sun.jbi.component.InstallationContext installContext,
174: String bootClassName, List bootClassPathElements,
175: List sharedLibraryNames) throws javax.jbi.JBIException {
176: return false;
177: }
178:
179: /*******************************************************************
180: * EnvironmentContext Methods
181: ******************************************************************/
182:
183: /**
184: * Indicates whether or not the JBI framework has been fully started. This
185: * method provides clients with a way of determining if the JBI framework
186: * started up in passive mode as a result of on-demand initialization.
187: * The 'start' parameter instructs the framework to
188: * start completely if it has not already done so. If the framework has
189: * already been started, the request to start again is ignored.
190: * @param start requests that the framework start completely before
191: * returning.
192: * @return true if the framework is completely started, false otherwise.
193: */
194: public boolean isFrameworkReady(boolean start) {
195: return true;
196: }
197:
198: public String getAppServerInstallRoot() {
199: return ROOT_PATH;
200: }
201:
202: public String getAppServerInstanceRoot() {
203: return ROOT_PATH;
204: }
205:
206: public com.sun.jbi.ComponentManager getComponentManager() {
207: return this ;
208: }
209:
210: public com.sun.jbi.ComponentQuery getComponentQuery() {
211: return null;
212: }
213:
214: public com.sun.jbi.ComponentQuery getComponentQuery(
215: String targetName) {
216: return null;
217: }
218:
219: /**
220: * Get a reference to the persisted JBI registry.
221: * @return Registry instance
222: */
223: public com.sun.jbi.registry.Registry getRegistry() {
224: return null;
225: }
226:
227: /**
228: * Get a read-only reference to the persisted JBI Registry. A DOM registry document
229: * object is returned.
230: * @return the registry document
231: */
232: public org.w3c.dom.Document getReadOnlyRegistry() {
233: return null;
234: }
235:
236: public com.sun.jbi.messaging.ConnectionManager getConnectionManager() {
237: return null;
238: }
239:
240: public java.util.Properties getInitialProperties() {
241: return null;
242: }
243:
244: public String getJbiInstallRoot() {
245: return ROOT_PATH;
246: }
247:
248: public String getJbiInstanceRoot() {
249: return ROOT_PATH;
250: }
251:
252: public com.sun.jbi.management.MBeanHelper getMBeanHelper() {
253: return null;
254: }
255:
256: public com.sun.jbi.management.MBeanNames getMBeanNames() {
257: return new com.sun.jbi.management.support.MBeanNamesImpl(
258: "com.sun.jbi", "server");
259: }
260:
261: public javax.management.MBeanServer getMBeanServer() {
262: return MBeanServerFactory.createMBeanServer("com.sun.jbi");
263: }
264:
265: public Object getManagementClass(String str) {
266: return null;
267: }
268:
269: public com.sun.jbi.management.ManagementMessageFactory getManagementMessageFactory() {
270: return null;
271: }
272:
273: public javax.naming.InitialContext getNamingContext() {
274: return null;
275: }
276:
277: public com.sun.jbi.framework.EventNotifierCommon getNotifier() {
278: return null;
279: }
280:
281: public com.sun.jbi.ServiceUnitRegistration getServiceUnitRegistration() {
282: return null;
283: }
284:
285: /*******************************************************************
286: * StringTranslator Methods
287: ******************************************************************/
288:
289: public com.sun.jbi.StringTranslator getStringTranslator(String str) {
290: return this ;
291: }
292:
293: public com.sun.jbi.StringTranslator getStringTranslatorFor(
294: Object obj) {
295: return this ;
296: }
297:
298: public String getString(String str) {
299: return str;
300: }
301:
302: public String getString(String str, Object[] obj) {
303: return str;
304: }
305:
306: public String getString(String str, Object obj) {
307: return str;
308: }
309:
310: public String getString(String str, Object obj, Object obj2) {
311: return str;
312: }
313:
314: public String getString(String str, Object obj, Object obj2,
315: Object obj3) {
316: return str;
317: }
318:
319: public String getString(String str, Object obj, Object obj2,
320: Object obj3, Object obj4) {
321: return str;
322: }
323:
324: public javax.transaction.TransactionManager getTransactionManager() {
325: return null;
326: }
327:
328: public com.sun.jbi.VersionInfo getVersionInfo() {
329: return null;
330: }
331:
332: public WsdlFactory getWsdlFactory() throws WsdlException {
333: return null;
334: }
335:
336: /**
337: * This method is used to scaffold EnvironmentContext.isStartOnDeployEnabled()
338: * This method is used only for testing and always returns true
339: */
340: public boolean isStartOnDeployEnabled() {
341: return true;
342: }
343:
344: /**
345: * This method is used to find out if start-onverify is enabled.
346: * When this is enabled components are started automatically when
347: * an application has to be verified for them
348: * This is controlled by the property com.sun.jbi.startOnVerify.
349: * By default start-on-verify is enabled.
350: * It is disabled only if com.sun.jbi.startOnVerify=false.
351: */
352: public boolean isStartOnVerifyEnabled() {
353: return true;
354: }
355:
356: /** Little impl of ComponentContext. */
357: class ComponentContextImpl implements ComponentContext {
358: private DeliveryChannelImpl mChannel;
359:
360: ComponentContextImpl(DeliveryChannelImpl channel) {
361: mChannel = channel;
362: }
363:
364: /*******************************************************************
365: * ComponentContext Methods
366: ******************************************************************/
367:
368: public ServiceEndpoint activateEndpoint(QName serviceName,
369: String endpointName) throws javax.jbi.JBIException {
370: return mChannel.activateEndpoint(serviceName, endpointName);
371: }
372:
373: public void deactivateEndpoint(ServiceEndpoint endpoint)
374: throws javax.jbi.JBIException {
375: mChannel.deactivateEndpoint(endpoint);
376: }
377:
378: public void deregisterExternalEndpoint(
379: ServiceEndpoint externalEndpoint)
380: throws javax.jbi.JBIException {
381:
382: }
383:
384: public String getComponentName() {
385: return mChannel.getChannelId();
386: }
387:
388: public javax.jbi.messaging.DeliveryChannel getDeliveryChannel()
389: throws javax.jbi.messaging.MessagingException {
390: return mChannel;
391: }
392:
393: public ServiceEndpoint getEndpoint(
394: javax.xml.namespace.QName service, String name) {
395: return null;
396: }
397:
398: public org.w3c.dom.Document getEndpointDescriptor(
399: ServiceEndpoint endpoint) throws javax.jbi.JBIException {
400: return mChannel.getEndpointDescriptor(endpoint);
401: }
402:
403: public ServiceEndpoint[] getEndpointsForService(
404: javax.xml.namespace.QName serviceName) {
405: return mChannel.getEndpointsForService(serviceName);
406: }
407:
408: public ServiceEndpoint[] getExternalEndpoints(
409: javax.xml.namespace.QName interfaceName) {
410: return null;
411: }
412:
413: public ServiceEndpoint[] getExternalEndpointsForService(
414: javax.xml.namespace.QName serviceName) {
415: return null;
416: }
417:
418: public String getInstallRoot() {
419: return NMRContext.ROOT_PATH;
420: }
421:
422: public java.util.logging.Logger getLogger(String suffix,
423: String resourceBundleName)
424: throws java.util.MissingResourceException,
425: javax.jbi.JBIException {
426: return null;
427: }
428:
429: public String getWorkspaceRoot() {
430: return NMRContext.ROOT_PATH;
431: }
432:
433: public void registerExternalEndpoint(
434: ServiceEndpoint externalEndpoint) {
435:
436: }
437:
438: public ServiceEndpoint resolveEndpointReference(
439: org.w3c.dom.DocumentFragment endpointReference) {
440: return null;
441: }
442:
443: public javax.jbi.management.MBeanNames getMBeanNames() {
444: return null;
445: }
446:
447: public javax.management.MBeanServer getMBeanServer() {
448: return null;
449: }
450:
451: public com.sun.jbi.management.ManagementMessageFactory getManagementMessageFactory() {
452: return null;
453: }
454:
455: public javax.naming.InitialContext getNamingContext() {
456: return null;
457: }
458:
459: public Object getTransactionManager() {
460: return null;
461: }
462:
463: public ServiceEndpoint[] getEndpoints(QName interfaceName) {
464: return mChannel.getEndpoints(interfaceName);
465: }
466:
467: public WsdlFactory getWsdlFactory() throws WsdlException {
468: return null;
469: }
470:
471: }
472:
473: }
|