Source Code Cross Referenced for GenericTransactionManagerLookupFactory.java in  » ESB » mule » org » mule » transaction » lookup » 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 » mule » org.mule.transaction.lookup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: GenericTransactionManagerLookupFactory.java 11244 2008-03-07 05:06:27Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.transaction.lookup;
012:
013:        import org.mule.api.lifecycle.Initialisable;
014:        import org.mule.api.lifecycle.InitialisationException;
015:        import org.mule.api.lifecycle.LifecycleTransitionResult;
016:        import org.mule.api.transaction.TransactionManagerFactory;
017:        import org.mule.config.i18n.CoreMessages;
018:        import org.mule.util.JndiContextHelper;
019:        import org.mule.util.StringUtils;
020:
021:        import java.util.Map;
022:
023:        import javax.naming.Context;
024:        import javax.naming.NamingException;
025:        import javax.transaction.TransactionManager;
026:
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:
030:        /**
031:         * A factory performing a JNDI lookup for TransactionManager. <p/> NOTE: Java EE 1.4
032:         * specification does not mandate application server vendors to expose a
033:         * TransactionManager for direct use, nor does it name the standard way to locate it.
034:         * For some servers the TransactionManager is not even available in the global JNDI
035:         * namespace, so your only bet is to run Mule in the same JVM as the application
036:         * server.
037:         */
038:        public class GenericTransactionManagerLookupFactory implements 
039:                TransactionManagerFactory, Initialisable {
040:            protected final Log logger = LogFactory.getLog(getClass());
041:
042:            protected Context context;
043:
044:            private Map environment;
045:
046:            private TransactionManager txManager;
047:
048:            private String jndiName;
049:
050:            public String getJndiName() {
051:                return jndiName;
052:            }
053:
054:            public void setJndiName(final String jndiName) {
055:                this .jndiName = jndiName;
056:            }
057:
058:            public TransactionManager getTxManager() {
059:                return txManager;
060:            }
061:
062:            public void setTxManager(final TransactionManager txManager) {
063:                this .txManager = txManager;
064:            }
065:
066:            public Map getEnvironment() {
067:                return environment;
068:            }
069:
070:            public void setEnvironment(final Map environment) {
071:                this .environment = environment;
072:            }
073:
074:            public Context getContext() {
075:                return context;
076:            }
077:
078:            public void setContext(final Context context) {
079:                this .context = context;
080:            }
081:
082:            /** @see org.mule.api.transaction.TransactionManagerFactory#create() */
083:            public TransactionManager create() throws Exception {
084:                // implementing the Initilisable interface does not call it??
085:                initialise();
086:                if (txManager == null) {
087:                    txManager = (TransactionManager) context.lookup(jndiName);
088:                }
089:
090:                return txManager;
091:            }
092:
093:            /**
094:             * Method used to perform any initialisation work. If a fatal error occurs during
095:             * initialisation an <code>InitialisationException</code> should be thrown,
096:             * causing the Mule instance to shutdown. If the error is recoverable, say by
097:             * retrying to connect, a <code>RecoverableException</code> should be thrown.
098:             * There is no guarantee that by throwing a Recoverable exception that the Mule
099:             * instance will not shut down.
100:             *
101:             * @throws org.mule.api.lifecycle.InitialisationException
102:             *          if a fatal error occurs
103:             *          causing the Mule instance to shutdown
104:             */
105:            public LifecycleTransitionResult initialise()
106:                    throws InitialisationException {
107:                if (txManager == null
108:                        && StringUtils.isEmpty(StringUtils.trim(jndiName))) {
109:                    throw new InitialisationException(CoreMessages
110:                            .propertiesNotSet("jndiName"), this );
111:                }
112:
113:                try {
114:                    if (context == null) {
115:                        context = JndiContextHelper
116:                                .initialise(getEnvironment());
117:                    }
118:                } catch (NamingException e) {
119:                    throw new InitialisationException(CoreMessages
120:                            .failedToCreate("Jndi context"), e, this);
121:                }
122:                return LifecycleTransitionResult.OK;
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.