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


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:        package org.apache.openjpa.kernel;
020:
021:        import java.util.Properties;
022:
023:        import org.apache.openjpa.conf.OpenJPAConfiguration;
024:        import org.apache.openjpa.util.RuntimeExceptionTranslator;
025:
026:        ///////////////////////////////////////////////////////////////
027:        // NOTE: when adding a public API method, be sure to add it to 
028:        // JDO and JPA facades!
029:        ///////////////////////////////////////////////////////////////
030:
031:        /**
032:         * Delegating broker factory that can also perform exception translation
033:         * for use in facades.
034:         *
035:         * @since 0.4.0
036:         * @author Abe White
037:         * @nojavadoc
038:         */
039:        public class DelegatingBrokerFactory implements  BrokerFactory {
040:
041:            private final BrokerFactory _factory;
042:            private final DelegatingBrokerFactory _del;
043:            private final RuntimeExceptionTranslator _trans;
044:
045:            /**
046:             * Constructor; supply delegate.
047:             */
048:            public DelegatingBrokerFactory(BrokerFactory factory) {
049:                this (factory, null);
050:            }
051:
052:            /**
053:             * Constructor; supply delegate and exception translator.
054:             */
055:            public DelegatingBrokerFactory(BrokerFactory factory,
056:                    RuntimeExceptionTranslator trans) {
057:                _factory = factory;
058:                if (factory instanceof  DelegatingBrokerFactory)
059:                    _del = (DelegatingBrokerFactory) factory;
060:                else
061:                    _del = null;
062:                _trans = trans;
063:            }
064:
065:            /**
066:             * Return the direct delegate.
067:             */
068:            public BrokerFactory getDelegate() {
069:                return _factory;
070:            }
071:
072:            /**
073:             * Return the native delegate.
074:             */
075:            public BrokerFactory getInnermostDelegate() {
076:                return (_del == null) ? _factory : _del.getInnermostDelegate();
077:            }
078:
079:            public int hashCode() {
080:                return getInnermostDelegate().hashCode();
081:            }
082:
083:            public boolean equals(Object other) {
084:                if (other == this )
085:                    return true;
086:                if (other instanceof  DelegatingBrokerFactory)
087:                    other = ((DelegatingBrokerFactory) other)
088:                            .getInnermostDelegate();
089:                return getInnermostDelegate().equals(other);
090:            }
091:
092:            /**
093:             * Translate the OpenJPA exception.
094:             */
095:            protected RuntimeException translate(RuntimeException re) {
096:                return (_trans == null) ? re : _trans.translate(re);
097:            }
098:
099:            public OpenJPAConfiguration getConfiguration() {
100:                try {
101:                    return _factory.getConfiguration();
102:                } catch (RuntimeException re) {
103:                    throw translate(re);
104:                }
105:            }
106:
107:            public Properties getProperties() {
108:                try {
109:                    return _factory.getProperties();
110:                } catch (RuntimeException re) {
111:                    throw translate(re);
112:                }
113:            }
114:
115:            public Object putUserObject(Object key, Object val) {
116:                try {
117:                    return _factory.putUserObject(key, val);
118:                } catch (RuntimeException re) {
119:                    throw translate(re);
120:                }
121:            }
122:
123:            public Object getUserObject(Object key) {
124:                try {
125:                    return _factory.getUserObject(key);
126:                } catch (RuntimeException re) {
127:                    throw translate(re);
128:                }
129:            }
130:
131:            public Broker newBroker() {
132:                try {
133:                    return _factory.newBroker();
134:                } catch (RuntimeException re) {
135:                    throw translate(re);
136:                }
137:            }
138:
139:            public Broker newBroker(String user, String pass, boolean managed,
140:                    int connRetainMode, boolean findExisting) {
141:                try {
142:                    return _factory.newBroker(user, pass, managed,
143:                            connRetainMode, findExisting);
144:                } catch (RuntimeException re) {
145:                    throw translate(re);
146:                }
147:            }
148:
149:            public void addLifecycleListener(Object listener, Class[] classes) {
150:                try {
151:                    _factory.addLifecycleListener(listener, classes);
152:                } catch (RuntimeException re) {
153:                    throw translate(re);
154:                }
155:            }
156:
157:            public void removeLifecycleListener(Object listener) {
158:                try {
159:                    _factory.removeLifecycleListener(listener);
160:                } catch (RuntimeException re) {
161:                    throw translate(re);
162:                }
163:            }
164:
165:            public void addTransactionListener(Object listener) {
166:                try {
167:                    _factory.addTransactionListener(listener);
168:                } catch (RuntimeException re) {
169:                    throw translate(re);
170:                }
171:            }
172:
173:            public void removeTransactionListener(Object listener) {
174:                try {
175:                    _factory.removeTransactionListener(listener);
176:                } catch (RuntimeException re) {
177:                    throw translate(re);
178:                }
179:            }
180:
181:            public void close() {
182:                try {
183:                    _factory.close();
184:                } catch (RuntimeException re) {
185:                    throw translate(re);
186:                }
187:            }
188:
189:            public boolean isClosed() {
190:                try {
191:                    return _factory.isClosed();
192:                } catch (RuntimeException re) {
193:                    throw translate(re);
194:                }
195:            }
196:
197:            public void lock() {
198:                try {
199:                    _factory.lock();
200:                } catch (RuntimeException re) {
201:                    throw translate(re);
202:                }
203:            }
204:
205:            public void unlock() {
206:                try {
207:                    _factory.unlock();
208:                } catch (RuntimeException re) {
209:                    throw translate(re);
210:                }
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.