public class BshScriptFactory extends ObjectSE implements ScriptFactory, BeanClassLoaderAware
ScriptFactory
実装。 通常、ScriptFactoryPostProcessor
と組み合わせて使用されます。設定例については、後者の javadoc を参照してください。
BshScriptUtils
, ScriptFactoryPostProcessor
コンストラクターと説明 |
---|
BshScriptFactory(StringSE scriptSourceLocator) 指定されたスクリプトソースの新しい BshScriptFactory を作成します。 |
BshScriptFactory(StringSE scriptSourceLocator, ClassSE<?>... scriptInterfaces) 指定されたスクリプトソースの新しい BshScriptFactory を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
ObjectSE | getScriptedObject(ScriptSource scriptSource, ClassSE<?>... actualInterfaces) BshScriptUtils を介して BeanShell スクリプトをロードして解析します。 |
ClassSE<?> | getScriptedObjectType(ScriptSource scriptSource) スクリプト Java オブジェクトの型を判別します。 |
ClassSE<?>[] | getScriptInterfaces() スクリプトが実装することになっているビジネスインターフェースを返します。 |
StringSE | getScriptSourceLocator() スクリプトのソースを指すロケーターを返します。 |
boolean | requiresConfigInterface() BeanShell スクリプトには、構成インターフェースが必要です。 |
boolean | requiresScriptedObjectRefresh(ScriptSource scriptSource) リフレッシュが必要かどうかを判断します(例: |
void | setBeanClassLoader(ClassLoaderSE classLoader) Bean class loader SE を Bean インスタンスに提供するコールバック。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public BshScriptFactory(StringSE scriptSourceLocator)
この BshScriptFactory
バリアントでは、スクリプトは完全なクラスを宣言するか、スクリプトオブジェクトの実際のインスタンスを返す必要があります。
scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。public BshScriptFactory(StringSE scriptSourceLocator, @Nullable ClassSE<?>... scriptInterfaces)
スクリプトは、対応するプロキシを生成する(指定されたインターフェースを実装する)必要がある単純なスクリプトか、完全なクラスを宣言するか、スクリプトオブジェクトの実際のインスタンスを返す(この場合、指定されたインターフェースがある場合は、実装する必要があります)そのクラス / インスタンスによって)。
scriptSourceLocator
- スクリプトのソースを指すロケーター。実際にスクリプトを作成するポストプロセッサーによって解釈されます。scriptInterfaces
- スクリプトオブジェクトが実装することになっている Java インターフェース (null
の場合があります)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
の requiresConfigInterface
ScriptFactory.getScriptInterfaces()
@Nullable public ObjectSE getScriptedObject(ScriptSource scriptSource, @Nullable ClassSE<?>... actualInterfaces) throws IOExceptionSE, ScriptCompilationException
BshScriptUtils
を介して BeanShell スクリプトをロードして解析します。ScriptFactory
の getScriptedObject
scriptSource
- スクリプトソーステキストを取得する実際の ScriptSource (非 null
)actualInterfaces
- スクリプトインターフェースと生成された設定インターフェースを含む、公開する実際のインターフェース (該当する場合 ; null
の可能性があります)IOExceptionSE
- スクリプトの取得に失敗した場合 ScriptCompilationException
- スクリプトのコンパイルが失敗した場合 BshScriptUtils.createBshObject(String, Class[], ClassLoader)
@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