Make app coord svc namespace ext point

This commit is contained in:
Richard Cordovano 2017-03-11 13:21:13 -05:00
parent bd0649af96
commit de8dc8f425
2 changed files with 19 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2016-2017 Basis Technology Corp.
* Copyright 2011-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -19,15 +19,15 @@
package org.sleuthkit.autopsy.coordinationservice;
/**
* Root node for Autopsy coordination service namespace.
* Interface for providers of application-level coordination service namespaces.
*/
public final class CoordinationServiceNamespace {
private static final String ROOT = "autopsy";
public interface AppCoordinationServiceNamespace {
public static String getRoot() {
return ROOT;
}
/**
* Gets the name of the root node of the namespace for the application.
*
* @return The name of the root node for the application namespace.
*/
public String getAppNamespaceRoot();
private CoordinationServiceNamespace() {
}
}

View File

@ -19,7 +19,9 @@
package org.sleuthkit.autopsy.coordinationservice;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.curator.RetryPolicy;
@ -34,6 +36,7 @@ import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.core.UserPreferences;
/**
@ -92,7 +95,13 @@ public final class CoordinationService {
* @return The name of the root node for the application namespace.
*/
public static String getAppNamespaceRoot() {
return DEFAULT_NAMESPACE_ROOT;
Collection<? extends AppCoordinationServiceNamespace> providers = Lookup.getDefault().lookupAll(AppCoordinationServiceNamespace.class);
Iterator<? extends AppCoordinationServiceNamespace> it = providers.iterator();
if (it.hasNext()) {
return it.next().getAppNamespaceRoot();
} else {
return DEFAULT_NAMESPACE_ROOT;
}
}
/**