001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /*
019: * ChainBuilder ESB
020: * Visual Enterprise Integration
021: *
022: * Copyright (C) 2006 Bostech Corporation
023: *
024: * This program is free software; you can redistribute it and/or modify it
025: * under the terms of the GNU General Public License as published by the
026: * Free Software Foundation; either version 2 of the License, or (at your option)
027: * any later version.
028: *
029: * This program is distributed in the hope that it will be useful,
030: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
031: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
032: * for more details.
033: *
034: * You should have received a copy of the GNU General Public License along with
035: * this program; if not, write to the Free Software Foundation, Inc.,
036: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
037: *
038: * $Id: CbEndpoint.java 9916 2007-11-07 10:51:32Z lzheng $
039: */
040: package com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging;
041:
042: import javax.jbi.messaging.MessageExchange;
043: import javax.jbi.messaging.MessageExchange.Role;
044: import javax.wsdl.Definition;
045: import javax.xml.namespace.QName;
046:
047: import org.w3c.dom.Document;
048:
049: public abstract class CbEndpoint {
050:
051: protected QName service;
052: protected String endpoint;
053: protected QName interfaceName;
054: protected Document description;
055: protected Definition definition;
056: protected CbServiceUnit serviceUnit;
057:
058: public CbEndpoint() {
059: }
060:
061: public CbEndpoint(CbServiceUnit serviceUnit, QName service,
062: String endpoint) {
063: this .serviceUnit = serviceUnit;
064: this .service = service;
065: this .endpoint = endpoint;
066: }
067:
068: /**
069: * @return Returns the endpoint.
070: */
071: public String getEndpoint() {
072: return endpoint;
073: }
074:
075: /**
076: * @param endpoint The endpoint to set.
077: */
078: public void setEndpoint(String endpoint) {
079: this .endpoint = endpoint;
080: }
081:
082: /**
083: * @return Returns the service.
084: */
085: public QName getService() {
086: return service;
087: }
088:
089: /**
090: * @param service The service to set.
091: */
092: public void setService(QName service) {
093: this .service = service;
094: }
095:
096: /**
097: * @return Returns the role.
098: */
099: public abstract Role getRole();
100:
101: /**
102: * @return Returns the description.
103: */
104: public Document getDescription() {
105: return description;
106: }
107:
108: /**
109: * @param description The description to set.
110: */
111: public void setDescription(Document description) {
112: this .description = description;
113: }
114:
115: /**
116: * @return Returns the interfaceName.
117: */
118: public QName getInterfaceName() {
119: return interfaceName;
120: }
121:
122: /**
123: * @param interfaceName The interfaceName to set.
124: */
125: public void setInterfaceName(QName interfaceName) {
126: this .interfaceName = interfaceName;
127: }
128:
129: /**
130: * @return Returns the serviceUnit.
131: */
132: public CbServiceUnit getServiceUnit() {
133: return serviceUnit;
134: }
135:
136: /**
137: * @param serviceUnit The serviceUnit to set.
138: */
139: public void setServiceUnit(CbServiceUnit serviceUnit) {
140: this .serviceUnit = serviceUnit;
141: }
142:
143: public boolean isExchangeOkay(MessageExchange exchange) {
144: // TODO: We could check the MEP here
145: return true;
146: }
147:
148: public abstract void activate() throws Exception;
149:
150: public abstract void deactivate() throws Exception;
151:
152: public abstract IExchangeProcessor getProcessor();
153:
154: public String toString() {
155: return "CbEndpoint[service: "
156: + service
157: + ", "
158: + "endpoint: "
159: + endpoint
160: + ", "
161: + "role: "
162: + (getRole() == Role.PROVIDER ? "provider" : "consumer")
163: + "]";
164: }
165:
166: public Definition getDefinition() {
167: return definition;
168: }
169:
170: public void setDefinition(Definition definition) {
171: this .definition = definition;
172: }
173:
174: public String getSaName() {
175: String suName = this .getServiceUnit().getName();
176: String saName = null;
177: int underscorePosition = suName.indexOf("_");
178: if (underscorePosition > 1)
179: saName = suName.substring(0, underscorePosition);
180: return saName;
181: }
182: }
|