Skip to main content

Release 8.1.0

Date: Aug 21, 2019

8.1.0 introduces some significant new features including:

  • Configurable Annotations
  • Default PojoSwaps
  • Config Imports
  • BasicRest, BasicRestGroup classes
  • Path variables on resource paths
  • Request Attributes API
  • Role Guards
  • Improved 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_fileCharset WSERIALIZER_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.

    public Map<String,Object> toMap() - Can be any type of map with string keys and object vals.public ObjectMap toMap()public Map<String,Object> toMap(BeanSession bs) - Can be any type of map with string keys and object vals.public ObjectMap toMap(BeanSession bs)public static T fromMap(Map<String,Object> m) - Can be any type of map with string keys and object vals.public static T fromMap(ObjectMap m)public static T fromMap(BeanSession bs, Map<String,Object> m) - Can be any type of map with string keys and object vals.public static T fromMap(BeanSession bs, ObjectMap m)
  • New convenience debugging methods on Marshall API:

    Marshalloaj.marshall.Marshall.format(String,Object...) format(String,Object...) - MessageFormat-style formatter.oaj.marshall.Marshall.out(String,Object...) out(String,Object...) - Prints MessageFormat-style messages to STDOUT.oaj.marshall.Marshall.err(String,Object...) err(String,Object...) - Prints MessageFormat-style messages to STDERR.
  • Serializer and parser APIs now throw IOExceptions in addition to SerializeException and ParseException to 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 Date
    • TemporalCalendarSwap - For Calendar
  • All serializers and parsers now have built-in default swaps for common class types:

    EnumerationIteratorLocaleCalendar - 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.TimeZoneXMLGregorianCalendarZoneId

juneau-config

  • Support for import statements:

    // Import values from another configuration:
    <ParentConfig1>

    [Foo]
    bar = baz
  • The ConfigFileStore now automatically resolves file extensions. New configuration property for specifying search paths for file extensions: FILESTORE_extensions

  • Fixed a bug where instances of ConfigMemoryStore ended up resolving to the same object.

  • Uses application.properties file 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 or application.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:

    BeanConfigCsvConfigHtmlConfigHtmlDocConfig JsoConfigJsonConfigJsonSchemaConfigMsgPackConfigOpenApiConfigParserConfigPlainTextConfig RdfConfigSerializerConfigSoapXmlConfigUonConfigUrlEncodingConfigXmlConfig
  • New support for using Servlet request attributes:

    RequestAttributesRestContext REST_attrsRestContext.Builder attrs(String...) attr(String,Object) RestMethodContext RestMethodContext.RESTMETHOD_attrs RESTMETHOD_attrsRestRequestgetAttributes()RestResponsegetAttributes() RestResponse.attr(String,Object) attr(String,Object)Attr RestMethod.attrs() RestResource.attrs()

    This deprecates the following APIs:

    RequestProperties RestMethodPropertiesRestRequest 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 of BasicRestServlet are registered as top-level servlets even though you don't want them to be.

    BasicRest - Non-servlet equivalent to BasicRestServlet BasicRestGroup - Non-servlet equivalent to BasicRestServletGroup BasicRestJena - Non-servlet equivalent to BasicRestServletJena BasicRestJenaGroup - Non-servlet equivalent to BasicRestServletJenaGroup
  • HTML widgets now have access to the RestResponse object if they need access to the output bean.

  • New annotations for simplified role-based guards on classes and methods:

    RestResource roleGuard() rolesDeclared() RestMethod RestMethod.roleGuard roleGuard() RestMethod.rolesDeclared rolesDeclared()
  • New annotations for fine-tuned handling of http-methods/http-headers as query parameters and others:

    RestResource allowedHeaderParams() allowedMethodHeaders() allowedMethodParams()
  • The @RestResource(path) annotation can now use variables:

    @RestResource(
    path="/myResource/{foo}/{bar}"
    )
    public class MyResource extends BasicRestServlet {...}
  • New methods:

    RestRequestgetCharset()RestResponsegetCharset()
  • New interface method for catching arbitrary thrown objects and converting them to other throwables:

    RestCallHandler RestCallHandler.convertThrowable(Throwable) convertThrowable(Throwable) BasicRestCallHandler convertThrowable(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 RestLoggingAndDebugging for 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.