svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.personaldb / org.gvsig.personaldb.lib / org.gvsig.personaldb.lib.impl / src / main / java / org / gvsig / personaldb / impl / PersonalDBDefaultImplLibrary.java @ 40560
History | View | Annotate | Download (2.61 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.personaldb.impl; |
25 |
|
26 |
import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary; |
27 |
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters; |
28 |
import org.gvsig.personaldb.PersonalDBLibrary; |
29 |
import org.gvsig.personaldb.PersonalDBLocator; |
30 |
import org.gvsig.tools.library.AbstractLibrary; |
31 |
import org.gvsig.tools.library.LibraryException; |
32 |
|
33 |
/**
|
34 |
* Library for default implementation initialization and configuration.
|
35 |
*
|
36 |
* @author gvSIG team
|
37 |
* @version $Id$
|
38 |
*/
|
39 |
public class PersonalDBDefaultImplLibrary extends AbstractLibrary { |
40 |
|
41 |
@Override
|
42 |
public void doRegistration() { |
43 |
registerAsImplementationOf(PersonalDBLibrary.class); |
44 |
require(JDBCLibrary.class); |
45 |
} |
46 |
|
47 |
@Override
|
48 |
protected void doInitialize() throws LibraryException { |
49 |
PersonalDBLocator.registerManager(DefaultPersonalDBManager.class); |
50 |
} |
51 |
|
52 |
@Override
|
53 |
protected void doPostInitialize() throws LibraryException { |
54 |
if (PersonalDBLocator.getManager() instanceof DefaultPersonalDBManager) { |
55 |
|
56 |
String databasePath =
|
57 |
System.getProperty("personalDBPath", "~/.gvsig-personaldb"); |
58 |
String databasePort = System.getProperty("personalDBPort"); |
59 |
|
60 |
String personalDBURL =
|
61 |
databasePort == null ? "jdbc:h2:" + databasePath |
62 |
: "jdbc:h2:tcp://localhost:" + databasePort + "/" |
63 |
+ databasePath; |
64 |
|
65 |
JDBCResourceParameters parameters = new JDBCResourceParameters();
|
66 |
parameters.setJDBCDriverClassName("org.h2.Driver");
|
67 |
parameters.setUrl(personalDBURL); |
68 |
|
69 |
((DefaultPersonalDBManager) PersonalDBLocator.getManager()) |
70 |
.open(parameters); |
71 |
} |
72 |
} |
73 |
|
74 |
} |