001: // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003: /*
004: * FileBindingComponent.java
005: *
006: * SUN PROPRIETARY/CONFIDENTIAL.
007: * This software is the proprietary information of Sun Microsystems, Inc.
008: * Use is subject to license terms.
009: *
010: */
011: package com.sun.jbi.binding.file;
012:
013: import org.w3c.dom.DocumentFragment;
014:
015: import javax.jbi.component.Component;
016: import javax.jbi.servicedesc.ServiceEndpoint;
017:
018: /**
019: * This class implements the Component contract with JBI.
020: *
021: * @author Sun Microsystems, Inc.
022: */
023: public class FileBindingComponent implements
024: javax.jbi.component.Component {
025: /**
026: * Lifecycle object.
027: */
028: private FileBindingLifeCycle mLifeCycle;
029:
030: /**
031: * Resolver object.
032: */
033: private FileBindingResolver mResolver;
034:
035: /**
036: * Service unit manager.
037: */
038: private FileBindingSUManager mSUManager;
039:
040: /**
041: * Creates a new instance of FileBindingComponent
042: */
043: public FileBindingComponent() {
044: mLifeCycle = new FileBindingLifeCycle();
045: mSUManager = new FileBindingSUManager();
046: mResolver = new FileBindingResolver();
047: mLifeCycle.setSUManager(mSUManager);
048: mLifeCycle.setResolver(mResolver);
049: }
050:
051: /**
052: * This method is called by JBI to check if this component, in the role of
053: * provider of the service indicated by the given exchange, can actually
054: * perform the operation desired.
055: *
056: * @param endpoint
057: * @param exchange
058: *
059: * @return true if its OK.
060: */
061: public boolean isExchangeWithConsumerOkay(
062: javax.jbi.servicedesc.ServiceEndpoint endpoint,
063: javax.jbi.messaging.MessageExchange exchange) {
064: /* Should not always return true
065: * The capabilities of this component has to be checked first.
066: * Not implemented right now
067: */
068: return true;
069: }
070:
071: /**
072: * This method is called by JBI to check if this component, in the role of
073: * consumer of the service indicated by the given exchange, can actually
074: * interact with the the provider completely.
075: *
076: * @param endpoint
077: * @param exchange
078: *
079: * @return true if OK.
080: */
081: public boolean isExchangeWithProviderOkay(
082: javax.jbi.servicedesc.ServiceEndpoint endpoint,
083: javax.jbi.messaging.MessageExchange exchange) {
084: /* Should not always return true
085: * The capabilities of this component has to be checked first.
086: * Not implemented right now
087: */
088: return true;
089: }
090:
091: /**
092: * Returns the lifecycle object for this component.
093: *
094: * @return component life cycle object for file binding.
095: */
096: public javax.jbi.component.ComponentLifeCycle getLifeCycle() {
097: return mLifeCycle;
098: }
099:
100: /**
101: * Returns a resolver for meta-data.
102: *
103: * @param ServiceEndpoint endpoint reference object.
104: *
105: * @return Descriptor for file binding.
106: */
107: public org.w3c.dom.Document getServiceDescription(
108: javax.jbi.servicedesc.ServiceEndpoint ServiceEndpoint) {
109: org.w3c.dom.Document desc = null;
110:
111: try {
112: desc = mResolver.getServiceDescription(ServiceEndpoint);
113: } catch (Exception e) {
114: e.printStackTrace();
115: }
116:
117: return desc;
118: }
119:
120: /**
121: * Returns the SU manager which is in charge of handling deployment. Acc to the
122: * spec the object should be the same everytime this method is called.
123: *
124: * @return SU manager.
125: */
126: public javax.jbi.component.ServiceUnitManager getServiceUnitManager() {
127: return mSUManager;
128: }
129:
130: /**
131: * Resolve the endpoint reference using the given capabilities of the
132: * consumer. This is called by JBI when its trying to resove the given EPR
133: * on behalf of the component.
134: *
135: * @param epr endpoint reference.
136: *
137: * @return Service enpoint.
138: */
139: public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
140: return null;
141: }
142: }
|