001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.spooler; 020 021import lucee.runtime.config.Config; 022import lucee.runtime.config.RemoteClient; 023import lucee.runtime.exp.PageException; 024import lucee.runtime.net.rpc.client.WSClient; 025import lucee.runtime.op.Caster; 026import lucee.runtime.type.KeyImpl; 027import lucee.runtime.type.Struct; 028import lucee.runtime.type.StructImpl; 029 030public abstract class SpoolerTaskWS extends SpoolerTaskSupport { 031 032 private RemoteClient client; 033 034 035 public SpoolerTaskWS(ExecutionPlan[] plans,RemoteClient client) { 036 super(plans); 037 this.client=client; 038 } 039 040 @Override 041 public final Object execute(Config config) throws PageException { 042 try { 043 WSClient rpc = 044 WSClient.getInstance(null,client.getUrl(),client.getServerUsername(),client.getServerPassword(),client.getProxyData()); 045 046 return rpc.callWithNamedValues(config, KeyImpl.init(getMethodName()), getArguments()); 047 } 048 catch (Throwable t) { 049 throw Caster.toPageException(t); 050 } 051 } 052 053 @Override 054 public String subject() { 055 return client.getLabel(); 056 } 057 058 @Override 059 public Struct detail() { 060 Struct sct=new StructImpl(); 061 sct.setEL("label", client.getLabel()); 062 sct.setEL("url", client.getUrl()); 063 064 return sct; 065 } 066 067 protected abstract String getMethodName(); 068 protected abstract Struct getArguments(); 069}