Source Code Cross Referenced for Main.java in  » RSS-RDF » Jena-2.5.5 » jena » examples » ontology » persistentOntology » 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 » jena.examples.ontology.persistentOntology 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*****************************************************************************
002:         * Source code information
003:         * -----------------------
004:         * Original author    Ian Dickinson, HP Labs Bristol
005:         * Author email       ian.dickinson@hp.com
006:         * Package            Jena 2
007:         * Web                http://jena.sourceforge.net
008:         * Created            22-Aug-2003
009:         * Filename           $RCSfile: Main.java,v $
010:         * Revision           $Revision: 1.2 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2005/10/08 08:38:07 $
014:         *               by   $Author: ian_dickinson $
015:         *
016:         * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
017:         * (see footer for full conditions)
018:         *****************************************************************************/package jena.examples.ontology.persistentOntology;
019:
020:        // Imports
021:        ///////////////
022:        import com.hp.hpl.jena.ontology.*;
023:        import com.hp.hpl.jena.rdf.model.ModelMaker;
024:
025:        /**
026:         * <p>
027:         * Simple execution wrapper for persistent ontology example.
028:         * </p>
029:         * <p>
030:         * Usage:
031:         * <pre>
032:         * java jena.examples.ontology.persistentOntology.Main
033:         *                  [--dbUser string]     e.g: --dbUser ijd
034:         *                  [--dbURL string]      e.g: --dbURL jdbc:postgresql://localhost/jenatest
035:         *                  [--dbPw string]       e.g: --dbPw nosecrets
036:         *                  [--dbType string]     e.g: --dbType PostgreSQL
037:         *                  [--dbDriver string]   e.g: --dbDriver org.postgresql.Driver
038:         *                  [--reload]            if true will reload the source data
039:         *                  [sourceURL]           optional source URL for the data to persist
040:         * </pre>
041:         * If no db parameters or source URL is given, defaults will be used.
042:         * </p>
043:         *
044:         * @author Ian Dickinson, HP Labs
045:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
046:         * @version CVS $Id: Main.java,v 1.2 2005/10/08 08:38:07 ian_dickinson Exp $
047:         */
048:        public class Main {
049:            // Constants
050:            //////////////////////////////////
051:
052:            public static final String ONT1 = "urn:x-hp-jena:test1";
053:            public static final String ONT2 = "urn:x-hp-jena:test2";
054:
055:            public static final String DB_URL = "jdbc:postgresql://localhost/jenatest";
056:            public static final String DB_USER = "ijd";
057:            public static final String DB_PASSWD = "";
058:            public static final String DB = "PostgreSQL";
059:            public static final String DB_DRIVER = "org.postgresql.Driver";
060:
061:            // Static variables
062:            //////////////////////////////////
063:
064:            // database connection parameters, with defaults
065:            private static String s_dbURL = DB_URL;
066:            private static String s_dbUser = DB_USER;
067:            private static String s_dbPw = DB_PASSWD;
068:            private static String s_dbType = DB;
069:            private static String s_dbDriver = DB_DRIVER;
070:
071:            // if true, reload the data
072:            private static boolean s_reload = false;
073:
074:            // source URL to load data from; if null, use default
075:            private static String s_source;
076:
077:            // Instance variables
078:            //////////////////////////////////
079:
080:            // Constructors
081:            //////////////////////////////////
082:
083:            // External signature methods
084:            //////////////////////////////////
085:
086:            public static void main(String[] args) {
087:                processArgs(args);
088:
089:                // check for default sources
090:                if (s_source == null) {
091:                    s_source = getDefaultSource();
092:                }
093:
094:                // create the helper class we use to handle the persistent ontologies
095:                PersistentOntology po = new PersistentOntology();
096:
097:                // ensure the JDBC driver class is loaded
098:                try {
099:                    Class.forName(s_dbDriver);
100:                } catch (Exception e) {
101:                    System.err
102:                            .println("Failed to load the driver for the database: "
103:                                    + e.getMessage());
104:                    System.err
105:                            .println("Have you got the CLASSPATH set correctly?");
106:                }
107:
108:                // are we re-loading the data this time?
109:                if (s_reload) {
110:
111:                    // we pass cleanDB=true to clear out existing models
112:                    // NOTE: this will remove ALL Jena models from the named persistent store, so
113:                    // use with care if you have existing data stored
114:                    ModelMaker maker = po.getRDBMaker(s_dbURL, s_dbUser,
115:                            s_dbPw, s_dbType, true);
116:
117:                    // now load the source data into the newly cleaned db
118:                    po.loadDB(maker, s_source);
119:                }
120:
121:                // now we list the classes in the database, to show that the persistence worked
122:                ModelMaker maker = po.getRDBMaker(s_dbURL, s_dbUser, s_dbPw,
123:                        s_dbType, false);
124:                po.listClasses(maker, s_source);
125:            }
126:
127:            // Internal implementation methods
128:            //////////////////////////////////
129:
130:            /**
131:             * Process any command line arguments
132:             */
133:            private static void processArgs(String[] args) {
134:                int i = 0;
135:                while (i < args.length) {
136:                    String arg = args[i++];
137:
138:                    if (arg.equals("--dbUser")) {
139:                        s_dbURL = args[i++];
140:                    } else if (arg.equals("--dbURL")) {
141:                        s_dbURL = args[i++];
142:                    } else if (arg.equals("--dbPasswd")) {
143:                        s_dbPw = args[i++];
144:                    } else if (arg.equals("--dbType")) {
145:                        s_dbType = args[i++];
146:                    } else if (arg.equals("--reload")) {
147:                        s_reload = true;
148:                    } else if (arg.equals("--dbDriver")) {
149:                        s_dbDriver = args[i++];
150:                    } else {
151:                        // assume this is a URL to load data from
152:                        s_source = arg;
153:                    }
154:                }
155:            }
156:
157:            /**
158:             * Answer the default source document, and set up the document manager
159:             * so that we can find it on the file system
160:             *
161:             * @return The URI of the default source document
162:             */
163:            private static String getDefaultSource() {
164:                // use the ont doc mgr to map from a generic URN to a local source file
165:                OntDocumentManager.getInstance().addAltEntry(ONT1,
166:                        "file:src-examples/data/test1.owl");
167:                OntDocumentManager.getInstance().addAltEntry(ONT2,
168:                        "file:src-examples/data/test2.owl");
169:
170:                return ONT1;
171:            }
172:
173:            //==============================================================================
174:            // Inner class definitions
175:            //==============================================================================
176:
177:        }
178:
179:        /*
180:         (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
181:         All rights reserved.
182:
183:         Redistribution and use in source and binary forms, with or without
184:         modification, are permitted provided that the following conditions
185:         are met:
186:
187:         1. Redistributions of source code must retain the above copyright
188:         notice, this list of conditions and the following disclaimer.
189:
190:         2. Redistributions in binary form must reproduce the above copyright
191:         notice, this list of conditions and the following disclaimer in the
192:         documentation and/or other materials provided with the distribution.
193:
194:         3. The name of the author may not be used to endorse or promote products
195:         derived from this software without specific prior written permission.
196:
197:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
198:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
200:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
201:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
202:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
203:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
204:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
205:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
206:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.