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


001:        /*
002:         * Copyright 2002 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:        package com.sun.portal.portletcontainercommon.descriptor;
014:
015:        import java.io.InputStream;
016:
017:        import java.util.List;
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.logging.Logger;
021:
022:        import org.jdom.Element;
023:        import org.jdom.Namespace;
024:        import com.sun.portal.log.common.PortalLogger;
025:
026:        /**
027:         * The Portlet Application Descriptor is the main entry point of accessing 
028:         * the portlet deployment descriptor. 
029:         * <P>
030:         * The PortletAppDescriptor loads the portlet app descriptors into memory, 
031:         * it delegates the loading of sub descriptors to the individual descriptor 
032:         * classes. The load() method is used to load the portlet app descriptor.
033:         * Note that the load() method also loads the immediate children of the
034:         * portlet app descriptor' by calling their load() methods. 
035:         * <P>
036:         * The PortletAppDescriptor class provides member methods to get to its
037:         * sub descriptors, as well as portlet app name and description. 
038:         * The following get**() methods are available:
039:         * <UL>
040:         *   <LI><code>getPortletsDescriptor()</code>
041:         *   <LI><code>getPortletAppName()</code>
042:         *   <LI><code>getUserAttributeDescriptors()</code>
043:         *   <LI><code>getPortletAppDescription()</code>
044:         *</UL>
045:         *
046:         */
047:        public class PortletAppDescriptor {
048:
049:            // Portlet App Descriptor Element Names
050:            public static final String PORTLET_APP = "portlet-app";
051:            public static final String PORTLET_APP_NAME = "portlet-app-name";
052:            public static final String DESCRIPTION = "description";
053:            public static final String DISPLAY_NAME = "display-name";
054:            public static final String USER_ATTRIBUTE = "user-attribute";
055:            public static final String SECURITY_CONSTRAINT = "security-constraint";
056:            public static final String XML_LANG_ATTR = "lang";
057:
058:            private List _descriptions = new ArrayList();
059:            private List _displayNames = new ArrayList();
060:            private PortletsDescriptor _portletsDescriptor;
061:            private SecurityConstraintDescriptor _secConstraintDescriptor;
062:            private List _userAttributeDescriptors = new ArrayList();
063:            private InputStream _extStream;
064:            private DeploymentExtensionDescriptor _depExtDescriptor;
065:
066:            // Create a logger for this class
067:            private static Logger debugLogger = PortalLogger
068:                    .getLogger(PortletAppDescriptor.class);
069:
070:            public PortletAppDescriptor(Logger logger, InputStream extStream) {
071:                _extStream = extStream;
072:            }
073:
074:            /**
075:             * Loads the portlet app descriptor into memory.
076:             * <P>
077:             * This class only loads the top level elements, it delegates the load 
078:             * action into sub descriptor classes.
079:             * <P>
080:             * @param The root Element of the deployment descriptor document
081:             */
082:            public void load(Element root, Namespace namespace,
083:                    DeploymentDescriptorReader reader)
084:                    throws DeploymentDescriptorException {
085:
086:                List descriptionElements = root.getChildren(DESCRIPTION,
087:                        namespace);
088:                for (Iterator i = descriptionElements.iterator(); i.hasNext();) {
089:                    Element descriptionElement = (Element) i.next();
090:                    _descriptions.add(descriptionElement.getTextTrim());
091:                }
092:
093:                List displayNameElements = root.getChildren(DISPLAY_NAME,
094:                        namespace);
095:                for (Iterator i = displayNameElements.iterator(); i.hasNext();) {
096:                    Element displayNameElement = (Element) i.next();
097:
098:                    _displayNames.add(displayNameElement.getTextTrim());
099:                }
100:
101:                //load deployment extension
102:                if (_extStream != null) {
103:                    _depExtDescriptor = reader
104:                            .loadDeploymentExtensionDescriptor(_extStream);
105:                }
106:
107:                _portletsDescriptor = new PortletsDescriptor(debugLogger,
108:                        _depExtDescriptor);
109:                _portletsDescriptor.load(root, namespace);
110:
111:                // loads user attribute descriptors
112:                List userAttrElements = root.getChildren(USER_ATTRIBUTE,
113:                        namespace);
114:                for (int i = 0; i < userAttrElements.size(); i++) {
115:                    Element userAttrElement = (Element) userAttrElements.get(i);
116:                    UserAttributeDescriptor userAttrDescriptor = new UserAttributeDescriptor(
117:                            debugLogger);
118:                    userAttrDescriptor.load(userAttrElement, namespace);
119:                    _userAttributeDescriptors.add(userAttrDescriptor);
120:                }
121:
122:                // loads security-constraint
123:                Element secConstraintElement = root.getChild(
124:                        SECURITY_CONSTRAINT, namespace);
125:                if (secConstraintElement != null) {
126:                    _secConstraintDescriptor = new SecurityConstraintDescriptor(
127:                            debugLogger);
128:                    _secConstraintDescriptor.load(secConstraintElement,
129:                            namespace);
130:                }
131:
132:            }
133:
134:            /**
135:             * Returns the PortletsDescriptor.
136:             * <P>
137:             * @return PortletsDescriptor
138:             */
139:            public PortletsDescriptor getPortletsDescriptor() {
140:                return _portletsDescriptor;
141:            }
142:
143:            /**
144:             * Returns the UserAttributeDescriptors.
145:             * <P>
146:             * @return <code>List</code> of UserAttributeDescriptors.
147:             */
148:            public List getUserAttributeDescriptors() {
149:                return _userAttributeDescriptors;
150:            }
151:
152:            /**
153:             * Returns the app description as a <code>String</code>. If there's more
154:             * than one descriptions are defined, returns the first one. 
155:             * <P>
156:             * @return <code>String</code> of the description. The return
157:             * value could be null if no description is defined.
158:             */
159:            public String getPortletAppDescription() {
160:                String description = null;
161:                if (!_descriptions.isEmpty()) {
162:                    description = (String) _descriptions.get(0);
163:                }
164:                return description;
165:            }
166:
167:            /**
168:             * Returns the portlet app descriptions.
169:             * <P>
170:             * @return <code>List</code> of the <code>String</code>s. The returned value could 
171:             * be empty list if description is not defined.
172:             */
173:            public List getPortletAppDescriptions() {
174:                return _descriptions;
175:            }
176:
177:            /**
178:             * Returns the portlet app display names.
179:             * <P>
180:             * @return <code>List</code> of <code>String</code>s. The returned value could 
181:             * be empty list if display name is not defined.
182:             */
183:            public List getPortletAppDisplayNames() {
184:                return _displayNames;
185:            }
186:
187:            /**
188:             * Returns the SecurityConstrintDescriptor.
189:             * <P>
190:             * @return SecurityConstraintDescriptor
191:             */
192:            public SecurityConstraintDescriptor getSecurityConstraintDescriptor() {
193:                return _secConstraintDescriptor;
194:            }
195:
196:            /*
197:             * Returns whether the portlet app allows preferences values to be
198:             * saved in the render method.
199:             *
200:             * @return true if preferences can be saved in the render method,
201:             * false if not.
202:             */
203:            public boolean isSavePreferencesAllowed() {
204:                boolean isAllowed = false;
205:
206:                if (_depExtDescriptor != null) {
207:                    isAllowed = _depExtDescriptor.isSavePreferencesAllowed();
208:                }
209:
210:                return isAllowed;
211:
212:            }
213:
214:            public DeploymentExtensionDescriptor getDeploymentExtensionDescriptor() {
215:                return _depExtDescriptor;
216:            }
217:
218:            /**
219:             * The toString method.
220:             * <P>
221:             * @return the <code>String</code> representation of the deployment
222:             * descriptor.
223:             */
224:            public String toString() {
225:                StringBuffer sb = new StringBuffer("PortletAppDescriptor [");
226:
227:                sb.append(" portlet app descriptions [");
228:                Iterator iterator0 = _descriptions.iterator();
229:                while (iterator0.hasNext()) {
230:                    sb.append((String) iterator0.next());
231:                }
232:                sb.append(" ]");
233:
234:                sb.append(" portlet app display names [");
235:                Iterator iterator2 = _displayNames.iterator();
236:                while (iterator2.hasNext()) {
237:                    sb.append((String) iterator2.next());
238:                }
239:                sb.append(" ]");
240:
241:                sb.append(getPortletsDescriptor().toString());
242:
243:                Iterator iterator1 = _userAttributeDescriptors.iterator();
244:                while (iterator1.hasNext()) {
245:                    UserAttributeDescriptor userAttrDescriptor = (UserAttributeDescriptor) iterator1
246:                            .next();
247:                    sb.append(userAttrDescriptor.toString());
248:                    sb.append("\n");
249:                }
250:
251:                sb.append("]");
252:                sb.append(" security constraint description [");
253:                if (_secConstraintDescriptor != null) {
254:                    sb.append(_secConstraintDescriptor.toString());
255:                }
256:
257:                sb.append("]");
258:
259:                return sb.toString();
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.