Skip to content

Commit

Permalink
FORGE-1644: Created Addon.getStorageDirectory()
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Mar 7, 2014
1 parent 01299b3 commit 56ca857
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.jboss.forge.furnace.addons;

import java.io.File;
import java.util.Set;
import java.util.concurrent.Future;

Expand All @@ -25,42 +26,47 @@ public interface Addon
/**
* Get the ID of this {@link Addon}.
*/
public AddonId getId();
AddonId getId();

/**
* Get the {@link ClassLoader} containing the resources of this {@link Addon}.
*/
public ClassLoader getClassLoader();
ClassLoader getClassLoader();

/**
* Get the {@link EventManager} of this {@link Addon}.
*/
public EventManager getEventManager();
EventManager getEventManager();

/**
* Get the {@link ServiceRegistry} containing services provided by this {@link Addon}.
*/
public ServiceRegistry getServiceRegistry();
ServiceRegistry getServiceRegistry();

/**
* Get the {@link AddonRepository} from which this {@link Addon} was loaded.
*/
public AddonRepository getRepository();
AddonRepository getRepository();

/**
* Get the {@link AddonStatus} of this {@link Addon}.
*/
public AddonStatus getStatus();
AddonStatus getStatus();

/**
* Get the {@link Set} of {@link AddonDependency} for this {@link Addon} (never <code>null</code>.)
*/
public Set<AddonDependency> getDependencies();
Set<AddonDependency> getDependencies();

/**
* Return the {@link Future} representing the boot-up sequence for this {@link Addon} instance. Returns
* <code>null</code> if the {@link Addon} is not starting, {@link AddonStatus#isStarted()} or
* {@link AddonStatus#isFailed()}
*/
public Future<Void> getFuture();
Future<Void> getFuture();

/**
* Return the storage area for this addon. Files relevant to the addon execution should be stored here.
*/
File getStorageDirectory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,12 @@ public static File getTempDirectory()
{
return new File(System.getProperty("java.io.tmpdir"));
}

/**
* Get the addon storage dir
*/
public static File getAddonStorageDir()
{
return new File(getUserForgeDir(), "store").getAbsoluteFile();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.jboss.forge.furnace.impl.addons;

import java.io.File;
import java.util.Set;
import java.util.concurrent.Future;

Expand All @@ -18,6 +19,7 @@
import org.jboss.forge.furnace.repositories.AddonRepository;
import org.jboss.forge.furnace.spi.ServiceRegistry;
import org.jboss.forge.furnace.util.Assert;
import org.jboss.forge.furnace.util.OperatingSystemUtils;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
Expand Down Expand Up @@ -101,6 +103,12 @@ public AddonStatus getStatus()
return result;
}

@Override
public File getStorageDirectory()
{
return new File(OperatingSystemUtils.getAddonStorageDir(), id.getName()).getAbsoluteFile();
}

@Override
public String toString()
{
Expand Down

0 comments on commit 56ca857

Please sign in to comment.