00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 package org.jaebi.test.server.service;
00012
00013 import java.io.File;
00014 import java.io.PrintStream;
00015
00016 import org.jaebi.server.service.ServiceMediatorImpl;
00017 import org.jaebi.server.service.exception.ServiceMediatorExecException;
00018 import org.jaebi.server.service.exception.ServiceMediatorInitException;
00019 import org.jaebi.server.service.xml.JAXBMarshallerWrapper;
00020 import org.jaebi.server.service.xml.JAXBMarshallerWrapperImpl;
00021 import org.jaebi.server.service.xml.exception.JAXBMarshallerWrapperInitException;
00022 import org.jaebi.server.service.xml.exception.JAXBMarshallerWrapperMarshallException;
00023 import org.jaebi.server.service.xml.exception.JAXBMarshallerWrapperUnmarshallException;
00024 import org.jaebi.server.service.xml.xrequest.Xrequest;
00025 import org.jaebi.server.service.xml.xresponse.Xresponse;
00026
00027
00032 public class MainTestServiceMediatorImpl {
00033
00037 public static void main(String[] args) {
00038 JAXBMarshallerWrapper marshWrapReq = null;
00039 JAXBMarshallerWrapper marshWrapRes = null;
00040 Xrequest newReq = null;
00041 Xresponse newRes = null;
00042 String newResS = null;
00043 File sourceFile = new File("/Users/detro/workspace-nb/JAEBI/XML-Examples/xrequest-example.select-ok-004.xml");
00044 ServiceMediatorImpl mediator = null;
00045 PrintStream out = System.out;
00046
00047 try {
00048 marshWrapReq = new JAXBMarshallerWrapperImpl("org.jaebi.server.service.xml.xrequest");
00049 marshWrapRes = new JAXBMarshallerWrapperImpl("org.jaebi.server.service.xml.xresponse");
00050 newReq = (Xrequest)marshWrapReq.unmarshall(sourceFile);
00051
00052 out.println(">> Letto File XML e Creato relativo XREQUEST");
00053 } catch ( JAXBMarshallerWrapperInitException inite) {
00054 inite.printStackTrace();
00055 } catch ( JAXBMarshallerWrapperUnmarshallException unmarshe) {
00056 unmarshe.printStackTrace();
00057 }
00058
00059 try {
00060 mediator = new ServiceMediatorImpl("/Users/detro/workspace-nb/JAEBI/web/BackEndHandlerImpl.properties");
00061
00062 out.println(">> Istanziato il Service Mediator");
00063 } catch ( ServiceMediatorInitException inite) {
00064 inite.printStackTrace();
00065 }
00066
00067 try {
00068 newRes = (Xresponse)mediator.executeService(null, (Object)newReq);
00069 marshWrapRes.setFormattedMarshalling(true);
00070 newResS = marshWrapRes.marshall(newRes);
00071
00072 out.println(">> Eseguito il Service");
00073 } catch ( ServiceMediatorExecException exece) {
00074 exece.printStackTrace();
00075 } catch ( JAXBMarshallerWrapperMarshallException marshe) {
00076 marshe.printStackTrace();
00077 }
00078
00079 out.println(">> Risultato:");
00080 out.println(newResS);
00081
00082
00083 }
00084
00085 }