001 package railo.runtime.spooler; 002 003 import railo.runtime.config.Config; 004 import railo.runtime.config.RemoteClient; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.net.rpc.client.RPCClient; 007 import railo.runtime.op.Caster; 008 import railo.runtime.type.Struct; 009 import railo.runtime.type.StructImpl; 010 011 public abstract class SpoolerTaskWS extends SpoolerTaskSupport { 012 013 private RemoteClient client; 014 015 016 public SpoolerTaskWS(ExecutionPlan[] plans,RemoteClient client) { 017 super(plans); 018 this.client=client; 019 } 020 021 /** 022 * @return 023 * @see railo.runtime.spooler.SpoolerTask#execute() 024 */ 025 public final Object execute(Config config) throws PageException { 026 try { 027 RPCClient rpc = getRPCClient(client); 028 return rpc.callWithNamedValues(config, getMethodName(), getArguments()); 029 } 030 catch (Throwable t) { 031 throw Caster.toPageException(t); 032 } 033 } 034 035 /** 036 * @see railo.runtime.spooler.SpoolerTask#subject() 037 */ 038 public String subject() { 039 return client.getLabel(); 040 } 041 042 /** 043 * @see railo.runtime.spooler.SpoolerTask#detail() 044 */ 045 public Struct detail() { 046 Struct sct=new StructImpl(); 047 sct.setEL("label", client.getLabel()); 048 sct.setEL("url", client.getUrl()); 049 050 return sct; 051 } 052 053 public static RPCClient getRPCClient(RemoteClient client) throws PageException { 054 return new RPCClient(client.getUrl(),client.getServerUsername(),client.getServerPassword(),client.getProxyData()); 055 } 056 057 058 protected abstract String getMethodName(); 059 protected abstract Struct getArguments(); 060 }