Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit be48eeb

Browse files
Marek PotociarGerrit Code Review
authored andcommitted
Merge "Remove the default JAX-B providers from Jersey Client: - introduced new media module, jersey-media-jaxb - enabled injection support for ForcedAutoDiscoverable types - incorporated feedback from Marek"
2 parents 16f125b + 1392a11 commit be48eeb

File tree

65 files changed

+649
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+649
-150
lines changed

bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@
231231
<artifactId>jersey-declarative-linking</artifactId>
232232
<version>${project.version}</version>
233233
</dependency>
234+
<dependency>
235+
<groupId>org.glassfish.jersey.media</groupId>
236+
<artifactId>jersey-media-jaxb</artifactId>
237+
<version>${project.version}</version>
238+
</dependency>
234239
<dependency>
235240
<groupId>org.glassfish.jersey.media</groupId>
236241
<artifactId>html-json</artifactId>

bundles/jaxrs-ri/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<artifactId>jersey-common</artifactId>
8080
<version>${project.version}</version>
8181
</dependency>
82+
<dependency>
83+
<groupId>org.glassfish.jersey.media</groupId>
84+
<artifactId>jersey-media-jaxb</artifactId>
85+
<version>${project.version}</version>
86+
</dependency>
8287
<dependency>
8388
<groupId>org.glassfish.jersey.core</groupId>
8489
<artifactId>jersey-client</artifactId>
@@ -107,6 +112,12 @@
107112
<version>${project.version}</version>
108113
<classifier>sources</classifier>
109114
</dependency>
115+
<dependency>
116+
<groupId>org.glassfish.jersey.media</groupId>
117+
<artifactId>jersey-media-jaxb</artifactId>
118+
<version>${project.version}</version>
119+
<classifier>sources</classifier>
120+
</dependency>
110121
<dependency>
111122
<groupId>org.glassfish.jersey.core</groupId>
112123
<artifactId>jersey-client</artifactId>
@@ -243,7 +254,7 @@
243254
<goal>unpack-dependencies</goal>
244255
</goals>
245256
<configuration>
246-
<includeGroupIds>javax.ws.rs,org.glassfish.jersey.core,org.glassfish.jersey.containers</includeGroupIds>
257+
<includeGroupIds>javax.ws.rs,org.glassfish.jersey.core,org.glassfish.jersey.containers,org.glassfish.jersey.jaxb</includeGroupIds>
247258
<includeClassifiers>sources</includeClassifiers>
248259
<outputDirectory>${generated.src.dir}</outputDirectory>
249260
</configuration>

core-client/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@
117117

118118
<dependencies>
119119
<dependency>
120-
<groupId>org.glassfish.jersey.core</groupId>
121-
<artifactId>jersey-common</artifactId>
122-
<version>${project.version}</version>
120+
<groupId>javax.ws.rs</groupId>
121+
<artifactId>javax.ws.rs-api</artifactId>
123122
</dependency>
124123

125124
<dependency>
126-
<groupId>javax.ws.rs</groupId>
127-
<artifactId>javax.ws.rs-api</artifactId>
125+
<groupId>org.glassfish.jersey.core</groupId>
126+
<artifactId>jersey-common</artifactId>
127+
<version>${project.version}</version>
128128
</dependency>
129129

130130
<dependency>

core-client/src/test/java/org/glassfish/jersey/client/ClientConfigTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -161,9 +161,6 @@ public void testCustomProvidersFeature() {
161161

162162
final ClientConfig runtimeConfig = runtime.getConfig();
163163

164-
assertEquals(1, runtimeConfig.getClasses().size());
165-
assertEquals(1, runtimeConfig.getInstances().size());
166-
167164
assertTrue(runtimeConfig.isRegistered(MyProvider.class));
168165
assertTrue(runtimeConfig.isEnabled(feature));
169166

core-common/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@
177177
<scope>provided</scope>
178178
</dependency>
179179

180-
<dependency>
181-
<groupId>javax.xml.bind</groupId>
182-
<artifactId>jaxb-api</artifactId>
183-
<!-- TODO scope as provided -->
184-
<!--scope>provided</scope-->
185-
</dependency>
186-
187180
<dependency>
188181
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
189182
<artifactId>jersey-guava</artifactId>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,7 +37,7 @@
3737
* only if the new code is made subject to such option by the copyright
3838
* holder.
3939
*/
40-
package org.glassfish.jersey.server.internal.inject;
40+
package org.glassfish.jersey.internal.inject;
4141

4242
import javax.ws.rs.ProcessingException;
4343
import javax.ws.rs.WebApplicationException;

core-common/src/main/java/org/glassfish/jersey/message/internal/EntityInputStream.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -56,7 +56,7 @@
5656
*
5757
* @author Marek Potociar (marek.potociar at oracle.com)
5858
*/
59-
class EntityInputStream extends InputStream {
59+
public class EntityInputStream extends InputStream {
6060
private InputStream input;
6161
private boolean closed;
6262

@@ -82,7 +82,7 @@ public static EntityInputStream create(InputStream inputStream) {
8282
*
8383
* @param input underlying wrapped input stream.
8484
*/
85-
protected EntityInputStream(InputStream input) {
85+
public EntityInputStream(InputStream input) {
8686
this.input = input;
8787
}
8888

@@ -240,7 +240,7 @@ public boolean isClosed() {
240240
*
241241
* @return wrapped input stream instance.
242242
*/
243-
protected final InputStream getWrappedStream() {
243+
public final InputStream getWrappedStream() {
244244
return input;
245245
}
246246

@@ -249,7 +249,7 @@ protected final InputStream getWrappedStream() {
249249
*
250250
* @param wrapped new input stream instance to be wrapped.
251251
*/
252-
protected final void setWrappedStream(InputStream wrapped) {
252+
public final void setWrappedStream(InputStream wrapped) {
253253
input = wrapped;
254254
}
255255
}

core-common/src/main/java/org/glassfish/jersey/message/internal/MessagingBinders.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -46,15 +46,10 @@
4646
import javax.ws.rs.ext.MessageBodyWriter;
4747

4848
import javax.inject.Singleton;
49-
import javax.xml.parsers.DocumentBuilderFactory;
50-
import javax.xml.parsers.SAXParserFactory;
51-
import javax.xml.stream.XMLInputFactory;
52-
import javax.xml.transform.TransformerFactory;
5349

5450
import org.glassfish.jersey.internal.ServiceFinderBinder;
5551
import org.glassfish.jersey.spi.HeaderDelegateProvider;
5652

57-
import org.glassfish.hk2.api.PerThread;
5853
import org.glassfish.hk2.utilities.binding.AbstractBinder;
5954

6055
/**
@@ -98,7 +93,6 @@ protected void configure() {
9893
// Message body providers (both readers & writers)
9994
bindSingletonWorker(ByteArrayProvider.class);
10095
bindSingletonWorker(DataSourceProvider.class);
101-
bindSingletonWorker(DocumentProvider.class);
10296
bindSingletonWorker(FileProvider.class);
10397
bindSingletonWorker(FormMultivaluedMapProvider.class);
10498
bindSingletonWorker(FormProvider.class);
@@ -108,25 +102,10 @@ protected void configure() {
108102
bindSingletonWorker(RenderedImageProvider.class);
109103
bindSingletonWorker(StringMessageProvider.class);
110104

111-
bindSingletonWorker(XmlJaxbElementProvider.App.class);
112-
bindSingletonWorker(XmlJaxbElementProvider.Text.class);
113-
bindSingletonWorker(XmlJaxbElementProvider.General.class);
114-
115-
bindSingletonWorker(XmlCollectionJaxbProvider.App.class);
116-
bindSingletonWorker(XmlCollectionJaxbProvider.Text.class);
117-
bindSingletonWorker(XmlCollectionJaxbProvider.General.class);
118-
119-
bindSingletonWorker(XmlRootElementJaxbProvider.App.class);
120-
bindSingletonWorker(XmlRootElementJaxbProvider.Text.class);
121-
bindSingletonWorker(XmlRootElementJaxbProvider.General.class);
122-
123105
// Message body readers
124106
bind(SourceProvider.StreamSourceReader.class).to(MessageBodyReader.class).in(Singleton.class);
125107
bind(SourceProvider.SaxSourceReader.class).to(MessageBodyReader.class).in(Singleton.class);
126108
bind(SourceProvider.DomSourceReader.class).to(MessageBodyReader.class).in(Singleton.class);
127-
bind(XmlRootObjectJaxbProvider.App.class).to(MessageBodyReader.class).in(Singleton.class);
128-
bind(XmlRootObjectJaxbProvider.Text.class).to(MessageBodyReader.class).in(Singleton.class);
129-
bind(XmlRootObjectJaxbProvider.General.class).to(MessageBodyReader.class).in(Singleton.class);
130109
/*
131110
* TODO: com.sun.jersey.core.impl.provider.entity.EntityHolderReader
132111
*/
@@ -136,11 +115,6 @@ protected void configure() {
136115
bind(SourceProvider.SourceWriter.class).to(MessageBodyWriter.class).in(Singleton.class);
137116
install(new ServiceFinderBinder<HeaderDelegateProvider>(HeaderDelegateProvider.class, applicationProperties, runtimeType));
138117

139-
// XML factory injection points
140-
bindFactory(DocumentBuilderFactoryInjectionProvider.class).to(DocumentBuilderFactory.class).in(PerThread.class);
141-
bindFactory(SaxParserFactoryInjectionProvider.class).to(SAXParserFactory.class).in(PerThread.class);
142-
bindFactory(XmlInputFactoryInjectionProvider.class).to(XMLInputFactory.class).in(PerThread.class);
143-
bindFactory(TransformerFactoryInjectionProvider.class).to(TransformerFactory.class).in(PerThread.class);
144118
}
145119

146120
private <T extends MessageBodyReader & MessageBodyWriter> void bindSingletonWorker(Class<T> worker) {

core-common/src/main/java/org/glassfish/jersey/model/internal/CommonConfig.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -601,8 +601,11 @@ public int compare(final AutoDiscoverable o1, final AutoDiscoverable o2) {
601601
});
602602

603603
// Forced (always invoked).
604-
providers.addAll(Arrays.asList(
605-
ServiceFinder.find(ForcedAutoDiscoverable.class, true).toArray()));
604+
final List<ForcedAutoDiscoverable> forcedAutoDiscroverables = new LinkedList<ForcedAutoDiscoverable>();
605+
for (Class<ForcedAutoDiscoverable> forcedADType : ServiceFinder.find(ForcedAutoDiscoverable.class, true).toClassArray()) {
606+
forcedAutoDiscroverables.add(locator.createAndInitialize(forcedADType));
607+
}
608+
providers.addAll(forcedAutoDiscroverables);
606609

607610
// Regular.
608611
if (!forcedOnly) {

core-common/src/main/resources/org/glassfish/jersey/internal/localization.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ committing.stream.already.initialized=Stream provider has already been initializ
4646
committing.stream.buffering.illegal.state=Cannot setup buffering as bytes have already been written to the output stream. The entity buffering can be initialized only before first bytes are written to the entity output stream.
4747
component.cannot.be.null=Registered component instance cannot be null.
4848
component.class.cannot.be.null=Registered component class cannot be null.
49-
component.type.already.registered=Cannot new create registration for component type {0}: Existing previous registration found for the type.
49+
component.type.already.registered=Cannot create new registration for component type {0}: Existing previous registration found for the type.
5050
component.contracts.empty.or.null=Attempt to register component of type {0} to null or empty array of contracts is ignored.
5151
configuration.not.modifiable=The configuration is not modifiable in this context.
5252
contract.not.assignable=Contract {0} can not be registered for component {1}: Contract not assignable to component.
@@ -90,7 +90,6 @@ error.template.parser.illegal.char.start.name=Illegal character "{0}" at positio
9090
error.template.parser.invalid.syntax=Invalid syntax for the expression "{0}" associated with the name "{1}" in a path template "{2}".
9191
error.template.parser.invalid.syntax.terminated=Invalid syntax in the template "{0}". Check if a path parameter is terminated with a "}".
9292
error.template.parser.name.more.than.once=The name "{0}" is declared more than once with different regular expressions in a path template "{1}".
93-
error.unmarshalling.jaxb=Error un-marshalling JAXB object of type: {0}.
9493
# {0} - List of localized messages, e.g.: [FATAL] <localized_message>; source=<object>
9594
errors.and.warnings.detected=Following issues have been detected: {0}
9695
exception.caught.while.loading.spi.providers=Exception caught while loading SPI providers.

0 commit comments

Comments
 (0)