Source Code Cross Referenced for RuleExecutionSetProvider.java in  » Rule-Engine » hammurapi-rules » biz » hammurapi » rules » jsr94 » admin » 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 » Rule Engine » hammurapi rules » biz.hammurapi.rules.jsr94.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package biz.hammurapi.rules.jsr94.admin;
002:
003:        import java.io.IOException;
004:        import java.io.Serializable;
005:        import java.io.StringReader;
006:        import java.net.MalformedURLException;
007:        import java.net.URL;
008:        import java.rmi.RemoteException;
009:        import java.util.HashMap;
010:        import java.util.Map;
011:
012:        import javax.rules.admin.RuleExecutionSet;
013:        import javax.rules.admin.RuleExecutionSetCreateException;
014:        import javax.xml.parsers.FactoryConfigurationError;
015:        import javax.xml.parsers.ParserConfigurationException;
016:        import javax.xml.transform.TransformerException;
017:
018:        import org.w3c.dom.Element;
019:        import org.xml.sax.SAXException;
020:
021:        import biz.hammurapi.config.ConfigurationException;
022:        import biz.hammurapi.xml.dom.DOMUtils;
023:
024:        /**
025:         * Rule execution set provider.
026:         * @author Pavel Vlasov
027:         *
028:         */
029:        class RuleExecutionSetProvider implements 
030:                javax.rules.admin.RuleExecutionSetProvider {
031:
032:            private Map properties = new HashMap();
033:
034:            /**
035:             * Constructor.
036:             * @param properties
037:             */
038:            public RuleExecutionSetProvider(Map properties) {
039:                if (properties != null) {
040:                    this .properties.putAll(properties);
041:                }
042:            }
043:
044:            /**
045:             * Creates rule execution set from XML Element.
046:             * Properties are ignored.
047:             */
048:            public RuleExecutionSet createRuleExecutionSet(Element holder,
049:                    Map properties) throws RuleExecutionSetCreateException,
050:                    RemoteException {
051:                try {
052:                    return new biz.hammurapi.rules.jsr94.admin.RuleExecutionSet(
053:                            holder, properties);
054:                } catch (ConfigurationException e) {
055:                    throw new RuleExecutionSetCreateException(
056:                            "Could not instantiate rules: " + e, e);
057:                } catch (TransformerException e) {
058:                    throw new RuleExecutionSetCreateException(
059:                            "Could not parse XML definition: " + e, e);
060:                }
061:            }
062:
063:            /**
064:             * Creates rule execution set from XML String
065:             * The first parameter shall be of type String.
066:             */
067:            public RuleExecutionSet createRuleExecutionSet(
068:                    Serializable xmlString, Map properties)
069:                    throws RuleExecutionSetCreateException, RemoteException {
070:                try {
071:                    return createRuleExecutionSet(DOMUtils.parse(
072:                            new StringReader((String) xmlString))
073:                            .getDocumentElement(), properties);
074:                } catch (SAXException e) {
075:                    throw new RuleExecutionSetCreateException(
076:                            "Could not parse XML String: " + e, e);
077:                } catch (IOException e) {
078:                    throw new RuleExecutionSetCreateException(
079:                            "Should never happen: " + e, e);
080:                } catch (ParserConfigurationException e) {
081:                    throw new RuleExecutionSetCreateException(
082:                            "Could not parse XML String: " + e, e);
083:                } catch (FactoryConfigurationError e) {
084:                    throw new RuleExecutionSetCreateException(
085:                            "Could not parse XML String: " + e);
086:                }
087:            }
088:
089:            /**
090:             * Constructs rule execution set from URI. Prefix <code>resource:</code> in uri indicates that 
091:             * rule set shall be loaded from classloader, otherwise it is loaded from URL.
092:             */
093:            public RuleExecutionSet createRuleExecutionSet(String uri,
094:                    Map properties) throws RuleExecutionSetCreateException,
095:                    IOException, RemoteException {
096:                try {
097:                    if (uri.startsWith("resource:")) {
098:                        return new biz.hammurapi.rules.jsr94.admin.RuleExecutionSet(
099:                                uri,
100:                                DOMUtils
101:                                        .parse(
102:                                                getClass()
103:                                                        .getClassLoader()
104:                                                        .getResourceAsStream(
105:                                                                uri
106:                                                                        .substring("resource:"
107:                                                                                .length())))
108:                                        .getDocumentElement(), properties);
109:                    }
110:
111:                    return new biz.hammurapi.rules.jsr94.admin.RuleExecutionSet(
112:                            uri, DOMUtils.parse(new URL(uri).openStream())
113:                                    .getDocumentElement(), properties);
114:                } catch (MalformedURLException e) {
115:                    throw new RuleExecutionSetCreateException("Malformed URI: "
116:                            + uri, e);
117:                } catch (SAXException e) {
118:                    throw new RuleExecutionSetCreateException(
119:                            "Could not parse XML definition: " + e, e);
120:                } catch (IOException e) {
121:                    throw new RuleExecutionSetCreateException(
122:                            "Could not read XML definition: " + e, e);
123:                } catch (ParserConfigurationException e) {
124:                    throw new RuleExecutionSetCreateException(
125:                            "Could not parse XML definition: " + e, e);
126:                } catch (FactoryConfigurationError e) {
127:                    throw new RuleExecutionSetCreateException(
128:                            "Could not parse XML definition: " + e);
129:                } catch (ConfigurationException e) {
130:                    throw new RuleExecutionSetCreateException(
131:                            "Could not instantiate rules: " + e, e);
132:                } catch (TransformerException e) {
133:                    throw new RuleExecutionSetCreateException(
134:                            "Could not parse XML definition: " + e, e);
135:                }
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.