root / trunk / org.gvsig.postgresql / org.gvsig.postgresql.provider / src / main / java / org / gvsig / postgresql / dal / PostgreSQLLibrary.java @ 570
History | View | Annotate | Download (3.58 KB)
1 |
|
---|---|
2 |
package org.gvsig.postgresql.dal; |
3 |
|
4 |
import org.gvsig.fmap.dal.DALLibrary; |
5 |
import org.gvsig.fmap.dal.DALLocator; |
6 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
7 |
import org.gvsig.fmap.dal.store.db.DBHelper; |
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary; |
9 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase; |
10 |
import org.gvsig.metadata.exceptions.MetadataException; |
11 |
import org.gvsig.tools.library.AbstractLibrary; |
12 |
import org.gvsig.tools.library.LibraryException; |
13 |
|
14 |
|
15 |
public class PostgreSQLLibrary extends AbstractLibrary { |
16 |
|
17 |
public static final String NAME = "PostgreSQL"; |
18 |
|
19 |
@Override
|
20 |
public void doRegistration() { |
21 |
registerAsServiceOf(DALLibrary.class); |
22 |
require(JDBCLibrary.class); |
23 |
} |
24 |
|
25 |
@Override
|
26 |
protected void doInitialize() throws LibraryException { |
27 |
} |
28 |
|
29 |
@Override
|
30 |
protected void doPostInitialize() throws LibraryException { |
31 |
LibraryException ex = null;
|
32 |
|
33 |
DataManagerProviderServices dataman = |
34 |
(DataManagerProviderServices) DALLocator.getDataManager(); |
35 |
|
36 |
try {
|
37 |
Class.forName(PostgreSQLHelper.POSTGRESQL_JDBC_DRIVER);
|
38 |
} catch(Throwable th) { |
39 |
PostgreSQLHelper.LOGGER.warn("Can't load PostgreSQL JDBC Driver.",th);
|
40 |
} |
41 |
|
42 |
DBHelper.registerParametersDefinition( |
43 |
NAME + "StoreParameters",
|
44 |
PostgreSQLStoreParameters.class, |
45 |
dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
46 |
); |
47 |
DBHelper.registerParametersDefinition( |
48 |
NAME + "NewStoreParameters",
|
49 |
PostgreSQLNewStoreParameters.class, |
50 |
dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
51 |
); |
52 |
DBHelper.registerParametersDefinition( |
53 |
NAME + "ServerExplorerParameters",
|
54 |
PostgreSQLServerExplorerParameters.class, |
55 |
dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
56 |
); |
57 |
// DBHelper.registerParametersDefinition(
|
58 |
// NAME + "ResourceParameters",
|
59 |
// PostgreSQLResourceParameters.class,
|
60 |
// dataman.getResourceAsStream(this, NAME + "Parameters.xml")
|
61 |
// );
|
62 |
try {
|
63 |
DBHelper.registerMetadataDefinition( |
64 |
NAME, |
65 |
JDBCStoreProviderBase.class, |
66 |
dataman.getResourceAsStream(this, NAME + "Metadata.xml") |
67 |
); |
68 |
} catch (MetadataException e) {
|
69 |
ex = new LibraryException(this.getClass(), e); |
70 |
} |
71 |
|
72 |
// ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
|
73 |
// .getResourceManager();
|
74 |
//
|
75 |
// if (!resman.getResourceProviders().contains(NAME)) {
|
76 |
// resman.register(NAME,
|
77 |
// "Resource for " + NAME,
|
78 |
// PostgreSQLResource.class,
|
79 |
// PostgreSQLResourceParameters.class
|
80 |
// );
|
81 |
// }
|
82 |
|
83 |
if (!dataman.getStoreProviderRegister().exits(NAME)) {
|
84 |
dataman.registerStoreProviderFactory(new PostgreSQLStoreProviderFactory());
|
85 |
} |
86 |
|
87 |
if (!dataman.getServerExplorerRegister().exits(NAME)) {
|
88 |
dataman.registerServerExplorerFactory(new PostgreSQLServerExplorerFactory());
|
89 |
} |
90 |
|
91 |
// Por compatibilidad con gvSIG 2.3 registramos otra vez la factoria con
|
92 |
// el nombre que tenia antes.
|
93 |
if (!dataman.getServerExplorerRegister().exits("PostgreSQLExplorer")) { |
94 |
dataman.registerServerExplorerFactory(new PostgreSQLServerExplorerFactory("PostgreSQLExplorer")); |
95 |
} |
96 |
|
97 |
if (ex != null) { |
98 |
throw ex;
|
99 |
} |
100 |
} |
101 |
|
102 |
} |