svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / impl / DataServerExplorerToDataExplorerFactoryWrapper.java @ 47779
History | View | Annotate | Download (2.08 KB)
1 | 43020 | jjdelcerro | package org.gvsig.fmap.dal.impl; |
---|---|---|---|
2 | |||
3 | import org.apache.commons.lang3.reflect.ConstructorUtils; |
||
4 | import org.gvsig.fmap.dal.DataServerExplorer; |
||
5 | import org.gvsig.fmap.dal.DataServerExplorerParameters; |
||
6 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
7 | import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerFactory; |
||
8 | import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
||
9 | import org.gvsig.tools.dynobject.DynObject; |
||
10 | 45037 | jjdelcerro | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; |
||
12 | 43020 | jjdelcerro | |
13 | 45037 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
14 | 43020 | jjdelcerro | public class DataServerExplorerToDataExplorerFactoryWrapper extends AbstractDataServerExplorerFactory { |
15 | |||
16 | 45037 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(DataServerExplorerToDataExplorerFactoryWrapper.class); |
17 | |||
18 | 43020 | jjdelcerro | private final Class explorerClass; |
19 | private final Class parametersClass; |
||
20 | |||
21 | public DataServerExplorerToDataExplorerFactoryWrapper(
|
||
22 | 45037 | jjdelcerro | String name,
|
23 | String description,
|
||
24 | Class explorerClass,
|
||
25 | 43020 | jjdelcerro | Class parametersClass
|
26 | 45037 | jjdelcerro | ) { |
27 | 43020 | jjdelcerro | super(name, description);
|
28 | this.explorerClass = explorerClass;
|
||
29 | this.parametersClass = parametersClass;
|
||
30 | 45037 | jjdelcerro | LOGGER.warn("Creating wrapper for old style DataServerExplorer (" + explorerClass.getName() + ")."); |
31 | |||
32 | 43020 | jjdelcerro | } |
33 | |||
34 | @Override
|
||
35 | public DataServerExplorer create(DataServerExplorerParameters parameters, DataServerExplorerProviderServices providerServices) throws InitializeException { |
||
36 | try {
|
||
37 | DataServerExplorer explorer = (DataServerExplorer) ConstructorUtils.invokeConstructor( |
||
38 | explorerClass, parameters, providerServices |
||
39 | ); |
||
40 | return explorer;
|
||
41 | } catch (Exception ex) { |
||
42 | throw new InitializeException(ex); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | @Override
|
||
47 | public DynObject createParameters() {
|
||
48 | try {
|
||
49 | 45037 | jjdelcerro | return (DynObject) parametersClass.newInstance();
|
50 | 43020 | jjdelcerro | } catch (Exception e) { |
51 | 45037 | jjdelcerro | throw new RuntimeException(e); |
52 | } |
||
53 | 43020 | jjdelcerro | } |
54 | |||
55 | 45037 | jjdelcerro | @Override
|
56 | public boolean isStoreSupported(String name) { |
||
57 | return false; |
||
58 | } |
||
59 | |||
60 | 43020 | jjdelcerro | } |