Source Code Cross Referenced for ProducerEntityManagerFactory.java in  » Portal » Open-Portal » com » sun » portal » wsrp » consumer » producermanager » 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 » Portal » Open Portal » com.sun.portal.wsrp.consumer.producermanager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2003 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.wsrp.consumer.producermanager;
013:
014:        import java.util.logging.Level;
015:        import java.util.logging.Logger;
016:
017:        import javax.servlet.http.HttpServletRequest;
018:
019:        import com.iplanet.sso.SSOToken;
020:
021:        import com.sun.portal.wsrp.consumer.common.WSRPConsumerConfig;
022:        import com.sun.portal.wsrp.consumer.common.WSRPConsumerException;
023:        import com.sun.portal.log.common.PortalLogger;
024:
025:        /**
026:         * <code>ProducerEntityManagerFactory</code> is a singleton class which
027:         * provides methods for obtaining the <code>ProducerEntityManager</code>.
028:         */
029:        public class ProducerEntityManagerFactory {
030:
031:            private ProducerEntityManagerFactory() {
032:            }
033:
034:            //
035:            // static instance
036:            //
037:            private static ProducerEntityManagerFactory pemFactory = null;
038:
039:            private static Logger logger = PortalLogger
040:                    .getLogger(ProducerEntityManagerFactory.class);
041:
042:            //
043:            // TBD: caching of each PEM instances
044:            //
045:
046:            /**
047:             * Initialize static instance of ProducerEntityManagerFactory.
048:             */
049:            public static void init() {
050:                //
051:                // init pemFactory instance
052:                //
053:                pemFactory = new ProducerEntityManagerFactory();
054:
055:            }
056:
057:            /**
058:             * Get a static instance of ProducerEntityManagerFactory.  It's assumed
059:             * that init() has already been called.
060:             *
061:             * @return a <code>ProducerEntityManagerFactory</code> instance.
062:             */
063:            public static ProducerEntityManagerFactory getInstance() {
064:                if (pemFactory == null) {
065:                    init();
066:                }
067:                return pemFactory;
068:            }
069:
070:            /**
071:             * Get an instance of ProducerEntityManager from a servlet.
072:             *
073:             * @param consumerId a <code>String</code> value identifying the consumer entity.
074:             * @param request a <code>HttpServletRequest</code> to be used for establishing user context.
075:             * @return a <code>ProducerEntityManager</code> value
076:             * @exception WSRPConsumerException if an error occurs
077:             */
078:            public ProducerEntityManager getProducerEntityManager(
079:                    String consumerId, HttpServletRequest request)
080:                    throws WSRPConsumerException {
081:
082:                if (logger.isLoggable(Level.FINEST)) {
083:                    String[] param = { "consumerId", consumerId };
084:                    logger.log(Level.FINEST, "PSWS_CSPWCP00001", param);
085:                }
086:
087:                WSRPConsumerConfig config = WSRPConsumerConfig.getInstance();
088:
089:                String pemClassname = config
090:                        .getProducerEntityManagerClassname();
091:                ProducerEntityManager pem = loadProducerEntityManagerClass(pemClassname);
092:                pem.init(consumerId, request);
093:
094:                return pem;
095:            }
096:
097:            /**
098:             * Get an instance of ProducerEntityManager using credentials supplied
099:             * in a form of username and password.
100:             *
101:             * @param consumerId a <code>String</code> value identifying the consumer entity
102:             * @param username user id for establishing user context
103:             * @param password user password for establishing user context
104:             * @return a <code>ProducerEntityManager</code> value
105:             * @exception WSRPConsumerException if an error occurs
106:             */
107:            public ProducerEntityManager getProducerEntityManager(
108:                    String consumerId, String username, String password)
109:                    throws WSRPConsumerException {
110:
111:                if (logger.isLoggable(Level.FINEST)) {
112:                    String[] param = { "consumerId", consumerId };
113:                    logger.log(Level.FINEST, "PSWS_CSPWCP00001", param);
114:                    param[0] = "username";
115:                    param[1] = username;
116:                    logger.log(Level.FINEST, "PSWS_CSPWCP00001", param);
117:                }
118:
119:                WSRPConsumerConfig config = WSRPConsumerConfig.getInstance();
120:
121:                String pemClassname = config
122:                        .getProducerEntityManagerClassname();
123:                ProducerEntityManager pem = loadProducerEntityManagerClass(pemClassname);
124:                pem.init(consumerId, username, password);
125:
126:                return pem;
127:            }
128:
129:            /**
130:             * Get an instance of ProducerEntityManager using credentials supplied
131:             * in a form of SSOToken.
132:             *
133:             * @param ssoToken a <code>SSOToken</code> 
134:             * @param portalId a <code>String</code> value identifying the portal
135:             * @param consumerId value identifying the consumer entity
136:             * @return a <code>ProducerEntityManager</code> value
137:             * @exception WSRPConsumerException if an error occurs
138:             */
139:            public ProducerEntityManager getProducerEntityManager(
140:                    SSOToken ssoToken, String portalId, String consumerId)
141:                    throws WSRPConsumerException {
142:
143:                if (logger.isLoggable(Level.FINEST)) {
144:                    String[] param = { "portalId", portalId };
145:                    logger.log(Level.FINEST, "PSWS_CSPWCP00001", param);
146:                    param[0] = "consumerId";
147:                    param[1] = consumerId;
148:                    logger.log(Level.FINEST, "PSWS_CSPWCP00001", param);
149:                }
150:
151:                WSRPConsumerConfig config = WSRPConsumerConfig.getInstance();
152:
153:                String pemClassname = config
154:                        .getProducerEntityManagerClassname();
155:                ProducerEntityManager pem = loadProducerEntityManagerClass(pemClassname);
156:                pem.init(ssoToken, portalId, consumerId);
157:
158:                return pem;
159:            }
160:
161:            protected ProducerEntityManager loadProducerEntityManagerClass(
162:                    String classname) throws WSRPConsumerException {
163:
164:                ProducerEntityManager pem = null;
165:                try {
166:                    pem = (ProducerEntityManager) (Class.forName(classname)
167:                            .newInstance());
168:                } catch (ClassNotFoundException cnfe) {
169:                    throw new WSRPConsumerException(
170:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
171:                            cnfe);
172:                } catch (NoClassDefFoundError ncdfe) {
173:                    throw new WSRPConsumerException(
174:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
175:                            ncdfe);
176:                } catch (IllegalAccessException iae) {
177:                    throw new WSRPConsumerException(
178:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
179:                            iae);
180:                } catch (ClassCastException cce) {
181:                    throw new WSRPConsumerException(
182:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
183:                            cce);
184:                } catch (InstantiationException ie) {
185:                    throw new WSRPConsumerException(
186:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
187:                            ie);
188:                } catch (SecurityException se) {
189:                    throw new WSRPConsumerException(
190:                            "ProducerEntityManagerFactory.loadProducerEntityMangerClass(): failed to load PEM class.",
191:                            se);
192:                }
193:                return pem;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.