1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.binding.HostingRedirector; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 29 public class HostingRedirectorHandler extends AbstractHandler 30 { 31 public static final String TAG_NAME = "hostingRedirector"; 32 33 private HandlerMaker maker = null; 34 35 protected HostingRedirectorHandler(HandlerMaker maker) 36 { 37 this.maker = maker; 38 } 39 40 public RegistryObject unmarshal(Element element) 41 { 42 HostingRedirector obj = new HostingRedirector(); 43 44 obj.setBindingKey(element.getAttribute("bindingKey")); 46 47 50 53 return obj; 54 } 55 56 public void marshal(RegistryObject object,Element parent) 57 { 58 HostingRedirector redirector = (HostingRedirector)object; 59 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 60 61 String bindingKey = redirector.getBindingKey(); 62 if (bindingKey != null) 63 element.setAttribute("bindingKey",bindingKey); 64 65 parent.appendChild(element); 66 } 67 68 69 70 71 72 73 74 public static void main(String args[]) 75 throws Exception 76 { 77 HandlerMaker maker = HandlerMaker.getInstance(); 78 AbstractHandler handler = maker.lookup(HostingRedirectorHandler.TAG_NAME); 79 80 Element parent = XMLUtils.newRootElement(); 81 Element child = null; 82 83 HostingRedirector redirector = new HostingRedirector(); 84 redirector.setBindingKey("92658289-0bd7-443c-8948-0bb4460b44c0"); 85 86 System.out.println(); 87 88 RegistryObject regObject = redirector; 89 handler.marshal(regObject,parent); 90 child = (Element )parent.getFirstChild(); 91 parent.removeChild(child); 92 XMLUtils.writeXML(child,System.out); 93 94 System.out.println(); 95 96 regObject = handler.unmarshal(child); 97 handler.marshal(regObject,parent); 98 child = (Element )parent.getFirstChild(); 99 parent.removeChild(child); 100 XMLUtils.writeXML(child,System.out); 101 102 System.out.println(); 103 } 104 } | Popular Tags |