00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.scalagent.kjndi.ksoap;
00024
00025 import java.lang.*;
00026 import java.util.Vector;
00027 import java.util.Hashtable;
00028
00029 import com.scalagent.ksoap.SoapObject;
00030
00031 public class ConversionSoapHelper {
00032
00033 public static final String NAMESPACE = "urn:JndiService";
00034
00035 public static SoapObject getSoapObject(String action, String name, Object object) {
00036
00037 SoapObject sO = null;
00038
00039 if (action.equals("bind")) {
00040 sO = getSoapBind(action,name,object);
00041 } else if (action.equals("lookup")) {
00042 sO = getSoapLookup(action,name,object);
00043 } else if (action.equals("rebind")) {
00044 sO = getSoapRebind(action,name,object);
00045 } else if (action.equals("unbind")) {
00046 sO = getSoapUnbind(action,name,object);
00047 }
00048 return sO;
00049 }
00050
00051 private static SoapObject getSoapBind(String action, String name, Object obj) {
00052 SoapObject sO = new SoapObject(NAMESPACE, action);
00053
00054
00055 return sO;
00056 }
00057
00058 private static SoapObject getSoapLookup(String action, String name, Object obj) {
00059 SoapObject sO = new SoapObject(NAMESPACE, action);
00060 sO.addProperty("name",name);
00061 return sO;
00062 }
00063
00064 private static SoapObject getSoapRebind(String action, String name, Object obj) {
00065 SoapObject sO = new SoapObject(NAMESPACE, action);
00066
00067
00068 return sO;
00069 }
00070
00071 private static SoapObject getSoapUnbind(String action, String name, Object obj) {
00072 SoapObject sO = new SoapObject(NAMESPACE, action);
00073 sO.addProperty("name",name);
00074 return sO;
00075 }
00076
00077
00081 public static Object getObject(SoapObject sO)
00082 throws Exception {
00083
00084 Hashtable h = null;
00085 String nameSpace = sO.getNamespace();
00086 String name = sO.getName();
00087
00088 if (nameSpace.equals(NAMESPACE)) {
00089 if (name.equals("lookupResponse") ||
00090 name.equals("bindResponse") ||
00091 name.equals("unbindResponse") ||
00092 name.equals("rebindResponse")) {
00093 Object o = sO.getProperty("return");
00094 h = (Hashtable) sO.getProperty("return");
00095 } else if (name.equals("sendResponse")) {
00096 return null;
00097 } else {
00098 throw new Exception("SoapObject " + name
00099 + " can't be converted to a Hashtable.");
00100 }
00101 } else {
00102 throw new Exception("SoapObject " + nameSpace
00103 + " != urn:JndiService.");
00104 }
00105
00106 String className = (String) h.get("className");
00107 if (className == null)
00108 throw new Exception("SoapObject " + name
00109 + " no className found.");
00110
00111 if (className.equals("org.objectweb.joram.client.jms.soap.SoapConnectionFactory")) {
00112 return com.scalagent.kjoram.ksoap.SoapConnectionFactory.decode(h);
00113 } else if (className.equals("org.objectweb.joram.client.jms.Queue")){
00114 return com.scalagent.kjoram.Queue.decode(h);
00115 } else if (className.equals("org.objectweb.joram.client.jms.Topic")){
00116 return com.scalagent.kjoram.Topic.decode(h);
00117 } else if (className.equals("org.objectweb.joram.client.jms.TemporaryQueue")){
00118 return com.scalagent.kjoram.TemporaryQueue.decode(h);
00119 } else if (className.equals("org.objectweb.joram.client.jms.TemporaryTopic")){
00120 return com.scalagent.kjoram.TemporaryTopic.decode(h);
00121 }
00122 throw new Exception("SoapObject " + className
00123 + " can't be converted to an Object.");
00124 }
00125 }