本文整理了Java中groovy.lang.GroovyClassLoader.getTimeStamp()
方法的一些代码示例,展示了GroovyClassLoader.getTimeStamp()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GroovyClassLoader.getTimeStamp()
方法的具体详情如下:
包路径:groovy.lang.GroovyClassLoader
类名称:GroovyClassLoader
方法名:getTimeStamp
[英]gets the time stamp of a given class. For groovy generated classes this usually means to return the value of the static field __timeStamp. If the parameter doesn't have such a field, then Long.MAX_VALUE is returned
[中]获取给定类的时间戳。对于groovy生成的类,这通常意味着返回静态字段\uuu timeStamp的值。如果参数没有这样的字段,则为Long。返回最大值
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Indicates if a class is recompilable. Recompilable means, that the classloader
* will try to locate a groovy source file for this class and then compile it again,
* adding the resulting class as entry to the cache. Giving null as class is like a
* recompilation, so the method should always return true here. Only classes that are
* implementing GroovyObject are compilable and only if the timestamp in the class
* is lower than Long.MAX_VALUE.
* <p>
* NOTE: First the parent loaders will be asked and only if they don't return a
* class the recompilation will happen. Recompilation also only happen if the source
* file is newer.
*
* @param cls the class to be tested. If null the method should return true
* @return true if the class should be compiled again
* @see #isSourceNewer(URL, Class)
*/
protected boolean isRecompilable(Class cls) {
if (cls == null) return true;
if (cls.getClassLoader() == this) return false;
if (recompile == null && !config.getRecompileGroovySource()) return false;
if (recompile != null && !recompile) return false;
if (!GroovyObject.class.isAssignableFrom(cls)) return false;
long timestamp = getTimeStamp(cls);
if (timestamp == Long.MAX_VALUE) return false;
return true;
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Decides if the given source is newer than a class.
*
* @param source the source we may want to compile
* @param cls the former class
* @return true if the source is newer, false else
* @throws IOException if it is not possible to open an
* connection for the given source
* @see #getTimeStamp(Class)
*/
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
long lastMod;
// Special handling for file:// protocol, as getLastModified() often reports
// incorrect results (-1)
if (isFile(source)) {
// Coerce the file URL to a File
// See ClassNodeResolver.isSourceNewer for another method that replaces '|' with ':'.
// WTF: Why is this done and where is it documented?
String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
File file = new File(path);
lastMod = file.lastModified();
} else {
URLConnection conn = source.openConnection();
lastMod = conn.getLastModified();
conn.getInputStream().close();
}
long classTime = getTimeStamp(cls);
return classTime + config.getMinimumRecompilationInterval() < lastMod;
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* Decides if the given source is newer than a class.
*
* @param source the source we may want to compile
* @param cls the former class
* @return true if the source is newer, false else
* @throws IOException if it is not possible to open an
* connection for the given source
* @see #getTimeStamp(Class)
*/
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
long lastMod;
// Special handling for file:// protocol, as getLastModified() often reports
// incorrect results (-1)
if (source.getProtocol().equals("file")) {
// Coerce the file URL to a File
String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
File file = new File(path);
lastMod = file.lastModified();
} else {
URLConnection conn = source.openConnection();
lastMod = conn.getLastModified();
conn.getInputStream().close();
}
long classTime = getTimeStamp(cls);
return classTime + config.getMinimumRecompilationInterval() < lastMod;
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* Indicates if a class is recompilable. Recompileable means, that the classloader
* will try to locate a groovy source file for this class and then compile it again,
* adding the resulting class as entry to the cache. Giving null as class is like a
* recompilation, so the method should always return true here. Only classes that are
* implementing GroovyObject are compileable and only if the timestamp in the class
* is lower than Long.MAX_VALUE.
* <p/>
* NOTE: First the parent loaders will be asked and only if they don't return a
* class the recompilation will happen. Recompilation also only happen if the source
* file is newer.
*
* @param cls the class to be tested. If null the method should return true
* @return true if the class should be compiled again
* @see #isSourceNewer(URL, Class)
*/
protected boolean isRecompilable(Class cls) {
if (cls == null) return true;
if (cls.getClassLoader()==this) return false;
if (recompile == null && !config.getRecompileGroovySource()) return false;
if (recompile != null && !recompile.booleanValue()) return false;
if (!GroovyObject.class.isAssignableFrom(cls)) return false;
long timestamp = getTimeStamp(cls);
if (timestamp == Long.MAX_VALUE) return false;
return true;
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* Indicates if a class is recompilable. Recompilable means, that the classloader
* will try to locate a groovy source file for this class and then compile it again,
* adding the resulting class as entry to the cache. Giving null as class is like a
* recompilation, so the method should always return true here. Only classes that are
* implementing GroovyObject are compilable and only if the timestamp in the class
* is lower than Long.MAX_VALUE.
* <p/>
* NOTE: First the parent loaders will be asked and only if they don't return a
* class the recompilation will happen. Recompilation also only happen if the source
* file is newer.
*
* @param cls the class to be tested. If null the method should return true
* @return true if the class should be compiled again
* @see #isSourceNewer(URL, Class)
*/
protected boolean isRecompilable(Class cls) {
if (cls == null) return true;
if (cls.getClassLoader() == this) return false;
if (recompile == null && !config.getRecompileGroovySource()) return false;
if (recompile != null && !recompile) return false;
if (!GroovyObject.class.isAssignableFrom(cls)) return false;
long timestamp = getTimeStamp(cls);
if (timestamp == Long.MAX_VALUE) return false;
return true;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* Indicates if a class is recompilable. Recompileable means, that the classloader
* will try to locate a groovy source file for this class and then compile it again,
* adding the resulting class as entry to the cache. Giving null as class is like a
* recompilation, so the method should always return true here. Only classes that are
* implementing GroovyObject are compileable and only if the timestamp in the class
* is lower than Long.MAX_VALUE.
* <p/>
* NOTE: First the parent loaders will be asked and only if they don't return a
* class the recompilation will happen. Recompilation also only happen if the source
* file is newer.
*
* @param cls the class to be tested. If null the method should return true
* @return true if the class should be compiled again
* @see #isSourceNewer(URL, Class)
*/
protected boolean isRecompilable(Class cls) {
if (cls == null) return true;
if (cls.getClassLoader()==this) return false;
if (recompile == null && !config.getRecompileGroovySource()) return false;
if (recompile != null && !recompile.booleanValue()) return false;
if (!GroovyObject.class.isAssignableFrom(cls)) return false;
long timestamp = getTimeStamp(cls);
if (timestamp == Long.MAX_VALUE) return false;
return true;
}
代码示例来源:origin: org.kohsuke.droovy/groovy
/**
* Indicates if a class is recompilable. Recompileable means, that the classloader
* will try to locate a groovy source file for this class and then compile it again,
* adding the resulting class as entry to the cache. Giving null as class is like a
* recompilation, so the method should always return true here. Only classes that are
* implementing GroovyObject are compileable and only if the timestamp in the class
* is lower than Long.MAX_VALUE.
* <p/>
* NOTE: First the parent loaders will be asked and only if they don't return a
* class the recompilation will happen. Recompilation also only happen if the source
* file is newer.
*
* @param cls the class to be tested. If null the method should return true
* @return true if the class should be compiled again
* @see #isSourceNewer(URL, Class)
*/
protected boolean isRecompilable(Class cls) {
if (cls == null) return true;
if (cls.getClassLoader()==this) return false;
if (recompile == null && !config.getRecompileGroovySource()) return false;
if (recompile != null && !recompile.booleanValue()) return false;
if (!GroovyObject.class.isAssignableFrom(cls)) return false;
long timestamp = getTimeStamp(cls);
if (timestamp == Long.MAX_VALUE) return false;
return true;
}
代码示例来源:origin: org.kohsuke.droovy/groovy
/**
* Decides if the given source is newer than a class.
*
* @param source the source we may want to compile
* @param cls the former class
* @return true if the source is newer, false else
* @throws IOException if it is not possible to open an
* connection for the given source
* @see #getTimeStamp(Class)
*/
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
long lastMod;
// Special handling for file:// protocol, as getLastModified() often reports
// incorrect results (-1)
if (source.getProtocol().equals("file")) {
// Coerce the file URL to a File
String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
File file = new File(path);
lastMod = file.lastModified();
} else {
URLConnection conn = source.openConnection();
lastMod = conn.getLastModified();
conn.getInputStream().close();
}
long classTime = getTimeStamp(cls);
return classTime + config.getMinimumRecompilationInterval() < lastMod;
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* Decides if the given source is newer than a class.
*
* @param source the source we may want to compile
* @param cls the former class
* @return true if the source is newer, false else
* @throws IOException if it is not possible to open an
* connection for the given source
* @see #getTimeStamp(Class)
*/
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
long lastMod;
// Special handling for file:// protocol, as getLastModified() often reports
// incorrect results (-1)
if (isFile(source)) {
// Coerce the file URL to a File
String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
File file = new File(path);
lastMod = file.lastModified();
} else {
URLConnection conn = source.openConnection();
lastMod = conn.getLastModified();
conn.getInputStream().close();
}
long classTime = getTimeStamp(cls);
return classTime + config.getMinimumRecompilationInterval() < lastMod;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* Decides if the given source is newer than a class.
*
* @param source the source we may want to compile
* @param cls the former class
* @return true if the source is newer, false else
* @throws IOException if it is not possible to open an
* connection for the given source
* @see #getTimeStamp(Class)
*/
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
long lastMod;
// Special handling for file:// protocol, as getLastModified() often reports
// incorrect results (-1)
if (isFile(source)) {
// Coerce the file URL to a File
String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
File file = new File(path);
lastMod = file.lastModified();
} else {
URLConnection conn = source.openConnection();
lastMod = conn.getLastModified();
conn.getInputStream().close();
}
long classTime = getTimeStamp(cls);
return classTime + config.getMinimumRecompilationInterval() < lastMod;
}
内容来源于网络,如有侵权,请联系作者删除!