//try {
// Forward
CFMLFactory factory = CFMLEngineImpl.getInstance().getCFMLFactory(context, config, req);
PageContext pc=null;
// CFC Files
String cfc;
Object parameters=null;
try {
cfc="/"+serviceName.replace('.','/')+".cfc";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pc=createPageContext(factory,cfc,"method="+serviceMethodName,baos,req);
PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfc);
if(caster==null)caster=((ConfigImpl)pc.getConfig()).getAMFCaster(configMap);
parameters=caster.toCFMLObject(rawParams);
if(source!=null) {
print(pc,cfc+"?method="+serviceMethodName);
// Map
//print.err(parameters);
if(parameters instanceof Map){
//print.err("map");
pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
}
// List
else if(parameters instanceof List){
//print.err("list");
pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
}
else {
ArrayList list = new ArrayList();
list.add(parameters);
pc.getHttpServletRequest().setAttribute("argumentCollection", list);
}
// Execute
pc.execute(cfc,true);
// write back response
writeBackResponse(pc,rsp);
// After
return caster.toAMFObject(pc.variablesScope().get(AMF_FORWARD,null));
}
}
finally {
if(pc!=null)factory.releaseRailoPageContext(pc);
}
// CFML Files
String cfml;
try {
cfml="/"+(serviceName.replace('.','/')+'/'+serviceMethodName.replace('.','/'))+".cfm";
pc=createPageContext(factory,cfml,"",null,req);
PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfml);
if(source!=null) {
print(pc,cfml);
// Before
Struct params=new StructImpl();
pc.variablesScope().setEL(FLASH,params);
params.setEL(PARAMS,parameters);
// Execute
pc.execute(cfml,true);
// write back response
writeBackResponse(pc,rsp);
// After
Object flash=pc.variablesScope().get(FLASH,null);
if(flash instanceof Struct) {
return caster.toAMFObject(((Struct)flash).get(RESULT,null));
}
return null;
}
}
finally {
if(pc!=null)factory.releaseRailoPageContext(pc);
}
throw new AMFException("can't find cfml ("+cfml+") or cfc ("+cfc+") matching the request");
}