Source Code Cross Referenced for PBStateEvent.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » 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 » Database ORM » db ojb » org.apache.ojb.broker 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.broker;
002:
003:        /* Copyright 2003-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * 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:        import org.apache.commons.lang.builder.ToStringBuilder;
019:
020:        /**
021:         * The <code>PBStateEvent</code> encapsulates information about
022:         * the life-cycle/transaction demarcation of the used {@link org.apache.ojb.broker.PersistenceBroker}
023:         * instance.
024:         *
025:         * @author Armin Waibel
026:         * @version $Id: PBStateEvent.java,v 1.5.2.1 2005/12/21 22:22:08 tomdz Exp $
027:         */
028:        public final class PBStateEvent extends PersistenceBrokerEvent {
029:            /** Denotes an event that happens before the broker will be closed. */
030:            public static final int KEY_BEFORE_CLOSE = 1;
031:            /** Denotes an event that happens before a transaction will be started. */
032:            public static final int KEY_BEFORE_BEGIN = 2;
033:            /** Denotes an event that happens before a transaction will be comitted. */
034:            public static final int KEY_BEFORE_COMMIT = 3;
035:            /** Denotes an event that happens before a transaction will be rolled back. */
036:            public static final int KEY_BEFORE_ROLLBACK = 4;
037:            /** Denotes an event that happens after a transaction was started. */
038:            public static final int KEY_AFTER_BEGIN = 5;
039:            /** Denotes an event that happens after a transaction was comitted. */
040:            public static final int KEY_AFTER_COMMIT = 6;
041:            /** Denotes an event that happens after a broker was opened. */
042:            public static final int KEY_AFTER_OPEN = 7;
043:            /** Denotes an event that happens after a transaction was rolled back. */
044:            public static final int KEY_AFTER_ROLLBACK = 8;
045:
046:            private Type eventType;
047:
048:            /**
049:             * Creates a new event instance.
050:             * 
051:             * @param broker    The broker
052:             * @param eventType The type of the event
053:             */
054:            public PBStateEvent(PersistenceBroker broker, Type eventType) {
055:                super (broker);
056:                this .eventType = eventType;
057:            }
058:
059:            /**
060:             * {@inheritDoc}
061:             */
062:            public String toString() {
063:                ToStringBuilder buf = new ToStringBuilder(this );
064:                buf.append("type", eventType.toString()).append(
065:                        "source object", getSource());
066:                return buf.toString();
067:            }
068:
069:            /**
070:             * Returns the event type.
071:             * 
072:             * @return The event type
073:             */
074:            public Type getEventType() {
075:                return eventType;
076:            }
077:
078:            /**
079:             * Enum-like class for the event types.
080:             */
081:            public static class Type {
082:                /** Denotes an event that happens before a transaction will be started. */
083:                public static final Type BEFORE_BEGIN = new Type(
084:                        KEY_BEFORE_BEGIN);
085:                /** Denotes an event that happens after a transaction was started. */
086:                public static final Type AFTER_BEGIN = new Type(KEY_AFTER_BEGIN);
087:                /** Denotes an event that happens before a transaction will be comitted. */
088:                public static final Type BEFORE_COMMIT = new Type(
089:                        KEY_BEFORE_COMMIT);
090:                /** Denotes an event that happens after a transaction was comitted. */
091:                public static final Type AFTER_COMMIT = new Type(
092:                        KEY_AFTER_COMMIT);
093:                /** Denotes an event that happens before a transaction will be rolled back. */
094:                public static final Type BEFORE_ROLLBACK = new Type(
095:                        KEY_BEFORE_ROLLBACK);
096:                /** Denotes an event that happens after a transaction was rolled back. */
097:                public static final Type AFTER_ROLLBACK = new Type(
098:                        KEY_AFTER_ROLLBACK);
099:                /** Denotes an event that happens after a broker was opened. */
100:                public static final Type AFTER_OPEN = new Type(KEY_AFTER_OPEN);
101:                /** Denotes an event that happens before the broker will be closed. */
102:                public static final Type BEFORE_CLOSE = new Type(
103:                        KEY_BEFORE_CLOSE);
104:
105:                private int type;
106:
107:                /**
108:                 * Creates a new instance.
109:                 * 
110:                 * @param type The type value
111:                 */
112:                protected Type(int type) {
113:                    this .type = type;
114:                }
115:
116:                /**
117:                 * {@inheritDoc}
118:                 */
119:                public final boolean equals(Object obj) {
120:                    if (obj == this ) {
121:                        return true;
122:                    }
123:                    if (!(obj instanceof  PBStateEvent)) {
124:                        return false;
125:                    }
126:
127:                    return type == ((Type) obj).type;
128:                }
129:
130:                /**
131:                 * {@inheritDoc}
132:                 */
133:                public final int hashCode() {
134:                    return type;
135:                }
136:
137:                /**
138:                 * Returns the type id.
139:                 * 
140:                 * @return The type id
141:                 */
142:                public final int typeId() {
143:                    return type;
144:                }
145:
146:                /**
147:                 * {@inheritDoc}
148:                 */
149:                public String toString() {
150:                    return this .getClass().getName() + " [type= "
151:                            + typeAsName(type) + "]";
152:                }
153:
154:                private String typeAsName(int aType) {
155:                    if (aType == KEY_AFTER_BEGIN) {
156:                        return "AFTER_BEGIN";
157:                    } else if (aType == KEY_AFTER_COMMIT) {
158:                        return "AFTER_COMMIT";
159:                    } else if (aType == KEY_AFTER_OPEN) {
160:                        return "AFTER_OPEN";
161:                    } else if (aType == KEY_AFTER_ROLLBACK) {
162:                        return "AFTER_ROLLBACK";
163:                    } else if (aType == KEY_BEFORE_BEGIN) {
164:                        return "BEFORE_BEGIN";
165:                    } else if (aType == KEY_BEFORE_CLOSE) {
166:                        return "BEFORE_CLOSE";
167:                    } else if (aType == KEY_BEFORE_COMMIT) {
168:                        return "BEFORE_COMMIT";
169:                    } else if (aType == KEY_BEFORE_ROLLBACK) {
170:                        return "BEFORE_ROLLBACK";
171:                    } else {
172:                        throw new OJBRuntimeException("Could not find type "
173:                                + aType);
174:                    }
175:                }
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.