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


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.rewriter.rom;
006:
007:        import com.sun.portal.rewriter.services.DataService;
008:        import com.sun.portal.rewriter.services.DataServiceException;
009:        import com.sun.portal.rewriter.util.Debug;
010:        import com.sun.portal.rewriter.util.Resource;
011:        import com.sun.portal.rewriter.util.collections.TypedHashCache;
012:        import com.sun.portal.rewriter.util.xml.Document;
013:
014:        import org.xml.sax.SAXException;
015:
016:        import java.io.FileReader;
017:        import java.io.Reader;
018:        import java.util.Set;
019:
020:        /**
021:         * Wrapper class to be used by admin module of Rewriter to edit/delete/create
022:         * new RuleSet's
023:         *
024:         * @version 1.0 12/15/2001
025:         * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
026:         */
027:        public final class RuleSetManager {
028:            private static RuleSetManager defaultManager;
029:
030:            private final TypedHashCache ruleSetCache = new TypedHashCache(
031:                    RuleSet.class);
032:            private DataService dataService;
033:
034:            public RuleSetManager(final DataService aDataService) {
035:                dataService = aDataService;
036:                dataService.getChangeNotifier().addObserver(ruleSetCache);
037:                if (defaultManager == null) {
038:                    defaultManager = this ;
039:                }
040:            }//init()
041:
042:            public DataService getDataService() {
043:                return dataService;
044:            }//getDataService()
045:
046:            /**
047:             * first it will look into the cache else it creates one and stores in the
048:             * cache
049:             */
050:            public RuleSet fetchRuleSet(final String aRuleSetID)
051:                    throws InvalidXMLException, DataServiceException {
052:                if (aRuleSetID.equals(Rule.NONE)) {
053:                    return null;
054:                }
055:
056:                final RuleSet result = (RuleSet) ruleSetCache.get(aRuleSetID);
057:                if (result != null) {
058:                    return result;
059:                }
060:
061:                //if not present in cache create one and store the same
062:                String lXMLString = retrieve(aRuleSetID);
063:
064:                if (Debug.isMessageEnabled()) {
065:                    Debug
066:                            .recordRuleSetMessage("\n\n\nRetrieved XML For RuleSet ID: "
067:                                    + aRuleSetID + " is\n\n" + lXMLString);
068:                }
069:
070:                RuleSet lRuleSet = create(lXMLString);
071:                ruleSetCache.put(lRuleSet.getID(), lRuleSet);
072:                return lRuleSet;
073:            }//fetchRuleSet()
074:
075:            public Set getRuleSetNames() throws DataServiceException {
076:                return dataService.retrieveKeys();
077:            }//getRuleSetNames()
078:
079:            public String matchesWithID(final String aXMLString)
080:                    throws DataServiceException, InvalidXMLException {
081:                final RuleSet r = create(aXMLString);
082:                return dataService.matchesWithID(r.getID());
083:            }//matchesWithID()
084:
085:            private boolean isRuleSetExists(final String aXMLString)
086:                    throws DataServiceException, InvalidXMLException {
087:                if (matchesWithID(aXMLString) == null) {
088:                    return false;
089:                } else {
090:                    return true;
091:                }
092:            }//isRuleSetExists()
093:
094:            public String retrieve(final String aRuleSetID)
095:                    throws DataServiceException {
096:                return dataService.retrieveXML(aRuleSetID);
097:            }//retrive()
098:
099:            public String store(final String aXMLString)
100:                    throws InvalidXMLException, DataServiceException {
101:                final RuleSet r = create(aXMLString);
102:                final String keyIDFromXML = r.getID();
103:
104:                if (isRuleSetExists(aXMLString)) {
105:                    delete(keyIDFromXML);
106:                }
107:
108:                return dataService.storeXML(keyIDFromXML, aXMLString);
109:            }//store()
110:
111:            public String delete(final String aRuleSetID)
112:                    throws DataServiceException {
113:                return dataService.deleteKey(aRuleSetID);
114:            }//delete()
115:
116:            public static RuleSet create(final String aXMLString)
117:                    throws InvalidXMLException {
118:                try {
119:                    return new RuleSet(Document.create(aXMLString)
120:                            .getRootNode());
121:                } catch (InvalidXMLException iXMLe) {
122:                    throw iXMLe;
123:                } catch (SAXException se) {
124:                    throw new InvalidXMLException(se.getMessage(), aXMLString,
125:                            se, InvalidXMLException.SAX_EXCEPTION);
126:                } catch (Exception e) {
127:                    e.printStackTrace();
128:                    throw new InvalidXMLException(e.getMessage(), aXMLString,
129:                            e, InvalidXMLException.UNKNOWN_EXCEPTION);
130:                }//try/catch
131:            }//create()
132:
133:            public static RuleSet create(final Reader aXMLStringReader)
134:                    throws InvalidXMLException {
135:                return create(Resource.read(aXMLStringReader));
136:            }//create()
137:
138:            public static boolean validate(final String aXMLString) {
139:                try {
140:                    create(aXMLString);
141:                    return true;
142:                } catch (Exception e) {
143:                    return false;
144:                }//try/catch
145:            }//validate
146:
147:            public static final RuleSetManager getDefault() {
148:                return defaultManager;
149:            }//getDefault()
150:
151:            public static void main(String[] args) throws Exception {
152:                RuleSet lRuleSet = RuleSetManager
153:                        .create(new FileReader(args[0]));
154:                Debug.println(lRuleSet.toXML());
155:            }//main()
156:
157:        }//class RuleSetManager
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.