Source Code Cross Referenced for AxionDBConfiguration.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » mashup » db » ui » 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 » IDE Netbeans » etl.project » org.netbeans.modules.mashup.db.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *                 Sun Public License Notice
003:         *
004:         * The contents of this file are subject to the Sun Public License
005:         * Version 1.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://www.sun.com/
008:         *
009:         * The Original Code is NetBeans. The Initial Developer of the Original
010:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
011:         * Microsystems, Inc. All Rights Reserved.
012:
013:        If you wish your version of this file to be governed by only the CDDL
014:        or only the GPL Version 2, indicate your decision by adding
015:        "[Contributor] elects to include this software in this distribution
016:        under the [CDDL or GPL Version 2] license." If you do not indicate a
017:        single choice of license, a recipient has the option to distribute
018:        your version of this file under either the CDDL, the GPL Version 2 or
019:        to extend the choice of license to its licensees as provided above.
020:        However, if you add GPL Version 2 code and therefore, elected the GPL
021:        Version 2 license, then the option applies only if the new code is
022:        made subject to such option by the copyright holder.
023:
024:        If you wish your version of this file to be governed by only the CDDL
025:        or only the GPL Version 2, indicate your decision by adding
026:        "[Contributor] elects to include this software in this distribution
027:        under the [CDDL or GPL Version 2] license." If you do not indicate a
028:        single choice of license, a recipient has the option to distribute
029:        your version of this file under either the CDDL, the GPL Version 2 or
030:        to extend the choice of license to its licensees as provided above.
031:        However, if you add GPL Version 2 code and therefore, elected the GPL
032:        Version 2 license, then the option applies only if the new code is
033:        made subject to such option by the copyright holder.
034:         */
035:        package org.netbeans.modules.mashup.db.ui;
036:
037:        import java.io.File;
038:        import java.io.FileInputStream;
039:        import java.io.FileNotFoundException;
040:        import java.io.FileOutputStream;
041:        import java.io.IOException;
042:        import java.util.Properties;
043:
044:        import net.java.hulp.i18n.Logger;
045:        import org.netbeans.modules.etl.logger.Localizer;
046:        import org.netbeans.modules.etl.logger.LogUtil;
047:        import org.openide.nodes.BeanNode;
048:        import org.openide.util.NbBundle;
049:
050:        /**
051:         *
052:         * @author karthikeyan s
053:         */
054:        public class AxionDBConfiguration {
055:
056:            private static final AxionDBConfiguration DEFAULT = new AxionDBConfiguration();
057:            public static final String PROP_DB_LOC = "DBLocation";
058:            public static final String PROP_DRIVER_LOC = "DriverLocation";
059:            public static final String PROP_LOC = "location";
060:            public static final String PROP_DRV_LOC = "driver";
061:            private static transient final Logger mLogger = LogUtil
062:                    .getLogger(FlatfileResulSetPanel.class.getName());
063:            private static transient final Localizer mLoc = Localizer.get();
064:
065:            public static AxionDBConfiguration getDefault() {
066:                return DEFAULT;
067:            }
068:
069:            public String displayName() {
070:                String nbBundle4 = mLoc.t("PRSR001: MashupDB Configuration");
071:                return Localizer.parse(nbBundle4);
072:            }
073:
074:            protected final String putProperty(String key, String value,
075:                    boolean notify) {
076:                System.setProperty(key, value);
077:                return System.getProperty(key);
078:            }
079:
080:            protected final String getProperty(String key) {
081:                return System.getProperty(key);
082:            }
083:
084:            public String getDriver() {
085:                File conf = getConfigFile();
086:                if (conf != null) {
087:                    Properties prop = new Properties();
088:                    FileInputStream in = null;
089:                    try {
090:                        in = new FileInputStream(conf);
091:                        prop.load(in);
092:                    } catch (FileNotFoundException ex) {
093:                        //ignore
094:                    } catch (IOException ioEx) {
095:                        //ignore
096:                    }
097:                    String drv = prop.getProperty(PROP_DRIVER_LOC);
098:                    if (drv != null) {
099:                        return drv;
100:                    }
101:                } else {
102:                    // Check for mashup driver under soa cluster.
103:                    String nbHomeDir = System.getProperty("netbeans.home")
104:                            + File.separator + ".." + File.separator + "soa2"
105:                            + File.separator + "modules" + File.separator
106:                            + "ext" + File.separator + "etl" + File.separator
107:                            + "axiondb.jar";
108:                    File driver = new File(nbHomeDir);
109:                    if (!driver.exists()) {
110:
111:                        // check for mashup driver under extra cluster.
112:                        nbHomeDir = System.getProperty("netbeans.home")
113:                                + File.separator + ".." + File.separator
114:                                + "extra" + File.separator + "modules"
115:                                + File.separator + "ext" + File.separator
116:                                + "etl" + File.separator + "axiondb.jar";
117:                        driver = new File(nbHomeDir);
118:                        if (!driver.exists()) {
119:                            nbHomeDir = "";
120:                        }
121:                        return nbHomeDir;
122:                    }
123:                }
124:                return "";
125:            }
126:
127:            public void setDriver(String driver) {
128:                driver = driver.trim();
129:                File conf = getConfigFile();
130:                try {
131:                    FileInputStream in = new FileInputStream(conf);
132:                    Properties oldProp = new Properties();
133:                    oldProp.load(in);
134:                    String dbLoc = oldProp.getProperty(PROP_DB_LOC);
135:                    in.close();
136:                    FileOutputStream out = new FileOutputStream(conf);
137:                    Properties prop = new Properties();
138:                    prop.setProperty(PROP_DRIVER_LOC, driver);
139:                    prop.setProperty(PROP_DB_LOC, dbLoc);
140:                    String nbBundle3 = mLoc
141:                            .t("PRSR001: MashupDB Configurations");
142:                    prop.store(out, Localizer.parse(nbBundle3));
143:                    out.close();
144:                } catch (FileNotFoundException ex) {
145:                    //ignore
146:                } catch (IOException ex) {
147:                    //ignore
148:                }
149:            }
150:
151:            /**
152:             * Returns the AXION location or an empty string if the AXION location
153:             * is not set. Never returns null.
154:             * @return dbLocation
155:             */
156:            public String getLocation() {
157:                File conf = getConfigFile();
158:                if (conf != null) {
159:                    Properties prop = new Properties();
160:                    FileInputStream in = null;
161:                    try {
162:                        in = new FileInputStream(conf);
163:                        prop.load(in);
164:                    } catch (FileNotFoundException ex) {
165:                        //ignore
166:                    } catch (IOException ioEx) {
167:                        //ignore
168:                    }
169:                    return prop.getProperty(PROP_DB_LOC);
170:                }
171:                return System.getProperty("netbeans.user") + File.separator
172:                        + "MashupDatabases" + File.separator;
173:            }
174:
175:            /**
176:             * Sets the AXION location.
177:             *
178:             * @param location the AXION location. A null value is valid and
179:             *        will be returned by getLocation() as an empty
180:             *        string (meaning "not set"). An empty string is valid
181:             *        and has the meaning "set to the default location".
182:             */
183:            public void setLocation(String location) {
184:                location = location.trim();
185:                if (!location.endsWith(File.separator)) {
186:                    location = location + File.separator;
187:                }
188:                File conf = getConfigFile();
189:                try {
190:                    FileInputStream in = new FileInputStream(conf);
191:                    Properties oldProp = new Properties();
192:                    oldProp.load(in);
193:                    String drv = oldProp.getProperty(PROP_DRIVER_LOC);
194:                    in.close();
195:                    FileOutputStream out = new FileOutputStream(conf);
196:                    Properties prop = new Properties();
197:                    prop.setProperty(PROP_DB_LOC, location);
198:                    prop.setProperty(PROP_DRIVER_LOC, drv);
199:                    String nbBundle3 = mLoc
200:                            .t("PRSR001: MashupDB Configurations");
201:                    prop.store(out, Localizer.parse(nbBundle3));
202:                    out.close();
203:                    File db = new File(location);
204:                    if (!db.exists()) {
205:                        db.mkdir();
206:                    }
207:                } catch (FileNotFoundException ex) {
208:                    //ignore
209:                } catch (IOException ex) {
210:                    //ignore
211:                }
212:            }
213:
214:            public static File getConfigFile() {
215:                String nbUsrDir = System.getProperty("netbeans.user");
216:
217:                // Check for mashup driver under soa cluster.
218:                String nbHomeDir = System.getProperty("netbeans.home")
219:                        + File.separator + ".." + File.separator + "soa1"
220:                        + File.separator + "modules" + File.separator + "ext"
221:                        + File.separator + "etl" + File.separator
222:                        + "axiondb.jar";
223:                File driver = new File(nbHomeDir);
224:                if (!driver.exists()) {
225:
226:                    // check for mashup driver under extra cluster.
227:                    nbHomeDir = System.getProperty("netbeans.home")
228:                            + File.separator + ".." + File.separator + "extra"
229:                            + File.separator + "modules" + File.separator
230:                            + "ext" + File.separator + "etl" + File.separator
231:                            + "axiondb.jar";
232:                    driver = new File(nbHomeDir);
233:                    if (!driver.exists()) {
234:                        nbHomeDir = "";
235:                    } else {
236:                        nbHomeDir = driver.getAbsolutePath();
237:                    }
238:                }
239:                String DEFAULT_DB_LOCATION = System
240:                        .getProperty("netbeans.user")
241:                        + File.separator + "MashupDatabases" + File.separator;
242:                nbUsrDir = nbUsrDir + File.separator + "config"
243:                        + File.separator + "Databases" + File.separator
244:                        + "MashupDB";
245:                File conf = new File(nbUsrDir);
246:                if (!conf.exists()) {
247:                    conf.mkdir();
248:                }
249:                nbUsrDir = nbUsrDir + File.separator
250:                        + "MashupDBConfig.properties";
251:                conf = new File(nbUsrDir);
252:                if (!conf.exists()) {
253:                    try {
254:                        conf.createNewFile();
255:                        Properties prop = new Properties();
256:                        prop.setProperty(PROP_DB_LOC, DEFAULT_DB_LOCATION);
257:                        prop.setProperty(PROP_DRIVER_LOC, nbHomeDir);
258:                        FileOutputStream out = null;
259:                        try {
260:                            out = new FileOutputStream(conf);
261:                            String nbBundle2 = mLoc
262:                                    .t("PRSR001: Mashup Database Location");
263:                            prop.store(out, Localizer.parse(nbBundle2));
264:                            out.close();
265:                        } catch (FileNotFoundException ex) {
266:                            //ignore
267:                        } catch (IOException ioEx) {
268:                            //igonre
269:                        }
270:                    } catch (IOException ex) {
271:                        conf = null;
272:                    }
273:                }
274:                return conf;
275:            }
276:
277:            protected static BeanNode createViewNode()
278:                    throws java.beans.IntrospectionException {
279:                BeanNode nd = new BeanNode(AxionDBConfiguration.getDefault());
280:                String nbBundle1 = mLoc.t("PRSR001: Mashup Database");
281:                nd.setName(Localizer.parse(nbBundle1));
282:                return nd;
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.