01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.catalog;
18:
19: import java.io.Serializable;
20: import java.net.URL;
21: import java.util.Map;
22:
23: /**
24: * This is the required addition on the part of a data provider.
25: *
26: * Example:<pre><code>
27: * public class MyService implements ServiceExtension {
28: * public Map<String, Serializable> createParams( URL url ) {
29: * if( url.toString().endsWith(".my") ){
30: * Map<String, Serializable> map = new HashMap<String, Serializable>();
31: * map.put("url",url);
32: * return map;
33: * }
34: * return null; // url must be for someone else
35: * }
36: * public IService createService( URL id, Map<String, Serializable> params ) {
37: * if( params.get("url") == null ||
38: * !params.get("url").toString().endsWith(".xml") ){
39: * return null;
40: * }
41: * return new MyService( params );
42: * }
43: * }
44: * <code></pre>
45: * We also use this interface internally, so look in this plugin for additional examples.
46: *
47: * @author David Zwiers, Refractions Research
48: * @since 0.6
49: */
50: public interface ServiceExtension {
51:
52: public final static String EXTENSION_ID = "net.refractions.udig.catalog.ServiceExtension"; //$NON-NLS-1$
53:
54: /**
55: * Creates an IService based on the params provided. This may or may not return a singleton,
56: * caching is optional. Error messages can be retrieved using the getStatus and getMessage
57: * methods. It is important to note that this method must inspect the url to determine if it can
58: * be used to create the service. If it cannot, null must be returned.
59: *
60: * @param id The sugested service id, should be generated when null.
61: * @param params The set of connection params. These param values may either be parsed, or
62: * unparsed (String).
63: * @return the IService created, or null when a service cannot be created from these params.
64: * @see IService#getStatus()
65: * @see IService#getMessage()
66: */
67: IService createService(URL id, Map<String, Serializable> params);
68:
69: /**
70: * The primary intention is for drag 'n' drop. This generates a set of params for the given URL
71: * ... in most cases this will be passed to the createService method. It is important to note
72: * that this method must inspect the url to determine if it can be used to create the service.
73: * If it cannot, null must be returned.
74: *
75: * @param url The potential source of params.
76: * @return Map of params to be used for creation, <code>null</code> if the URL cannot be used.
77: */
78: Map<String, Serializable> createParams(URL url);
79: }
|