Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ public DependenceManager(Properties dependencies) {
}
}

@Override
public List<String> comprehend(Collection<String> resourceNames) {
return comprehend(resourceNames, false);
}

@Override
public List<String> comprehend(Collection<String> resourceNames,
boolean withDefault) {
if (resourceNames.isEmpty() && !withDefault)
Expand Down Expand Up @@ -155,12 +153,10 @@ public List<String> comprehend(Collection<String> resourceNames,
return retList;
}

@Override
public List<String> comprehend(String resourceNames) {
return comprehend(resourceNames, false);
}

@Override
public List<String> comprehend(String resourceNames, boolean withDefault) {
if (null == resourceNames)
return comprehend(new ArrayList<String>(), withDefault);
Expand All @@ -169,12 +165,10 @@ public List<String> comprehend(String resourceNames, boolean withDefault) {
return comprehend(l, withDefault);
}

@Override
public List<String> comprehend() {
return comprehend(DEFAULT, false);
}

@Override
public final void addDependency(String dependent,
Collection<String> dependsOn) {
createNode_(dependent, dependsOn);
Expand Down Expand Up @@ -339,7 +333,6 @@ public String debugString() {
return sb.toString();
}

@Override
public int compareTo(Node o) {
if (null == o)
return -1;
Expand Down
3 changes: 2 additions & 1 deletion java/core/src/main/java/com/greenscriptool/IResource.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.greenscriptool;

import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;

public interface IResource {
public interface IResource extends Serializable {
Reader getReader();
Writer getWriter();
String getKey();
Expand Down
26 changes: 1 addition & 25 deletions java/core/src/main/java/com/greenscriptool/Minimizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,27 @@ public Minimizer(ICompressor compressor, ResourceType type) {
init_(compressor, type);
}

@Override
public void enableDisableMinimize(boolean enable) {
minimize_ = enable || ResourceType.CSS == type_;
if (logger_.isDebugEnabled())
logger_.debug("minimize " + (enable ? "enabled" : "disabled"));
clearCache();
}

@Override
public void enableDisableCompress(boolean enable) {
compress_ = enable;
if (logger_.isDebugEnabled())
logger_.debug("compress " + (enable ? "enabled" : "disabled"));
clearCache();
}

@Override
public void enableDisableCache(boolean enable) {
useCache_ = enable;
if (logger_.isDebugEnabled())
logger_.debug("cache " + (enable ? "enabled" : "disabled"));
clearCache();
}

@Override
public void enableDisableInMemoryCache(boolean enable) {
inMemory_ = enable;
if (logger_.isDebugEnabled())
Expand All @@ -114,7 +110,6 @@ public void enableDisableInMemoryCache(boolean enable) {
clearCache();
}

@Override
public void enableDisableProcessInline(boolean enable) {
processInline_ = enable;
if (logger_.isDebugEnabled())
Expand All @@ -127,23 +122,19 @@ public void enableDisableVerifyResource(boolean verify) {
// verifyResource_ = verify;
}

@Override
public boolean isMinimizeEnabled() {
// now css type resource is always minimized
return minimize_ || ResourceType.CSS == type_;
}

@Override
public boolean isCompressEnabled() {
return compress_;
}

@Override
public boolean isCacheEnabled() {
return useCache_;
}

@Override
public void setResourceDir(String dir) {
checkInitialize_(false);
if (rootDir_ == null) throw new IllegalStateException("rootDir need to be intialized first");
Expand All @@ -158,7 +149,6 @@ public void setResourceDir(String dir) {
if (!f.isDirectory()) throw new IllegalArgumentException("not a directory");
}

@Override
public void setRootDir(String dir) {
checkInitialize_(false);
if (fl_ == null) throw new IllegalStateException("file locator need to initialized first");
Expand All @@ -169,14 +159,12 @@ public void setRootDir(String dir) {
logger_.debug(String.format("root dir set to %1$s", dir));
}

@Override
public void setUrlContextPath(String ctxPath) {
if (null == ctxPath) throw new NullPointerException();
if (ctxPath.endsWith("/")) ctxPath = ctxPath.substring(0, ctxPath.length() - 1);
ctxPath_ = ctxPath;
}

@Override
public void setCacheDir(File dir) {
// comment below as inmemory configuration does not require dir to be exists
// this is relevant when deploy app on readonly file system like heroku and gae
Expand All @@ -186,7 +174,6 @@ public void setCacheDir(File dir) {
cache_ = new FileCache(dir);
}

@Override
public void setResourceUrlRoot(String urlRoot) {
if (ctxPath_ == null) throw new IllegalStateException("ctxPath must be intialized first");
if (!urlRoot.startsWith("/"))
Expand All @@ -200,7 +187,6 @@ public void setResourceUrlRoot(String urlRoot) {
logger_.debug(String.format("url root set to %1$s", urlRoot));
}

@Override
public void setResourceUrlPath(String urlPath) {
checkInitialize_(false);
if (null == resourceUrlRoot_) {
Expand All @@ -217,7 +203,6 @@ public void setResourceUrlPath(String urlPath) {
logger_.debug(String.format("url path set to %1$s", urlPath));
}

@Override
public void setCacheUrlPath(String urlPath) {
checkInitialize_(false);
if (null == resourceUrlRoot_) {
Expand All @@ -234,7 +219,6 @@ public void setCacheUrlPath(String urlPath) {
logger_.debug(String.format("cache url root set to %1$s", urlPath));
}

@Override
public void clearCache() {
cache_.clear();
processCache2_.clear();
Expand All @@ -243,7 +227,6 @@ public void clearCache() {

private IFileLocator fl_ = FileResource.defFileLocator;

@Override
public void setFileLocator(IFileLocator fileLocator) {
if (null == fileLocator)
throw new NullPointerException();
Expand All @@ -252,7 +235,6 @@ public void setFileLocator(IFileLocator fileLocator) {

private IBufferLocator bl_ = new BufferLocator();

@Override
public void setBufferLocator(IBufferLocator bufferLocator) {
if (null == bufferLocator)
throw new NullPointerException();
Expand All @@ -261,7 +243,6 @@ public void setBufferLocator(IBufferLocator bufferLocator) {

private IRouteMapper rm_ = null;

@Override
public void setRouteMapper(IRouteMapper routeMapper) {
if (null == routeMapper)
throw new NullPointerException();
Expand Down Expand Up @@ -294,7 +275,6 @@ private Set<File> imports_(File file) {
return files;
}

@Override
public long getLastModified(File file) {
long l = file.lastModified();
if (ResourceType.CSS == type_) {
Expand All @@ -306,7 +286,6 @@ public long getLastModified(File file) {
return l;
}

@Override
public void checkCache() {
for(List<String> l: processCache_.keySet()) {
for (String s: l) {
Expand All @@ -330,7 +309,6 @@ public void checkCache() {
* A convention used by this minimizer is resource name suffix with
* "_bundle". For any resource with the name suffix with "_bundle"
*/
@Override
public List<String> process(List<String> resourceNames) {
checkInitialize_(true);
if (resourceNames.isEmpty())
Expand Down Expand Up @@ -376,7 +354,7 @@ private final String getExtension_(String path) {
}

private ConcurrentMap<List<String>, List<String>> processCache2_ = new ConcurrentHashMap<List<String>, List<String>>();
@Override

public List<String> processWithoutMinimize(List<String> resourceNames) {
checkInitialize_(true);
if (resourceNames.isEmpty())
Expand Down Expand Up @@ -454,7 +432,6 @@ private void compress(String content, Writer out) {
}
}

@Override
public String processInline(String content) {
if (!processInline_)
return content;
Expand All @@ -474,7 +451,6 @@ public String processInline(String content) {
}
}

@Override
public String processStatic(File file) {
String content = null;
try {
Expand Down
8 changes: 0 additions & 8 deletions java/core/src/main/java/com/greenscriptool/RenderSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ private final void trace(String s, Object... args) {
// logger_.info(s);
}

@Override
public void declareInline(String inline, int priority) {
priority = -1 * priority;
StringBuffer sb = inlines_.get(priority);
Expand All @@ -81,7 +80,6 @@ public void declareInline(String inline, int priority) {
sb.append("\n").append(inline);
}

@Override
public void declare(String nameList, String media, String browser) {
d_.processInlineDependency(nameList);
String[] sa = nameList.split(SEPARATOR);
Expand All @@ -92,7 +90,6 @@ public void declare(String nameList, String media, String browser) {
}
}

@Override
public void declare(List<String> nameList, String media, String browser) {
media = canonical_(media);
browser = canonical_(browser);
Expand All @@ -101,7 +98,6 @@ public void declare(List<String> nameList, String media, String browser) {
}
}

@Override
public List<String> output(String nameList, boolean withDependencies, boolean all, String media, String browser) {
if (null != nameList) declare(nameList, null, null);

Expand Down Expand Up @@ -139,7 +135,6 @@ public List<String> output(String nameList, boolean withDependencies, boolean al
return l;
}

@Override
public String outputInline() {
StringBuilder all = new StringBuilder();
for (StringBuffer sb: inlines_.values()) {
Expand Down Expand Up @@ -172,7 +167,6 @@ private Set<String> getByMediaAndBrowser_(String media, String browser) {
return set;
}

@Override
public Set<String> getMedias(String browser) {
Set<String> set = new HashSet<String>();
browser = canonical_(browser);
Expand All @@ -183,7 +177,6 @@ public Set<String> getMedias(String browser) {
return set;
}

@Override
public Set<String> getBrowsers() {
Set<String> set = new HashSet<String>();
for (Resource r: declared_) {
Expand All @@ -193,7 +186,6 @@ public Set<String> getBrowsers() {
return set;
}

@Override
public boolean hasDeclared() {
return declared_.size() > 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
public class BufferLocator implements IBufferLocator {
Map<String, BufferResource> buffers = new HashMap<String, BufferResource>();

@Override
public BufferResource locate(String key) {
return this.buffers.get(key);
}

@Override
public BufferResource newBuffer(List<String> resourceNames, String extension) {
String key = UUID.randomUUID().toString() + extension;
BufferResource buffer = new BufferResource(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@

import com.greenscriptool.IResource;

public class BufferResource implements IResource, Serializable {

/**
*
*/
private static final long serialVersionUID = 3173516477770425002L;
public class BufferResource implements IResource {
private static final long serialVersionUID = 3173516477770425002L;

private String key_;
private String buffer_;
Expand All @@ -23,18 +19,16 @@ public BufferResource(String key) {
key_ = key;
}

@Override
public Reader getReader() {
return new StringReader(buffer_);
}


@Override
public Writer getWriter() {
return new StringWriter(){
@Override
public void close() {
BufferResource.this.buffer_ = this.toString();
BufferResource.this.onWriterClose();
}
};
}
Expand All @@ -44,7 +38,6 @@ public String toString() {
return buffer_;
}

@Override
public String getKey() {
return key_;
}
Expand All @@ -57,4 +50,7 @@ public static void main(String[] args) throws Exception {
System.out.println(br);
}

protected void onWriterClose() {
// Do nothing.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public ClosureCompressor(ResourceType type) {
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
}

@Override
public void compress(Reader r, Writer w) throws Exception {
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
JSSourceFile file = JSSourceFile.fromInputStream("greenscript.js", new ReaderInputStream(r));
Expand Down
Loading