Class TapServiceKit


  • public class TapServiceKit
    extends java.lang.Object
    Handles asynchronous population of the TAP metadata hierarchy. It owns a TapMetaReader and invokes its methods as required to populate the metadata hiearchy objects, providing methods that allow callbacks to be invoked when the relevant items are available.

    This class is intended for use with Swing; some methods must be invoked from the Event Dispatch Thread as documented.

    Since:
    23 Mar 2015
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      TapServiceKit​(EndpointSet endpointSet, java.lang.String ivoid, TapMetaPolicy metaPolicy, uk.ac.starlink.util.ContentCoding coding, int queueLimit)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void acquireCapability​(ResultHandler<TapCapability> handler)
      Asynchronously acquires TAP capability information.
      void acquireExamples​(ResultHandler<DaliExample[]> handler)
      Asynchronously acquires a list of service-specific query examples, if available.
      void acquireResource​(ResultHandler<java.util.Map<java.lang.String,​java.lang.String>> handler)
      Asynchronously acquires information about the registry resource corresponding to this service.
      void acquireRoles​(ResultHandler<RegRole[]> handler)
      Asynchronously acquires information from the RegTAP rr.res_role table corresponding to this service.
      void acquireSchemas​(ResultHandler<SchemaMeta[]> handler)
      Asynchronously acquires TAP database schema list.
      EndpointSet getEndpointSet()
      Returns the endpoint set used by this kit.
      java.lang.String getIvoid()
      Returns the resource identifier for this kit if known.
      TapMetaReader getMetaReader()
      Returns the TapMetaReader in use by this kit.
      EndpointSet getRegTapEndpointSet()
      Returns the URL at which a RegTAP service lives that can be queried for information about this service's registry record.
      boolean onColumns​(TableMeta tmeta, java.lang.Runnable callback)
      Invokes a runnable on the Event Dispatch Thread when the column metadata is available for a given table metadata object.
      boolean onForeignKeys​(TableMeta tmeta, java.lang.Runnable callback)
      Invokes a runnable on the Event Dispatch Thread when the foreign key metadata is available for a given table metadata object.
      boolean onTables​(SchemaMeta smeta, java.lang.Runnable callback)
      Invokes a runnable on the Event Dispatch Thread when the table metadata is available for a given schema metadata object.
      void shutdown()
      Releases resources and terminates any currently running asynchronous metadata reads.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TapServiceKit

        public TapServiceKit​(EndpointSet endpointSet,
                             java.lang.String ivoid,
                             TapMetaPolicy metaPolicy,
                             uk.ac.starlink.util.ContentCoding coding,
                             int queueLimit)
        Constructor.
        Parameters:
        endpointSet - service location set
        ivoid - IVORN of TAP service, if known (may be null)
        metaPolicy - implementation for reading table metadata
        coding - configures HTTP compression
        queueLimit - maximum number of table metadata requests queued to service; more than that and older ones will be dropped
    • Method Detail

      • getEndpointSet

        public EndpointSet getEndpointSet()
        Returns the endpoint set used by this kit.
        Returns:
        service locations
      • getIvoid

        public java.lang.String getIvoid()
        Returns the resource identifier for this kit if known.
        Returns:
        IVORN for TAP service resource, or null
      • onTables

        public boolean onTables​(SchemaMeta smeta,
                                java.lang.Runnable callback)
        Invokes a runnable on the Event Dispatch Thread when the table metadata is available for a given schema metadata object. This method, and the supplied callback, are invoked on the EDT.
        Parameters:
        smeta - schema metadata item
        callback - runnable to be invoked on the EDT when smeta.getTables() has a non-null return
        Returns:
        true iff callback has been called synchronously
      • onColumns

        public boolean onColumns​(TableMeta tmeta,
                                 java.lang.Runnable callback)
        Invokes a runnable on the Event Dispatch Thread when the column metadata is available for a given table metadata object. This method, and the supplied callback, are invoked on the EDT.
        Parameters:
        tmeta - table metadata item
        callback - runnable to be invoked on the EDT when tmeta.getColumns() has a non-null return
        Returns:
        true iff callback has been called synchronously
      • onForeignKeys

        public boolean onForeignKeys​(TableMeta tmeta,
                                     java.lang.Runnable callback)
        Invokes a runnable on the Event Dispatch Thread when the foreign key metadata is available for a given table metadata object. This method, and the supplied callback, are invoked on the EDT.
        Parameters:
        tmeta - table metadata item
        callback - runnable to be invoked on the EDT when tmeta.getForeignKeys() has a non-null return
        Returns:
        true iff callback has been called synchronously
      • acquireSchemas

        public void acquireSchemas​(ResultHandler<SchemaMeta[]> handler)
        Asynchronously acquires TAP database schema list.
        Parameters:
        handler - receiver for schema information
      • acquireCapability

        public void acquireCapability​(ResultHandler<TapCapability> handler)
        Asynchronously acquires TAP capability information.
        Parameters:
        handler - receiver for TAP capability object
      • acquireResource

        public void acquireResource​(ResultHandler<java.util.Map<java.lang.String,​java.lang.String>> handler)
        Asynchronously acquires information about the registry resource corresponding to this service. The result is a map of standard RegTAP resource column names to their values.
        Parameters:
        handler - receiver for resource metadata map
      • acquireRoles

        public void acquireRoles​(ResultHandler<RegRole[]> handler)
        Asynchronously acquires information from the RegTAP rr.res_role table corresponding to this service.
        Parameters:
        handler - receiver for role list
      • acquireExamples

        public void acquireExamples​(ResultHandler<DaliExample[]> handler)
        Asynchronously acquires a list of service-specific query examples, if available.
        Parameters:
        handler - receiver for example list
      • getRegTapEndpointSet

        public EndpointSet getRegTapEndpointSet()
        Returns the URL at which a RegTAP service lives that can be queried for information about this service's registry record.

        The default implementation returns the default value from Endpoints.getRegTapEndpointSet().

        Returns:
        RegTAP URL
      • shutdown

        public void shutdown()
        Releases resources and terminates any currently running asynchronous metadata reads. Calling this method does not prevent future use of this object.
      • getMetaReader

        public TapMetaReader getMetaReader()
        Returns the TapMetaReader in use by this kit. This method will not block, but may return null if the reader to use has not yet been determined.
        Returns:
        metaReader in use, or null