Java Doc for IService.java in  » GIS » udig-1.1 » net » refractions » udig » catalog » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » udig 1.1 » net.refractions.udig.catalog 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.refractions.udig.catalog.IService

All known Subclasses:   net.refractions.udig.catalog.rasterings.AbstractRasterService,  net.refractions.udig.catalog.internal.oracle.OracleServiceImpl,  net.refractions.udig.catalog.internal.db2.DB2Service,  net.refractions.udig.catalog.hsql.internal.HsqlServiceImpl,  net.refractions.udig.catalog.memory.internal.MemoryServiceImpl,  net.refractions.udig.mapgraphic.internal.MapGraphicService,  net.refractions.udig.catalog.internal.shp.ShpServiceImpl,  net.refractions.udig.catalog.internal.wfs.WFSServiceImpl,  net.refractions.udig.catalog.internal.postgis.PostGISServiceImpl,  net.refractions.udig.catalog.internal.gml.GMLServiceImpl,  net.refractions.udig.catalog.internal.arcsde.ArcServiceImpl,  net.refractions.udig.catalog.internal.wms.WMSServiceImpl,
IService
abstract public class IService implements IResolve(Code)
Represents a geo spatial service handle. Follows the same design as IResource.

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.

Implementing an IService

Implement the abstract methods and you are good to go.

Extending an IService

You may want to implement your own IService in order to provide a handle for a new kind of API.
  1. New method:
    
     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)
  2. Optional: Customize resolve method to advertise your new API "dynamically"
    
     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)
  3. Optional: cache your API as the "connection"
    
     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)

author:
   David Zwiers, Refractions Research
since:
   0.6
See Also:   IServiceInfo
See Also:   IServiceFactory




Method Summary
public  booleancanResolve(Class<T> adaptee)
     Harded coded to capture the IService contract.
public  voiddispose(IProgressMonitor monitor)
    
final public  booleanequals(Object arg0)
    
abstract public  Map<String, Serializable>getConnectionParams()
     Accessor to the set of params used to create this entry.
abstract public  IServiceInfogetInfo(IProgressMonitor monitor)
    
final public  inthashCode()
    
abstract public  List<? extends IGeoResource>members(IProgressMonitor monitor)
     Return list of IGeoResources managed by this service.
public  ICatalogparent(IProgressMonitor monitor)
     Returns LocalCatalog by defaul, subclass must override iff a custom catalog is used.
public  Tresolve(Class<T> adaptee, IProgressMonitor monitor)
     Will attempt to morph into the adaptee, and return that object.
public  StringtoString()
     Indicate class and id.



Method Detail
canResolve
public boolean canResolve(Class<T> adaptee)(Code)
Harded coded to capture the IService contract.

That is we *must* resolve the following:

  • IService: this
  • IServiceInfo.class: getInfo
  • List.class: members
  • ICatalog.class: parent

Here is an implementation example (for something that can adapt to DataStore):


 public <T> boolean canResolve( Class<T> adaptee ) {
 return adaptee != null
 && (adaptee.isAssignableFrom(DataStore.class) || super.canResolve(adaptee));
 }
 



dispose
public void dispose(IProgressMonitor monitor)(Code)



equals
final public boolean equals(Object arg0)(Code)
This should represent the identifier
See Also:   Object.equals(java.lang.Object)
Parameters:
  arg0 -



getConnectionParams
abstract public Map<String, Serializable> getConnectionParams()(Code)
Accessor to the set of params used to create this entry. There is no guarantee that these params created a usable service (@see getStatus() ). These params may have been modified within the factory during creation. This method is intended to be used for cloning (@see IServiceFactory) or for persistence between sessions.

IMPORTANT: Because of the serialization currently used only types that can be reconstructed from their toString() representation can be used. For example:


 valueThatIsSaved=url.toString().
 URL restoredValue=new URL(valueThatIsSaved);
 
Also only classes that this plugin can load can be loaded so custom classes from downstream plugins cannot be used. It is recommended that only "normal" types be used like Integer, URL, Float, etc...

This restriction will be lifted in the future. (Except for the loading issue that is a design issue that we will live with.)
See Also:   IServiceFactory



getInfo
abstract public IServiceInfo getInfo(IProgressMonitor monitor) throws IOException(Code)
IServiceInfo resolve(IServiceInfo.class,IProgressMonitor monitor);
See Also:   IService.resolve(ClassIProgressMonitor)



hashCode
final public int hashCode()(Code)
This should represent the identified
See Also:   Object.hashCode



members
abstract public List<? extends IGeoResource> members(IProgressMonitor monitor) throws IOException(Code)
Return list of IGeoResources managed by this service.

Many file based serivces will just contain a single IGeoResource.




parent
public ICatalog parent(IProgressMonitor monitor)(Code)
Returns LocalCatalog by defaul, subclass must override iff a custom catalog is used.



resolve
public T resolve(Class<T> adaptee, IProgressMonitor monitor) throws IOException(Code)
Will attempt to morph into the adaptee, and return that object. Harded coded to capture the IService contract.

That is we *must* resolve the following:

  • IService: this
  • IServiceInfo.class: getInfo
  • ICatalog.class: parent
Recomended adaptations:
  • ImageDescriptor.class: for a custom icon
  • List.class: members
May Block.

Example implementation:


 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);
 }
 

Parameters:
  adaptee -
Parameters:
  monitor - instance of adaptee, or null if unavailable (IServiceInfo and Listmust be supported)
See Also:   IServiceInfo
See Also:   IGeoResource
See Also:   IResolve.resolve(ClassIProgressMonitor)



toString
public String toString()(Code)
Indicate class and id. string representing this IResolve



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.