本文整理汇总了Java中org.apache.bsf.BSFDeclaredBean类的典型用法代码示例。如果您正苦于以下问题:Java BSFDeclaredBean类的具体用法?Java BSFDeclaredBean怎么用?Java BSFDeclaredBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BSFDeclaredBean类属于org.apache.bsf包,在下文中一共展示了BSFDeclaredBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
interpreter = BshUtil.getMasterInterpreter(null);
// declare the bsf manager for callbacks, etc.
try {
interpreter.set("bsf", mgr);
} catch (EvalError e) {
throw new BSFException("bsh internal error: "+e.toString());
}
for (int i=0; i<declaredBeans.size(); i++) {
BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i);
declareBean(bean);
}
}
示例2: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
/**
* Initialize the engine.
*/
public void initialize(final BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
ClassLoader parent = mgr.getClassLoader();
if (parent == null)
parent = GroovyShell.class.getClassLoader();
setLoader(mgr, parent);
execScripts = new HashMap<Object, Class>();
evalScripts = new HashMap<Object, Class>();
context = shell.getContext();
// create a shell
// register the mgr with object name "bsf"
context.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
示例3: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
interpreter = BshUtil.getMasterInterpreter(null);
// declare the bsf manager for callbacks, etc.
try {
interpreter.set("bsf", mgr);
} catch (EvalError e) {
throw new BSFException("bsh internal error: "+e.toString());
}
for(int i=0; i<declaredBeans.size(); i++) {
BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i);
declareBean(bean);
}
}
示例4: declareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void declareBean(BSFDeclaredBean bean) throws BSFException {
try {
interpreter.set(bean.name, bean.bean);
} catch (EvalError e) {
throw new BSFException("error declaring bean: " + bean.name + " : " + e.toString());
}
}
示例5: undeclareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
try {
interpreter.unset(bean.name);
} catch (EvalError e) {
throw new BSFException("bsh internal error: " + e.toString());
}
}
示例6: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// declare the bsf manager for callbacks, etc.
context.put("bsf", mgr);
for (int i = 0; i < declaredBeans.size(); i++) {
BSFDeclaredBean bean = (BSFDeclaredBean) declaredBeans.get(i);
declareBean(bean);
}
}
示例7: declareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void declareBean(BSFDeclaredBean bean) throws BSFException {
if ((bean.bean instanceof Number) ||
(bean.bean == null) ||
(bean.bean instanceof String) ||
(bean.bean instanceof Boolean)) {
global.put(bean.name, global, bean.bean);
}
else {
// Must wrap non-scriptable objects before presenting to Rhino
Scriptable wrapped = Context.toObject(bean.bean, global);
global.put(bean.name, global, wrapped);
}
}
示例8: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
/**
* Initialize the engine.
* Put the manager into the context-manager
* map hashtable too.
*/
@Override
public void initialize(BSFManager mgr, String lang,
@SuppressWarnings("rawtypes") // superclass does not support types
Vector declaredBeans)
throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// Initialize context and global scope object
try {
Context cx = Context.enter();
global = new ImporterTopLevel(cx);
Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
global.put("bsf", global, bsf);
@SuppressWarnings("unchecked") // superclass does not support types
final Vector<BSFDeclaredBean> beans = declaredBeans;
for (BSFDeclaredBean declaredBean : beans) {
declareBean(declaredBean);
}
}
catch (Throwable t) {
handleError(t);
}
finally {
Context.exit();
}
}
示例9: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
/**
* Initialize the engine.
*/
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// create a shell
shell = new GroovyShell(mgr.getClassLoader());
// register the mgr with object name "bsf"
shell.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
示例10: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
public void initialize (BSFManager mgr,
String lang,
Vector declaredBeans) throws BSFException {
super.initialize (mgr, lang, declaredBeans);
// Reference the REPL class to get primitives loaded.
Class repl = REPL.class;
// register the mgr with object name "bsf"
js.setGlobalValue ("bsf", new BSFFunctions (mgr, this));
int size = declaredBeans.size ();
for (int i = 0; i < size; i++)
declareBean ((BSFDeclaredBean) declaredBeans.elementAt (i));
}
示例11: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked") // super-class does not use generics
@Override
public void initialize(BSFManager mgr, String lang,
@SuppressWarnings("rawtypes") Vector declaredBeans) // super-class does not use generics
throws BSFException {
super.initialize(mgr, lang, declaredBeans);
jc = JexlHelper.createContext();
for (int i = 0; i < declaredBeans.size(); i++) {
BSFDeclaredBean bean = (BSFDeclaredBean) declaredBeans.elementAt(i);
jc.getVars().put(bean.name, bean.bean);
}
}
示例12: initialize
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
/**
* Initialize the engine.
* Put the manager into the context-manager
* map hashtable too.
*/
@Override
public void initialize(BSFManager mgr, String lang,
@SuppressWarnings("rawtypes") // superclass does not support types
Vector declaredBeans)
throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// Initialize context and global scope object
try {
Context cx = Context.enter();
global = new ImporterTopLevel(cx);
Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
global.put("bsf", global, bsf);
for(
@SuppressWarnings("unchecked")
Iterator<BSFDeclaredBean> it = declaredBeans.iterator();
it.hasNext();) {
declareBean(it.next());
}
}
catch (Throwable t) {
handleError(t);
}
finally {
Context.exit();
}
}
示例13: declareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void declareBean(BSFDeclaredBean bean) throws BSFException {
context.put(bean.name, bean.bean);
}
示例14: undeclareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
context.remove(bean.name);
}
示例15: undeclareBean
import org.apache.bsf.BSFDeclaredBean; //导入依赖的package包/类
@Override
public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
global.delete(bean.name);
}