Source Code Cross Referenced for ConnectionAssembler.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » assembler » assemblers » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.assembler.assemblers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         	(c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         	All rights reserved - see end of file.
004:         	$Id: ConnectionAssembler.java,v 1.11 2008/01/02 12:09:36 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.assembler.assemblers;
008:
009:        import com.hp.hpl.jena.JenaRuntime;
010:        import com.hp.hpl.jena.assembler.*;
011:        import com.hp.hpl.jena.rdf.model.*;
012:
013:        /**
014:         A ConnectionAssembler assembles a ConnectionDescription object which
015:         contains a database URL, user name, user password, and database type.
016:         Some of the components may have been specified in advance when the 
017:         Assembler was constructed. The ConnectionAssembler will also load any
018:         classes specified by dbClass[Property] statements of the root.
019:        
020:         @author kers
021:         */
022:        public class ConnectionAssembler extends AssemblerBase implements 
023:                Assembler {
024:            public final String defaultURL;
025:            public final String defaultUser;
026:            public final String defaultPassword;
027:            public final String defaultType;
028:
029:            protected static final Resource emptyRoot = ModelFactory
030:                    .createDefaultModel().createResource();
031:
032:            public ConnectionAssembler(Resource init) {
033:                defaultUser = get(init, "dbUser", null);
034:                defaultPassword = get(init, "dbPassword", null);
035:                defaultURL = get(init, "dbURL", null);
036:                defaultType = get(init, "dbType", null);
037:            }
038:
039:            public ConnectionAssembler() {
040:                this (emptyRoot);
041:            }
042:
043:            public Object open(Assembler a, Resource root, Mode irrelevant) {
044:                checkType(root, JA.Connection);
045:                String dbUser = getUser(root), dbPassword = getPassword(root);
046:                String dbURL = getURL(root), dbType = getType(root);
047:                loadClasses(root);
048:                return createConnection(root.getURI(), dbURL, dbType, dbUser,
049:                        dbPassword);
050:            }
051:
052:            /**
053:                Load all the classes that are named by the object of dbClass statements
054:                of <code>root</code>. Load all the classes named by the contents of
055:                system properties which are the objects of dbClassProperty statements
056:                of <code>root</code>.
057:             */
058:            private void loadClasses(Resource root) {
059:                for (StmtIterator it = root.listProperties(JA.dbClassProperty); it
060:                        .hasNext();) {
061:                    String propertyName = getString(it.nextStatement());
062:                    String className = JenaRuntime
063:                            .getSystemProperty(propertyName);
064:                    loadClass(root, className);
065:                }
066:                for (StmtIterator it = root.listProperties(JA.dbClass); it
067:                        .hasNext();) {
068:                    String className = getString(it.nextStatement());
069:                    loadClass(root, className);
070:                }
071:            }
072:
073:            protected ConnectionDescription createConnection(String subject,
074:                    String dbURL, String dbType, String dbUser,
075:                    String dbPassword) {
076:                return ConnectionDescription.create(subject, dbURL, dbUser,
077:                        dbPassword, dbType);
078:            }
079:
080:            public String getUser(Resource root) {
081:                return get(root, "dbUser", defaultUser);
082:            }
083:
084:            public String getPassword(Resource root) {
085:                return get(root, "dbPassword", defaultPassword);
086:            }
087:
088:            public String getURL(Resource root) {
089:                return get(root, "dbURL", defaultURL);
090:            }
091:
092:            public String getType(Resource root) {
093:                return get(root, "dbType", defaultType);
094:            }
095:
096:            protected String get(Resource root, String label, String ifAbsent) {
097:                Property property = JA.property(label);
098:                RDFNode L = getUnique(root, property);
099:                return L == null ? getIndirect(root, label, ifAbsent) : L
100:                        .isLiteral() ? ((Literal) L).getLexicalForm()
101:                        : ((Resource) L).getURI();
102:            }
103:
104:            private String getIndirect(Resource root, String label,
105:                    String ifAbsent) {
106:                Property property = JA.property(label + "Property");
107:                Literal name = getUniqueLiteral(root, property);
108:                return name == null ? ifAbsent : JenaRuntime
109:                        .getSystemProperty(name.getLexicalForm());
110:            }
111:        }
112:
113:        /*
114:         * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
115:         * All rights reserved.
116:         *
117:         * Redistribution and use in source and binary forms, with or without
118:         * modification, are permitted provided that the following conditions
119:         * are met:
120:         * 1. Redistributions of source code must retain the above copyright
121:         *    notice, this list of conditions and the following disclaimer.
122:         * 2. Redistributions in binary form must reproduce the above copyright
123:         *    notice, this list of conditions and the following disclaimer in the
124:         *    documentation and/or other materials provided with the distribution.
125:         * 3. The name of the author may not be used to endorse or promote products
126:         *    derived from this software without specific prior written permission.
127:         *
128:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
129:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
130:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
131:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
132:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
133:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
134:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
135:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
136:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
137:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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.