Source Code Cross Referenced for DatabaseRmsFactory.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » rmsimpls » dbrms » 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 » Workflow Engines » wfmopen 2.1.1 » de.danet.an.workflow.rmsimpls.dbrms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2005 Danet GmbH (www.danet.de), BU BTS.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * $Id: DatabaseRmsFactory.java,v 1.7 2006/10/15 19:29:51 mlipp Exp $
021:         *
022:         * $Log: DatabaseRmsFactory.java,v $
023:         * Revision 1.7  2006/10/15 19:29:51  mlipp
024:         * Merged changes from 1.4.x up to 1.4ea3pre1.
025:         *
026:         * Revision 1.6.2.1  2006/10/14 21:34:05  mlipp
027:         * Simplified resource assignment service implementation.
028:         *
029:         * Revision 1.6  2006/10/03 11:13:05  mlipp
030:         * Improved.
031:         *
032:         * Revision 1.5  2006/09/29 14:01:17  drmlipp
033:         * Improved property names.
034:         *
035:         * Revision 1.4  2006/09/29 12:32:11  drmlipp
036:         * Consistently using WfMOpen as projct name now.
037:         *
038:         * Revision 1.3  2006/09/29 11:39:16  drmlipp
039:         * Various fixes.
040:         *
041:         * Revision 1.2  2006/09/28 21:28:09  mlipp
042:         * Implementation continued.
043:         *
044:         * Revision 1.1  2006/09/28 15:03:56  drmlipp
045:         * Getting started with db RMS.
046:         *
047:         */
048:        package de.danet.an.workflow.rmsimpls.dbrms;
049:
050:        import java.io.IOException;
051:        import java.io.InputStream;
052:        import java.util.Properties;
053:
054:        import javax.naming.NamingException;
055:
056:        import de.danet.an.util.EJBUtil;
057:        import de.danet.an.workflow.spis.rms.FactoryConfigurationError;
058:        import de.danet.an.workflow.spis.rms.ResourceManagementService;
059:        import de.danet.an.workflow.spis.rms.ResourceManagementServiceFactory;
060:
061:        /**
062:         * This class provides an implementaion of the factory API based on
063:         * information obtained from a database.<P>
064:         *
065:         * Usage of this class as service factory requires several
066:         * configuration parameters for accessing the database.  The
067:         * factory uses the following ordered lookup procedure to determine
068:         * these parameters:
069:         *
070:         * <ul>
071:         *   <li>Look for parameters in JNDI. Lookup parameters in 
072:         *     <code>java:comp/env/de.danet.an.workflow.rmsimpls.dbrms.<i>parameter</i></code>. 
073:         *     The configuration for a parameter using 
074:         *     this mechanism thus looks like:
075:         * <PRE> &lt;env-entry&gt;
076:         *   &lt;description&gt;Configure database parameter <i>parameter</i>&lt;/description&gt;
077:         *   &lt;env-entry-name&gt;de.danet.an.workflow.rmsimpls.dbrms.<i>parameter</i>&lt;/env-entry-name&gt;
078:         *   &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
079:         *   &lt;env-entry-value&gt;<i>Value of parameter</i>&lt;/env-entry-value&gt;
080:         * &lt;/env-entry&gt;</PRE>
081:         *     Note that the environment entries must be inserted in the
082:         *     <code>ejb-jar.xml</code> or <code>web.xml</code> for every EJB
083:         *     resp. servlet that calls the
084:         *     {@link de.danet.an.workflow.spis.rms.ResourceManagementServiceFactory#newInstance
085:         *     <code>newInstance</code>} method of 
086:         *     <code>ResourceManagementServiceFactory</code>.</li>
087:         *
088:         *   <li>Find the application resource file 
089:         *     <code>de.danet.an.workflow.rmsimpls.dbrms-factory.properties</code>
090:         *     and look for entries "<code><i>parameter</i>
091:         *     = <i>Value of parameter</i></code>".</li>
092:         * </ul><P>
093:         *
094:         * The following parameters are used:
095:         * <dl>
096:         *   <dt><code>dataSource</code></dt>
097:         *   <dd>The lookup name of the data source in JNDI 
098:         *      (e.g. <code>java:/DefaultDS</code>).</dd>
099:         *   <dt><code>allUsersQuery</code>
100:         *   <dd>The query that returns the known users as a two column result with 
101:         *     the user's entry's primary key in the first column and the user's 
102:         *     display name in the second.</dd>
103:         *   <dt><code>allRolesQuery</code>
104:         *   <dd>The query that returns the known roles as a two column result with 
105:         *     the role's entry's primary key in the first column and the role's 
106:         *     display name in the second.</dd>
107:         *   <dt><code>allGroupsQuery</code>
108:         *   <dd>The query that returns the known groups as a two column result with
109:         *     the group's entry's primary key in the first column and group's 
110:         *     display name in the second.</dd>
111:         *   <dt><code>userNameQuery</code></dt>
112:         *   <dd>The query that returns user data as a single column result with the 
113:         *     user's display name in the only column. The user's entry's primary key
114:         *     is set as query parameter.</dd> 
115:         *   <dt><code>roleNameQuery</code></dt>
116:         *   <dd>The query that returns role data as a single column result with the 
117:         *     role's display name in the only column. The role's entry's primary key
118:         *     is set as query parameter.</dd> 
119:         *   <dt><code>groupNameQuery</code></dt>
120:         *   <dd>The query that returns group data as a single column result with the 
121:         *     group's display name in the only column. The group's entry's primary key
122:         *     is set as query parameter.</dd> 
123:         *   <dt><code>userLookupQuery</code></dt>
124:         *   <dd>The query that returns a user's data as a two column result with the
125:         *     user's entry's primary key in the first column and the user's display 
126:         *     name in the second. The user's account name (usually the login name) is 
127:         *     set as query parameter.</dd> 
128:         *   <dt><code>roleLookupQuery</code></dt>
129:         *   <dd>The query that returns a role's data as a two column result with the 
130:         *     role's entry's primary key in the first column and the role's display 
131:         *     name in the second. The role's "account" name (clear text name) is set 
132:         *     as query parameter.</dd> 
133:         *   <dt><code>groupLookupQuery</code></dt>
134:         *   <dd>The query that returns a group's data as a two column result with the
135:         *     group's entry's primary key in the first column and the group's name 
136:         *     display in the second. The groups's "account" name (clear text name) is 
137:         *     set as query parameter.</dd> 
138:         *   <dt><code>rolesQuery</code></dt>
139:         *   <dd>The query that returns a user's roles as a two column result with the 
140:         *     role's entry's primary key in the first column and the role's display 
141:         *     name in the second. The user's entry's primary key is set as query 
142:         *     parameter.</dd> 
143:         *   <dt><code>groupsQuery</code></dt>
144:         *   <dd>The query that returns a user's groups as a two column result with the
145:         *     group's entry's primary key in the first column and the group's display 
146:         *     name in the second. The user's entry's primary key is set as query 
147:         *     parameter.</dd> 
148:         * </dl><P>
149:         *
150:         * @author <a href="mailto:lipp@danet.de">Michael Lipp</a>
151:         * @version $Revision: 1.7 $
152:         */
153:        public class DatabaseRmsFactory extends
154:                ResourceManagementServiceFactory {
155:
156:            private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
157:                    .getLog(DatabaseRmsFactory.class);
158:
159:            /**
160:             * Create a new instance of this factory.
161:             *
162:             * @throws FactoryConfigurationError if configuration information is 
163:             * missing or invalid.
164:             */
165:            public DatabaseRmsFactory() throws FactoryConfigurationError {
166:            }
167:
168:            /* Comment copied from interface. */
169:            public ResourceManagementService newResourceManagementService()
170:                    throws FactoryConfigurationError {
171:                if (getResourceAssignmentContext() == null) {
172:                    throw new FactoryConfigurationError(
173:                            "Resource assignment context not configured.");
174:                }
175:
176:                // make fallbacks
177:                Properties fallbacks = new Properties();
178:
179:                // try to get properties from file
180:                Properties baseProps = new Properties(fallbacks);
181:                try {
182:                    InputStream is = DatabaseRmsFactory.class
183:                            .getResourceAsStream("/de.danet.an.workflow.rmsimpls.dbrms-factory.properties");
184:                    if (is != null) {
185:                        baseProps.load(is);
186:                    }
187:                } catch (IOException ex) {
188:                }
189:
190:                // Overrides from JNDI
191:                Properties props = new Properties(baseProps);
192:                String[] knownProps = { "dataSource", "allUsersQuery",
193:                        "allRolesQuery", "allGroupsQuery", "userNameQuery",
194:                        "roleNameQuery", "groupNameQuery", "userLookupQuery",
195:                        "roleLookupQuery", "groupLookupQuery", "rolesQuery",
196:                        "groupsQuery" };
197:                for (int i = 0; i < knownProps.length; i++) {
198:                    try {
199:                        String entry = (String) EJBUtil
200:                                .lookupJNDIEntry("java:comp/env/de.danet.an.workflow.rmsimpls.dbrms."
201:                                        + knownProps[i]);
202:                        props.setProperty(knownProps[i], entry);
203:                    } catch (NamingException ne) {
204:                        // Name not defined
205:                    }
206:                }
207:                for (int i = 0; i < knownProps.length; i++) {
208:                    if (props.getProperty(knownProps[i]) == null) {
209:                        throw new FactoryConfigurationError(
210:                                "Missing property: " + knownProps[i]);
211:                    }
212:                }
213:
214:                return new DatabaseRmsService(props,
215:                        getResourceAssignmentContext());
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.