Source Code Cross Referenced for ObjectMessageImpl.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 java.io.*;
004:        import javax.jms.*;
005:
006:        /**
007:         * <code>ObjectMessage</code> implementation.
008:         * @author Dimitar Gospodinov
009:         * @see javax.jms.ObjectMessage
010:         */
011:        public class ObjectMessageImpl extends MessageImpl implements 
012:                ObjectMessage {
013:
014:            private byte[] serializedObject = null;
015:
016:            /**
017:             * Creates empty <code>ObjectMessageImpl</code>.
018:             */
019:            public ObjectMessageImpl() {
020:                super ();
021:            }
022:
023:            /**
024:             * Creates new <code>ObjectMessageImpl</code> and sets its body to
025:             * <code>object</code> 
026:             * @param object
027:             * @throws JMSException
028:             */
029:            public ObjectMessageImpl(Serializable object) throws JMSException {
030:                setObject(object);
031:            }
032:
033:            /**
034:             * Creates new <code>ObjectMessageImpl</code> and sets its header, properties
035:             * and body to the corresponded values from <code>msg</code>
036:             * @param msg
037:             * @throws JMSException
038:             */
039:            public ObjectMessageImpl(ObjectMessage msg) throws JMSException {
040:                super (msg);
041:                setObject(msg.getObject());
042:            }
043:
044:            /**
045:             * @see javax.jms.ObjectMessage#setObject(java.io.Serializable)
046:             */
047:            public void setObject(Serializable object) throws JMSException {
048:                checkBodyWriteable();
049:                try {
050:                    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
051:                    ObjectOutputStream objectOut = new ObjectOutputStream(
052:                            bytesOut);
053:                    objectOut.writeObject(object);
054:                    objectOut.flush();
055:                    objectOut.close();
056:                    serializedObject = bytesOut.toByteArray();
057:                    bytesOut.close();
058:                } catch (IOException ex) {
059:                    throw new JMSException(ex.getMessage());
060:                }
061:            }
062:
063:            /**
064:             * @see javax.jms.ObjectMessage#getObject()
065:             */
066:            public Serializable getObject() throws JMSException {
067:                if (serializedObject == null) {
068:                    return null;
069:                }
070:                Serializable result;
071:                try {
072:                    ByteArrayInputStream bytesIn = new ByteArrayInputStream(
073:                            serializedObject);
074:                    ObjectInputStream objectIn = new ObjectInputStream(bytesIn);
075:                    result = (Serializable) objectIn.readObject();
076:                    objectIn.close();
077:                    bytesIn.close();
078:                    return result;
079:                } catch (IOException ex) {
080:                    throw new JMSException(ex.getMessage());
081:                } catch (ClassNotFoundException ex) {
082:                    throw new JMSException(ex.getMessage());
083:                }
084:            }
085:
086:            /**
087:             * @see javax.jms.ObjectMessage#clearBody()
088:             */
089:            public void clearBody() throws JMSException {
090:                super .clearBody();
091:                serializedObject = null;
092:            }
093:
094:            // Non-standard methods
095:
096:            /**
097:             * Sets message body in read-only mode.
098:             * @throws JMSException
099:             */
100:            void resetBody() throws JMSException {
101:                setBodyReadOnly();
102:            }
103:
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.