Source Code Cross Referenced for RulesRepositoryAdministrator.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » repository » 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 » drolls Rule Engine » org.drools.repository 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package org.drools.repository;
02:
03:        import javax.jcr.Node;
04:        import javax.jcr.PathNotFoundException;
05:        import javax.jcr.RepositoryException;
06:        import javax.jcr.Session;
07:        import javax.jcr.Workspace;
08:
09:        import org.apache.log4j.Logger;
10:
11:        /**
12:         * This class is for administering the rules repo.
13:         * Any "sensitive" actions can happen in here.
14:         * 
15:         * @author Michael Neale
16:         *
17:         */
18:        public class RulesRepositoryAdministrator {
19:
20:            private static final Logger log = Logger
21:                    .getLogger(RulesRepositoryAdministrator.class);
22:
23:            private final Session session;
24:
25:            /**
26:             * Pass in a session that is capable of doing admin-ey type stuff.
27:             */
28:            public RulesRepositoryAdministrator(Session session) {
29:                this .session = session;
30:            }
31:
32:            static boolean isNamespaceRegistered(Session session)
33:                    throws RepositoryException {
34:                Workspace ws = session.getWorkspace();
35:                //no need to set it up again, skip it if it has.
36:                String uris[] = ws.getNamespaceRegistry().getURIs();
37:                for (int i = 0; i < uris.length; i++) {
38:                    if (RulesRepository.DROOLS_URI.equals(uris[i])) {
39:                        return true;
40:                    }
41:                }
42:                return false;
43:            }
44:
45:            /**
46:             * This will tell you if the repository currently connected to is initialized.
47:             * This includes the basic data/folders, as well as the name space registered.
48:             * The name space registration is JCR implementation dependent (jackrabbit is the default).
49:             */
50:            public boolean isRepositoryInitialized() {
51:                try {
52:                    return isNamespaceRegistered(session)
53:                            && session.getRootNode().hasNode(
54:                                    RulesRepository.RULES_REPOSITORY_NAME);
55:                } catch (RepositoryException e) {
56:                    throw new RulesRepositoryException(e);
57:                }
58:            }
59:
60:            /**
61:             * Clears out the entire tree below the rules repository node of the JCR repository.
62:             * IMPORTANT: after calling this, RepositoryConfigurator.setupRulesRepository() should
63:             * be called to set up the minimal data for a "blank" setup. If importing other data, however, this is probably not needed.
64:             */
65:            public void clearRulesRepository() {
66:                log.debug("Clearing repository database. UserId="
67:                        + session.getUserID());
68:                try {
69:
70:                    if (session.getRootNode().hasNode(
71:                            RulesRepository.RULES_REPOSITORY_NAME)) {
72:                        System.out.println("Clearing rules repository");
73:                        Node node = session.getRootNode().getNode(
74:                                RulesRepository.RULES_REPOSITORY_NAME);
75:                        node.remove();
76:                        session.save();
77:                    } else {
78:                        System.out
79:                                .println("Repo not setup, ergo not clearing it !");
80:                    }
81:                } catch (PathNotFoundException e) {
82:                    log.error(e);
83:                } catch (RepositoryException e) {
84:                    log.error(e);
85:                }
86:            }
87:
88:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.