Revision 41999

View differences:

tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.personaldb</artifactId>
6
    <packaging>pom</packaging>
7
    <name>org.gvsig.personaldb</name>
8
    <description>PersonalDB project</description>
9
    
10
    <parent>
11
        <groupId>org.gvsig</groupId>
12
        <artifactId>org.gvsig.desktop.library</artifactId>
13
        <version>2.0.83</version>
14
    </parent>
15
 
16
    <dependencies>
17
        <dependency>
18
            <groupId>org.gvsig</groupId>
19
            <artifactId>org.gvsig.tools.lib</artifactId>
20
            <scope>compile</scope>
21
        </dependency>
22
        <dependency>
23
            <groupId>org.gvsig</groupId>
24
            <artifactId>org.gvsig.tools.lib</artifactId>
25
            <type>test-jar</type>
26
            <scope>test</scope>
27
        </dependency>
28
    </dependencies>
29
    
30
  <build>
31
    <plugins>
32
      <plugin>
33
        <groupId>org.codehaus.mojo</groupId>
34
        <artifactId>animal-sniffer-maven-plugin</artifactId>
35
        <configuration>
36
          <skip>true</skip>
37
        </configuration>
38
      </plugin>
39
    </plugins>
40
  </build>
41

  
42
  <modules>
43
      <module>org.gvsig.personaldb.lib</module>
44
      <module>org.gvsig.personaldb.main</module>
45
  </modules>
46

  
47
</project>
0 48

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/java/org/gvsig/personaldb/main/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28
<html xmlns="http://www.w3.org/1999/xhtml">
29
<head>
30
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31
<title>org.gvsig.personaldb package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>PersonalDB library testing and demo application.</p>
36

  
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/java/org/gvsig/personaldb/main/Main.java
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.main;
25

  
26
import java.sql.Connection;
27
import java.sql.DatabaseMetaData;
28
import java.sql.SQLException;
29

  
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
import org.gvsig.personaldb.PersonalDBException;
34
import org.gvsig.personaldb.PersonalDBLocator;
35
import org.gvsig.personaldb.PersonalDBManager;
36
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
37

  
38
/**
39
 * Main executable class for testing the PersonalDB library.
40
 * 
41
 * @author gvSIG Team
42
 * @version $Id$
43
 */
44
public class Main {
45

  
46
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
47

  
48
    public static void main(String args[]) {
49
        Main main = new Main();
50
        try {
51
            main.show();
52
        } catch (Throwable e) {
53
            e.printStackTrace();
54
            System.exit(-1);
55
        }
56
        System.exit(0);
57
    }
58

  
59
    public void show() throws PersonalDBException, SQLException {
60

  
61
        new DefaultLibrariesInitializer().fullInitialize();
62
        PersonalDBManager manager = PersonalDBLocator.getManager();
63

  
64
        Connection connection = manager.getConnection();
65
        DatabaseMetaData metadata = connection.getMetaData();
66
        LOG.info("DatabaseMetadata: {}", metadata);
67
    }
68

  
69
}
0 70

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
0 9

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.personaldb">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.personaldb.main</artifactId>
5
    <packaging>jar</packaging>
6
    <name>org.gvsig.personaldb.main</name>
7
    <parent>
8
        <groupId>org.gvsig</groupId>
9
        <artifactId>org.gvsig.personaldb</artifactId>
10
        <version>2.0.83</version>
11
    </parent>
12
    <dependencies>
13
        <dependency>
14
            <groupId>org.gvsig</groupId>
15
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
16
            <scope>compile</scope>
17
        </dependency>
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.personaldb.lib.impl</artifactId>
21
            <scope>runtime</scope>
22
        </dependency>
23
        <dependency>
24
            <groupId>org.gvsig</groupId>
25
            <artifactId>org.gvsig.tools.lib</artifactId>
26
            <scope>compile</scope>
27
        </dependency>        
28
        <dependency>
29
            <groupId>org.slf4j</groupId>
30
            <artifactId>slf4j-api</artifactId>
31
            <scope>compile</scope>
32
        </dependency>
33
    </dependencies>
34
    <build>
35
        <plugins>
36
            <plugin>
37
                <groupId>org.codehaus.mojo</groupId>
38
                <artifactId>exec-maven-plugin</artifactId>
39
                <executions>
40
                    <execution>
41
                        <goals>
42
                            <goal>exec</goal>
43
                        </goals>
44
                    </execution>
45
                </executions>
46
                <configuration>
47
                    <executable>java</executable>
48
                    <arguments>
49
                        <argument>-classpath</argument>
50
                        <!-- automatically creates the classpath using all project 
51
                            dependencies, also adding the project build directory -->
52
                        <classpath />
53
                        <argument>org.gvsig.personaldb.main.Main</argument>
54
                    </arguments>
55
                    <environmentVariables>
56
                    </environmentVariables>
57
                </configuration>
58
            </plugin>
59
        </plugins>
60
    </build>
61
</project>
0 62

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.personaldb.lib.impl</artifactId>
5
    <packaging>jar</packaging>
6
    <name>org.gvsig.personaldb.lib.impl</name>
7
    <parent>
8
        <groupId>org.gvsig</groupId>
9
        <artifactId>org.gvsig.personaldb.lib</artifactId>
10
        <version>2.0.83</version>
11
    </parent>
12
    <dependencies>
13
        <dependency>
14
            <groupId>org.gvsig</groupId>
15
            <artifactId>org.gvsig.tools.lib</artifactId>
16
            <scope>compile</scope>
17
        </dependency>
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
21
            <scope>compile</scope>
22
        </dependency>
23
        <dependency>
24
            <groupId>org.gvsig</groupId>
25
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
26
            <type>test-jar</type>
27
            <scope>test</scope>
28
        </dependency>
29
        <dependency>
30
            <groupId>org.gvsig</groupId>
31
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
32
            <scope>compile</scope>
33
        </dependency>
34
        <dependency>
35
            <groupId>org.gvsig</groupId>
36
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
37
            <scope>compile</scope>
38
        </dependency>
39
        <dependency>
40
            <groupId>org.gvsig</groupId>
41
            <artifactId>org.gvsig.fmap.dal.db.lib</artifactId>
42
            <scope>compile</scope>
43
        </dependency>
44
        <dependency>
45
            <groupId>org.gvsig</groupId>
46
            <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
47
            <scope>compile</scope>
48
        </dependency>
49
        <dependency>
50
            <groupId>commons-dbcp</groupId>
51
            <artifactId>commons-dbcp</artifactId>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>com.h2database</groupId>
56
            <artifactId>h2</artifactId>
57
            <scope>runtime</scope>
58
        </dependency>
59
        <dependency>
60
            <groupId>org.slf4j</groupId>
61
            <artifactId>slf4j-api</artifactId>
62
            <scope>compile</scope>
63
        </dependency>
64
    </dependencies>
65
</project>
66

  
0 67

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" output="target/classes" path="src/main/java">
4
		<attributes>
5
			<attribute name="optional" value="true"/>
6
			<attribute name="maven.pomderived" value="true"/>
7
		</attributes>
8
	</classpathentry>
9
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10
		<attributes>
11
			<attribute name="maven.pomderived" value="true"/>
12
		</attributes>
13
	</classpathentry>
14
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15
		<attributes>
16
			<attribute name="optional" value="true"/>
17
			<attribute name="maven.pomderived" value="true"/>
18
		</attributes>
19
	</classpathentry>
20
	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21
		<attributes>
22
			<attribute name="maven.pomderived" value="true"/>
23
		</attributes>
24
	</classpathentry>
25
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
26
		<attributes>
27
			<attribute name="maven.pomderived" value="true"/>
28
		</attributes>
29
	</classpathentry>
30
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31
		<attributes>
32
			<attribute name="maven.pomderived" value="true"/>
33
		</attributes>
34
	</classpathentry>
35
	<classpathentry kind="output" path="target/classes"/>
36
</classpath>
0 37

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.personaldb.lib.impl</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.m2e.core.maven2Builder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
22
	</natures>
23
</projectDescription>
0 24

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.personaldb">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.personaldb.impl.PersonalDBDefaultImplLibrary
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/java/org/gvsig/personaldb/impl/DefaultPersonalDBManager.java
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 java.sql.Connection;
27
import java.sql.SQLException;
28

  
29
import javax.sql.DataSource;
30

  
31
import org.apache.commons.dbcp.BasicDataSource;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataServerExplorerParameters;
37
import org.gvsig.fmap.dal.DataStoreParameters;
38
import org.gvsig.fmap.dal.exception.InitializeException;
39
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
40
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
41
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
42
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
43
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
44
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider;
45
import org.gvsig.personaldb.DBAccessException;
46
import org.gvsig.personaldb.DataServerExplorerParametersException;
47
import org.gvsig.personaldb.PersonalDBException;
48
import org.gvsig.personaldb.PersonalDBManager;
49
import org.gvsig.tools.dispose.impl.AbstractDisposable;
50
import org.gvsig.tools.exception.BaseException;
51

  
52
/**
53
 * Default {@link PersonalDBManager} implementation.
54
 * 
55
 * @author gvSIG Team
56
 * @version $Id$
57
 */
58
public class DefaultPersonalDBManager extends AbstractDisposable implements
59
    PersonalDBManager {
60

  
61
    private static final Logger LOG = LoggerFactory
62
        .getLogger(DefaultPersonalDBManager.class);
63

  
64
    private BasicDataSource dataSource;
65
    private JDBCResourceParameters resourceParameters;
66

  
67
    public Connection getConnection() throws PersonalDBException {
68

  
69
        try {
70
            return getDataSource().getConnection();
71
        } catch (SQLException e) {
72
            throw new DBAccessException(resourceParameters, e);
73
        }
74
    }
75

  
76
    private synchronized DataSource getDataSource() {
77

  
78
        if (dataSource == null) {
79
            dataSource = new BasicDataSource();
80
            dataSource.setDriverClassName(resourceParameters
81
                .getJDBCDriverClassName());
82
            dataSource.setUsername(resourceParameters.getUser());
83
            dataSource.setPassword(resourceParameters.getPassword());
84
            dataSource.setUrl(resourceParameters.getUrl());
85

  
86
            dataSource.setMaxWait(60L * 1000); // FIXME
87

  
88
            dataSource.setMaxActive(20);
89
            dataSource.setMaxIdle(4);
90
            dataSource.setMinIdle(1);
91
            dataSource.setInitialSize(1);
92

  
93
            // FIXME Set Pool parameters:
94
            /*
95
             * dataSource.setMaxOpenPreparedStatements(maxActive);
96
             * dataSource.setMaxWait(maxActive);
97
             * dataSource.setDefaultReadOnly(defaultReadOnly);
98
             * dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation
99
             * )
100
             * ;
101
             * dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis
102
             * );
103
             * dataSource.setTestOnBorrow(testOnBorrow);
104
             * dataSource.setTestOnReturn(testOnReturn);
105
             * dataSource.setTestWhileIdle(testOnReturn);
106
             * dataSource
107
             * .setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
108
             * 
109
             * dataSource.setAccessToUnderlyingConnectionAllowed(allow);
110
             * dataSource.setLoginTimeout(seconds);
111
             * dataSource.setLogWriter(out);
112
             */
113
        }
114

  
115
        return dataSource;
116
    }
117

  
118
    public DataStoreParameters getDataStoreParameters()
119
        throws PersonalDBException {
120

  
121
        return getJDBCStoreParameters();
122
    }
123

  
124
    public DataStoreParameters getDataStoreParameters(String schema,
125
        String table) throws PersonalDBException {
126

  
127
        JDBCStoreParameters params = getJDBCStoreParameters();
128
        params.setSchema(schema);
129
        params.setTable(table);
130
        return params;
131
    }
132

  
133
    private JDBCStoreParameters getJDBCStoreParameters()
134
        throws PersonalDBException {
135
        try {
136
            JDBCStoreParameters params =
137
                (JDBCStoreParameters) DALLocator.getDataManager()
138
                    .createStoreParameters(JDBCStoreProvider.NAME);
139

  
140
            params.setUrl(resourceParameters.getUrl());
141
            params.setJDBCDriverClassName(resourceParameters
142
                .getJDBCDriverClassName());
143

  
144
            return params;
145
        } catch (InitializeException e) {
146
            throw new DataServerExplorerParametersException(
147
                JDBCServerExplorer.NAME, e);
148
        } catch (ProviderNotRegisteredException e) {
149
            throw new DataServerExplorerParametersException(
150
                JDBCServerExplorer.NAME, e);
151
        }
152
    }
153

  
154
    public DataServerExplorerParameters getDataServerExplorerParameters()
155
        throws PersonalDBException {
156
        return getJDBCServerExplorerParameters();
157
    }
158

  
159
    public DataServerExplorerParameters getDataServerExplorerParameters(
160
        String schema) throws PersonalDBException {
161
        JDBCServerExplorerParameters params = getJDBCServerExplorerParameters();
162
        params.setSchema(schema);
163
        return params;
164
    }
165

  
166
    private JDBCServerExplorerParameters getJDBCServerExplorerParameters()
167
        throws PersonalDBException {
168
        try {
169
            JDBCServerExplorerParameters params =
170
                (JDBCServerExplorerParameters) DALLocator.getDataManager()
171
                    .createServerExplorerParameters(JDBCServerExplorer.NAME);
172

  
173
            params.setUrl(resourceParameters.getUrl());
174
            params.setJDBCDriverClassName(resourceParameters
175
                .getJDBCDriverClassName());
176

  
177
            return params;
178
        } catch (InitializeException e) {
179
            throw new DataServerExplorerParametersException(
180
                JDBCServerExplorer.NAME, e);
181
        } catch (ProviderNotRegisteredException e) {
182
            throw new DataServerExplorerParametersException(
183
                JDBCServerExplorer.NAME, e);
184
        }
185
    }
186

  
187
    public void open(JDBCResourceParameters resourceParameters) {
188
        LOG.debug(
189
            "Creating connection to personal database with parameters: {}",
190
            resourceParameters);
191

  
192
        this.resourceParameters = resourceParameters;
193
    }
194

  
195
    @Override
196
    protected void doDispose() throws BaseException {
197
        try {
198
            dataSource.close();
199
        } catch (SQLException e) {
200
            throw new DBAccessException(resourceParameters, e);
201
        }
202
    }
203
}
0 204

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.impl/src/main/java/org/gvsig/personaldb/impl/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28
<html xmlns="http://www.w3.org/1999/xhtml">
29
<head>
30
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31
<title>org.gvsig.personaldb package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>PersonalDB library API default implementation.</p>
36

  
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.83/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
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
}
0 75

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.personaldb.lib.api</artifactId>
5
    <packaging>jar</packaging>
6
    <name>org.gvsig.personaldb.lib.api</name>
7
    <parent>
8
        <groupId>org.gvsig</groupId>
9
        <artifactId>org.gvsig.personaldb.lib</artifactId>
10
        <version>2.0.83</version>
11
    </parent>
12
    <dependencies>
13
        <dependency>
14
            <groupId>org.gvsig</groupId>
15
            <artifactId>org.gvsig.tools.lib</artifactId>
16
            <scope>compile</scope>
17
        </dependency>
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
21
            <scope>compile</scope>
22
        </dependency>
23
    </dependencies>
24

  
25
    <build>
26
      <plugins>
27
        <plugin>
28
          <!-- Packaging tests in jar -->
29
          <groupId>org.apache.maven.plugins</groupId>
30
          <artifactId>maven-jar-plugin</artifactId>
31
          <executions>
32
            <!-- Generates a jar file only with the test classes -->
33
            <execution>
34
              <goals>
35
                <goal>test-jar</goal>
36
              </goals>
37
              <configuration>
38
                <includes>
39
                  <include>**/**</include>
40
                </includes>
41
              </configuration>
42
            </execution>
43
          </executions>
44
        </plugin> 
45
      </plugins>
46
    </build>
47

  
48
</project>
0 49

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/DataServerExplorerParametersException.java
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;
25

  
26

  
27
/**
28
 * Exception thrown when there is an error creating a connection to the
29
 * personal database.
30
 * 
31
 * @author gvSIG Team
32
 * @version $Id$
33
 */
34
public class DataServerExplorerParametersException extends PersonalDBException {
35

  
36
    private static final long serialVersionUID = 8918999379397938916L;
37

  
38
    private final static String MESSAGE_FORMAT =
39
        "Error creating a DataServerExplorerParameters for the personal "
40
            + "database of the type: %(name)";
41
    private final static String MESSAGE_KEY =
42
        "_DataServerExplorerParametersException";
43

  
44
    /**
45
     * Constructor with a message and a cause
46
     */
47
    public DataServerExplorerParametersException(String name,
48
        Throwable cause) {
49
        super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
50
        setValue("name", name);
51
    }
52
}
0 53

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBManager.java
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;
25

  
26
import java.sql.Connection;
27

  
28
import org.gvsig.fmap.dal.DataParameters;
29
import org.gvsig.fmap.dal.DataServerExplorerParameters;
30
import org.gvsig.fmap.dal.DataStoreParameters;
31

  
32
/**
33
 * This class is responsible of the management of the library's business logic.
34
 * It is the library's main entry point, and provides all the services to manage
35
 * {@link Connection}s and {@link DataParameters} to connect to the personal
36
 * database.
37
 * 
38
 * @see PersonalDBService
39
 * @author gvSIG team
40
 * @version $Id$
41
 */
42
public interface PersonalDBManager {
43

  
44
    /**
45
     * Returns a {@link Connection} the personal database.
46
     * 
47
     * @return a connection to the personal database
48
     * @throws PersonalDBException
49
     *             if there is an error getting the connection
50
     */
51
    public Connection getConnection() throws PersonalDBException;
52

  
53
    /**
54
     * Returns a {@link DataStoreParameters} to connect to the personal database
55
     * through the DAL library.
56
     * 
57
     * @return the DAL data store parameters to connect to connect to the
58
     *         database
59
     * @throws PersonalDBException
60
     *             if there is an error creating the parameters
61
     */
62
    public DataStoreParameters getDataStoreParameters()
63
        throws PersonalDBException;
64

  
65
    /**
66
     * Returns a {@link DataStoreParameters} to connect to the personal database
67
     * through the DAL library.
68
     * 
69
     * @param schema
70
     *            the schema of the table to load data from
71
     * @param table
72
     *            the name of the table to load data from
73
     * @return the DAL data store parameters to connect to connect to the
74
     *         database
75
     * @throws PersonalDBException
76
     *             if there is an error creating the parameters
77
     */
78
    public DataStoreParameters getDataStoreParameters(String schema,
79
        String table) throws PersonalDBException;
80

  
81
    /**
82
     * Returns a {@link DataServerExplorerParameters} to connect to the personal
83
     * database
84
     * through the DAL library.
85
     * 
86
     * @return the DAL data server explorer parameters to connect to connect to
87
     *         the
88
     *         database
89
     * @throws PersonalDBException
90
     *             if there is an error creating the parameters
91
     */
92
    public DataServerExplorerParameters getDataServerExplorerParameters()
93
        throws PersonalDBException;
94

  
95
    /**
96
     * Returns a {@link DataServerExplorerParameters} to connect to the personal
97
     * database
98
     * through the DAL library.
99
     * 
100
     * @param schema
101
     *            the schema of the database to connect to
102
     * @return the DAL data server explorer parameters to connect to connect to
103
     *         the
104
     *         database
105
     * @throws PersonalDBException
106
     *             if there is an error creating the parameters
107
     */
108
    public DataServerExplorerParameters getDataServerExplorerParameters(
109
        String schema) throws PersonalDBException;
110

  
111
}
0 112

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/DBAccessException.java
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;
25

  
26
import org.gvsig.fmap.dal.DataParameters;
27

  
28
/**
29
 * Exception thrown when there is an error creating a connection to the
30
 * personal database.
31
 * 
32
 * @author gvSIG Team
33
 * @version $Id$
34
 */
35
public class DBAccessException extends PersonalDBException {
36

  
37
    private static final long serialVersionUID = 8918999379397938916L;
38

  
39
    private final static String MESSAGE_FORMAT =
40
        "Access error to a database whose parameters are: %(parameters)";
41
    private final static String MESSAGE_KEY = "_DBAccessException";
42

  
43
    /**
44
     * Constructor with a message and a cause
45
     */
46
    public DBAccessException(DataParameters parameters, Throwable cause) {
47
        super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
48
        setValue("parameters", parameters.toString());
49
    }
50
}
0 51

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBException.java
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;
25

  
26
import org.gvsig.tools.exception.BaseException;
27

  
28
/**
29
 * Generic exception thrown in the PersonalDB API when the exception or error
30
 * may be dealt by the program or the user of the program which is a client of
31
 * the PersonalDB API.
32
 * 
33
 * @see {@link PersonalDBManager}
34
 * @author gvSIG team.
35
 * @version $Id$
36
 */
37
public class PersonalDBException extends BaseException {
38

  
39
    private static final long serialVersionUID = 6756475060924237176L;
40

  
41
    private static final String MESSAGE =
42
        "An error has been produced in the PersonalDB library";
43

  
44
    private static final String KEY = "_PersonalDBException";
45

  
46
    /**
47
     * Constructor to be used in rare cases, usually you must create a new child
48
     * exception class for each case.
49
     * <strong>Don't use this constructor in child classes.</strong>
50
     */
51
    public PersonalDBException() {
52
        super(MESSAGE, KEY, serialVersionUID);
53
    }
54

  
55
    /**
56
     * Constructor to be used in rare cases, usually you must create a new child
57
     * exception class for each case.
58
     * <p>
59
     * <strong>Don't use this constructor in child classes.</strong>
60
     * </p>
61
     * 
62
     * @param cause
63
     *            the original cause of the exception
64
     */
65
    public PersonalDBException(Exception cause) {
66
        super(MESSAGE, cause, KEY, serialVersionUID);
67
    }
68

  
69
    /**
70
     * @see BaseException#BaseException(String, String, long).
71
     * @param message
72
     *            the default messageFormat to describe the exception
73
     * @param key
74
     *            the key to use to search a localized messageFormnata
75
     * @param code
76
     *            the unique code to identify the exception
77
     */
78
    protected PersonalDBException(String message, String key, long code) {
79
        super(message, key, code);
80
    }
81

  
82
    /**
83
     * @see BaseException#BaseException(String, Throwable, String, long).
84
     * @param message
85
     *            the default messageFormat to describe the exception
86
     * @param cause
87
     *            the original cause of the exception
88
     * @param key
89
     *            the key to use to search a localized messageFormnata
90
     * @param code
91
     *            the unique code to identify the exception
92
     */
93
    protected PersonalDBException(String message, Throwable cause,
94
        String key, long code) {
95
        super(message, cause, key, code);
96
    }
97
}
0 98

  
tags/org.gvsig.desktop-2.0.83/org.gvsig.desktop.library/org.gvsig.personaldb/org.gvsig.personaldb.lib/org.gvsig.personaldb.lib.api/src/main/java/org/gvsig/personaldb/PersonalDBLocator.java
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;
25

  
26
import org.gvsig.tools.locator.BaseLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29

  
30
/**
31
 * This locator is the entry point for the PersonalDB library, providing
32
 * access to all PersonalDB services through the {@link PersonalDBManager}
33
 * .
34
 * 
35
 * @author gvSIG team
36
 * @version $Id$
37
 */
38
public class PersonalDBLocator extends BaseLocator {
39

  
40
    /**
41
     * PersonalDB manager name.
42
     */
43
    public static final String MANAGER_NAME = "PersonalDB.manager";
44

  
45
    /**
46
     * PersonalDB manager description.
47
     */
48
    public static final String MANAGER_DESCRIPTION = "PersonalDB Manager";
49

  
50
    private static final String LOCATOR_NAME = "PersonalDB.locator";
51

  
52
    /**
53
     * Unique instance.
54
     */
55
    private static final PersonalDBLocator INSTANCE =
56
        new PersonalDBLocator();
57

  
58
    /**
59
     * Return the singleton instance.
60
     * 
61
     * @return the singleton instance
62
     */
63
    public static PersonalDBLocator getInstance() {
64
        return INSTANCE;
65
    }
66

  
67
    /**
68
     * Return the Locator's name.
69
     * 
70
     * @return a String with the Locator's name
71
     */
72
    public final String getLocatorName() {
73
        return LOCATOR_NAME;
74
    }
75

  
76
    /**
77
     * Return a reference to the PersonalDBManager.
78
     * 
79
     * @return a reference to the PersonalDBManager
80
     * @throws LocatorException
81
     *             if there is no access to the class or the class cannot be
82
     *             instantiated
83
     * @see Locator#get(String)
84
     */
85
    public static PersonalDBManager getManager() throws LocatorException {
86
        return (PersonalDBManager) getInstance().get(MANAGER_NAME);
87
    }
88

  
89
    /**
90
     * Registers the Class implementing the PersonalDBManager interface.
91
     * 
92
     * @param clazz
93
     *            implementing the PersonalDBManager interface
94
     */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff