Source Code Cross Referenced for MockConnection.java in  » Testing » MockEJB » org » mockejb » jms » 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 » Testing » MockEJB » org.mockejb.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.mockejb.jms;
002:
003:        import javax.jms.*;
004:        import java.util.*;
005:        import org.mockejb.MethodNotImplementedException;
006:
007:        /**
008:         * @author Dimitar Gospodinov
009:         */
010:        abstract class MockConnection implements  Connection {
011:
012:            private String clientId;
013:            private boolean closed = false;
014:            private boolean started = false;
015:            private final List sessions = new ArrayList();
016:
017:            MockConnection(String id) {
018:                clientId = id;
019:            }
020:
021:            public Session createSession(boolean transacted, int acknowledgeMode)
022:                    throws JMSException {
023:                checkClosed();
024:                MockSession sess = createMockSession(transacted,
025:                        acknowledgeMode);
026:                sessions.add(sess);
027:                return sess;
028:            }
029:
030:            /**
031:             * Returns client Id for this connection.
032:             * @see javax.jms.Connection#getClientID()
033:             */
034:            public String getClientID() throws JMSException {
035:                checkClosed();
036:                return clientId;
037:            }
038:
039:            /**
040:             * @see javax.jms.Connection#setClientID(java.lang.String)
041:             */
042:            public void setClientID(String arg0) throws JMSException {
043:                throw new javax.jms.IllegalStateException(
044:                        "Client ID can not be set!");
045:            }
046:
047:            /**
048:             * Returns metadata for MockEJB JMS connection.
049:             * @see javax.jms.Connection#getMetaData()
050:             */
051:            public ConnectionMetaData getMetaData() throws JMSException {
052:                checkClosed();
053:                return new ConnectionMetaDataImpl();
054:            }
055:
056:            /**
057:             * Not implemented.
058:             * @see javax.jms.Connection#getExceptionListener()
059:             */
060:            public ExceptionListener getExceptionListener() throws JMSException {
061:                throw new MethodNotImplementedException("getExceptionListener",
062:                        "QueueConnectionImpl");
063:            }
064:
065:            /**
066:             * Not implemented.
067:             * @see javax.jms.Connection#setExceptionListener(javax.jms.ExceptionListener)
068:             */
069:            public void setExceptionListener(ExceptionListener listener)
070:                    throws JMSException {
071:
072:                throw new MethodNotImplementedException("setExceptionListener",
073:                        "QueueConnectionImpl");
074:            }
075:
076:            /**
077:             * Does nothing.
078:             * @see javax.jms.Connection#close()
079:             */
080:            public void close() throws JMSException {
081:                if (closed) {
082:                    return;
083:                }
084:                stop();
085:                ListIterator it = sessions.listIterator();
086:                while (it.hasNext()) {
087:                    Session s = (Session) it.next();
088:                    s.close();
089:                    it.remove();
090:                }
091:                closed = true;
092:            }
093:
094:            /**
095:             * Not implemented.
096:             * @see javax.jms.Connection#start()
097:             */
098:            public void start() throws JMSException {
099:                checkClosed();
100:                started = true;
101:                // "Asynchronously" deliver any messages received while the connection was stopped.
102:                // This will simply invoke MessageListeners if any.
103:                Iterator it = sessions.iterator();
104:                while (it.hasNext()) {
105:                    MockSession sess = (MockSession) it.next();
106:                    sess.consumeMessages();
107:                }
108:            }
109:
110:            /**
111:             * Not implemented.
112:             * @see javax.jms.Connection#stop()
113:             */
114:            public void stop() throws JMSException {
115:                checkClosed();
116:                started = false;
117:            }
118:
119:            public ConnectionConsumer createConnectionConsumer(
120:                    Destination destination, java.lang.String messageSelector,
121:                    ServerSessionPool sessionPool, int maxMessages)
122:                    throws JMSException {
123:
124:                throw new MethodNotImplementedException(
125:                        "createConnectionConsumer", "MockConnection");
126:
127:            }
128:
129:            public ConnectionConsumer createDurableConnectionConsumer(
130:                    Topic topic, java.lang.String subscriptionName,
131:                    java.lang.String messageSelector,
132:                    ServerSessionPool sessionPool, int maxMessages)
133:                    throws JMSException {
134:
135:                throw new MethodNotImplementedException(
136:                        "createDurableConnectionConsumer", "MockConnection");
137:            }
138:
139:            // Non-standard methods
140:
141:            void checkClosed() throws javax.jms.IllegalStateException {
142:                if (closed) {
143:                    throw new javax.jms.IllegalStateException(
144:                            "Unable to perform operation on closed connection!");
145:                }
146:            }
147:
148:            abstract MockSession createMockSession(boolean transacted,
149:                    int acknowledgeMode);
150:
151:            boolean isStarted() {
152:                return started;
153:            }
154:
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.