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


001:        /**
002:         * $Id: DSAMEMultiPortalConstants.java,v 1.6 2005/10/20 17:01:50 jtb Exp $
003:         * Copyright 2004 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.desktop.context;
014:
015:        import java.util.Map;
016:        import java.util.HashMap;
017:        import com.sun.portal.admin.common.util.AdminUtil;
018:
019:        public class DSAMEMultiPortalConstants implements  DSAMEConstants {
020:
021:            private static Map instances = new HashMap(2);
022:
023:            /**
024:             * Always holds the id of the first instance created.
025:             * This is used only during the getInstance with no args.
026:             * The only use this has, is to avoid the cost of getting the 
027:             * key set from the map and then iterating thru the set to 
028:             * get the poralId when only one entry exists.
029:             */
030:            private static String loneId = null;
031:
032:            private DSAMEMultiPortalConstants(String id) {
033:                //Every portal MUST have a valid portal id.
034:                validateId(id);
035:                //In case of an upgraded portal, the service and attrs do
036:                //not have a portal id in their names
037:                if (!id.equals(AdminUtil.UPGRADED_PORTAL)) {
038:                    id = id.trim();
039:                    MP_ATTR_PREFIX = "sunPortal" + id + "Desktop";
040:                    MP_SUN_DESKTOP_SERVICE = "SunPortal" + id
041:                            + "DesktopService";
042:                    MP_SUN_DESKTOP_OBJECT_CLASS = "SunPortal" + id
043:                            + "DesktopPerson";
044:                    MP_ATTR_DEFAULTCHANNELNAME = MP_ATTR_PREFIX
045:                            + "DefaultChannelName";
046:                    MP_ATTR_EDITPROVIDERCONTAINERNAME = MP_ATTR_PREFIX
047:                            + "EditProviderContainerName";
048:                    MP_ATTR_COMMUNITY_PARENT_CONTAINER_URL_PARAMETER = MP_ATTR_PREFIX
049:                            + "CommunityParentContainerURLParameter";
050:                    MP_ATTR_COMMUNITY_HOME_CONTAINER_NAME = MP_ATTR_PREFIX
051:                            + "CommunityHomeContainerName";
052:                    MP_ATTR_COMMUNITY_CREATE_CONTAINER_NAME = MP_ATTR_PREFIX
053:                            + "CommunityCreateContainerName";
054:
055:                    MP_ATTR_DESKTOP_TYPE = MP_ATTR_PREFIX + "Type";
056:                    MP_ATTR_DP_DOCUMENT_USER = MP_ATTR_PREFIX
057:                            + "DpDocumentUser";
058:                    MP_ATTR_DP_LAST_MODIFIED_USER = MP_ATTR_PREFIX
059:                            + "DpLastModifiedUser";
060:                }
061:            }
062:
063:            /**
064:             * portalId may contain only letters, digits and hyphen.
065:             *
066:             * @throws ContextError if the identifier is invalid
067:             */
068:            private void validateId(String id) {
069:                if (id == null || id.length() == 0) {
070:                    throw new ContextError("Invalid portal identifier");
071:                } else if (id.matches(".*[^a-zA-Z0-9-].*")) {
072:                    throw new ContextError("Invalid portal identifier");
073:                }
074:            }
075:
076:            /**
077:             * The prefix MP indicates MULTI_PORTAL
078:             * Conventionally, the identifiers should be lower case as they are not
079:             * being set in the static initilizers. But practically these are
080:             * constants for a portal server instance, hence the capitalization.
081:             */
082:
083:            // Attribute Prefix
084:            public String MP_ATTR_PREFIX = ATTR_PREFIX;
085:
086:            //
087:            // Service Names
088:            //
089:            public String MP_SUN_DESKTOP_SERVICE = "SunPortalDesktopService";
090:
091:            public String MP_SUN_DESKTOP_OBJECT_CLASS = "SunPortalDesktopPerson";
092:
093:            //
094:            // Dynamic Attributes
095:            //
096:            public String MP_ATTR_DEFAULTCHANNELNAME = ATTR_PREFIX
097:                    + "DefaultChannelName";
098:
099:            public String MP_ATTR_EDITPROVIDERCONTAINERNAME = ATTR_PREFIX
100:                    + "EditProviderContainerName";
101:
102:            public String MP_ATTR_COMMUNITY_PARENT_CONTAINER_URL_PARAMETER = ATTR_PREFIX
103:                    + "CommunityParentContainerURLParameter";
104:
105:            public String MP_ATTR_COMMUNITY_HOME_CONTAINER_NAME = ATTR_PREFIX
106:                    + "CommunityHomeContainerName";
107:
108:            public String MP_ATTR_COMMUNITY_CREATE_CONTAINER_NAME = ATTR_PREFIX
109:                    + "CommunityCreateContainerName";
110:
111:            public String MP_ATTR_DESKTOP_TYPE = ATTR_PREFIX + "Type";
112:
113:            //
114:            // User Attributes
115:            //
116:            public String MP_ATTR_DP_DOCUMENT_USER = ATTR_PREFIX
117:                    + "DpDocumentUser";
118:
119:            public String MP_ATTR_DP_LAST_MODIFIED_USER = ATTR_PREFIX
120:                    + "DpLastModifiedUser";
121:
122:            //
123:            // instance management
124:            //
125:
126:            public static synchronized void createInstance(String id) {
127:                if (!instances.containsKey(id)) {
128:                    instances.put(id, new DSAMEMultiPortalConstants(id));
129:                    if (instances.size() == 1) {
130:                        loneId = id;
131:                    }
132:                }
133:            }
134:
135:            /**
136:             * For the desktop code, there is always only one instance of this class
137:             * since each portal runs in its own JVM. This method returns such 
138:             * instance which has been created using createInstance. It throws a
139:             * ContextError if no instance exists or if more than one instances
140:             * exist. So ideally, there will be only one instance in existance
141:             * if this class is being properly used in the desktop code.
142:             */
143:            public static DSAMEMultiPortalConstants getInstance() {
144:                int n = instances.size();
145:                if (n == 0) {
146:                    throw new ContextError("Instance does not exist");
147:                } else if (n > 1) {
148:                    throw new ContextError("Invalid use of getInstance: "
149:                            + " More than one instance exists");
150:                }
151:                return (DSAMEMultiPortalConstants) instances.get(loneId);
152:            }
153:
154:            /**
155:             * The desktop code executes in VM in which there is only one
156:             * portal. Thus there is a single instance of this 
157:             * class which gets initialized at the servlet init time. 
158:             * Once initialized, this never changes during the lifetime of that VM.
159:             * But in case of admin mbeans, the situation is different. Different 
160:             * mbeans belonging to different portals run in the same JVM of the cacao
161:             * server. Each mbean knows which portal it belongs to and hence can
162:             * request an instance of this class initialized for a specific portal.
163:             * So this method is used by the mbeans to get a specific instance. The rule 
164:             * to use this method still remains same, that is, one MUST first create
165:             * an instance before trying to get it, otherwise a ContextError is 
166:             * thrown.
167:             */
168:            public static DSAMEMultiPortalConstants getInstance(String id) {
169:                if (!instances.containsKey(id)) {
170:                    throw new ContextError("Instance does not exist");
171:                }
172:                return (DSAMEMultiPortalConstants) instances.get(id);
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.