Source Code Cross Referenced for GroupServiceConfiguration.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » groups » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal.groups 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2002 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.groups;
007:
008:        import java.util.ArrayList;
009:        import java.util.HashMap;
010:        import java.util.List;
011:        import java.util.Map;
012:
013:        import javax.xml.parsers.SAXParserFactory;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:        import org.jasig.portal.utils.ResourceLoader;
018:        import org.xml.sax.Attributes;
019:        import org.xml.sax.InputSource;
020:        import org.xml.sax.XMLReader;
021:
022:        /**
023:         * Parses service descriptions found in the file found at SERVICES_XML.  The
024:         * elements of each service are stored in a ComponentGroupServiceDescriptor.
025:         *
026:         * @author Dan Ellentuck
027:         * @version $Revision: 34758 $
028:         */
029:        public class GroupServiceConfiguration {
030:            private static final Log log = LogFactory
031:                    .getLog(GroupServiceConfiguration.class);
032:
033:            // The file containing the configuration:
034:            private static String SERVICES_XML = "/properties/groups/compositeGroupServices.xml";
035:
036:            // Singleton instance.
037:            private static GroupServiceConfiguration configuration;
038:
039:            private GroupConfigurationHandler serviceHandler;
040:            private List serviceDescriptors = new ArrayList();
041:            private Map attributes = new HashMap();
042:
043:            // Handler for parsing the xml source.
044:            class GroupConfigurationHandler extends
045:                    org.xml.sax.helpers.DefaultHandler {
046:                ComponentGroupServiceDescriptor svcDescriptor;
047:                String elementName;
048:                StringBuffer elementValue;
049:
050:                public void startElement(String namespaceURI, String localName,
051:                        String qName, Attributes atts) {
052:                    elementName = qName;
053:                    elementValue = new StringBuffer();
054:
055:                    if (qName.equals("servicelist")) {
056:                        infoMessage("Parsing group service configuration.");
057:                        parseAttributes(atts);
058:                    } else if (qName.equals("service")) {
059:                        debugMessage("Parsing configuration for component service.");
060:                        svcDescriptor = new ComponentGroupServiceDescriptor();
061:                        for (int i = 0; i < atts.getLength(); i++) {
062:                            String name = atts.getQName(i);
063:                            String value = atts.getValue(i);
064:                            svcDescriptor.put(name, value);
065:                        }
066:                    }
067:                }
068:
069:                public void endElement(String namespaceURI, String localName,
070:                        String qName) {
071:                    String val = elementValue.toString();
072:                    if (qName.equals("service")) {
073:                        serviceDescriptors.add(svcDescriptor);
074:                        debugMessage("Parsed configuration for "
075:                                + svcDescriptor.getName());
076:                    } else if (qName.equals("servicelist")) {
077:                        debugMessage("Done parsing group service configuration.");
078:                    } else if (qName.equals("internally_managed")) {
079:                        svcDescriptor.setInternallyManaged("TRUE"
080:                                .equalsIgnoreCase(val));
081:                    } else if (qName.equals("caching_enabled")) {
082:                        svcDescriptor.setCachingEnabled("TRUE"
083:                                .equalsIgnoreCase(val));
084:                    } else {
085:                        svcDescriptor.setAttribute(elementName, val);
086:                    }
087:                }
088:
089:                public void characters(char ch[], int start, int length) {
090:                    if (elementName == null || elementName.equals("service")
091:                            || elementName.equals("servicelist"))
092:                        return;
093:                    String chValue = new String(ch, start, length);
094:                    elementValue.append(chValue);
095:                }
096:            }
097:
098:            public GroupServiceConfiguration() {
099:                super ();
100:                serviceHandler = new GroupConfigurationHandler();
101:            }
102:
103:            /**
104:             * Record a message at "Debug" level.
105:             * @deprecated see comment inside method
106:             */
107:            protected void debugMessage(String msg) {
108:                /*
109:                 * This method is not in keeping with best practices.
110:                 * Prepending "Group services:" to the message is unnecessary because
111:                 * Commons Logging is capable of reporting from where the logging message
112:                 * originated when configured to do so.  The org.jasig.portal.groups package 
113:                 * in its entirety can be mapped to its own logger.
114:                 * Logging directly allows instutions wishing to take the performance hit of
115:                 * doing so to configure log4j to report from exactly what line of code
116:                 * each logging message originates.  Going through this method causes all
117:                 * such messages to appear to come from here rather than from whereever
118:                 * this method is being invoked from.
119:                 */
120:                log.debug("Group services: " + msg);
121:            }
122:
123:            /**
124:             *
125:             */
126:            public Map getAttributes() {
127:                return attributes;
128:            }
129:
130:            public static synchronized GroupServiceConfiguration getConfiguration()
131:                    throws Exception {
132:                if (configuration == null) {
133:                    configuration = new GroupServiceConfiguration();
134:                    configuration.parseXml();
135:                }
136:                return configuration;
137:            }
138:
139:            /**
140:             *
141:             */
142:            public String getDefaultService() {
143:                return (String) getAttributes().get("defaultService");
144:            }
145:
146:            /**
147:             *
148:             */
149:            public String getNodeSeparator() {
150:                Object nodeSeparator = getAttributes().get("nodeSeparator");
151:                return (nodeSeparator == null) ? IGroupConstants.NODE_SEPARATOR
152:                        : (String) nodeSeparator;
153:            }
154:
155:            public List getServiceDescriptors() {
156:                return serviceDescriptors;
157:            }
158:
159:            /**
160:             * Record a message at "info" level.
161:             * @deprecated see comment inside method
162:             */
163:            protected void infoMessage(String msg) {
164:                /*
165:                 * This method is not in keeping with best practices.
166:                 * Prepending "Group services:" to the message is unnecessary because
167:                 * Commons Logging is capable of reporting from where the logging message
168:                 * originated when configured to do so.  The org.jasig.portal.groups package 
169:                 * in its entirety can be mapped to its own logger.
170:                 * Logging directly allows instutions wishing to take the performance hit of
171:                 * doing so to configure log4j to report from exactly what line of code
172:                 * each logging message originates.  Going through this method causes all
173:                 * such messages to appear to come from here rather than from whereever
174:                 * this method is being invoked from.
175:                 */
176:                log.info("Group services: " + msg);
177:            }
178:
179:            /**
180:             *
181:             */
182:            protected void parseAttributes(Attributes atts) {
183:                String name, value;
184:                for (int i = 0; i < atts.getLength(); i++) {
185:                    name = atts.getQName(i);
186:                    value = atts.getValue(i);
187:                    getAttributes().put(name, value);
188:                }
189:            }
190:
191:            protected void parseXml() throws Exception {
192:                InputSource xmlSource = new InputSource(ResourceLoader
193:                        .getResourceAsStream(GroupServiceConfiguration.class,
194:                                SERVICES_XML));
195:
196:                if (xmlSource != null) {
197:                    XMLReader reader = SAXParserFactory.newInstance()
198:                            .newSAXParser().getXMLReader();
199:                    reader.setContentHandler(serviceHandler);
200:                    reader.parse(xmlSource);
201:                }
202:            }
203:
204:            public static synchronized void reset() {
205:                configuration = null;
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.