You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/05/26 11:34:08 UTC
svn commit: r660143 - in /servicemix/smx4/specs/trunk: ./ jaxb-api-2.1/
jaxb-api-2.1/src/main/java/javax/xml/bind/
jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/
jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/ jaxws-api-2.1/
Author: gnodet
Date: Mon May 26 02:34:07 2008
New Revision: 660143
URL: http://svn.apache.org/viewvc?rev=660143&view=rev
Log:
Add jaxb-api 2.1 specs
Added:
servicemix/smx4/specs/trunk/jaxb-api-2.1/
- copied from r659025, servicemix/smx4/specs/trunk/jaxb-api-2.0/
servicemix/smx4/specs/trunk/jaxb-api-2.1/pom.xml
- copied, changed from r659029, servicemix/smx4/specs/trunk/jaxb-api-2.0/pom.xml
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/DataBindingException.java
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXB.java
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java
Modified:
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Marshaller.java
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSchema.java
servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java
servicemix/smx4/specs/trunk/jaxws-api-2.1/pom.xml
servicemix/smx4/specs/trunk/pom.xml
Copied: servicemix/smx4/specs/trunk/jaxb-api-2.1/pom.xml (from r659029, servicemix/smx4/specs/trunk/jaxb-api-2.0/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/pom.xml?p2=servicemix/smx4/specs/trunk/jaxb-api-2.1/pom.xml&p1=servicemix/smx4/specs/trunk/jaxb-api-2.0/pom.xml&r1=659029&r2=660143&rev=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/pom.xml (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/pom.xml Mon May 26 02:34:07 2008
@@ -28,10 +28,10 @@
</parent>
<groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxb-api-2.0</artifactId>
+ <artifactId>org.apache.servicemix.specs.jaxb-api-2.1</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
- <name>Apache ServiceMix Specs :: JAXB API 2.0</name>
+ <name>Apache ServiceMix Specs :: JAXB API 2.1</name>
<dependencies>
<dependency>
@@ -69,7 +69,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Export-Package>javax.xml.bind*;version=2.0;-split-package:=merge-first</Export-Package>
+ <Export-Package>javax.xml.bind*;version=2.1;-split-package:=merge-first</Export-Package>
<Import-Package>*</Import-Package>
<Private-Package>org.apache.servicemix.specs.locator</Private-Package>
<Bundle-Activator>org.apache.servicemix.specs.locator.Activator</Bundle-Activator>
Added: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/DataBindingException.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/DataBindingException.java?rev=660143&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/DataBindingException.java (added)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/DataBindingException.java Mon May 26 02:34:07 2008
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 javax.xml.bind;
+
+public class DataBindingException extends RuntimeException {
+
+ public DataBindingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DataBindingException(Throwable cause) {
+ super(cause);
+ }
+}
Added: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXB.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXB.java?rev=660143&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXB.java (added)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXB.java Mon May 26 02:34:07 2008
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 javax.xml.bind;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.beans.Introspector;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.namespace.QName;
+
+final public class JAXB {
+
+ private JAXB() {
+ }
+
+ public static void marshal(Object object, File file) {
+ if (file == null) {
+ throw new IllegalStateException("No file is given");
+ }
+ marshal(object, new StreamResult(file));
+ }
+
+ public static void marshal(Object object, OutputStream os) {
+ if (os == null) {
+ throw new IllegalStateException("No output stream is given");
+ }
+ marshal(object, new StreamResult(os));
+ }
+
+ public static void marshal(Object object, Writer writer) {
+ if (writer == null) {
+ throw new IllegalStateException("No writer is given");
+ }
+ marshal(object, new StreamResult(writer));
+ }
+
+ public static void marshal(Object object, String str) {
+ if (str == null) {
+ throw new IllegalStateException("No string destination is given");
+ }
+ try {
+ marshal(object, new URI(str));
+ } catch (URISyntaxException e) {
+ marshal(object, new File(str));
+ }
+ }
+
+ public static void marshal(Object object, URI uri) {
+ if (uri == null) {
+ throw new IllegalStateException("No uri is given");
+ }
+ try {
+ marshal(object, uri.toURL());
+ } catch (IOException e) {
+ throw new DataBindingException(e);
+ }
+ }
+
+ public static void marshal(Object object, URL url) {
+ if (url == null) {
+ throw new IllegalStateException("No url is given");
+ }
+ try {
+ URLConnection con = url.openConnection();
+ con.setDoOutput(true);
+ con.setDoInput(false);
+ con.connect();
+ marshal(object, new StreamResult(con.getOutputStream()));
+ } catch (IOException e) {
+ throw new DataBindingException(e);
+ }
+ }
+
+ public static void marshal(Object object, Result result) {
+ try {
+ JAXBContext context;
+ if (object instanceof JAXBElement) {
+ context = getContext(((JAXBElement<?>) object).getDeclaredType());
+ } else {
+ Class<?> clazz = object.getClass();
+ XmlRootElement r = clazz.getAnnotation(XmlRootElement.class);
+ if (r == null) {
+ // we need to infer the name
+ object = new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())),
+ clazz, object);
+ }
+ context = getContext(clazz);
+ }
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
+ m.marshal(object, result);
+ } catch (JAXBException e) {
+ throw new DataBindingException(e);
+ }
+ }
+
+ public static <T> T unmarshal(File file, Class<T> type) {
+ if (file == null) {
+ throw new IllegalStateException("No file is given");
+ }
+ return unmarshal(new StreamSource(file), type);
+ }
+
+ public static <T> T unmarshal(URL url, Class<T> type) {
+ if (url == null) {
+ throw new IllegalStateException("No url is given");
+ }
+ return unmarshal(new StreamSource(url.toExternalForm()), type);
+ }
+
+ public static <T> T unmarshal(URI uri, Class<T> type) {
+ if (uri == null) {
+ throw new IllegalStateException("No uri is given");
+ }
+ try {
+ return unmarshal(uri.toURL(), type);
+ } catch (MalformedURLException e) {
+ throw new DataBindingException(e);
+ }
+ }
+
+ public static <T> T unmarshal(String str, Class<T> type) {
+ if (str == null) {
+ throw new IllegalStateException("No string destination is given");
+ }
+ try {
+ return unmarshal(new URI(str), type);
+ } catch (URISyntaxException e) {
+ return unmarshal(new File(str), type);
+ }
+ }
+
+ public static <T> T unmarshal(InputStream is, Class<T> type) {
+ if (is == null) {
+ throw new IllegalStateException("No input stream is given");
+ }
+ return unmarshal(new StreamSource(is), type);
+ }
+
+ public static <T> T unmarshal(Reader reader, Class<T> type) {
+ if (reader == null) {
+ throw new IllegalStateException("No reader is given");
+ }
+ return unmarshal(new StreamSource(reader), type);
+ }
+
+ public static <T> T unmarshal(Source source, Class<T> type) {
+ try {
+ JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(source, type);
+ return item.getValue();
+ } catch (JAXBException e) {
+ throw new DataBindingException(e);
+ }
+ }
+
+ private static <T> JAXBContext getContext(Class<T> type) throws JAXBException {
+ return JAXBContext.newInstance(type);
+ }
+
+
+}
Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Marshaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Marshaller.java?rev=660143&r1=659025&r2=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Marshaller.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Marshaller.java Mon May 26 02:34:07 2008
@@ -18,6 +18,7 @@
import java.io.OutputStream;
import java.io.Writer;
+import java.io.File;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
@@ -61,6 +62,8 @@
void marshal(Object jaxbElement, ContentHandler handler) throws JAXBException;
+ void marshal(Object jaxbElement, File file) throws JAXBException;
+
void marshal(Object jaxbElement, Node node) throws JAXBException;
void marshal(Object jaxbElement, OutputStream os) throws JAXBException;
Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSchema.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSchema.java?rev=660143&r1=659025&r2=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSchema.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSchema.java Mon May 26 02:34:07 2008
@@ -32,4 +32,8 @@
String namespace() default "";
XmlNs[] xmlns() default {};
+
+ String location() default NO_LOCATION;
+
+ static final String NO_LOCATION = "##generate";
}
Added: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java?rev=660143&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java (added)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java Mon May 26 02:34:07 2008
@@ -0,0 +1,14 @@
+package javax.xml.bind.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface XmlSeeAlso {
+
+ Class[] value();
+
+}
Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java?rev=660143&r1=659025&r2=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java Mon May 26 02:34:07 2008
@@ -19,6 +19,10 @@
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -77,6 +81,20 @@
private boolean formattedOutput;
private boolean fragment;
+ public void marshal(Object obj, File file) throws JAXBException {
+ checkNotNull(obj, "obj", file, "file");
+ try {
+ OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
+ try {
+ marshal(obj, new StreamResult(os));
+ } finally {
+ os.close();
+ }
+ } catch (IOException e) {
+ throw new JAXBException(e);
+ }
+ }
+
public final void marshal(Object obj, OutputStream os) throws JAXBException {
checkNotNull(obj, "obj", os, "os");
marshal(obj, new StreamResult(os));
Modified: servicemix/smx4/specs/trunk/jaxws-api-2.1/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.1/pom.xml?rev=660143&r1=660142&r2=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.1/pom.xml (original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.1/pom.xml Mon May 26 02:34:07 2008
@@ -96,7 +96,7 @@
</dependency>
<dependency>
<groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxb-api-2.0</artifactId>
+ <artifactId>org.apache.servicemix.specs.jaxb-api-2.1</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
Modified: servicemix/smx4/specs/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/pom.xml?rev=660143&r1=660142&r2=660143&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/pom.xml (original)
+++ servicemix/smx4/specs/trunk/pom.xml Mon May 26 02:34:07 2008
@@ -39,6 +39,7 @@
<module>saaj-api-1.3</module>
<module>stax-api-1.0</module>
<module>jaxb-api-2.0</module>
+ <module>jaxb-api-2.1</module>
<module>jaxws-api-2.0</module>
<module>jaxws-api-2.1</module>
</modules>