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 @ 43020
History | View | Annotate | Download (1.7 KB)
1 | 43020 | jjdelcerro | |
---|---|---|---|
2 | package org.gvsig.fmap.dal.impl; |
||
3 | |||
4 | import org.apache.commons.lang3.reflect.ConstructorUtils; |
||
5 | import org.gvsig.fmap.dal.DataServerExplorer; |
||
6 | import org.gvsig.fmap.dal.DataServerExplorerParameters; |
||
7 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
8 | import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerFactory; |
||
9 | import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
||
10 | import org.gvsig.tools.dynobject.DynObject; |
||
11 | |||
12 | |||
13 | public class DataServerExplorerToDataExplorerFactoryWrapper extends AbstractDataServerExplorerFactory { |
||
14 | |||
15 | private final Class explorerClass; |
||
16 | private final Class parametersClass; |
||
17 | |||
18 | public DataServerExplorerToDataExplorerFactoryWrapper(
|
||
19 | String name,
|
||
20 | String description,
|
||
21 | Class explorerClass,
|
||
22 | Class parametersClass
|
||
23 | ) { |
||
24 | super(name, description);
|
||
25 | this.explorerClass = explorerClass;
|
||
26 | this.parametersClass = parametersClass;
|
||
27 | |||
28 | } |
||
29 | |||
30 | @Override
|
||
31 | public DataServerExplorer create(DataServerExplorerParameters parameters, DataServerExplorerProviderServices providerServices) throws InitializeException { |
||
32 | try {
|
||
33 | DataServerExplorer explorer = (DataServerExplorer) ConstructorUtils.invokeConstructor( |
||
34 | explorerClass, parameters, providerServices |
||
35 | ); |
||
36 | return explorer;
|
||
37 | } catch (Exception ex) { |
||
38 | throw new InitializeException(ex); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | @Override
|
||
43 | public DynObject createParameters() {
|
||
44 | try {
|
||
45 | return (DynObject) parametersClass.newInstance();
|
||
46 | } catch (Exception e) { |
||
47 | throw new RuntimeException(e); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | } |