Source Code Cross Referenced for EndpointBean.java in  » ESB » open-esb » com » sun » jbi » binding » file » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.jbi.binding.file 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * @(#)EndpointBean.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.binding.file;
030:
031:        import com.sun.jbi.binding.file.util.ConfigData;
032:
033:        import java.io.Serializable;
034:
035:        import java.util.ArrayList;
036:        import java.util.HashMap;
037:        import java.util.Hashtable;
038:        import java.util.Iterator;
039:        import java.util.List;
040:
041:        import javax.jbi.servicedesc.ServiceEndpoint;
042:
043:        import javax.xml.namespace.QName;
044:
045:        /**
046:         * This Bean object holds all the attributes of an endpoint.
047:         *
048:         * @author Sun Microsystems, Inc.
049:         */
050:        public final class EndpointBean {
051:            /**
052:             * File thread corresponding to this endpoint.
053:             */
054:            private FileThreads mFileThreads;
055:
056:            /**
057:             * Table that stores the opreation and corresponding MEP.
058:             */
059:            private HashMap mMessagePatterns = null;
060:
061:            /**
062:             * Table for storing the xml tags and values  present in the config file.
063:             * This table stores  throws filebinding sepcific configuration
064:             * information correspondint to each endpoint.
065:             */
066:            private Hashtable mConfigTable = null;
067:
068:            /**
069:             * Operations.
070:             */
071:            private List mOperations = null;
072:
073:            /**
074:             * Endpoint Reference as returned by the NMS.
075:             */
076:            private ServiceEndpoint mServiceEndpoint;
077:
078:            /**
079:             * Deployment Id.
080:             */
081:            private String mDeploymentId;
082:
083:            /**
084:             * Receiver thread.
085:             */
086:            private Thread mThread;
087:
088:            /**
089:             * Denotes if an endpoint is consumer or provider
090:             */
091:            private int mRole;
092:
093:            private Object mDefinition;
094:
095:            private String mDeploymentType;
096:
097:            /**
098:             * Constructor. Creates a new Table, list.
099:             */
100:            public EndpointBean() {
101:                mConfigTable = new Hashtable();
102:                mOperations = new ArrayList();
103:                mMessagePatterns = new HashMap();
104:            }
105:
106:            /**
107:             * Gets a unique combination key
108:             * 
109:             * @return key
110:             */
111:            public String getKey() {
112:                String servicenamespace = getValue(ConfigData.SERVICE_NAMESPACE);
113:                String servicename = getValue(ConfigData.SERVICE_LOCALNAME);
114:                String interfacenamespace = getValue(ConfigData.INTERFACE_NAMESPACE);
115:                String interfacename = getValue(ConfigData.INTERFACE_LOCALNAME);
116:                String endpointname = getValue(ConfigData.ENDPOINTNAME);
117:
118:                QName serqname = new QName(servicenamespace, servicename);
119:                QName interqname = new QName(interfacenamespace, interfacename);
120:
121:                if (mRole == ConfigData.PROVIDER) {
122:                    return serqname.toString() + interqname.toString()
123:                            + endpointname + ConfigData.PROVIDER_STRING;
124:                } else {
125:                    return serqname.toString() + interqname.toString()
126:                            + endpointname + ConfigData.CONSUMER_STRING;
127:                }
128:            }
129:
130:            public void setWsdlDefintion(Object def) {
131:                mDefinition = def;
132:            }
133:
134:            public Object getWsdlDefinition() {
135:                return mDefinition;
136:            }
137:
138:            /**
139:             * Returns the default operation, which is normally the first operation
140:             * defined in the XML or WSDL.
141:             *
142:             * @return QName name of the operation.
143:             */
144:            public QName getDefaultOperation() {
145:                QName operation = null;
146:
147:                try {
148:                    OperationBean op = (OperationBean) mOperations.get(0);
149:                    operation = new QName(op.getNamespace(), op.getName());
150:                } catch (Exception e) {
151:                    ;
152:                }
153:
154:                return operation;
155:            }
156:
157:            /**
158:             * Sets the deployment Id corresponding to this endpoint Bean.
159:             *
160:             * @param suId Service unit Id.
161:             */
162:            public void setDeploymentId(String suId) {
163:                mDeploymentId = suId;
164:            }
165:
166:            /**
167:             * Fetches the deployment Id coresponding to this bean.
168:             *
169:             * @return Service unit ID.
170:             */
171:            public String getDeploymentId() {
172:                return mDeploymentId;
173:            }
174:
175:            /**
176:             * Gets the file extension corresponding to an operation.
177:             *
178:             * @param operation operation name.
179:             *
180:             * @return file extension corresponding to operation.
181:             */
182:            public String getExtension(String operation) {
183:                String ext = null;
184:                Iterator iter = mOperations.iterator();
185:
186:                while (iter.hasNext()) {
187:                    OperationBean op = (OperationBean) iter.next();
188:
189:                    if (op.getName().trim().equals(operation)) {
190:                        ext = op.getFileExtension();
191:
192:                        break;
193:                    }
194:                }
195:
196:                return ext;
197:            }
198:
199:            /**
200:             * Sets the file thread.
201:             *
202:             * @param ft File thread object.
203:             */
204:            public void setFileThread(FileThreads ft) {
205:                mFileThreads = ft;
206:            }
207:
208:            /**
209:             * Gets the file thread.
210:             *
211:             * @return file thread object.
212:             */
213:            public FileThreads getFileThread() {
214:                return mFileThreads;
215:            }
216:
217:            /**
218:             * Returns the input type corresponding to an operation name.
219:             *
220:             * @param operation operation name.
221:             *
222:             * @return input message type for the operation.
223:             */
224:            public String getInputType(String operation) {
225:                String inputtype = null;
226:                Iterator iter = mOperations.iterator();
227:
228:                while (iter.hasNext()) {
229:                    OperationBean op = (OperationBean) iter.next();
230:
231:                    if (op.getName().trim().equals(operation)) {
232:                        inputtype = op.getInputType();
233:
234:                        break;
235:                    }
236:                }
237:
238:                return inputtype;
239:            }
240:
241:            /**
242:             * Gets the MEP corresponding to the operation name.
243:             *
244:             * @param operation operation name.
245:             *
246:             * @return String representing the operation , if not present then null
247:             */
248:            public String getMEP(String operation) {
249:                String mep = null;
250:                Iterator iter = mOperations.iterator();
251:
252:                while (iter.hasNext()) {
253:                    OperationBean op = (OperationBean) iter.next();
254:
255:                    if (op.getName().trim().equals(operation)) {
256:                        mep = op.getMep();
257:
258:                        break;
259:                    }
260:                }
261:
262:                return mep;
263:            }
264:
265:            /**
266:             * Gets the operation name corresponding to the input type in WSDL.
267:             *
268:             * @param input name of the input type.
269:             *
270:             * @return String representing the operation , if not present then null
271:             */
272:            public QName getOperation(String input) {
273:                QName operation = null;
274:
275:                Iterator iter = mOperations.iterator();
276:
277:                while (iter.hasNext()) {
278:                    OperationBean op = (OperationBean) iter.next();
279:
280:                    if (op.getQName().trim().equals(input)) {
281:                        operation = new QName(op.getNamespace(), op.getName());
282:
283:                        break;
284:                    }
285:                }
286:
287:                return operation;
288:            }
289:
290:            /**
291:             * Gets the fully qualified name of operation given the position in  XML or
292:             * WSDL.
293:             *
294:             * @param index occurence of operation inXML or WSDL.
295:             *
296:             * @return the QName of operation.
297:             */
298:            public QName getOperationQName(int index) {
299:                String local = ((OperationBean) mOperations.get(index))
300:                        .getName();
301:                String namespace = ((OperationBean) mOperations.get(index))
302:                        .getNamespace();
303:
304:                return new QName(namespace, local);
305:            }
306:
307:            /**
308:             * Returns the number of operations in XML or WSDL.
309:             *
310:             * @return number of operations for this endpoint.
311:             */
312:            public int getOperationsCount() {
313:                return mOperations.size();
314:            }
315:
316:            /**
317:             * Returns the output type corresponding to an operation.
318:             *
319:             * @param operation operation name.
320:             *
321:             * @return output message type.
322:             */
323:            public String getOutputType(String operation) {
324:                String outputtype = null;
325:                Iterator iter = mOperations.iterator();
326:
327:                while (iter.hasNext()) {
328:                    OperationBean op = (OperationBean) iter.next();
329:
330:                    if (op.getName().trim().equals(operation)) {
331:                        outputtype = op.getOutputType();
332:
333:                        break;
334:                    }
335:                }
336:
337:                return outputtype;
338:            }
339:
340:            /**
341:             * Gets the file prefix corresponding to an operation.
342:             *
343:             * @param operation operation name.
344:             *
345:             * @return output file prefix.
346:             */
347:            public String getPrefix(String operation) {
348:                String prefix = null;
349:                Iterator iter = mOperations.iterator();
350:
351:                while (iter.hasNext()) {
352:                    OperationBean op = (OperationBean) iter.next();
353:
354:                    if (op.getName().trim().equals(operation)) {
355:                        prefix = op.getOutputFilePrefix();
356:
357:                        break;
358:                    }
359:                }
360:
361:                return prefix;
362:            }
363:
364:            /**
365:             * Sets the receiver thread.
366:             *
367:             * @param t thread
368:             */
369:            public void setReceiverThread(Thread t) {
370:                mThread = t;
371:            }
372:
373:            /**
374:             * Returns the receiver thread.
375:             *
376:             * @return receiver thread object.
377:             */
378:            public Thread getReceiverThread() {
379:                return mThread;
380:            }
381:
382:            /**
383:             * Sets the role of this endpoint, provider or consumer.
384:             *
385:             * @param role should be provider or comsumer, 0 or 1.
386:             */
387:            public void setRole(int role) {
388:                if ((role != ConfigData.PROVIDER)
389:                        && (role != ConfigData.CONSUMER)) {
390:                    mRole = ConfigData.CONSUMER;
391:                } else {
392:                    mRole = role;
393:                }
394:            }
395:
396:            /**
397:             * Returns the role.
398:             *
399:             * @return role
400:             */
401:            public int getRole() {
402:                return mRole;
403:            }
404:
405:            /**
406:             * Sets the endpoint reference once the endpoitn has been activated  with
407:             * the NMS.
408:             *
409:             * @param ref endpoint reference
410:             */
411:            public void setServiceEndpoint(ServiceEndpoint ref) {
412:                mServiceEndpoint = ref;
413:            }
414:
415:            /**
416:             * Gets the enpoint reference corresponding to this endpoint.
417:             *
418:             * @return endpoint reference.
419:             */
420:            public ServiceEndpoint getServiceEndpoint() {
421:                return mServiceEndpoint;
422:            }
423:
424:            /**
425:             * Returns a unique name which is a combination of service name and
426:             * endpoint name.
427:             *
428:             * @return unique name of this endpoint. Its a combination of service  name
429:             *         and endpoint name.
430:             */
431:            public String getUniqueName() {
432:                String servicenamespace = getValue(ConfigData.SERVICE_NAMESPACE);
433:                String servicename = getValue(ConfigData.SERVICE_LOCALNAME);
434:                String endpointname = getValue(ConfigData.ENDPOINTNAME);
435:
436:                if ((servicenamespace != null) && (endpointname != null)) {
437:                    if (servicenamespace.trim().equals("")) {
438:                        return servicename + endpointname;
439:                    } else {
440:                        return "{" + servicenamespace + "}" + servicename
441:                                + endpointname;
442:                    }
443:                }
444:
445:                return null;
446:            }
447:
448:            /**
449:             * Sets the value for the key in the table.
450:             *
451:             * @param key for which value has to be retrieved.
452:             * @param value corresponding to the key
453:             */
454:            public void setValue(String key, String value) {
455:                if (key == null) {
456:                    return;
457:                }
458:
459:                if (value == null) {
460:                    value = "";
461:                }
462:
463:                mConfigTable.put(key, value);
464:            }
465:
466:            /**
467:             * Returns the value associated with the key from the table.
468:             *
469:             * @param key the tag name for which value is required.
470:             *
471:             * @return value corresponding to the tag as in config file.
472:             */
473:            public String getValue(String key) {
474:                if (key == null) {
475:                    return null;
476:                }
477:
478:                return (String) mConfigTable.get(key);
479:            }
480:
481:            /**
482:             * Adds an entry for operation-mep in table.
483:             *
484:             * @param oper operation name.
485:             * @param mep corresponding MEP.
486:             */
487:            public void addMessagePattern(String oper, String mep) {
488:                try {
489:                    mMessagePatterns.put(oper, mep);
490:                } catch (Exception e) {
491:                    e.printStackTrace();
492:                }
493:            }
494:
495:            /**
496:             * Adds an operation to the endpoint.
497:             *
498:             * @param namespace namespace uri
499:             * @param name local name
500:             * @param mep exchange pattern.
501:             * @param input input message type.
502:             * @param output output message type.
503:             * @param ext file extension.
504:             * @param prefix output file prefix.
505:             */
506:            public void addOperation(String namespace, String name, String mep,
507:                    String input, String output, String ext, String prefix) {
508:                OperationBean op = new OperationBean(namespace, name, mep,
509:                        input, output, ext, prefix);
510:                mOperations.add(op);
511:            }
512:
513:            /**
514:             * Getter for property mDeploymentType.
515:             * @return Value of property mDeploymentType.
516:             */
517:            public java.lang.String getDeploymentType() {
518:                return mDeploymentType;
519:            }
520:
521:            /**
522:             * Setter for property mDeploymentType.
523:             * @param mDeploymentType New value of property mDeploymentType.
524:             */
525:            public void setDeploymentType(java.lang.String mDeploymentType) {
526:                this.mDeploymentType = mDeploymentType;
527:            }
528:
529:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.