Revision: 43115 http://brlcad.svn.sourceforge.net/brlcad/?rev=43115&view=rev Author: ronaldbowers Date: 2011-02-08 15:57:26 +0000 (Tue, 08 Feb 2011)
Log Message: ----------- - splitting GeometryService into basic functionality and a caching layer. The caching will be relocated to Gomez. Added Paths: ----------- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/CatalogEntry.java jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryService.java jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceException.java jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceImpl.java Removed Paths: ------------- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceSPI.java Added: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/CatalogEntry.java =================================================================== --- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/CatalogEntry.java (rev 0) +++ jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/CatalogEntry.java 2011-02-08 15:57:26 UTC (rev 43115) @@ -0,0 +1,32 @@ +package org.brlcad.geometryservice; + +import java.util.Map; +import java.util.TreeMap; + +/** + * Information about versioned geometry + */ +public class CatalogEntry { + + private final String name; + private final String version; + private final Map<String, String> metaData; + + public CatalogEntry(String name, String version, Map<String, String> metaData) { + this.name = name; + this.version = version; + this.metaData = new TreeMap<String, String>(metaData); + } + + public String getName() { + return name; + } + + public String getVersion() { + return version; + } + + public Map<String, String> getMetaData() { + return metaData; + } +} Property changes on: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/CatalogEntry.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Copied: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryService.java (from rev 43108, jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceSPI.java) =================================================================== --- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryService.java (rev 0) +++ jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryService.java 2011-02-08 15:57:26 UTC (rev 43115) @@ -0,0 +1,82 @@ +package org.brlcad.geometryservice; + +import java.io.File; +import java.util.List; +import java.util.Map; + +/** + * Classes that implement this interface enable the client to interact + * with the BRL-CAD geometry service. The functions provided by the interface + * are as follows: + * <p/> + * <ol> + * <li> Download versioned geometry from the BRL-CAD Geometry Service and + * store the downloaded geometry in a local file.</li> + * <li> Enable queries of the BRL-CAD geometry service.</li> + * <li> Enable retrieval of geometry metadata from the geometry service.<li> + * <li> Provide an estimate for the memory footprint of prepped geometry for a specified geometry.</li> + * </ol> + * <p/> + * Implementation can be performed in two stages. The first comprises downloading + * the geometries. The second covers querying geometries and metadata. + */ +public interface GeometryService { + + /** + * Version number that implies that the most recent version is desired. + */ + final static int HEAD = -1; + + + /** + * Loads the requested geometry. + * <p>Determines if the specified geometry is available from the BRL-CAD + * geometry service and if so downloads the geometry. The geometry to retrieve + * is specified by a name and a version string. The download geometry is stored on + * the local disk as a .g file and a File + * to the downloaded geometry is created and returned.</p> + * + * @param geometryName the name of the geometry, such as T62 + * @param version the version. + * @return a File object that points to the local on-disk geometry file. + * @throws GeometryServiceException if the BRL-CAD service cannot be reached or the + * specified geometry does not exist. + */ + File get(String geometryName, String version) throws GeometryServiceException; + + /** + * Retrieves the metadata associated with the specified geometry. + * + * @param geometryName the name of the geometry, such as T62 + * @param version the name of version + * @return the metadata as a collection of key-value pairs. + * @throws GeometryServiceException if the BRL-CAD service cannot be reached or the + * specified geometry does not exist. + */ + Map<String, String> getMetadata(String geometryName, String version) throws GeometryServiceException; + + /** + * Executes a query of the geometry service. + * + * @param query an object that defines the query. The exact form of the query is undetermined + * at this time. + * @return A list of CatalogEntries that match the query + * @throws GeometryServiceException if the BRL-CAD service cannot be reached or + * the query is badly-formed.. + */ + List<CatalogEntry> query(Object query) throws GeometryServiceException; + + /** + * Provides an estimate of the memory usage of the prepped geometry + * corresponding to the given geometry name and version. + * + * @param geometryName the name of the geometry, such as T62 + * @param version the version + * @return the estimated memory usage. + * @throws GeometryServiceException if the BRL-CAD service cannot be reached or the + * specified geometry does not exist. + */ + long estimateFootprint(String geometryName, String version) throws GeometryServiceException; + + +} Property changes on: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryService.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceException.java =================================================================== --- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceException.java (rev 0) +++ jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceException.java 2011-02-08 15:57:26 UTC (rev 43115) @@ -0,0 +1,25 @@ +package org.brlcad.geometryservice; + +/** + * Exception that is thrown when there is an issue retrieving geometry + * from the BRL-CAD geometry service + */ +public class GeometryServiceException extends Exception { + + + public GeometryServiceException() { + } + + public GeometryServiceException(String s) { + super(s); + } + + public GeometryServiceException(String s, Throwable throwable) { + super(s, throwable); + } + + public GeometryServiceException(Throwable throwable) { + super(throwable); + } +} + Property changes on: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceImpl.java =================================================================== --- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceImpl.java (rev 0) +++ jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceImpl.java 2011-02-08 15:57:26 UTC (rev 43115) @@ -0,0 +1,7 @@ +package org.brlcad.geometryservice; + +/** + * Implementation of the geometry service + */ +public class GeometryServiceImpl { +} Property changes on: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceSPI.java =================================================================== --- jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceSPI.java 2011-02-08 15:47:47 UTC (rev 43114) +++ jbrlcad/trunk/src/main/java/org/brlcad/geometryservice/GeometryServiceSPI.java 2011-02-08 15:57:26 UTC (rev 43115) @@ -1,206 +0,0 @@ -package org.brlcad.geometryservice; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * Classes that implement this interface enable the client to interact - * with the BRL-CAD geometry service. The functions provided by the interface - * are as follows: - * <p/> - * <ol> - * <li> Verify that the geometry service is reachable.</li> - * <li> Download versioned geometry from the BRL-CAD Geometry Service.</li> - * <li> Store downloaded geometry in a local cache.</li> - * <li> Check the cache for a copy of the desired geometry before downloading.</li> - * <li> Provide a catalog of the local cache.</li> - * <li> Clear the local cache.</li> - * <li> Enable queries of the BRL-CAD geometry service.</li> - * <li> Enable retrieval of geometry metadata from the geometry service.<li> - * <li> Provide an estimate for the memory footprint of prepped geometry for a specified geometry.</li> - * </ol> - * <p/> - * Implementation can be performed in two stages. The first comprises downloading and - * caching the geometries. The second covers querying geometries and metadata. - */ -public interface GeometryServiceSPI { - - /** - * Version number that implies that the most recent version is desired. - */ - final static int HEAD = -1; - - /** - * Tests the connection to the geometry service. - * - * @return true if the connection is operational, false otherwise. - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - */ - boolean ping(); - - /** - * Loads the requested geometry. - * Determines if the specified geometry is available from the local cache, and - * if so returns a File object that points to the local copy. Otherwise, this - * method retrieves the geometry specified from the geometry service. The - * geometry to retrieve is specified by a name and a version number. - * The download geometry is stored in the local cache as a .g file and a File - * to the downloaded geometry is created and returned. - * - * @param geometryName the name of the geometry, such as T62 - * @param version the revision number of the geometry or HEAD for the latest version - * @return a File object that points to the local on-disk geometry file. - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - */ - File get(String geometryName, int version) throws IOException; - - /** - * Loads the requested geometry. - * <p>Determines if the specified geometry is available from the local cache, and - * if so returns a File object that points to the local copy. Otherwise, this - * method retrieves the geometry specified from the geometry service. The - * geometry to retrieve is specified by a name and a version string. - * The download geometry is stored in the local cache as a .g file and a File - * to the downloaded geometry is created and returned.</p> - * - * @param geometryName the name of the geometry, such as T62 - * @param versionTag the name of a tagged version. - * @return a File object that points to the local on-disk geometry file. - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - */ - File get(String geometryName, String versionTag) throws IOException; - - - /** - * Determines if the requested geometry is in the local cache. Should - * be called before downloading geometry from the geometry service. - * - * @param geometryName the name of the geometry, such as T62 - * @param version the revision number of the geometry or HEAD for the latest version - * @return a File object that points to the local on-disk geometry file. - * @throws IllegalStateException if the location of the local cache has - * not been specified. - */ - boolean isInCache(String geometryName, int version); - - - /** - * Determines if the requested geometry is in the local cache. Should - * be called before downloading geometry from the geometry service. - * - * @param geometryName the name of the geometry, such as T62 - * @param versionTag the name of a tagged version - * @return a File object that points to the local on-disk geometry file. - * @throws IllegalStateException if the location of the local cache has - * not been specified. - */ - boolean isInCache(String geometryName, String versionTag); - - /** - * Removes all items from the local geometry cache. - * - * @throws IllegalStateException if the location of the local cache has - * not been specified. - */ - void clearCache(); - - /** - * Provides a list of all of the entries in the local cache. - * - * @return a list of the geometries in the cache. - * @throws IllegalStateException if the location of the local cache has - * not been specified. - */ - List<CacheEntry> getCacheEntries(); - - /** - * Retrieves the metadata associated with the specified geometry. - * - * @param geometryName the name of the geometry, such as T62 - * @param version the revision number of the geometry or HEAD for the latest version - * @return the metadata as a collection of key-value pairs. - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - */ - Map<String, String> getMetadata(String geometryName, int version) throws IOException; - - /** - * Retrieves the metadata associated with the specified geometry. - * - * @param geometryName the name of the geometry, such as T62 - * @param versionTag the name of a tagged version - * @return the metadata as a collection of key-value pairs. - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - */ - Map<String, String> getMetadata(String geometryName, String versionTag) throws IOException; - - /** - * Executes a query of the geometry service. - * @param query an object that defines the query. The exact form of the query is undetermined - * at this time. - * @return A list of CatalogEntries that d - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.IOException if the geometry service cannot be reached. - */ - List<CatalogEntry> query(Object query) throws IOException; - - /** - * Provides an estimate of the memory usage of the prepped geometry - * corresponding to the given geometry name and version. - * - * @param geometryName the name of the geometry, such as T62 - * @param version the revision number of the geometry or HEAD for the latest version - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - * @return the estimated memory usage. - */ - long estimateFootprint(String geometryName, int version) throws IOException; - - /** - * Provides an estimate of the memory usage of the prepped geometry - * corresponding to the given geometry name and version. - * - * @param geometryName the name of the geometry, such as T62 - * @param versionTag the name of a tagged version - * @throws IllegalStateException if the location of the geometry service has - * not been specified. - * @throws java.io.FileNotFoundException if the geometry cannot be found. - * @throws java.io.IOException if the geometry service cannot be reached. - * @return the estimated memory usage. - */ - long estimateFootprint(String geometryName, String versionTag) throws IOException; - - public interface CacheEntry { - void setName(String name); - - String getName(); - - void setVersion(String version); - - String getVersion(); - } - - public interface CatalogEntry extends CacheEntry { - void setMetadata(Map<String, String> md); - - Map<String, String> getMetadata(); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits