Release 8.1.0
Date: Aug 21, 2019
8.1.0 introduces some significant new features including:
Configurable AnnotationsDefault PojoSwapsConfig ImportsBasicRest,BasicRestGroupclassesPath variables on resource pathsRequest Attributes APIRole GuardsImproved REST logging/debugging- New MockRest API
juneau-marshall
-
New utility class for diffing beans:
BeanDiff -
New annotation for defining bean property names:
Name -
New serializer properties:
WriterSerializer WSERIALIZER_fileCharsetWSERIALIZER_streamCharset -
The following POJO methods can be used to convert a POJO to/from a Map before serialization and after parsing. It's a convenient way of defining a POJO transform.
- Can be any type of map with string keys and object vals.public Map<String,Object> toMap()public ObjectMap toMap() - Can be any type of map with string keys and object vals.public Map<String,Object> toMap(BeanSession bs)public ObjectMap toMap(BeanSession bs) - Can be any type of map with string keys and object vals.public static T fromMap(Map<String,Object> m)public static T fromMap(ObjectMap m) - Can be any type of map with string keys and object vals.public static T fromMap(BeanSession bs, Map<String,Object> m)public static T fromMap(BeanSession bs, ObjectMap m) -
New convenience debugging methods on Marshall API:
Marshall -oaj.marshall.Marshall.format(String,Object...) format(String,Object...)MessageFormat-style formatter. - Printsoaj.marshall.Marshall.out(String,Object...) out(String,Object...)MessageFormat-style messages to STDOUT. - Printsoaj.marshall.Marshall.err(String,Object...) err(String,Object...)MessageFormat-style messages to STDERR. -
Serializer and parser APIs now throw
IOExceptionsin addition toSerializeExceptionandParseExceptionto make it easier to determine if problems are stream based or syntax based. -
New Java 8 date-time transforms:
TemporalSwap- For all Java 8 temporal types (e.g. ZonedDateTime)TemporalDateSwap- For DateTemporalCalendarSwap- For Calendar
-
All serializers and parsers now have built-in default swaps for common class types:
Enumeration Iterator Locale Calendar - ISO offset date-time.Date - Local date-timeInstant - ISO instant.ZonedDateTime - ISO offset date-time.LocalDate - ISO local date.LocalDateTime - ISO local date-time.LocalTime - ISO local time.OffsetDateTime - ISO offset date-time.OffsetTime - ISO offset time.Year - ISO year.YearMonth - ISO year-month.Temporal - ISO instant.TimeZone XMLGregorianCalendar ZoneId
juneau-config
-
Support for import statements:
// Import values from another configuration:
<ParentConfig1>
[Foo]
bar = baz -
The
ConfigFileStorenow automatically resolves file extensions. New configuration property for specifying search paths for file extensions:FILESTORE_extensions -
Fixed a bug where instances of
ConfigMemoryStoreended up resolving to the same object. -
Uses
application.propertiesfile as a system default if present. Useful when being used in a Spring Boot application. -
New Config.setSystemProperties method for quickly moving configuration settings into the system properties.
-
Entries in the system config are automatically set as system properties. This means you can set any of the various serializer and parser settings (e.g.
JsonSerializer.simpleMode.b) in the default configuration area orapplication.properties.
juneau-rest-server
-
New annotations that can be applied to REST classes and methods to configure serializers and parsers.
Old way using generic properties:
@RestResource(
path="/atom",
title="Sample ATOM feed resource",
properties={
@Property(name=WSERIALIZER_quoteChar, value="'"),
@Property(name=RDF_rdfxml_tab, value="5"),
@Property(name=RDF_addRootProperty, value="true"),
@Property(name=BEAN_examples, value="{'org.apache.juneau.dto.atom.Feed': $F{AtomFeedResource_example.json}}")
}
...
)
public class AtomFeedResource extends BasicRestServletJena {
...
}New way using specific annotations:
@RestResource(
path="/atom",
title="Sample ATOM feed resource"
...
)
@SerializerConfig(quoteChar="'")
@RdfConfig(rdfxml_tab="5", addRootProperty="true")
@BeanConfig(examples="Feed: $F{AtomFeedResource_example.json}")
public class AtomFeedResource extends BasicRestServletJena {
...
}Config annotations are provided for all serializers and parsers:
BeanConfig CsvConfig HtmlConfig HtmlDocConfig JsoConfigJsonConfig JsonSchemaConfig MsgPackConfig OpenApiConfig ParserConfig PlainTextConfig RdfConfigSerializerConfig SoapXmlConfig UonConfig UrlEncodingConfig XmlConfig -
New support for using Servlet request attributes:
RequestAttributesRestContext REST_attrsRestContext.Builder attrs(String...)attr(String,Object)RestMethodContextRestMethodContext.RESTMETHOD_attrs RESTMETHOD_attrsRestRequest getAttributes() RestResponse getAttributes() RestResponse.attr(String,Object) attr(String,Object)Attr RestMethod.attrs()RestResource.attrs()This deprecates the following APIs:
RequestPropertiesRestMethodPropertiesRestRequest RestRequest.getProperties() getProperties()RestRequest.prop(String,Object) prop(String,Object) -
Added the following classes that provide the same support as the servlet classes but doesn't extend from
HttpServlet. This fixes an issue where instances ofBasicRestServletare registered as top-level servlets even though you don't want them to be. - Non-servlet equivalent toBasicRestBasicRestServlet - Non-servlet equivalent toBasicRestGroupBasicRestServletGroup - Non-servlet equivalent toBasicRestJenaBasicRestServletJena - Non-servlet equivalent toBasicRestJenaGroupBasicRestServletJenaGroup -
HTML widgets now have access to the
RestResponseobject if they need access to the output bean. -
New annotations for simplified role-based guards on classes and methods:
RestResourceroleGuard()rolesDeclared()RestMethodRestMethod.roleGuard roleGuard()RestMethod.rolesDeclared rolesDeclared() -
New annotations for fine-tuned handling of http-methods/http-headers as query parameters and others:
RestResourceallowedHeaderParams()allowedMethodHeaders()allowedMethodParams() -
The
@RestResource(path)annotation can now use variables:@RestResource(
path="/myResource/{foo}/{bar}"
)
public class MyResource extends BasicRestServlet {...} -
New methods:
RestRequest getCharset() RestResponse getCharset() -
New interface method for catching arbitrary thrown objects and converting them to other throwables:
RestCallHandlerRestCallHandler.convertThrowable(Throwable) convertThrowable(Throwable)BasicRestCallHandlerconvertThrowable(Throwable) -
Support for fine-tuned logging of HTTP requests and responses:
@RestResource(
debug="per-request",
logging=@Logging(
level="info",
rules={
@LoggingRule(codes="400-499", level="warning", req="short", res="short"),
@LoggingRule(codes="500-", level="severe", req="long", res="long")
}
)
)
public class MyRest {
@RestMethod(
method="POST",
path="foo",
logging=@Logging(
level="info",
rules={
@LoggingRule(exceptions="NotFound*", level="info"),
@LoggingRule(codes="200", disabled="true")
}
)
)
public String myMethod() throws Exception {...}
}See
RestLoggingAndDebuggingfor details. -
Fixed a bug where the HTTP response was returning 405 (method not found) but should really be 404 (not found) when no path patterns match on any of the Java methods.
juneau-rest-client
- PATCH support added.
Share feedback or follow-up questions for this page directly through GitHub.