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 @Override 022 public final Object execute(Config config) throws PageException { 023 try { 024 RPCClient rpc = getRPCClient(client); 025 return rpc.callWithNamedValues(config, getMethodName(), getArguments()); 026 } 027 catch (Throwable t) { 028 throw Caster.toPageException(t); 029 } 030 } 031 032 @Override 033 public String subject() { 034 return client.getLabel(); 035 } 036 037 @Override 038 public Struct detail() { 039 Struct sct=new StructImpl(); 040 sct.setEL("label", client.getLabel()); 041 sct.setEL("url", client.getUrl()); 042 043 return sct; 044 } 045 046 public static RPCClient getRPCClient(RemoteClient client) throws PageException { 047 return new RPCClient(client.getUrl(),client.getServerUsername(),client.getServerPassword(),client.getProxyData()); 048 } 049 050 051 protected abstract String getMethodName(); 052 protected abstract Struct getArguments(); 053 }