diff --git a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/stage/StagingManager.java b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/stage/StagingManager.java index 3dcbf5f2ce..0e27a6b1d4 100644 --- a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/stage/StagingManager.java +++ b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/stage/StagingManager.java @@ -44,7 +44,7 @@ public class StagingManager implements IStagingManager { protected static final Logger log = LoggerFactory.getLogger(StagingManager.class); - private File directory; + protected File directory; private Map resourcePathsCache = new ConcurrentHashMap(); protected Map inUse = new ConcurrentHashMap(); @@ -114,7 +114,7 @@ protected void clean(Path path, long ttlInMs, StagingPurgeContext context) throw try { String stagingPath = StagedResource.toPath(directory, new File((entry.getParent().toString() + "/" + entry.getFileName().toString()))); - IStagedResource resource = new StagedResource(directory, stagingPath, this); + IStagedResource resource = createStagedResource(stagingPath); if (stagingPath != null) { if (shouldCleanPath(resource, ttlInMs, context)) { if (resource.getFile() != null) { @@ -158,7 +158,7 @@ protected boolean cleanPath(IStagedResource resource, long ttlInMs, StagingPurge */ public IStagedResource create(Object... path) { String filePath = buildFilePath(path); - IStagedResource resource = new StagedResource(directory, filePath, this); + IStagedResource resource = createStagedResource(filePath); if (resource.exists()) { resource.delete(); } @@ -166,6 +166,10 @@ public IStagedResource create(Object... path) { this.resourcePathsCache.put(filePath, filePath); return resource; } + + protected IStagedResource createStagedResource(String filePath) { + return new StagedResource(directory, filePath, this); + } protected String buildFilePath(Object... path) { StringBuilder buffer = new StringBuilder(); @@ -188,7 +192,7 @@ public IStagedResource find(String path) { boolean foundResourcePath = resourcePathsCache.containsKey(path); if (!foundResourcePath && clusterEnabled) { synchronized (this) { - StagedResource staged = new StagedResource(directory, path, this); + IStagedResource staged = createStagedResource(path); if (staged.exists() && staged.getState() == State.DONE) { resourcePathsCache.put(path, path); resource = staged; @@ -196,7 +200,7 @@ public IStagedResource find(String path) { } } } else if (foundResourcePath) { - resource = new StagedResource(directory, path, this); + resource = createStagedResource(path); } } return resource;