Initial implementation of RestHttpPage class

This commit is contained in:
Ziver Koc 2014-10-07 15:26:51 +00:00
parent 6e271f56d9
commit a7e6324a10
11 changed files with 81 additions and 35 deletions

View file

@ -22,8 +22,15 @@
package zutil.net.ws.rest;
import zutil.converters.Converter;
import zutil.net.http.HttpHeaderParser;
import zutil.net.http.HttpPage;
import zutil.net.http.HttpPrintStream;
import zutil.net.http.HttpURL;
import zutil.net.ws.WSInterface;
import zutil.net.ws.WSMethodDef;
import zutil.net.ws.WSParameterDef;
import zutil.net.ws.WebServiceDef;
import java.util.Map;
@ -31,12 +38,49 @@ import java.util.Map;
* User: Ziver
*/
public class RestHttpPage implements HttpPage {
/** The object that the functions will be invoked from **/
private WebServiceDef wsDef;
/** This instance of the web service class is used if session is disabled **/
private WSInterface ws;
public RestHttpPage( WSInterface wsObject ){
this.ws = wsObject;
this.wsDef = new WebServiceDef(ws.getClass());
}
@Override
public void respond(HttpPrintStream out,
Map<String, String> client_info,
HttpHeaderParser client_info,
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request) {
execute(request);
}
private void execute(Map<String, String> input){
}
private Object[] prepareInputParams(WSMethodDef method, Map<String, String> input){
Object[] inputParams = new Object[method.getInputCount()];
// Get the parameter values
for(int i=0; i<method.getInputCount() ;i++){
WSParameterDef param = method.getInput( i );
if( input.containsKey(param.getName()) ){
inputParams[i] = Converter.fromString(
input.get(param.getName()),
param.getParamClass());
}
}
return inputParams;
}
private void generateResponse(){
}
}

View file

@ -31,6 +31,7 @@ import org.dom4j.io.XMLWriter;
import org.xml.sax.SAXException;
import zutil.converters.Converter;
import zutil.log.LogUtil;
import zutil.net.http.HttpHeaderParser;
import zutil.net.http.HttpPage;
import zutil.net.http.HttpPrintStream;
import zutil.net.ws.*;
@ -110,7 +111,7 @@ public class SOAPHttpPage implements HttpPage{
public void respond(HttpPrintStream out,
Map<String, String> client_info,
HttpHeaderParser client_info,
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request) {