Revision 43861 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.png/src/main/java/org/gvsig/fmap/dal/file/png/PngLibrary.java
PngLibrary.java | ||
---|---|---|
20 | 20 |
* For any additional information, do not hesitate to contact us |
21 | 21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
22 | 22 |
*/ |
23 |
|
|
24 | 23 |
package org.gvsig.fmap.dal.file.png; |
25 | 24 |
|
26 | 25 |
import java.util.ArrayList; |
... | ... | |
30 | 29 |
import org.gvsig.fmap.dal.DALFileLocator; |
31 | 30 |
import org.gvsig.fmap.dal.DALLibrary; |
32 | 31 |
import org.gvsig.fmap.dal.FileHelper; |
32 |
import org.gvsig.fmap.dal.file.imageio.ImageIOFileSystemServerProviderFactory; |
|
33 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProvider; |
|
34 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProviderFactory; |
|
35 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProviderParameters; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
|
33 | 37 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
34 | 38 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
39 |
import org.gvsig.metadata.MetadataLocator; |
|
40 |
import org.gvsig.metadata.MetadataManager; |
|
35 | 41 |
import org.gvsig.metadata.exceptions.MetadataException; |
42 |
import org.gvsig.tools.dynobject.DynClass; |
|
36 | 43 |
import org.gvsig.tools.library.AbstractLibrary; |
37 | 44 |
import org.gvsig.tools.library.LibraryException; |
38 | 45 |
|
39 | 46 |
/** |
40 | 47 |
* Png Library to register provider components |
48 |
* |
|
41 | 49 |
* @author fdiaz |
42 | 50 |
* |
43 | 51 |
*/ |
44 | 52 |
public class PngLibrary extends AbstractLibrary { |
45 | 53 |
|
54 |
public static String NAME = "PNG"; |
|
55 |
public static String DESCRIPTION = "PNG provider"; |
|
56 |
public static String[] FILE_EXTENSIONS = new String[]{"png"}; |
|
57 |
|
|
46 | 58 |
@Override |
47 | 59 |
public void doRegistration() { |
48 | 60 |
registerAsServiceOf(DALLibrary.class); |
... | ... | |
50 | 62 |
|
51 | 63 |
} |
52 | 64 |
|
53 |
@Override
|
|
54 |
protected void doInitialize() throws LibraryException {
|
|
55 |
}
|
|
65 |
@Override
|
|
66 |
protected void doInitialize() throws LibraryException {
|
|
67 |
}
|
|
56 | 68 |
|
57 |
@Override
|
|
58 |
protected void doPostInitialize() throws LibraryException {
|
|
59 |
List<Throwable> exs = new ArrayList<Throwable>();
|
|
69 |
@Override
|
|
70 |
protected void doPostInitialize() throws LibraryException {
|
|
71 |
List<Throwable> exs = new ArrayList<>();
|
|
60 | 72 |
|
61 |
FileHelper.registerParametersDefinition( |
|
62 |
PngStoreProviderParameters.PARAMETERS_DEFINITION_NAME, |
|
63 |
PngStoreProviderParameters.class, PngStoreProvider.NAME+"Parameters.xml"); |
|
64 |
try { |
|
65 |
FileHelper.registerMetadataDefinition( |
|
66 |
PngStoreProvider.METADATA_DEFINITION_NAME, |
|
67 |
PngStoreProvider.class, PngStoreProvider.NAME+"Metadata.xml"); |
|
68 |
} catch (MetadataException e) { |
|
69 |
exs.add(e); |
|
70 |
} |
|
73 |
FileHelper.registerParametersDefinition( |
|
74 |
NAME + "StoreProviderParameters", |
|
75 |
ImageIOStoreProviderParameters.class, |
|
76 |
this.getClass().getClassLoader(), |
|
77 |
this.getClass().getResource(NAME + "Parameters.xml")); |
|
78 |
try { |
|
79 |
try { |
|
80 |
FileHelper.registerMetadataDefinition( |
|
81 |
NAME, |
|
82 |
ImageIOStoreProvider.class, |
|
83 |
this.getClass().getClassLoader(), |
|
84 |
this.getClass().getResource(NAME + "Metadata.xml")); |
|
85 |
} catch (MetadataException e) { |
|
86 |
exs.add(e); |
|
87 |
} |
|
71 | 88 |
|
72 |
DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices(); |
|
89 |
DataManagerProviderServices datamanager = DALSPILocator.getDataManagerProviderServices(); |
|
90 |
FilesystemServerExplorerManager explorerManager = DALFileLocator.getFilesystemServerExplorerManager(); |
|
73 | 91 |
|
74 |
|
|
75 |
try { |
|
76 |
if (!dataman.getStoreProviders() |
|
77 |
.contains(PngStoreProvider.NAME)) { |
|
78 |
dataman.registerStoreProviderFactory( |
|
79 |
new PngStoreProviderFactory( |
|
80 |
PngStoreProvider.NAME, |
|
81 |
PngStoreProvider.DESCRIPTION)); |
|
92 |
if (!datamanager.getStoreProviders().contains(NAME)) { |
|
93 |
datamanager.registerStoreProviderFactory( |
|
94 |
new ImageIOStoreProviderFactory( |
|
95 |
NAME, |
|
96 |
DESCRIPTION)); |
|
82 | 97 |
} |
83 |
} catch (RuntimeException e) { |
|
84 |
exs.add(e); |
|
85 |
} |
|
98 |
explorerManager.registerProviderFactory( |
|
99 |
new ImageIOFileSystemServerProviderFactory( |
|
100 |
NAME, |
|
101 |
DESCRIPTION, |
|
102 |
FILE_EXTENSIONS |
|
103 |
) |
|
104 |
); |
|
105 |
} catch (Exception e) { |
|
106 |
exs.add(e); |
|
107 |
} |
|
86 | 108 |
|
87 |
//FIXME: Cambiar usando la factoria |
|
88 |
try { |
|
89 |
DALFileLocator.getFilesystemServerExplorerManager() |
|
90 |
.registerProvider(PngStoreProvider.NAME, |
|
91 |
PngStoreProvider.DESCRIPTION, |
|
92 |
PngFileSystemServerProvider.class); |
|
93 |
} catch (RuntimeException e) { |
|
94 |
exs.add(e); |
|
95 |
} |
|
109 |
if (exs.size() > 0) { |
|
110 |
throw new LibraryException(this.getClass(), exs); |
|
111 |
} |
|
96 | 112 |
|
97 |
if (exs.size() > 0) { |
|
98 |
throw new LibraryException(this.getClass(), exs); |
|
99 |
} |
|
100 |
} |
|
101 |
} |
|
113 |
} |
|
114 |
|
|
115 |
public static DynClass getMatadataDefinition() { |
|
116 |
MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
|
117 |
DynClass metadataDefinition = (DynClass) metadataManager.getDefinition(NAME); |
|
118 |
return metadataDefinition; |
|
119 |
} |
|
120 |
} |
Also available in: Unified diff