gvsig-mssqlserver / trunk / org.gvsig.mssqlserver / org.gvsig.mssqlserver.provider / src / main / java / org / gvsig / mssqlserver / dal / MSSQLServerLibrary.java @ 5
History | View | Annotate | Download (3.98 KB)
1 | 5 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
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 2
|
||
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 | */
|
||
22 | package org.gvsig.mssqlserver.dal; |
||
23 | |||
24 | import org.gvsig.fmap.dal.DALLibrary; |
||
25 | import org.gvsig.fmap.dal.DALLocator; |
||
26 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
27 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
28 | import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary; |
||
29 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase; |
||
30 | import org.gvsig.metadata.exceptions.MetadataException; |
||
31 | import org.gvsig.tools.library.AbstractLibrary; |
||
32 | import org.gvsig.tools.library.LibraryException; |
||
33 | |||
34 | public class MSSQLServerLibrary extends AbstractLibrary { |
||
35 | |||
36 | // com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||
37 | |||
38 | public static final String NAME = "MSSQLServer"; |
||
39 | |||
40 | @Override
|
||
41 | public void doRegistration() { |
||
42 | registerAsServiceOf(DALLibrary.class); |
||
43 | require(JDBCLibrary.class); |
||
44 | } |
||
45 | |||
46 | @Override
|
||
47 | protected void doInitialize() throws LibraryException { |
||
48 | } |
||
49 | |||
50 | @Override
|
||
51 | protected void doPostInitialize() throws LibraryException { |
||
52 | LibraryException ex = null;
|
||
53 | |||
54 | DataManagerProviderServices dataman = |
||
55 | (DataManagerProviderServices) DALLocator.getDataManager(); |
||
56 | |||
57 | DBHelper.registerParametersDefinition( |
||
58 | NAME + "StoreParameters",
|
||
59 | MSSQLServerStoreParameters.class, |
||
60 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
61 | ); |
||
62 | DBHelper.registerParametersDefinition( |
||
63 | NAME + "NewStoreParameters",
|
||
64 | MSSQLServerNewStoreParameters.class, |
||
65 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
66 | ); |
||
67 | DBHelper.registerParametersDefinition( |
||
68 | NAME + "ServerExplorerParameters",
|
||
69 | MSSQLServerExplorerParameters.class, |
||
70 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
71 | ); |
||
72 | // DBHelper.registerParametersDefinition(
|
||
73 | // NAME + "ResourceParameters",
|
||
74 | // MSSQLServerResourceParameters.class,
|
||
75 | // dataman.getResourceAsStream(this, NAME + "Parameters.xml")
|
||
76 | // );
|
||
77 | try {
|
||
78 | DBHelper.registerMetadataDefinition( |
||
79 | NAME, |
||
80 | JDBCStoreProviderBase.class, |
||
81 | dataman.getResourceAsStream(this, NAME + "Metadata.xml") |
||
82 | ); |
||
83 | } catch (MetadataException e) {
|
||
84 | ex = new LibraryException(this.getClass(), e); |
||
85 | } |
||
86 | |||
87 | // ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
|
||
88 | // .getResourceManager();
|
||
89 | //
|
||
90 | // if (!resman.getResourceProviders().contains(NAME)) {
|
||
91 | // resman.register(NAME,
|
||
92 | // "Resource for " + NAME,
|
||
93 | // MSSQLServerResource.class,
|
||
94 | // MSSQLServerResourceParameters.class
|
||
95 | // );
|
||
96 | // }
|
||
97 | |||
98 | if (!dataman.getStoreProviderRegister().exits(NAME)) {
|
||
99 | dataman.registerStoreProviderFactory(new MSSQLServerStoreProviderFactory());
|
||
100 | } |
||
101 | |||
102 | if (!dataman.getServerExplorerRegister().exits(NAME)) {
|
||
103 | dataman.registerServerExplorerFactory(new MSSQLServerExplorerFactory());
|
||
104 | } |
||
105 | if (ex != null) { |
||
106 | throw ex;
|
||
107 | } |
||
108 | } |
||
109 | |||
110 | } |