public class StandardScriptFactory extends ObjectSE implements ScriptFactory, BeanClassLoaderAware
ScriptFactory
実装(Java 6+ に含まれる)。JavaScript、Groovy、JRuby、その他の JSR-223 準拠のエンジンをサポートします。 通常、ScriptFactoryPostProcessor
と組み合わせて使用されます。設定例については、後者の javadoc を参照してください。
ScriptFactoryPostProcessor
コンストラクターと説明 |
---|
StandardScriptFactory(StringSE scriptSourceLocator) 指定されたスクリプトソースの新しい StandardScriptFactory を作成します。 |
StandardScriptFactory(StringSE scriptSourceLocator, ClassSE<?>... scriptInterfaces) 指定されたスクリプトソースの新しい StandardScriptFactory を作成します。 |
StandardScriptFactory(StringSE scriptEngineName, StringSE scriptSourceLocator) 指定されたスクリプトソースの新しい StandardScriptFactory を作成します。 |
StandardScriptFactory(StringSE scriptEngineName, StringSE scriptSourceLocator, ClassSE<?>... scriptInterfaces) 指定されたスクリプトソースの新しい StandardScriptFactory を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected ObjectSE | adaptToInterfaces(ObjectSE script, ScriptSource scriptSource, ClassSE<?>... actualInterfaces) |
protected ObjectSE | evaluateScript(ScriptSource scriptSource) |
ObjectSE | getScriptedObject(ScriptSource scriptSource, ClassSE<?>... actualInterfaces) JSR-223 の ScriptEngine を介してスクリプトをロードして解析します。 |
ClassSE<?> | getScriptedObjectType(ScriptSource scriptSource) スクリプト Java オブジェクトの型を判別します。 |
ClassSE<?>[] | getScriptInterfaces() スクリプトが実装することになっているビジネスインターフェースを返します。 |
StringSE | getScriptSourceLocator() スクリプトのソースを指すロケーターを返します。 |
boolean | requiresConfigInterface() スクリプトが構成インターフェースを生成する必要があるかどうかを返します。 |
boolean | requiresScriptedObjectRefresh(ScriptSource scriptSource) リフレッシュが必要かどうかを判断します(例: |
protected ScriptEngineSE | retrieveScriptEngine(ScriptSource scriptSource) |
void | setBeanClassLoader(ClassLoaderSE classLoader) Bean class loader SE を Bean インスタンスに提供するコールバック。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public StandardScriptFactory(StringSE scriptSourceLocator)
scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。public StandardScriptFactory(StringSE scriptSourceLocator, ClassSE<?>... scriptInterfaces)
scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。scriptInterfaces
- スクリプトオブジェクトが実装することになっている Java インターフェース public StandardScriptFactory(StringSE scriptEngineName, StringSE scriptSourceLocator)
scriptEngineName
- 使用する JSR-223 ScriptEngine の名前 (スクリプトソースから推論される代わりに明示的に与えられる)scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。public StandardScriptFactory(@Nullable StringSE scriptEngineName, StringSE scriptSourceLocator, @Nullable ClassSE<?>... scriptInterfaces)
scriptEngineName
- 使用する JSR-223 ScriptEngine の名前 (スクリプトソースから推論される代わりに明示的に与えられる)scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。scriptInterfaces
- スクリプトオブジェクトが実装することになっている Java インターフェース public void setBeanClassLoader(ClassLoaderSE classLoader)
BeanClassLoaderAware
class loader
SE を Bean インスタンスに提供するコールバック。 通常の Bean プロパティの設定後、ただし InitializingBean's
InitializingBean.afterPropertiesSet()
メソッドやカスタム init-method などの初期化コールバックの前に呼び出されます。
BeanClassLoaderAware
の setBeanClassLoader
classLoader
- 所有クラスローダー public StringSE getScriptSourceLocator()
ScriptFactory
サポートされている一般的なロケータは、Spring リソースの場所 ( "file:C:/myScript.bsh"" や "classpath:myPackage/myScript.bsh" など) とインラインスクリプト ( "inline:myScriptText..." ) です。
@Nullable public ClassSE<?>[] getScriptInterfaces()
ScriptFactory
スクリプト自体がその Java インターフェースを決定する場合(Groovy の場合など)、null
を返すことができます。
ScriptFactory
の getScriptInterfaces
public boolean requiresConfigInterface()
ScriptFactory
getScriptInterfaces()
で適切な構成インターフェースが指定されておらず、Java 署名自体を決定しないスクリプトの場合です。ScriptFactory
の requiresConfigInterface
ScriptFactory.getScriptInterfaces()
@Nullable public ObjectSE getScriptedObject(ScriptSource scriptSource, @Nullable ClassSE<?>... actualInterfaces) throws IOExceptionSE, ScriptCompilationException
ScriptFactory
の getScriptedObject
scriptSource
- スクリプトソーステキストを取得する実際の ScriptSource (非 null
)actualInterfaces
- スクリプトインターフェースと生成された設定インターフェースを含む、公開する実際のインターフェース (該当する場合 ; null
の可能性があります)IOExceptionSE
- スクリプトの取得に失敗した場合 ScriptCompilationException
- スクリプトのコンパイルが失敗した場合 protected ObjectSE evaluateScript(ScriptSource scriptSource)
@Nullable protected ScriptEngineSE retrieveScriptEngine(ScriptSource scriptSource)
@Nullable protected ObjectSE adaptToInterfaces(@Nullable ObjectSE script, ScriptSource scriptSource, ClassSE<?>... actualInterfaces)
@Nullable public ClassSE<?> getScriptedObjectType(ScriptSource scriptSource) throws IOExceptionSE, ScriptCompilationException
ScriptFactory
実装では、生成されたスクリプトクラスなどのスクリプトメタデータをキャッシュすることをお勧めします。このメソッドは同時に呼び出すことができ、スレッドセーフな方法で実装する必要があることに注意してください。
ScriptFactory
の getScriptedObjectType
scriptSource
- スクリプトソーステキストを取得する実際の ScriptSource (非 null
)null
IOExceptionSE
- スクリプトの取得に失敗した場合 ScriptCompilationException
- スクリプトのコンパイルが失敗した場合 public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource)
ScriptFactory
isModified()
メソッドなどを使用)。ScriptFactory
の requiresScriptedObjectRefresh
scriptSource
- スクリプトソーステキストを取得する実際の ScriptSource (非 null
)ScriptFactory.getScriptedObject(org.springframework.scripting.ScriptSource, java.lang.Class<?>...)
呼び出しが必要かどうか ScriptSource.isModified()
public StringSE toString()
ObjectSE
の toStringSE