本文整理了Java中org.mozilla.javascript.Context.getCurrentContext()
方法的一些代码示例,展示了Context.getCurrentContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getCurrentContext()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getCurrentContext
[英]Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.
[中]获取当前上下文。当前上下文为每个线程;此方法查找与当前线程关联的上下文。
代码示例来源:origin: apache/incubator-druid
@Override
public Object apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toObject(res, scope) : null;
}
};
代码示例来源:origin: apache/incubator-druid
@Override
public String apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toString(res) : null;
}
};
代码示例来源:origin: apache/incubator-druid
@Override
public double apply(Object[] args)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
return Context.toNumber(fn.call(cx, scope, scope, args));
}
};
代码示例来源:origin: org.freemarker/freemarker
public Object exec(List arguments) throws TemplateModelException {
Context cx = Context.getCurrentContext();
Object[] args = arguments.toArray();
BeansWrapper wrapper = getWrapper();
for (int i = 0; i < args.length; i++) {
args[i] = wrapper.unwrap((TemplateModel) args[i]);
}
return wrapper.wrap(((Function) getScriptable()).call(cx,
ScriptableObject.getTopLevelScope(fnThis), fnThis, args));
}
}
代码示例来源:origin: rhino/js
private static RegExpImpl getImpl()
{
Context cx = Context.getCurrentContext();
return (RegExpImpl) ScriptRuntime.getRegExpProxy(cx);
}
代码示例来源:origin: rhino/js
/**
* @deprecated NativeJavaPackage is an internal class, do not use
* it directly.
*/
public NativeJavaPackage(String packageName) {
this(false, packageName,
Context.getCurrentContext().getApplicationClassLoader());
}
代码示例来源:origin: alexo/wro4j
/**
* Makes sure the context is properly initialized.
*/
private void initContext() {
if (Context.getCurrentContext() == null) {
Context.enter();
}
}
代码示例来源:origin: geogebra/geogebra
/**
* @deprecated NativeJavaPackage is an internal class, do not use
* it directly.
*/
@Deprecated
public NativeJavaPackage(String packageName) {
this(false, packageName,
Context.getCurrentContext().getApplicationClassLoader());
}
代码示例来源:origin: geogebra/geogebra
/**
* Returns representation of the [[ThrowTypeError]] object.
* See ECMA 5 spec, 13.2.3
*
* @deprecated {@link #typeErrorThrower(Context)}
*/
@Deprecated
public static BaseFunction typeErrorThrower() {
return typeErrorThrower(Context.getCurrentContext());
}
代码示例来源:origin: geogebra/geogebra
private static RegExpImpl getImpl()
{
Context cx = Context.getCurrentContext();
return (RegExpImpl) ScriptRuntime.getRegExpProxy(cx);
}
代码示例来源:origin: rhino/js
/**
* @see #isJavaPrimitiveWrap()
*/
public final void setJavaPrimitiveWrap(boolean value)
{
Context cx = Context.getCurrentContext();
if (cx != null && cx.isSealed()) {
Context.onSealedMutation();
}
javaPrimitiveWrap = value;
}
代码示例来源:origin: httpunit/httpunit
private Object toScriptable( ScriptableDelegate[] list ) {
Object[] delegates = new Object[ list.length ];
for (int i = 0; i < delegates.length; i++) {
delegates[i] = toScriptable( list[i] );
}
return Context.getCurrentContext().newArray( this, delegates );
}
代码示例来源:origin: httpunit/httpunit
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
super.initialize( parent, scriptable );
_document = (Document) parent;
_style = (Style) Context.getCurrentContext().newObject( this, "Style" );
}
代码示例来源:origin: geogebra/geogebra
/**
* @see #isJavaPrimitiveWrap()
*/
public final void setJavaPrimitiveWrap(boolean value)
{
Context cx = Context.getCurrentContext();
if (cx != null && cx.isSealed()) {
Context.onSealedMutation();
}
javaPrimitiveWrap = value;
}
代码示例来源:origin: org.alfresco/alfresco-repository
public Scriptable getPeoplePaging(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
{
List<PersonInfo> persons = getPeopleImpl(filter, pagingRequest, sortBy, sortAsc);
Object[] peopleRefs = new Object[persons.size()];
for (int i = 0; i < peopleRefs.length; i++)
{
peopleRefs[i] = persons.get(i).getNodeRef();
}
return Context.getCurrentContext().newArray(getScope(), peopleRefs);
}
代码示例来源:origin: org.alfresco/alfresco-repository
/**
* @return Array of settable permissions for this Node
*/
public Scriptable getSettablePermissions()
{
Set<String> permissions = this.services.getPermissionService().getSettablePermissions(getNodeRef());
Object[] result = permissions.toArray(new Object[0]);
return Context.getCurrentContext().newArray(this.scope, result);
}
代码示例来源:origin: org.apache.druid/druid-processing
@Override
public double apply(Object[] args)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
return Context.toNumber(fn.call(cx, scope, scope, args));
}
};
代码示例来源:origin: httpunit/httpunit
static ElementArray newElementArray( Scriptable parent ) {
try {
return (ElementArray) Context.getCurrentContext().newObject( parent, "ElementArray" );
} catch (PropertyException e) {
throw new RhinoException( e );
} catch (NotAFunctionException e) {
throw new RhinoException( e );
} catch (JavaScriptException e) {
throw new RhinoException( e );
}
}
代码示例来源:origin: httpunit/httpunit
public Scriptable jsGet_frames() throws SAXException, PropertyException, JavaScriptException, NotAFunctionException {
if (_frames == null) {
WebResponse.Scriptable scriptables[] = getDelegate().getFrames();
Window[] frames = new Window[ scriptables.length ];
for (int i = 0; i < frames.length; i++) {
frames[ i ] = (Window) toScriptable( scriptables[ i ] );
}
_frames = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" );
_frames.initialize( frames );
}
return _frames;
}
代码示例来源:origin: httpunit/httpunit
private void initializeControls() throws PropertyException, NotAFunctionException, JavaScriptException {
ScriptableDelegate scriptables[] = getDelegate().getElementDelegates();
Control[] controls = new Control[ scriptables.length ];
for (int i = 0; i < controls.length; i++) {
controls[ i ] = (Control) toScriptable( scriptables[ i ] );
}
_controls = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" );
_controls.initialize( controls );
}
内容来源于网络,如有侵权,请联系作者删除!