Skip to content

Commit

Permalink
Merge 'origin/2.x' into 'origin/3.0'
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Sep 25, 2024
2 parents 9ac4c9d + e6460de commit d341493
Show file tree
Hide file tree
Showing 27 changed files with 1,079 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,34 @@ public final class ClientProperties {
@PropertyAlias
public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT;

/**
* If {@code true} then disable configuration of Json Binding (JSR-367)
* feature on client.
* <p>
* By default, Json Binding on client is automatically enabled if global
* property
* {@value org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE}
* is not disabled. If set then the client property value overrides the
* global property value.
* <p>
* The default value is {@code false}.
* </p>
* <p>
* The name of the configuration property is <tt>{@value}</tt>.
* </p>
* <p>This constant is an alias for {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE_CLIENT}.</p>
*
* @see org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE
* @since 2.45
*/
@PropertyAlias
public static final String JSON_BINDING_FEATURE_DISABLE = CommonProperties.JSON_BINDING_FEATURE_DISABLE_CLIENT;

/**
* If {@code true} then disable configuration of Json Processing (JSR-353)
* feature on client.
* <p>
* By default Json Processing on client is automatically enabled if global
* By default, Json Processing on client is automatically enabled if global
* property
* {@value org.glassfish.jersey.CommonProperties#JSON_PROCESSING_FEATURE_DISABLE}
* is not disabled. If set then the client property value overrides the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/


package org.glassfish.jersey;

import javax.ws.rs.core.Application;

/**
* Implementation of this interface is capable of returning {@link Application}.
*/
public interface ApplicationSupplier {
/**
* Get Application.
*
* @return Application.
*/
Application getApplication();

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class CommonProperties {
/**
* If {@code true} then disable feature auto discovery globally on client/server.
* <p>
* By default auto discovery is automatically enabled. The value of this property may be overridden by the client/server
* By default, auto discovery is automatically enabled. The value of this property may be overridden by the client/server
* variant of this property.
* <p>
* The default value is {@code false}.
Expand All @@ -98,10 +98,55 @@ public final class CommonProperties {
*/
public static final String FEATURE_AUTO_DISCOVERY_DISABLE_SERVER = "jersey.config.server.disableAutoDiscovery";


/**
* If {@code true} then disable configuration of Json Binding (JSR-367) feature.
* <p>
* By default, Json Binding is automatically enabled. The value of this property may be overridden by the client/server
* variant of this property.
* <p>
* The default value is {@code false}.
* </p>
* <p>
* The name of the configuration property is <tt>{@value}</tt>.
* </p>
* @since 2.45
*/
public static final String JSON_BINDING_FEATURE_DISABLE = "jersey.config.disableJsonBinding";

/**
* Client-specific version of {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE}.
*
* If present, it overrides the generic one for the client environment.
* @since 2.45
*/
public static final String JSON_BINDING_FEATURE_DISABLE_CLIENT = "jersey.config.client.disableJsonBinding";

/**
* Server-specific version of {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE}.
*
* If present, it overrides the generic one for the server environment.
* @since 2.45
*/
public static final String JSON_BINDING_FEATURE_DISABLE_SERVER = "jersey.config.server.disableJsonBinding";

/**
* Disables configuration of Json Binding (JSR-367) feature for {@link javax.ws.rs.core.Application} subclasses whose
* package names are specified as a value. The value is comma-separated string defining prefixes of the application
* package names.
* <p>
* By default, Json Binding is automatically enabled.
* <p>
* The name of the configuration property is <tt>{@value}</tt>.
* </p>
* @since 2.45
*/
public static final String JSON_BINDING_FEATURE_DISABLE_APPLICATION = "jersey.config.application.disableJsonBinding";

/**
* If {@code true} then disable configuration of Json Processing (JSR-353) feature.
* <p>
* By default Json Processing is automatically enabled. The value of this property may be overridden by the client/server
* By default, Json Processing is automatically enabled. The value of this property may be overridden by the client/server
* variant of this property.
* <p>
* The default value is {@code false}.
Expand Down Expand Up @@ -164,7 +209,7 @@ public final class CommonProperties {
/**
* If {@code true} then disable configuration of MOXy Json feature.
* <p>
* By default MOXy Json is automatically enabled. The value of this property may be overridden by the client/server
* By default, MOXy Json is automatically enabled. The value of this property may be overridden by the client/server
* variant of this property.
* <p>
* The default value is {@code false}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -389,6 +389,27 @@ public static boolean isProperty(final Object value) {
}
}

/**
* Converts the property value to {@code boolean} and checks it is {@code true} or empty.
* Returns {@code true} if the value is {@code true} or empty but not {@code null}.
*
* <p>
* The rationale behind this is that system property {@code -Dprop=true} is the same as {@code -Dprop}.
* The property {@code -Dprop=false} behaves as if the {@code -Dprop} is not set at all.
* </p>
*
* @param value property value.
* @return {@code boolean} property value or {@code true} if the property value is not set or {@code false} if the property
* is otherwise not convertible.
*/
public static boolean isPropertyOrNotSet(final Object value) {
if (value instanceof Boolean) {
return Boolean.class.cast(value);
} else {
return value != null && ("".equals(value.toString()) || Boolean.parseBoolean(value.toString()));
}
}

/**
* Faster replacement of {@code RuntimeType#name().toLowerCase(Locale.ROOT)}
* @param runtimeType The runtime type to lower case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -199,4 +199,15 @@ public void testconvertValue() {

}

@Test
public void isPropertyOrNotSetTest() {
assertEquals(false, PropertiesHelper.isPropertyOrNotSet((Boolean) null));
assertEquals(true, PropertiesHelper.isPropertyOrNotSet(Boolean.TRUE));
assertEquals(false, PropertiesHelper.isPropertyOrNotSet(Boolean.FALSE));
assertEquals(false, PropertiesHelper.isPropertyOrNotSet((String) null));
assertEquals(true, PropertiesHelper.isPropertyOrNotSet(""));
assertEquals(false, PropertiesHelper.isPropertyOrNotSet("treu")); // false for non-boolean values
assertEquals(true, PropertiesHelper.isPropertyOrNotSet("TRUE"));
assertEquals(false, PropertiesHelper.isPropertyOrNotSet("false"));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -39,6 +39,7 @@
import jakarta.ws.rs.core.Configuration;
import jakarta.ws.rs.core.Feature;

import org.glassfish.jersey.ApplicationSupplier;
import org.glassfish.jersey.internal.Errors;
import org.glassfish.jersey.internal.config.ExternalPropertiesConfigurationFactory;
import org.glassfish.jersey.internal.inject.Binder;
Expand Down Expand Up @@ -70,7 +71,7 @@
* @author Michal Gajdos
* @author Marek Potociar
*/
public class ResourceConfig extends Application implements Configurable<ResourceConfig>, ServerConfig {
public class ResourceConfig extends Application implements Configurable<ResourceConfig>, ServerConfig, ApplicationSupplier {

private static final Logger LOGGER = Logger.getLogger(ResourceConfig.class.getName());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -302,7 +302,7 @@ public final class ServerProperties {
/**
* If {@code true} then disable auto discovery on server.
*
* By default auto discovery is automatically enabled if global property
* By default, auto discovery is automatically enabled if global property
* {@value org.glassfish.jersey.CommonProperties#FEATURE_AUTO_DISCOVERY_DISABLE} is not disabled. If set then the server
* property value overrides the global property value.
* <p>
Expand Down Expand Up @@ -342,10 +342,29 @@ public final class ServerProperties {
@PropertyAlias
public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER;

/**
* If {@code true} then disable configuration of Json Binding (JSR-367) feature on server.
*
* By default, Json Binding is automatically enabled if global property
* {@value org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE} is not disabled. If set then the server
* property value overrides the global property value.
* <p>
* The default value is {@code false}.
* </p>
* <p>
* The name of the configuration property is <tt>{@value}</tt>.
* </p>
* <p>This constant is an alias for {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE_SERVER}</p>
*
* @see org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE
*/
@PropertyAlias
public static final String JSON_BINDING_FEATURE_DISABLE = CommonProperties.JSON_BINDING_FEATURE_DISABLE_SERVER;

/**
* If {@code true} then disable configuration of Json Processing (JSR-353) feature on server.
*
* By default Json Processing is automatically enabled if global property
* By default, Json Processing is automatically enabled if global property
* {@value org.glassfish.jersey.CommonProperties#JSON_PROCESSING_FEATURE_DISABLE} is not disabled. If set then the server
* property value overrides the global property value.
* <p>
Expand Down Expand Up @@ -383,7 +402,7 @@ public final class ServerProperties {
/**
* If {@code true} then disable configuration of MOXy Json feature on server.
*
* By default MOXy Json is automatically enabled if global property
* By default, MOXy Json is automatically enabled if global property
* {@value org.glassfish.jersey.CommonProperties#MOXY_JSON_FEATURE_DISABLE} is not disabled. If set then the server
* property value overrides the global property value.
* <p>
Expand Down
52 changes: 52 additions & 0 deletions docs/src/main/docbook/appendix-properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,40 @@
</para>
</entry>
</row>
<row>
<entry>&jersey.common.CommonProperties.JSON_BINDING_FEATURE_DISABLE; /
&jersey.common.CommonProperties.JSON_BINDING_FEATURE_DISABLE_CLIENT; /
&jersey.common.CommonProperties.JSON_BINDING_FEATURE_DISABLE_SERVER;</entry>
<entry><literal>jersey.config.disableJsonBinding</literal> /
<literal>jersey.config.client.disableJsonBinding</literal> /
<literal>jersey.config.server.disableJsonBinding</literal></entry>
<entry>
<para>
Disables configuration of Json Binding (JSR-367) feature. Default value is <literal>false</literal>.
Can also be set as a system property.
</para>
<para>
Since 2.45.
</para>
</entry>
</row>
<row>
<entry>&jersey.common.CommonProperties.JSON_BINDING_FEATURE_DISABLE_APPLICATION; </entry>
<entry><literal>jersey.config.application.disableJsonBinding</literal></entry>
<entry>
<para>
Disables configuration of Json Binding (JSR-367) feature for <literal>javax.ws.rs.core.Application</literal>
subclasses whose package names are specified as a value. The value is comma-separated string
defining prefixes of the application package names. Can also be set as a system property.
</para>
<para>
By default, Json Binding is automatically enabled.
</para>
<para>
Since 2.45.
</para>
</entry>
</row>
<row>
<entry>&jersey.common.CommonProperties.JSON_PROCESSING_FEATURE_DISABLE; /
&jersey.common.CommonProperties.JSON_PROCESSING_FEATURE_DISABLE_CLIENT; /
Expand Down Expand Up @@ -415,6 +449,15 @@
</para>
</entry>
</row>
<row>
<entry>&jersey.server.ServerProperties.JSON_BINDING_FEATURE_DISABLE;</entry>
<entry><literal>jersey.config.server.disableJsonBinding</literal></entry>
<entry>
<para>
Disables configuration of Json Processing (JSR-353) feature. Default value is <literal>false</literal>.
</para>
</entry>
</row>
<row>
<entry>&jersey.server.ServerProperties.JSON_PROCESSING_FEATURE_DISABLE;</entry>
<entry><literal>jersey.config.server.disableJsonProcessing</literal></entry>
Expand Down Expand Up @@ -1033,6 +1076,15 @@
</para>
</entry>
</row>
<row>
<entry>&jersey.client.ClientProperties.JSON_BINDING_FEATURE_DISABLE;</entry>
<entry><literal>jersey.config.client.disableJsonBinding</literal></entry>
<entry>
<para>
Disables configuration of Json Binding (JSR-367) feature. Default value is <literal>false</literal>.
</para>
</entry>
</row>
<row>
<entry>&jersey.client.ClientProperties.JSON_PROCESSING_FEATURE_DISABLE;</entry>
<entry><literal>jersey.config.client.disableJsonProcessing</literal></entry>
Expand Down
Loading

0 comments on commit d341493

Please sign in to comment.