juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r1102702 - /juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java
Date Fri, 13 May 2011 12:56:57 GMT
Author: kstam
Date: Fri May 13 12:56:57 2011
New Revision: 1102702

URL: http://svn.apache.org/viewvc?rev=1102702&view=rev
Log:
JUDDI-476 can be used for logging/debug purposes

Added:
    juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java

Added: juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java?rev=1102702&view=auto
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java (added)
+++ juddi/trunk/uddi-ws/src/main/java/org/apache/juddi/jaxb/PrintUDDI.java Fri May 13 12:56:57
2011
@@ -0,0 +1,62 @@
+/*
+ * 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.jaxb;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.namespace.QName;
+
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.FindTModel;
+
+
+/**
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ * @param <T>
+ */
+public class PrintUDDI<T> {
+
+	static JAXBContext jaxbContext = null;
+	
+	private Marshaller getUDDIMarshaller() throws JAXBException {
+		if (jaxbContext==null) {
+			jaxbContext=JAXBContext.newInstance("org.uddi.api_v3");
+		}
+		Marshaller marshaller = jaxbContext.createMarshaller();
+		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+		marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+		marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+		
+		return marshaller;
+	}
+	
+	public String print(T object, Class<T> type) {
+		String xml = "";
+		try {
+			StringWriter writer = new StringWriter();
+			JAXBElement<T> element = new JAXBElement<T>(new QName("",object.getClass().getName()),type,object);
+			getUDDIMarshaller().marshal(element,writer);
+			xml=writer.toString();
+		} catch (JAXBException je) {
+			
+		}
+		return xml;
+	}
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message