[MOBY-guts] biomoby commit
Gary Schiltz
gss at pub.open-bio.org
Wed Mar 15 00:43:38 UTC 2006
gss
Tue Mar 14 19:43:38 EST 2006
Update of /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools
In directory pub.open-bio.org:/tmp/cvs-serv28251/src/org/semanticmoby/ref/tools
Modified Files:
URIInvestigator.java
Log Message:
Got rid of multithreading; converted to Unix line endings
s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools URIInvestigator.java,1.16,1.17
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java 2006/03/02 08:54:32 1.16
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java 2006/03/15 00:43:38 1.17
@@ -14,23 +14,12 @@
/**
- * This class is used to investigate URLs that potentially contain MOBY graphs.
- * Multiple instances can exist, each investigating a different URL. Keeping a
- * map of URL->instance mappings in the instances class variable is a simple
- * way to prevent multiple instances from investigating the same URL at any one
- * time. The static investigate() method adds to this map when it creates
- * instances to investigate URLs; the run() method removes its instance once
- * it is finished.
+ * Instances of this class are used to investigate URLs that are believed to
+ * contain MOBY resource description graphs.
*/
public class URIInvestigator {
/**
- * A map associating URLs being investigated with the instances that are
- * doing the investigating.
- */
- private static Map instances = new HashMap();
-
- /**
* The URL that is to be investigated for possible inclusion in the
* metadata repository.
*/
@@ -40,82 +29,11 @@
* Create an instance for investingating the given resource URL
* @param resourceURL the URL to investigate
*/
- private URIInvestigator(String resourceURL) {
-
+ public URIInvestigator(String resourceURL) {
this.resourceURL = resourceURL;
}
/**
- * Investigate a URL for the possibility that it contains a MOBY graph,
- * by creating an instance in which the investigation is to be conducted,
- * and calling the instance's start() method. If the URL is already being
- * investigated, then this call is a NO-OP.
- * @param resourceURL the URL to investigate
- */
- public synchronized static void investigate(String resourceURL) {
-
- synchronized (instances) {
-
- if (instances.get(resourceURL) != null) {
-
- if (Log.WARN) Log.warn("Already investigating " + resourceURL);
-
- return;
- }
-
- URIInvestigator investigator = new URIInvestigator(resourceURL);
- instances.put(resourceURL, investigator);
- investigator.start();
- }
- }
-
-
- /**
- * Start running in a separate thread.
- */
- private void start() {
-
- new Thread() {
-
- public void run() {
-
- URIInvestigator.this.run();
- }
- }.start();
- }
-
-
- /**
- * Find out what's at the URL that is being investigated. If doing a GET
- * on it returns a MOBY graph, then register the graph in the metadata
- * repository. If it does not contain a MOBY graph, then try de-registering
- * it from the repository.
- */
- private void run() {
-
- try {
-
- String repositoryName =
- MOBYProperties.getProperty("DB_REPOSITORY_NAME", true);
- syncGraph();
- } catch (MissingPropertyException e) {
-
- e.printStackTrace();
- if (Log.ERROR) Log.error("Missing DB_REPOSITORY_NAME property");
- } finally {
-
- // Regardless of the results of the URL investigation, remove
- // this instance from the static instances map.
- //
- synchronized (instances) {
-
- instances.remove(resourceURL);
- }
- }
- }
-
-
- /**
* Synchronize the resource URL's MOBY graph (if there is one) with the
* graph stored in the metadata repository (if there is one). This involves
* doing an HTTP GET on the resource URL; if there is already a graph stored
@@ -126,13 +44,13 @@
* modified), then there is nothing to do; if the request returns a 404
* (resource not found), then remove the graph from the database.
*/
- synchronized private void syncGraph() {
+ public void investigate() {
// The storage manager is used to access the metadata repository
StorageManager manager = new StorageManager();
// Find out if the resource is already registered, and if so, when
- // was its graph last modified.
+ // its graph was last modified.
Date lastModifiedDate = null;
boolean alreadyRegistered = false;
@@ -314,19 +232,20 @@
}
+ /**
+ * Deregisters the resource being investigated.
+ * @param manager the StorageManager used to actually do the deregistration
+ * @param removing if the removing flag is set, a message is written to the
+ * log stating that the resource has been removed
+ */
private void deregisterResource(StorageManager manager, boolean removing) {
-
try {
-
manager.deregisterResource(resourceURL);
-
if (removing) {
-
if(Log.INFO) Log.info("REMOVED : " + resourceURL);
}
}
catch (StorageException e) {
-
e.printStackTrace();
if (Log.ERROR) Log.error("Unable to de-register resource " + resourceURL);
}
More information about the MOBY-guts
mailing list