Represents a spatial service, which may be lazily loaded. The existance of this object does not ensure that the advertized data is guaranteed to exist, nor does this interface guarantee that the service exists based on this object's existance. We should also note the resource management is left to the user, and that resolve() is not guaranteed to return the same instance object from two subsequent calls, but may. This is merely a handle to some information about a service, and a method of aquiring an instance of the service ...
NOTE: This may be the result of communications with a metadata service, and as such this service described may not be running right now. Remember to check the service status.
public API getAPI( ProgressMonitor monitor){ if (monitor == null) monitor = new NullProgressMonitor(); monitor.beingTask("Connect to API",2); try { String server = getConnectionParams().get("server"); monitor.worked(1); return new API( s ); } finally { monitor.done(); } }
(note the use of NullProgressMonitor) public <T> boolean canResolve( Class<T> adaptee ) { return adaptee != null && (adaptee.isAssignableFrom(API.class) || super.canResolve(adaptee)); } public <T> T resolve( Class<T> adaptee, IProgressMonitor monitor ) throws IOException { if (monitor == null) monitor = new NullProgressMonitor(); if (adaptee == null) throw new NullPointerException("No adaptor specified" ); if (adaptee.isAssignableFrom(API.class)) { return adaptee.cast(getAPI(monitor)); } return super.resolve(adaptee, monitor); }
(note the call to super) API api = null; Throwable msg = null; public synchronized API getAPI( ProgressMonitor monitor){ if( api != null ) return api; if (monitor == null) monitor = new NullProgressMonitor(); monitor.beingTask("Connect to API",2); try { String server = getConnectionParams().get("server"); monitor.worked(1); api = new API( s ); monitor.worked(1); return api; } finally { monitor.done(); } } public Status getStatus() { return msg != null? Status.BROKEN : api == null? Status.NOTCONNECTED : Status.CONNECTED; } public Throwable getMessage(){ return msg; } public synchronized void dispose( ProgressMonitor monitor ){ if( api != null ){ api.dispose(); api = null; } if( msg != null ) msg = null; }
(Note the use of getMessage and getStatus)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|