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


001:        /*
002:         * Copyright 2004 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:         */
013:
014:        package com.sun.portal.subscriptions.context;
015:
016:        import java.util.Map;
017:        import java.util.HashMap;
018:        import com.sun.portal.admin.common.util.AdminUtil;
019:
020:        public class DSAMEMultiPortalConstants implements  DSAMEConstants {
021:
022:            // Attribute Prefix
023:
024:            public String MP_ATTR_PREFIX = ATTR_PREFIX;
025:
026:            //
027:            // Service Names
028:            //
029:
030:            public String MP_SUN_SUBSCRIPTION_SERVICE = "SunPortalSubscriptionsService";
031:
032:            //
033:            // dynamic Attributes
034:            //
035:
036:            public String MP_ATTR_MAX_CATEGORY_SUBSCRIPTIONS = ATTR_PREFIX
037:                    + "MaxCategorySubscriptions";
038:
039:            public String MP_ATTR_MAX_DISCUSSION_SUBSCRIPTIONS = ATTR_PREFIX
040:                    + "MaxDiscussionSubscriptions";
041:
042:            public String MP_ATTR_MAX_SAVED_SEARCH = ATTR_PREFIX
043:                    + "MaxSavedSearch";
044:
045:            //
046:            // User Attributes
047:            //
048:
049:            public String MP_ATTR_CATEGORY_SUBSCRIPTIONS = ATTR_PREFIX
050:                    + "CategorySubscriptions";
051:
052:            public String MP_ATTR_DISCUSSION_SUBSCRIPTIONS = ATTR_PREFIX
053:                    + "DiscussionSubscriptions";
054:
055:            public String MP_ATTR_SAVED_SEARCH = ATTR_PREFIX + "SavedSearch";
056:
057:            public String MP_ATTR_PROFILER_LAST_RUN = ATTR_PREFIX
058:                    + "ProfilerLastRun";
059:
060:            public String MP_ATTR_PROFILER_ENABLED = ATTR_PREFIX
061:                    + "ProfilerEnabled";
062:
063:            /*
064:             * HashMap permits null values and the null key.
065:             */
066:            private static Map instances = new HashMap(2);
067:
068:            /*
069:             * Always holds the id of the first instance created.
070:             * This is used only during the getInstance with no args.
071:             * The only use this has, is to avoid the cost of getting the 
072:             * key set from the map and then iterating thru the set to 
073:             * get the poralId when only one entry exists.
074:             */
075:            private static String loneId = null;
076:
077:            /*
078:             * DSAMEMultiPortalConstants
079:             */
080:            private DSAMEMultiPortalConstants(String id) {
081:                if (id != null && id.length() != 0) {
082:                    id = id.trim();
083:                    // Every portal MUST have a valid portal id
084:                    validateId(id);
085:                    // In case of an upgraded portal, the service and attrs do 
086:                    // not have a portal id in their names
087:                    if (!id.equals(AdminUtil.UPGRADED_PORTAL)) {
088:                        MP_SUN_SUBSCRIPTION_SERVICE = "SunPortal" + id
089:                                + "SubscriptionsService";
090:                        MP_ATTR_PREFIX = "sunPortal" + id;
091:                        MP_ATTR_MAX_CATEGORY_SUBSCRIPTIONS = MP_ATTR_PREFIX
092:                                + "MaxCategorySubscriptions";
093:                        MP_ATTR_MAX_DISCUSSION_SUBSCRIPTIONS = MP_ATTR_PREFIX
094:                                + "MaxDiscussionSubscriptions";
095:                        MP_ATTR_MAX_SAVED_SEARCH = MP_ATTR_PREFIX
096:                                + "MaxSavedSearch";
097:                        MP_ATTR_CATEGORY_SUBSCRIPTIONS = MP_ATTR_PREFIX
098:                                + "CategorySubscriptions";
099:                        MP_ATTR_DISCUSSION_SUBSCRIPTIONS = MP_ATTR_PREFIX
100:                                + "DiscussionSubscriptions";
101:                        MP_ATTR_SAVED_SEARCH = MP_ATTR_PREFIX + "SavedSearch";
102:                        MP_ATTR_PROFILER_LAST_RUN = MP_ATTR_PREFIX
103:                                + "ProfilerLastRun";
104:                        MP_ATTR_PROFILER_ENABLED = MP_ATTR_PREFIX
105:                                + "ProfilerEnabled";
106:                    }
107:                }
108:            }
109:
110:            /*
111:             * createInstance
112:             */
113:            public static synchronized void createInstance(String id) {
114:                if (!instances.containsKey(id)) {
115:                    instances.put(id, new DSAMEMultiPortalConstants(id));
116:                    if (instances.size() == 1) {
117:                        loneId = id;
118:                    }
119:                }
120:            }
121:
122:            /*
123:             * For the subscription code, there is always only one instance of
124:             * this class since each portal runs in its own JVM. This method
125:             * returns such instance which has been created using createInstance.
126:             * It throws a ContextError if no instance exists or if more than one
127:             * instances exist. So ideally, there will be only one instance in
128:             * existance if this class is being properly used in the desktop
129:             * code.
130:             */
131:            public static DSAMEMultiPortalConstants getInstance() {
132:                int n = instances.size();
133:                if (n == 0) {
134:                    throw new ContextError("Instance does not exist");
135:                } else if (n > 1) {
136:                    throw new ContextError("Invalid use of getInstance: "
137:                            + " More than one instance exists");
138:                }
139:                return (DSAMEMultiPortalConstants) instances.get(loneId);
140:            }
141:
142:            /*
143:             * The subscription code executes in VM in which there is only one
144:             * portal. Thus there is a single instance of this 
145:             * class which gets initialized at the servlet init time. 
146:             * Once initialized, this never changes during the lifetime of that VM.
147:             * But in case of admin mbeans, the situation is different. Different 
148:             * mbeans belonging to different portals run in the same JVM of the cacao
149:             * server. Each mbean knows which portal it belongs to and hence can
150:             * request an instance of this class initialized for a specific portal.
151:             * So this method is used by the mbeans to get a specific instance. The rule 
152:             * to use this method still remains same, that is, one MUST first create
153:             * an instance before trying to get it, otherwise a ContextError is 
154:             * thrown.
155:             */
156:            public static DSAMEMultiPortalConstants getInstance(String id) {
157:                if (!instances.containsKey(id)) {
158:                    throw new ContextError("Instance does not exist");
159:                }
160:                return (DSAMEMultiPortalConstants) instances.get(id);
161:            }
162:
163:            /*
164:             * portalId may contain only letters, digits and hyphen.
165:             *
166:             * @throws ContextError if the identifier is invalid
167:             */
168:            private void validateId(String id) {
169:                if (id.matches(".*[^a-zA-Z0-9-].*")) {
170:                    throw new ContextError("Invalid portal identifier");
171:                }
172:            }
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.