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 |
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 |
import org.slf4j.Logger; |
11 |
import org.slf4j.LoggerFactory; |
12 |
|
13 |
@SuppressWarnings("UseSpecificCatch") |
14 |
public class DataServerExplorerToDataExplorerFactoryWrapper extends AbstractDataServerExplorerFactory { |
15 |
|
16 |
private static final Logger LOGGER = LoggerFactory.getLogger(DataServerExplorerToDataExplorerFactoryWrapper.class); |
17 |
|
18 |
private final Class explorerClass; |
19 |
private final Class parametersClass; |
20 |
|
21 |
public DataServerExplorerToDataExplorerFactoryWrapper(
|
22 |
String name,
|
23 |
String description,
|
24 |
Class explorerClass,
|
25 |
Class parametersClass
|
26 |
) { |
27 |
super(name, description);
|
28 |
this.explorerClass = explorerClass;
|
29 |
this.parametersClass = parametersClass;
|
30 |
LOGGER.warn("Creating wrapper for old style DataServerExplorer (" + explorerClass.getName() + ")."); |
31 |
|
32 |
} |
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 |
return (DynObject) parametersClass.newInstance();
|
50 |
} catch (Exception e) { |
51 |
throw new RuntimeException(e); |
52 |
} |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public boolean isStoreSupported(String name) { |
57 |
return false; |
58 |
} |
59 |
|
60 |
} |