Source Code Cross Referenced for RegisteredEndpoint.java in  » ESB » open-esb » com » sun » jbi » messaging » 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.messaging 
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:         * @(#)RegisteredEndpoint.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.messaging.stats.METimestamps;
032:        import com.sun.jbi.messaging.stats.Value;
033:
034:        import com.sun.jbi.messaging.util.WSDLHelper;
035:
036:        import java.util.Date;
037:        import java.util.HashMap;
038:        import java.util.Iterator;
039:
040:        import java.util.concurrent.atomic.AtomicLong;
041:
042:        import java.util.logging.Logger;
043:
044:        import javax.jbi.servicedesc.ServiceEndpoint;
045:
046:        import javax.management.openmbean.CompositeData;
047:        import javax.management.openmbean.CompositeDataSupport;
048:        import javax.management.openmbean.CompositeType;
049:        import javax.management.openmbean.SimpleType;
050:        import javax.management.openmbean.OpenType;
051:
052:        import javax.xml.namespace.QName;
053:
054:        import org.w3c.dom.Document;
055:        import org.w3c.dom.DocumentFragment;
056:
057:        /** Abstract base class representing WSDL endpoint registered with the NMS.  
058:         * Specific endpoint types (dynamic, internal, external, mapped) extend this
059:         * class to address specific endpoint behavior.
060:         * @author Sun Microsystems, Inc.
061:         */
062:        public abstract class RegisteredEndpoint implements  ServiceEndpoint,
063:                EndpointStatistics {
064:            /******************** ENDPOINT TYPES ***********************/
065:
066:            // provided by component when resolving an endpoint reference
067:            public static final int DYNAMIC = 10;
068:            // registered using traditional NMR activation methods
069:            public static final int INTERNAL = 20;
070:            // external endpoints
071:            public static final int EXTERNAL = 30;
072:            // service connection
073:            public static final int LINKED = 40;
074:
075:            /** Qualified name of the service. */
076:            private QName mService;
077:            /** Local name of the endpoint. */
078:            private String mEndpoint;
079:            /** Id of the component which registered this endpoint. */
080:            String mOwnerId;
081:            /** Endpoint status. */
082:            private boolean mActive;
083:            /** Operations available for this endpoint. */
084:            private HashMap mOperations;
085:            /** Interfaces implemented by this endpoint. */
086:            private QName[] mInterfaces;
087:            /** Logger handle. */
088:            private Logger mLog = Logger.getLogger(this .getClass().getPackage()
089:                    .getName());
090:
091:            /** Primary statistics for external use.    */
092:            long mActivationTimestamp;
093:            AtomicLong mActiveExchanges;
094:            long mSendRequest;
095:            long mReceiveReply;
096:            long mReceiveRequest;
097:            long mSendReply;
098:            long mSendFault;
099:            long mReceiveFault;
100:            long mLastFaultTime;
101:            long mSendDONE;
102:            long mLastDONETime;
103:            long mReceiveDONE;
104:            long mSendERROR;
105:            long mLastERRORTime;
106:            long mReceiveERROR;
107:            Value mResponseTime;
108:            Value mChannelTime;
109:            Value mNMRTime;
110:            Value mComponentTime;
111:            Value mStatusTime;
112:
113:            /** Creates a new RegisteredEndpoint.
114:             *  @param service service name
115:             *  @param endpoint endpoint name
116:             *  @param ownerId id of component which is registering the service
117:             *  @param type endpoint type
118:             */
119:            public RegisteredEndpoint(QName service, String endpoint,
120:                    String ownerId) {
121:                mOwnerId = ownerId;
122:                mService = service;
123:                mEndpoint = endpoint;
124:                mActive = true;
125:                mResponseTime = new Value();
126:                mNMRTime = new Value();
127:                mComponentTime = new Value();
128:                mChannelTime = new Value();
129:                mStatusTime = new Value();
130:                mActivationTimestamp = System.currentTimeMillis();
131:                mActiveExchanges = new AtomicLong();
132:            }
133:
134:            /** Returns the local name of the registered endpoint.
135:             *  @return qualified name of service.
136:             */
137:            public String getEndpointName() {
138:                return mEndpoint;
139:            }
140:
141:            /** Returns the qualified name of the service offered at this endpoint.
142:             *  @return qualified name of service.
143:             */
144:            public QName getServiceName() {
145:                return mService;
146:            }
147:
148:            public String getOwnerId() {
149:                return mOwnerId;
150:            }
151:
152:            /** Indicates whether this reference is active.
153:             *  @return true if the reference is active, false otherwise.
154:             */
155:            public boolean isActive() {
156:                return mActive;
157:            }
158:
159:            /** Indicates the type of endpoint: INTERNAL, EXTERNAL, or DYNAMIC.
160:             */
161:            public abstract int getType();
162:
163:            /** Specifies whether the reference is active.
164:             *  @param isActive true for yes, false for no
165:             */
166:            public void setActive(boolean isActive) {
167:                mActive = isActive;
168:            }
169:
170:            public HashMap getOperations() {
171:                return (mOperations);
172:            }
173:
174:            public void setOperations(HashMap map) {
175:                mOperations = map;
176:            }
177:
178:            public QName[] getInterfaces() {
179:                return mInterfaces;
180:            }
181:
182:            public void setInterfaces(QName[] interfaces) {
183:                mInterfaces = interfaces;
184:            }
185:
186:            public boolean isInternal() {
187:                return getType() == RegisteredEndpoint.INTERNAL;
188:            }
189:
190:            public boolean isExternal() {
191:                return getType() == RegisteredEndpoint.EXTERNAL;
192:            }
193:
194:            public boolean isLinked() {
195:                return getType() == RegisteredEndpoint.LINKED;
196:            }
197:
198:            public boolean isDynamic() {
199:                return getType() == RegisteredEndpoint.DYNAMIC;
200:            }
201:
202:            /** Returns true if this endpoint implements the specified interface. */
203:            public boolean implements Interface(QName interfaceName) {
204:                boolean implemented = false;
205:
206:                if (mInterfaces != null) {
207:                    for (int i = 0; i < mInterfaces.length; i++) {
208:                        if (mInterfaces[i].equals(interfaceName)) {
209:                            implemented = true;
210:                            break;
211:                        }
212:                    }
213:                }
214:
215:                return implemented;
216:            }
217:
218:            /** Parse the endpoint descriptor for operation and interface details and
219:             *  load them into the endpoint reference.
220:             */
221:            public void parseDescriptor(Document descriptor)
222:                    throws javax.jbi.messaging.MessagingException {
223:                /** The descriptor should never be null, but this is a new requirement and
224:                 *  some components may not be up-to-date yet.  In the future, we should
225:                 *  throw an exception in this case.
226:                 */
227:                if (descriptor != null) {
228:                    mOperations = WSDLHelper.getOperationsForService(
229:                            descriptor, mService);
230:                    mInterfaces = WSDLHelper.getInterfacesForService(
231:                            descriptor, mService);
232:                }
233:            }
234:
235:            /**
236:             * <b>ExternalEndpoint implementation should override this method. </b>
237:             * <br><br>
238:             * Get a reference to this endpoint, using an endpoint reference vocabulary
239:             * that is known to the provider.
240:             * @param operationName the name of the operation to be performed by a
241:             * consumer of the generated endpoint reference. Set to <code>null</code>
242:             * if this is not applicable.
243:             * @return endpoint reference as an XML fragment; <code>null</code> if the
244:             * provider does not support such references.
245:             */
246:            public DocumentFragment getAsReference(QName operationName) {
247:                DocumentFragment doc = null;
248:
249:                try {
250:                    doc = EndpointReference.asReference(this );
251:                } catch (javax.jbi.messaging.MessagingException msgEx) {
252:                    mLog.warning(msgEx.toString());
253:                }
254:
255:                return doc;
256:            }
257:
258:            public void setInUse() {
259:                mActiveExchanges.incrementAndGet();
260:            }
261:
262:            public void resetInUse() {
263:                mActiveExchanges.decrementAndGet();
264:            }
265:
266:            synchronized void updateStatistics(MessageExchangeProxy me) {
267:                int mask = me.getPhaseMask();
268:                METimestamps ts = me.getTimestamps();
269:
270:                if ((mask & MessageExchangeProxy.PM_SEND_REPLY) != 0) {
271:                    mSendReply++;
272:                }
273:                if ((mask & MessageExchangeProxy.PM_SEND_FAULT) != 0) {
274:                    mSendFault++;
275:                    mLastFaultTime = System.currentTimeMillis();
276:                }
277:                if ((mask & MessageExchangeProxy.PM_SEND_DONE) != 0) {
278:                    mSendDONE++;
279:                    mLastDONETime = System.currentTimeMillis();
280:                }
281:                if ((mask & MessageExchangeProxy.PM_SEND_ERROR) != 0) {
282:                    mSendERROR++;
283:                    mLastERRORTime = System.currentTimeMillis();
284:                }
285:                if ((mask & MessageExchangeProxy.PM_RECEIVE_REQUEST) != 0) {
286:                    mReceiveRequest++;
287:                }
288:                if ((mask & MessageExchangeProxy.PM_RECEIVE_FAULT) != 0) {
289:                    mReceiveFault++;
290:                    mLastFaultTime = System.currentTimeMillis();
291:                }
292:                if ((mask & MessageExchangeProxy.PM_RECEIVE_DONE) != 0) {
293:                    mReceiveDONE++;
294:                    mLastDONETime = System.currentTimeMillis();
295:                }
296:                if ((mask & MessageExchangeProxy.PM_RECEIVE_ERROR) != 0) {
297:                    mReceiveERROR++;
298:                    mLastERRORTime = System.currentTimeMillis();
299:                }
300:                if (ts != null) {
301:                    mResponseTime.addSample(ts.mResponseTime);
302:                    mNMRTime.addSample(ts.mNMRTime);
303:                    mChannelTime.addSample(ts.mProviderChannelTime);
304:                    mComponentTime.addSample(ts.mProviderTime);
305:                }
306:            }
307:
308:            //-------------------------EndpointStatistics-------------------------------
309:
310:            public String getName() {
311:                return (toExternalName());
312:            }
313:
314:            /**
315:             * List of item names for CompositeData construction.
316:             */
317:            private static final String[] ITEM_NAMES = { "OwningChannel",
318:                    "ActivationTimestamp", "ActiveExchanges", "ReceiveRequest",
319:                    "SendReply", "SendFault", "ReceiveFault", "LastFaultTime",
320:                    "SendDONE", "ReceiveDONE", "LastDONETime", "SendERROR",
321:                    "ReceiveERROR", "LastERRORTime", "ResponseTimeMin (ns)",
322:                    "ResponseTimeAvg (ns)", "ResponseTimeMax (ns)",
323:                    "ResponseTimeStd (ns)", "NMRTimeMin (ns)",
324:                    "NMRTimeAvg (ns)", "NMRTimeMax (ns)", "NMRTimeStd (ns)",
325:                    "ComponentTimeMin (ns)", "ComponentTimeAvg (ns)",
326:                    "ComponentTimeMax (ns)", "ComponentTimeStd (ns)",
327:                    "ChannelTimeMin (ns)", "ChannelTimeAvg (ns)",
328:                    "ChannelTimeMax (ns)", "ChannelTimeStd (ns)" };
329:
330:            /**
331:             * List of descriptions of items for CompositeData construction.
332:             */
333:            private static final String ITEM_DESCRIPTIONS[] = {
334:                    "Owning DeliveryChannel", "Activation Timestamp (ms)",
335:                    "Active Exchanges", "Number of requests received",
336:                    "Number of replies sent", "Number of faults sent",
337:                    "Number of faults received", "Timestamp of last fault",
338:                    "Number of DONE requests sent",
339:                    "Number of DONE requests received",
340:                    "Timestamp of last DONE", "Number of ERROR requests sent",
341:                    "Number of ERROR requests received",
342:                    "Timestamp of last ERROR", "Response Time Min",
343:                    "Response Time Avg", "Response Time Max",
344:                    "Response Time Std", "NMR Time Min", "NMR Time Avg",
345:                    "NMR Time Max", "NMR Time Std", "Component Time Min",
346:                    "Component Time Avg", "Component Time Max",
347:                    "Component Time Std", "Channel Time Min",
348:                    "Channel Time Avg", "Channel Time Max", "Channel Time Std" };
349:
350:            /**
351:             * List of types of items for CompositeData construction.
352:             */
353:            private static final OpenType ITEM_TYPES[] = { SimpleType.STRING,
354:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
355:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
356:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
357:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
358:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
359:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
360:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
361:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
362:                    SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
363:                    SimpleType.LONG, SimpleType.LONG };
364:
365:            public CompositeData getStatistics() {
366:                try {
367:                    Object values[] = { mOwnerId, mActivationTimestamp,
368:                            mActiveExchanges.get(), mReceiveRequest,
369:                            mSendReply, mSendFault, mReceiveFault,
370:                            mLastFaultTime, mSendDONE, mReceiveDONE,
371:                            mLastDONETime, mSendERROR, mReceiveERROR,
372:                            mLastERRORTime, mResponseTime.getMin(),
373:                            (long) mResponseTime.getAverage(),
374:                            mResponseTime.getMax(),
375:                            (long) mResponseTime.getSd(), mNMRTime.getMin(),
376:                            (long) mNMRTime.getAverage(), mNMRTime.getMax(),
377:                            (long) mNMRTime.getSd(), mComponentTime.getMin(),
378:                            (long) mComponentTime.getAverage(),
379:                            mComponentTime.getMax(),
380:                            (long) mComponentTime.getSd(),
381:                            mChannelTime.getMin(),
382:                            (long) mChannelTime.getAverage(),
383:                            mChannelTime.getMax(), (long) mChannelTime.getSd() };
384:
385:                    return new CompositeDataSupport(new CompositeType(
386:                            "EndpointStatistics", "Endpoint statistics",
387:                            ITEM_NAMES, ITEM_DESCRIPTIONS, ITEM_TYPES),
388:                            ITEM_NAMES, values);
389:                } catch (javax.management.openmbean.OpenDataException odEx) {
390:                    ; // ignore this for now
391:                }
392:                return (null);
393:            }
394:
395:            //-------------------------------Object-----------------------------------
396:
397:            public int hashCode() {
398:                return (mService.hashCode() ^ mEndpoint.hashCode() ^ mOwnerId
399:                        .hashCode());
400:            }
401:
402:            /** Deep check for equality. */
403:            public boolean equals(Object obj) {
404:                RegisteredEndpoint target;
405:                boolean isEqual = false;
406:
407:                if (obj instanceof  RegisteredEndpoint) {
408:                    target = (RegisteredEndpoint) obj;
409:
410:                    if (target.mService.equals(mService)
411:                            && target.mEndpoint.equals(mEndpoint)
412:                            && target.mOwnerId.equals(mOwnerId)) {
413:                        isEqual = true;
414:                    }
415:                }
416:
417:                return isEqual;
418:            }
419:
420:            public String toExternalName() {
421:                StringBuilder sb = new StringBuilder();
422:                if (mService.getNamespaceURI() != null) {
423:                    sb.append(mService.getNamespaceURI());
424:                    sb.append(",");
425:                }
426:                sb.append(mService.getLocalPart().toString());
427:                sb.append(",");
428:                sb.append(mEndpoint);
429:                return (sb.toString());
430:            }
431:
432:            public String toStringBrief() {
433:                StringBuilder sb = new StringBuilder();
434:
435:                sb.append("          Owner:     ");
436:                sb.append(mOwnerId);
437:                sb.append("  Active: ");
438:                sb.append(mActive ? "True" : "False");
439:                sb.append("          ActiveExchanges: "
440:                        + mActiveExchanges.get());
441:                sb.append("\n          Service:   ");
442:                sb.append(mService);
443:                sb.append("\n          Endpoint:  ");
444:                sb.append(mEndpoint);
445:                if (mLastDONETime != 0) {
446:                    sb.append("\n        LastDoneTime  : "
447:                            + new Date(mLastDONETime).toString());
448:                }
449:                if (mLastERRORTime != 0) {
450:                    sb.append("\n        LastErrorTime : "
451:                            + new Date(mLastERRORTime).toString());
452:                }
453:                if (mLastFaultTime != 0) {
454:                    sb.append("\n        LastFaultTime : "
455:                            + new Date(mLastFaultTime).toString());
456:                }
457:                sb.append("\n");
458:                if (mOperations != null) {
459:                    sb.append("          Operations Count: ");
460:                    sb.append(mOperations.size());
461:                    sb.append("\n");
462:                    for (Iterator i = mOperations.values().iterator(); i
463:                            .hasNext();) {
464:                        sb.append("            ");
465:                        sb.append(i.next().toString());
466:                        sb.append("\n");
467:                    }
468:                }
469:                if (mInterfaces != null) {
470:                    sb.append("          Interfaces Count: ");
471:                    sb.append(mInterfaces.length);
472:                    sb.append("\n");
473:                    for (int i = 0; i < mInterfaces.length; i++) {
474:                        sb.append("            ");
475:                        sb.append(mInterfaces[i].toString());
476:                        sb.append("\n");
477:                    }
478:                }
479:                return (sb.toString());
480:            }
481:
482:            public String toString() {
483:                StringBuilder sb = new StringBuilder();
484:
485:                sb.append(toStringBrief());
486:                sb.append("            RecvRequest: " + mReceiveRequest);
487:                sb.append("  SendReply: " + mSendReply);
488:                sb.append("\n            RecvDONE: " + mReceiveDONE);
489:                sb.append("  SendDONE: " + mSendDONE);
490:                sb.append("\n            RecvERROR: " + mReceiveERROR);
491:                sb.append("  SendERROR: " + mSendERROR);
492:                sb.append("\n            RecvFault: " + mReceiveFault);
493:                sb.append("  SendFault: " + mSendFault);
494:                if (mResponseTime != null) {
495:                    sb.append("\n            ResponseTime:  "
496:                            + mResponseTime.toString());
497:                    sb.append("\n            ComponentTime: "
498:                            + mComponentTime.toString());
499:                    sb.append("\n            ChannelTime:   "
500:                            + mChannelTime.toString());
501:                    sb.append("\n            NMRTime:       "
502:                            + mNMRTime.toString());
503:                    sb.append("\n");
504:                }
505:                return (sb.toString());
506:            }
507:
508:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.