Revision 68
org.gvsig.fortunecookies/trunk/provider-based-implementation-with-user-interface/org.gvsig.fortunecookies/org.gvsig.fortunecookies.prov/org.gvsig.fortunecookies.prov.fileprovider/src/main/java/org/gvsig/fortunecookies/prov/fileprovider/FortuneCookieFileProviderFactory.java | ||
---|---|---|
42 | 42 |
*/ |
43 | 43 |
public class FortuneCookieFileProviderFactory implements ProviderFactory { |
44 | 44 |
|
45 |
private static final String PROVIDER_NAME = "FortuneCookie.providers.file"; |
|
46 |
private static final String PROVIDER_DESCRIPTION = |
|
47 |
"Provider to load fortune cookies from a web site"; |
|
45 |
private static final String PROVIDER_NAME = "FortuneCookie.providers.file"; |
|
46 |
private static final String PROVIDER_DESCRIPTION = "Provider to load fortune cookies from a web site"; |
|
48 | 47 |
|
49 |
private static final String PARAMETER_FILE = "File";
|
|
48 |
private static final String PARAMETER_FILE = "File";
|
|
50 | 49 |
|
51 |
private DynClass parametersDefinition;
|
|
50 |
private DynClass parametersDefinition;
|
|
52 | 51 |
|
53 |
public Provider create(DynObject parameters, ProviderServices services)
|
|
54 |
throws ServiceException {
|
|
55 |
return new FortuneCookieFileProvider(services, (File) parameters
|
|
56 |
.getDynValue(PARAMETER_FILE));
|
|
57 |
}
|
|
52 |
public Provider create(DynObject parameters, ProviderServices services)
|
|
53 |
throws ServiceException {
|
|
54 |
return new FortuneCookieFileProvider(services, (File) parameters
|
|
55 |
.getDynValue(PARAMETER_FILE));
|
|
56 |
}
|
|
58 | 57 |
|
59 |
public DynObject createParameters() {
|
|
60 |
return ToolsLocator.getDynObjectManager().createDynObject(
|
|
61 |
parametersDefinition);
|
|
62 |
}
|
|
58 |
public DynObject createParameters() {
|
|
59 |
return ToolsLocator.getDynObjectManager().createDynObject(
|
|
60 |
parametersDefinition);
|
|
61 |
}
|
|
63 | 62 |
|
64 |
public String getName() {
|
|
65 |
return PROVIDER_NAME;
|
|
66 |
}
|
|
63 |
public String getName() {
|
|
64 |
return PROVIDER_NAME;
|
|
65 |
}
|
|
67 | 66 |
|
68 |
public void initialize() { |
|
69 |
URL url = |
|
70 |
getClass().getClassLoader().getResource( |
|
71 |
"org/gvsig/fortunecookies/prov/fileprovider/messages.txt"); |
|
67 |
public void initialize() { |
|
68 |
URL url = getClass().getResource("messages.txt"); |
|
72 | 69 |
|
73 |
parametersDefinition = |
|
74 |
ToolsLocator.getDynObjectManager().createDynClass(PROVIDER_NAME, |
|
75 |
PROVIDER_DESCRIPTION); |
|
76 |
parametersDefinition.addDynField(PARAMETER_FILE) |
|
77 |
.setType(DataTypes.FILE).setMandatory(true).setDefaultDynValue( |
|
78 |
new File(url.getFile())); |
|
79 |
} |
|
70 |
parametersDefinition = ToolsLocator.getDynObjectManager() |
|
71 |
.createDynClass(PROVIDER_NAME, PROVIDER_DESCRIPTION); |
|
72 |
parametersDefinition.addDynField(PARAMETER_FILE) |
|
73 |
.setType(DataTypes.FILE).setMandatory(true).setDefaultDynValue( |
|
74 |
new File(url.getFile())); |
|
75 |
} |
|
80 | 76 |
|
81 | 77 |
} |
Also available in: Unified diff