本文整理汇总了Java中lucee.runtime.Component.call方法的典型用法代码示例。如果您正苦于以下问题:Java Component.call方法的具体用法?Java Component.call怎么用?Java Component.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lucee.runtime.Component
的用法示例。
在下文中一共展示了Component.call方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import lucee.runtime.Component; //导入方法依赖的package包/类
public static Object call(ConfigWeb config,Component cfc, String methodName, Object... arguments) {
try {
PageContext pc = ThreadLocalPageContext.get();
if(pc==null) {
//PageSource ps = cfc.getPageSource();
pc=ThreadUtil.createPageContext(
config,
DevNullOutputStream.DEV_NULL_OUTPUT_STREAM,
"Lucee", "/", "", null, null, null, null);
pc.addPageSource(cfc.getPageSource(), true);
}
return cfc.call(
ThreadLocalPageContext.get(),
methodName,
arguments);
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
}
示例2: setPropeties
import lucee.runtime.Component; //导入方法依赖的package包/类
public static void setPropeties(PageContext pc, Component cfc, Struct properties, boolean ignoreNotExisting) throws PageException {
if(properties==null) return;
// argumentCollection
if(properties.size()==1 && properties.containsKey(KeyConstants._argumentCollection) && !cfc.containsKey(KeyConstants._setArgumentCollection)) {
properties=Caster.toStruct(properties.get(KeyConstants._argumentCollection));
}
Iterator<Entry<Key, Object>> it = properties.entryIterator();
Entry<Key, Object> e;
while(it.hasNext()){
e = it.next();
if(ignoreNotExisting) {
try {
cfc.call(pc, "set"+e.getKey().getString(), new Object[]{e.getValue()});
}
catch(Throwable t){
ExceptionUtil.rethrowIfNecessary(t);
}
}
else {
cfc.call(pc, "set"+e.getKey().getString(), new Object[]{e.getValue()});
}
}
}
示例3: invoke
import lucee.runtime.Component; //导入方法依赖的package包/类
public static void invoke(Key name, Component cfc, Struct data, Object arg) {
if(cfc==null) return;
try {
PageContext pc = ThreadLocalPageContext.get();
Object[] args;
if(data==null) {
args=arg!=null?new Object[]{arg}:new Object[]{};
}
else {
args=arg!=null?new Object[]{arg,data}:new Object[]{data};
}
cfc.call(pc, name, args);
}
catch (PageException pe) {
throw new PageRuntimeException(pe);
}
}
示例4: call
import lucee.runtime.Component; //导入方法依赖的package包/类
public static Object call(ConfigWeb config,Component cfc, String methodName, Object... arguments) {
boolean unregister=false;
PageContext pc=null;
try {
pc = ThreadLocalPageContext.get();
// create PageContext if necessary
if(pc==null) {
pc=ThreadUtil.createPageContext(
config,
DevNullOutputStream.DEV_NULL_OUTPUT_STREAM,
Constants.NAME, "/", "", null, null, null, null, null,true,-1);
unregister=true;
pc.addPageSource(cfc.getPageSource(), true);
}
return cfc.call(pc, methodName, arguments);
}
catch (PageException pe) {
throw new PageRuntimeException(pe);
}
finally{
if(unregister)config.getFactory().releaseLuceePageContext(pc, true);
}
}
示例5: setPropeties
import lucee.runtime.Component; //导入方法依赖的package包/类
public static void setPropeties(PageContext pc, Component c, Struct properties, boolean ignoreNotExisting) throws PageException {
if(properties==null) return;
// argumentCollection
if(properties.size()==1 && properties.containsKey(KeyConstants._argumentCollection) && !c.containsKey(KeyConstants._setArgumentCollection)) {
properties=Caster.toStruct(properties.get(KeyConstants._argumentCollection));
}
Iterator<Entry<Key, Object>> it = properties.entryIterator();
Entry<Key, Object> e;
while(it.hasNext()){
e = it.next();
if(ignoreNotExisting) {
try {
c.call(pc, "set"+e.getKey().getString(), new Object[]{e.getValue()});
}
catch(Throwable t) {ExceptionUtil.rethrowIfNecessary(t);}
}
else {
c.call(pc, "set"+e.getKey().getString(), new Object[]{e.getValue()});
}
}
}
示例6: call
import lucee.runtime.Component; //导入方法依赖的package包/类
private Object call(Component app, PageContext pc, Collection.Key eventName, Object[] args, boolean catchAbort) throws PageException {
try {
return app.call(pc, eventName, args);
}
catch (PageException pe) {
if(Abort.isSilentAbort(pe)) {
if(catchAbort)
return ( pe instanceof PostContentAbort) ? Boolean.TRUE : Boolean.FALSE;
throw pe;
}
throw new ModernAppListenerException(pe,eventName.getString());
}
}
示例7: _invoke
import lucee.runtime.Component; //导入方法依赖的package包/类
private static Object _invoke(String name, Object[] args) throws PageException {
Key key = Caster.toKey(name);
Component c=component.get();
PageContext p=pagecontext.get();
MessageContext mc = messageContext.get();
if(c==null) throw new ApplicationException("missing component");
if(p==null) throw new ApplicationException("missing pagecontext");
UDF udf = Caster.toFunction(c.get(p,key,null),null);
FunctionArgument[] fa=null;
if(udf!=null) fa = udf.getFunctionArguments();
for(int i=0;i<args.length;i++) {
if(fa!=null && i<fa.length && fa[i].getType()==CFTypes.TYPE_UNKNOW) {
args[i]=AxisCaster.toLuceeType(p,fa[i].getTypeAsString(),args[i]);
}
else
args[i]=AxisCaster.toLuceeType(p,args[i]);
}
// return type
String rtnType=udf!=null?udf.getReturnTypeAsString():"any";
Object rtn = c.call(p, key, args);
// cast return value to Axis type
try {
RPCServer server = RPCServer.getInstance(p.getId(),p.getServletContext());
TypeMapping tm = mc!=null?mc.getTypeMapping():TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry());
rtn=Caster.castTo(p, rtnType, rtn, false);
Class<?> clazz = Caster.cfTypeToClass(rtnType);
return AxisCaster.toAxisType(tm,rtn,clazz.getComponentType()!=null?clazz:null);
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
}
}
示例8: toAMFObject
import lucee.runtime.Component; //导入方法依赖的package包/类
protected ASObject toAMFObject(Component cfc) throws PageException {
ASObject aso = new ASObject();
aso.setType(cfc.getCallName());
Component c=ComponentSpecificAccess.toComponentSpecificAccess(methodAccessLevel,cfc);
Property[] prop = cfc.getProperties(false);
Object v; UDF udf;
if(prop!=null)for(int i=0;i<prop.length;i++) {
boolean remotingFetch = Caster.toBooleanValue(prop[i].getDynamicAttributes().get(REMOTING_FETCH,Boolean.TRUE),true);
if(!remotingFetch) continue;
v=cfc.get(prop[i].getName(),null);
if(v==null){
v=c.get("get"+prop[i].getName(),null);
if(v instanceof UDF){
udf=(UDF) v;
if(udf.getReturnType()==CFTypes.TYPE_VOID) continue;
if(udf.getFunctionArguments().length>0) continue;
try {
v=c.call(ThreadLocalPageContext.get(), udf.getFunctionName(), ArrayUtil.OBJECT_EMPTY);
} catch (PageException e) {
continue;
}
}
}
aso.put(toString(prop[i].getName(),forceCFCLower), toAMFObject(v));
}
return aso;
}
示例9: _invoke
import lucee.runtime.Component; //导入方法依赖的package包/类
public static Object _invoke(String name, Object[] args) throws PageException {
Key key = Caster.toKey(name);
Component c=component.get();
PageContext p=pagecontext.get();
MessageContext mc = messageContext.get();
if(c==null) throw new ApplicationException("missing component");
if(p==null) throw new ApplicationException("missing pagecontext");
UDF udf = Caster.toFunction(c.get(p,key,null),null);
FunctionArgument[] fa=null;
if(udf!=null) fa = udf.getFunctionArguments();
for(int i=0;i<args.length;i++) {
if(fa!=null && i<fa.length && fa[i].getType()==CFTypes.TYPE_UNKNOW) {
args[i]=AxisCaster.toLuceeType(p,fa[i].getTypeAsString(),args[i]);
}
else
args[i]=AxisCaster.toLuceeType(p,args[i]);
}
// return type
String rtnType=udf!=null?udf.getReturnTypeAsString():"any";
Object rtn = c.call(p, key, args);
// cast return value to Axis type
try {
RPCServer server = RPCServer.getInstance(p.getId(),p,p.getServletContext());
TypeMapping tm = mc!=null?mc.getTypeMapping():TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry());
rtn=Caster.castTo(p, rtnType, rtn, false);
Class<?> clazz = Caster.cfTypeToClass(rtnType);
return AxisCaster.toAxisType(tm,rtn,clazz.getComponentType()!=null?clazz:null);
}
catch(Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
}
}
示例10: call
import lucee.runtime.Component; //导入方法依赖的package包/类
public static Component call(PageContext pc , String path, Object args) throws PageException {
// first argument is the component itself
Component c = CreateObject.doComponent(pc, path);
if(c.get(KeyConstants._init,null) instanceof UDF) {
// no arguments
if(args==null) {
c.call(pc, KeyConstants._init, EMPTY);
}
// named arguments
else if(Decision.isStruct(args)) {
Struct sct=Caster.toStruct(args);
c.callWithNamedValues(pc, KeyConstants._init, sct);
}
// not named arguments
else if(Decision.isArray(args)) {
Object[] arr=Caster.toNativeArray(args);
c.call(pc, KeyConstants._init, arr);
}
else {
c.call(pc, KeyConstants._init, new Object[]{args});
}
}
return c;
}
示例11: toAMFObject
import lucee.runtime.Component; //导入方法依赖的package包/类
protected ASObject toAMFObject(Component cfc) throws PageException {
// add properties
ASObject aso = doProperties?super.toAMFObject(cfc):new ASObject();
ComponentSpecificAccess cw=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_REMOTE,cfc);
Iterator it = cfc.entrySet().iterator();
Map.Entry entry;
Object v;
Collection.Key k;
UDF udf;
String name;
while(it.hasNext()) {
entry=(Entry) it.next();
k=KeyImpl.toKey(entry.getKey());
v=entry.getValue();
// add getters
if(v instanceof UDF){
if(!doGetters) continue;
udf=(UDF) v;
name=udf.getFunctionName();
if(!StringUtil.startsWithIgnoreCase(name, "get"))continue;
if(udf.getReturnType()==CFTypes.TYPE_VOID) continue;
if(udf.getFunctionArguments().length>0) continue;
try {
v=cfc.call(ThreadLocalPageContext.get(), name, ArrayUtil.OBJECT_EMPTY);
} catch (PageException e) {
continue;
}
name=name.substring(3);
aso.put(toString(name,forceCFCLower), toAMFObject(v));
}
// add remote data members
if(cw!=null && doRemoteValues){
v=cw.get(k,null);
if(v!=null)aso.put(toString(k,forceCFCLower), toAMFObject(v));
}
}
return aso;
}