01: /*
02: * Copyright 2004,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.bsf.util;
18:
19: import org.apache.bsf.BSFEngine;
20: import org.apache.bsf.BSFException;
21: import org.apache.bsf.BSFManager;
22:
23: /**
24: * This is a utility that engine implementors may use as the Java
25: * object they expose in the scripting language as "bsf". This has
26: * essentially a subset of the methods in BSFManager plus some
27: * stuff from the utils. Currently used by Javascript (Rhino) & BML.
28: *
29: * @author Sanjiva Weerawarana
30: */
31: public class BSFFunctions {
32: BSFManager mgr;
33: BSFEngine engine;
34:
35: public BSFFunctions(BSFManager mgr, BSFEngine engine) {
36: this .mgr = mgr;
37: this .engine = engine;
38: }
39:
40: public void addEventListener(Object src, String eventSetName,
41: String filter, Object script) throws BSFException {
42: EngineUtils.addEventListener(src, eventSetName, filter, engine,
43: mgr, "<event-binding>", 0, 0, script);
44: }
45:
46: public Object lookupBean(String name) {
47: return mgr.lookupBean(name);
48: }
49:
50: public void registerBean(String name, Object bean) {
51: mgr.registerBean(name, bean);
52: }
53:
54: public void unregisterBean(String name) {
55: mgr.unregisterBean(name);
56: }
57: }
|