Java Code Examples for org.springframework.scripting.ScriptSource#isModified()

The following examples show how to use org.springframework.scripting.ScriptSource#isModified() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BshScriptFactory.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	synchronized (this.scriptClassMonitor) {
		try {
			if (scriptSource.isModified()) {
				// New script content: Let's check whether it evaluates to a Class.
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = BshScriptUtils.determineBshObjectType(
						scriptSource.getScriptAsString(), this.beanClassLoader);
			}
			return this.scriptClass;
		}
		catch (EvalError ex) {
			this.scriptClass = null;
			throw new ScriptCompilationException(scriptSource, ex);
		}
	}
}
 
Example 2
Source File: BshScriptFactory.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	synchronized (this.scriptClassMonitor) {
		try {
			if (scriptSource.isModified()) {
				// New script content: Let's check whether it evaluates to a Class.
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = BshScriptUtils.determineBshObjectType(
						scriptSource.getScriptAsString(), this.beanClassLoader);
			}
			return this.scriptClass;
		}
		catch (EvalError ex) {
			this.scriptClass = null;
			throw new ScriptCompilationException(scriptSource, ex);
		}
	}
}
 
Example 3
Source File: BshScriptFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	synchronized (this.scriptClassMonitor) {
		try {
			if (scriptSource.isModified()) {
				// New script content: Let's check whether it evaluates to a Class.
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = BshScriptUtils.determineBshObjectType(
						scriptSource.getScriptAsString(), this.beanClassLoader);
			}
			return this.scriptClass;
		}
		catch (EvalError ex) {
			this.scriptClass = null;
			throw new ScriptCompilationException(scriptSource, ex);
		}
	}
}
 
Example 4
Source File: BshScriptFactory.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	try {
		synchronized (this.scriptClassMonitor) {
			if (scriptSource.isModified()) {
				// New script content: Let's check whether it evaluates to a Class.
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = BshScriptUtils.determineBshObjectType(
						scriptSource.getScriptAsString(), this.beanClassLoader);
			}
			return this.scriptClass;
		}
	}
	catch (EvalError ex) {
		throw new ScriptCompilationException(scriptSource, ex);
	}
}
 
Example 5
Source File: GroovyScriptFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	synchronized (this.scriptClassMonitor) {
		try {
			if (this.scriptClass == null || scriptSource.isModified()) {
				// New script content...
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = getGroovyClassLoader().parseClass(
						scriptSource.getScriptAsString(), scriptSource.suggestedClassName());

				if (Script.class.isAssignableFrom(this.scriptClass)) {
					// A Groovy script, probably creating an instance: let's execute it.
					Object result = executeScript(scriptSource, this.scriptClass);
					this.scriptResultClass = (result != null ? result.getClass() : null);
					this.cachedResult = new CachedResultHolder(result);
				}
				else {
					this.scriptResultClass = this.scriptClass;
				}
			}
			return this.scriptResultClass;
		}
		catch (CompilationFailedException ex) {
			this.scriptClass = null;
			this.scriptResultClass = null;
			this.cachedResult = null;
			throw new ScriptCompilationException(scriptSource, ex);
		}
	}
}
 
Example 6
Source File: GroovyScriptFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	try {
		synchronized (this.scriptClassMonitor) {
			if (this.scriptClass == null || scriptSource.isModified()) {
				// New script content...
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = getGroovyClassLoader().parseClass(
						scriptSource.getScriptAsString(), scriptSource.suggestedClassName());

				if (Script.class.isAssignableFrom(this.scriptClass)) {
					// A Groovy script, probably creating an instance: let's execute it.
					Object result = executeScript(scriptSource, this.scriptClass);
					this.scriptResultClass = (result != null ? result.getClass() : null);
					this.cachedResult = new CachedResultHolder(result);
				}
				else {
					this.scriptResultClass = this.scriptClass;
				}
			}
			return this.scriptResultClass;
		}
	}
	catch (CompilationFailedException ex) {
		throw new ScriptCompilationException(scriptSource, ex);
	}
}
 
Example 7
Source File: GroovyScriptFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
		throws IOException, ScriptCompilationException {

	synchronized (this.scriptClassMonitor) {
		try {
			if (this.scriptClass == null || scriptSource.isModified()) {
				// New script content...
				this.wasModifiedForTypeCheck = true;
				this.scriptClass = getGroovyClassLoader().parseClass(
						scriptSource.getScriptAsString(), scriptSource.suggestedClassName());

				if (Script.class.isAssignableFrom(this.scriptClass)) {
					// A Groovy script, probably creating an instance: let's execute it.
					Object result = executeScript(scriptSource, this.scriptClass);
					this.scriptResultClass = (result != null ? result.getClass() : null);
					this.cachedResult = new CachedResultHolder(result);
				}
				else {
					this.scriptResultClass = this.scriptClass;
				}
			}
			return this.scriptResultClass;
		}
		catch (CompilationFailedException ex) {
			this.scriptClass = null;
			this.scriptResultClass = null;
			this.cachedResult = null;
			throw new ScriptCompilationException(scriptSource, ex);
		}
	}
}
 
Example 8
Source File: BshScriptFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 9
Source File: StandardScriptFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 10
Source File: StandardScriptFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 11
Source File: JRubyScriptFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 12
Source File: BshScriptFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 13
Source File: GroovyScriptFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 14
Source File: StandardScriptFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 15
Source File: JRubyScriptFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 16
Source File: BshScriptFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 17
Source File: GroovyScriptFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 18
Source File: StandardScriptFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	return scriptSource.isModified();
}
 
Example 19
Source File: BshScriptFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}
 
Example 20
Source File: GroovyScriptFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) {
	synchronized (this.scriptClassMonitor) {
		return (scriptSource.isModified() || this.wasModifiedForTypeCheck);
	}
}