Author: kstam
Date: Tue Mar 15 19:57:12 2011
New Revision: 1081920

URL: http://svn.apache.org/viewvc?rev=1081920&view=rev
Log:
JUDDI-459 add support for JNDI-RMI notifications

Added:
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/InitialContextInfo.java
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/ObjectFactory.java
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/Property.java
    juddi/trunk/uddi-ws/src/test/java/org/apache/
    juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/
    
juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/InitialContextInfoTest.java
Modified:
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/api_v3/ObjectFactory.java
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/JAXBMarshaller.java

Added: 
juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/InitialContextInfo.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/InitialContextInfo.java?rev=1081920&view=auto
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/InitialContextInfo.java 
(added)
+++ juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/InitialContextInfo.java 
Tue Mar 15 19:57:12 2011
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+
+@XmlRootElement
+public class InitialContextInfo implements Serializable {
+
+       @XmlTransient
+       private static final long serialVersionUID = 5639256817185443090L;
+       
+       @XmlElement
+       protected List<Property> contextProperty;
+       
+       public InitialContextInfo() {
+               super();
+       }
+
+       public List<Property> getContextProperty() {
+               if (contextProperty==null) {
+                       contextProperty = new ArrayList<Property>();
+               }
+               return contextProperty;
+       }
+
+       public void setProperty(List<Property> contextProperty) {
+               this.contextProperty = contextProperty;
+       }
+
+}

Added: juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/ObjectFactory.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/ObjectFactory.java?rev=1081920&view=auto
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/ObjectFactory.java 
(added)
+++ juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/ObjectFactory.java Tue 
Mar 15 19:57:12 2011
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+package org.apache.juddi;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+import org.apache.juddi.api_v3.Publisher;
+
+
+/**
+ * This object contains factory methods for each 
+ * Java content interface and Java element interface. 
+ * <p>An ObjectFactory allows you to programatically 
+ * construct new instances of the Java representation 
+ * for XML content. The Java representation of XML 
+ * content can consist of schema derived interfaces 
+ * and classes representing the binding of schema 
+ * type definitions, element declarations and model 
+ * groups.  Factory methods for each of these are 
+ * provided in this class.
+ * 
+ * This object was copied from the UDDI generated package 
+ * and hand-edited to fit the juddi specific Publisher structures.
+ * 
+ * @author <a href="mailto:[email protected]";>Jeff Faath</a>
+ */
+@XmlRegistry
+public class ObjectFactory {
+       
+        private final static QName _InitialContextInfo_QNAME = new QName("", 
"initialContextInfo");
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of 
schema derived classes for package: org.apache.juddi.api_v3
+     * 
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link Publisher }
+     * 
+     */
+    public InitialContextInfo createInitialContextInfo() {
+        return new InitialContextInfo();
+    }
+    /**
+     * Create an instance of {@link JAXBElement }{@code <}{@link Publisher 
}{@code >}}
+     * 
+     */
+    @XmlElementDecl(namespace = "", name = "initialContextInfo")
+    public JAXBElement<InitialContextInfo> 
createInitialContextInfo(InitialContextInfo value) {
+        return new JAXBElement<InitialContextInfo>(_InitialContextInfo_QNAME, 
InitialContextInfo.class, null, value);
+    }
+
+  
+}

Added: juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/Property.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/Property.java?rev=1081920&view=auto
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/Property.java (added)
+++ juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/Property.java Tue Mar 15 
19:57:12 2011
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "property", propOrder = {
+    "name",
+    "value"
+})
+
+public class Property implements Serializable {
+
+       @XmlTransient
+       private static final long serialVersionUID = -4709832013883862802L;
+       
+       @XmlAttribute
+       protected String name;
+       @XmlAttribute
+       protected String value;
+       
+       public Property() {
+               super();
+       }
+       
+       public Property(String name, String value) {
+               super();
+               this.name = name;
+               this.value = value;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getValue() {
+               return value;
+       }
+
+       public void setValue(String value) {
+               this.value = value;
+       }
+
+
+}

Modified: 
juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/api_v3/ObjectFactory.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/api_v3/ObjectFactory.java?rev=1081920&r1=1081919&r2=1081920&view=diff
==============================================================================
--- 
juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/api_v3/ObjectFactory.java 
(original)
+++ 
juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/api_v3/ObjectFactory.java 
Tue Mar 15 19:57:12 2011
@@ -47,6 +47,7 @@ public class ObjectFactory {
     private final static QName _SavePublisher_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "save_publisher");
     private final static QName _DeletePublisher_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "delete_publisher");
     private final static QName _Publisher_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "publisher");
+   
     private final static QName _PublisherDetail_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "publisherDetail");
     private final static QName _GetPublisherDetail_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "get_publisherDetail");
     private final static QName _GetAllPublisherDetail_QNAME = new 
QName("urn:juddi-apache-org:api_v3", "get_allPublisherDetail");
@@ -84,6 +85,8 @@ public class ObjectFactory {
     public Publisher createPublisher() {
         return new Publisher();
     }
+    
+ 
 
     /**
      * Create an instance of {@link PublisherDetail }
@@ -153,6 +156,15 @@ public class ObjectFactory {
     public JAXBElement<Publisher> createPublisher(Publisher value) {
         return new JAXBElement<Publisher>(_Publisher_QNAME, Publisher.class, 
null, value);
     }
+    
+//    /**
+//     * Create an instance of {@link JAXBElement }{@code <}{@link RMIInfo 
}{@code >}}
+//     * 
+//     */
+//    @XmlElementDecl(name = "rmiInfo")
+//    public JAXBElement<RMIInfo> createRMIInfo(RMIInfo value) {
+//        return new JAXBElement<RMIInfo>(_RMIInfo_QNAME, RMIInfo.class, null, 
value);
+//    }
 
     /**
      * Create an instance of {@link JAXBElement }{@code <}{@link 
PublisherDetail }{@code >}}

Modified: 
juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/JAXBMarshaller.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/JAXBMarshaller.java?rev=1081920&r1=1081919&r2=1081920&view=diff
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/JAXBMarshaller.java 
(original)
+++ juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/JAXBMarshaller.java 
Tue Mar 15 19:57:12 2011
@@ -42,12 +42,16 @@ public class JAXBMarshaller {
        
        public static final String PACKAGE_UDDIAPI = "org.uddi.api_v3";
        public static final String PACKAGE_SUBSCRIPTION = "org.uddi.sub_v3";
+       public static final String PACKAGE_JUDDIAPI = "org.apache.juddi.api_v3";
+       public static final String PACKAGE_JUDDI = "org.apache.juddi";
 
        private static final Map<String, JAXBContext> JAXBContexts = new 
HashMap<String, JAXBContext>();
        static {
                try {
                        JAXBContexts.put(PACKAGE_UDDIAPI, 
JAXBContext.newInstance(PACKAGE_UDDIAPI));
                        JAXBContexts.put(PACKAGE_SUBSCRIPTION, 
JAXBContext.newInstance(PACKAGE_SUBSCRIPTION));
+                       JAXBContexts.put(PACKAGE_JUDDIAPI, 
JAXBContext.newInstance(PACKAGE_JUDDIAPI));
+                       JAXBContexts.put(PACKAGE_JUDDI, 
JAXBContext.newInstance(PACKAGE_JUDDI));
                } catch (JAXBException e) {
                        logger.error("Initialization of JAXBMarshaller failed:" 
+ e, e);
                        throw new ExceptionInInitializerError(e);
@@ -98,6 +102,7 @@ public class JAXBMarshaller {
 
                JAXBContext jc = JAXBContexts.get(thePackage);
                Marshaller marshaller = jc.createMarshaller();
+               marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, 
Boolean.TRUE);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                marshaller.marshal(object, baos);
                rawObject = baos.toString();

Added: 
juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/InitialContextInfoTest.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/InitialContextInfoTest.java?rev=1081920&view=auto
==============================================================================
--- 
juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/InitialContextInfoTest.java 
(added)
+++ 
juddi/trunk/uddi-ws/src/test/java/org/apache/juddi/InitialContextInfoTest.java 
Tue Mar 15 19:57:12 2011
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.juddi.InitialContextInfo;
+import org.apache.juddi.Property;
+import org.apache.juddi.jaxb.JAXBMarshaller;
+import org.junit.Test;
+import org.uddi.api_v3.InstanceDetails;
+
+
+/**
+ * Testing marshalling functionality, making sure UTF-8 is handled correctly.
+ * 
+ * @author <a href="mailto:[email protected]";>Kurt T Stam</a>
+ */
+public class InitialContextInfoTest {
+       
+       @Test
+       public void initialContextInfo_Java2XML()
+       {
+               try {
+                       List<Property> properties= new ArrayList<Property>();
+                       Property property1 = new 
Property(Context.INITIAL_CONTEXT_FACTORY,"value1");
+                       properties.add(property1);
+                       Property property2 = new 
Property(Context.PROVIDER_URL,"value2");
+                       properties.add(property2);
+                       InitialContextInfo contextInfo = new 
InitialContextInfo();
+                       contextInfo.setProperty(properties);
+                       JAXBContext jc = 
JAXBContext.newInstance(InitialContextInfo.class);
+                       Marshaller m = jc.createMarshaller();
+                       m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+               m.marshal(contextInfo, System.out);
+               } catch (JAXBException e) {
+                       e.printStackTrace();
+                       fail("No exception should be thrown");
+               }
+       }
+       
+       @Test
+       public void initialContextInfo_XML2JAVA()
+       {
+               try {
+                       String INITIAL_CONTEXT_XML = "<initialContextInfo>" +
+                                                               
"<contextProperty value=\"value1\" name=\"name1\"/>" +
+                                                               
"<contextProperty value=\"value2\" name=\"name2\"/>" +
+                                                        
"</initialContextInfo>";
+                       
+                       StringReader reader = new 
StringReader(INITIAL_CONTEXT_XML);
+                       JAXBContext jc = 
JAXBContext.newInstance(InitialContextInfo.class);
+                       Unmarshaller um = jc.createUnmarshaller();
+                       InitialContextInfo icInfo = (InitialContextInfo)  
um.unmarshal(new StreamSource(reader), InitialContextInfo.class).getValue();
+                       assertEquals("name1", 
icInfo.getContextProperty().get(0).getName());
+                       assertEquals("name2", 
icInfo.getContextProperty().get(1).getName());
+                       assertEquals("value2", 
icInfo.getContextProperty().get(1).getValue());
+               } catch (JAXBException jaxbe) {
+                       jaxbe.printStackTrace();
+                       fail("No exception should be thrown");
+               }
+       }
+       
+       @Test
+       public void bindingTemplate_XML2JAVA()
+       {
+               try {
+                       String instanceDetailsStr = 
+                                   
+                           "<instanceDetails xmlns=\"urn:uddi-org:api_v3\">" +
+                                     "<instanceParms><![CDATA[ " +
+                        "<initialContextInfo>" +
+                          "<contextProperty value=\"value1\" name=\"name1\"/>" 
+
+                          "<contextProperty value=\"value2\" name=\"name2\"/>" 
+
+                        "</initialContextInfo> ]]>" +
+                      "</instanceParms>" +
+                    "</instanceDetails>";
+       
+                       InstanceDetails details = (InstanceDetails) 
JAXBMarshaller.unmarshallFromString(instanceDetailsStr,JAXBMarshaller.PACKAGE_UDDIAPI);
+                       String instanceParmsStr = details.getInstanceParms();
+                       if (instanceParmsStr!=null) {
+                               InitialContextInfo icInfo = 
(InitialContextInfo) JAXBMarshaller.unmarshallFromString(instanceParmsStr, 
JAXBMarshaller.PACKAGE_JUDDI);
+                               assertEquals("name1" , 
icInfo.getContextProperty().get(0).getName());
+                               assertEquals("name2" , 
icInfo.getContextProperty().get(1).getName());
+                               assertEquals("value2", 
icInfo.getContextProperty().get(1).getValue());
+                       } else {
+                               fail("We should have data in 
instanceParmsStr.");
+                       }
+               } catch (JAXBException jaxbe) {
+                       jaxbe.printStackTrace();
+                       fail("No exception should be thrown");
+               }
+       }
+       
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to