Skip to main content

Release 6.3.0

Date: Jun 30, 2017

Juneau 6.3.0 is a major update with significant new functionality for defining proxy interfaces against arbitrary 3rd-party REST interfaces.

org.apache.juneau

  • New package: org.apache.juneau.http.

  • Support for dynamic beans. See @BeanProperty(name).

  • New doc: 2.8 - Virtual Beans

  • New doc: 2.13 - Comparison with Jackson

  • All parsers now allow for numeric types with 'K'/'M'/'G' suffixes to represent kilobytes, megabytes, and gigabytes.

    // Example
    int i = JsonParser.DEFAULT.parse("123M"); // 123MB
  • New/modified methods on ConfigFile:

    • ConfigFile.put(String,String,String,boolean)
    • ConfigFile.put(String,String,Object,Serializer,boolean,boolean)
    • ConfigFile.getObject(String,Type,Type...)
    • ConfigFile.getObject(String,Parser,Type,Type...)
    • ConfigFile.getObject(String,Class)
    • ConfigFile.getObject(String,Parser,Class)
    • ConfigFile.getObject(String,String,Type,Type...)
    • ConfigFile.getObject(String,String,Parser,Type,Type...)
    • ConfigFile.getObject(String,String,Class)
    • ConfigFile.getObject(String,String,Parser,Class)
    • ConfigFile.getObjectWithDefault(String,Object,Type,Type...)
    • ConfigFile.getObjectWithDefault(String,Parser,Object,Type,Type...)
    • ConfigFile.getObjectWithDefault(String,Object,Class)
    • ConfigFile.getObjectWithDefault(String,Parser,Object,Class)
  • New ability to interact with config file sections with proxy interfaces with new method ConfigFile.getSectionAsInterface(String,Class).

  • @BeanProperty annotation can now be applied to getters and setters defined on interfaces.

  • New methods on SerializerSession and ParserSession for retrieving context and runtime-override properties:

    • Session.getProperty(String)
    • Session.getProperty(String,String)
    • Session.getProperty(Class,String)
    • Session.getProperty(Class,String,Object)
  • New PartSerializer interface particularly tailored to HTTP headers, query parameters, form-data parameters, and path variables. Allows easy user-defined serialization of these objects. The interface can be used in the following locations:

    • Builder.partSerializer(Class)
    • Path.serializer
    • Query.serializer
    • QueryIfNE.serializer
    • FormData.serializer
    • FormDataIfNE.serializer
    • Header.serializer
    • HeaderIfNE.serializer
  • Across-the-board improvements to the URI-resolution support (i.e. how URIs get serialized).

    • New support for resolving URIs with the following newly-recognized protocols:

      • "context:/..." - Relative to context-root of the application.
      • "servlet:/..." - Relative to the servlet URI.
      • "request:/..." - Relative to the request URI.

      For example, currently we define HTML page links using variables and servlet-relative URIs...

      pages="{up:'$R{requestParentURI}', options:'?method=OPTIONS', upload:'upload'}"

      With these new protocols, we can define them like so:

      links="{top:'context:/', up:'request:/..' ,options:'servlet:/?method=OPTIONS', upload:'servlet:/upload'}"

      The old method of using variables and servlet-relative URIs will still be supported but using these new protocols should (hopefully) be easier to understand. These protocols work on all serialized URL and URI objects, as well as classes and properties annotated with @URI.

    • New classes:

    • New configuration properties:

      • SerializerContext.SERIALIZER_uriContext
      • SerializerContext.SERIALIZER_uriRelativity
      • SerializerContext.SERIALIZER_uriResolution
      • SerializerContext.SERIALIZER_maxIndent
  • New annotation property: @BeanProperty(value). The following two annotations are considered equivalent:

    @BeanProperty(name="foo")

    @BeanProperty("foo")
  • Fixed a race condition in ClassMeta.

  • URLENC_paramFormat has been moved to UonSerializer.UON_paramFormat, and the UON/URL-Encoding serializers will now always serialize all values as plain text. This means that arrays and maps are converted to simple comma-delimited lists.

  • Listener APIs added to serializers and parsers:

  • The BEAN_debug flag will now capture parser input and make it available through the ParserSession.getInputAsString() method so that it can be used in the listeners.

  • Significant new functionality introduced to the HTML serializer. Lots of new options for customizing the HTML output.

    • New @Html(render) annotation and HtmlRender class that allows you to customize the HTML output and CSS style on bean properties:

      HTML Render Example

      Annotation can be applied to POJO classes and bean properties.

    • Several new properties for customizing parts of the HTML page:

      • HtmlDocSerializerContext.HTMLDOC_title
      • HtmlDocSerializerContext.HTMLDOC_description
      • HtmlDocSerializerContext.HTMLDOC_branding
      • HtmlDocSerializerContext.HTMLDOC_header
      • HtmlDocSerializerContext.HTMLDOC_nav
      • HtmlDocSerializerContext.HTMLDOC_aside
      • HtmlDocSerializerContext.HTMLDOC_footer
      • HtmlDocSerializerContext.HTMLDOC_noResultsMessage
      • HtmlDocSerializerContext.HTMLDOC_cssUrl
      • HtmlDocSerializerContext.HTMLDOC_css
      • HtmlDocSerializerContext.HTMLDOC_template
    • New interface HtmlDocTemplate that allows full control over rendering of HTML produced by HtmlDocSerializer.

  • @NameProperty and @ParentProperty can now be applied to fields.

  • New properties on BeanContext:

    • BEAN_includeProperties
    • BEAN_excludeProperties
  • New annotation property: @BeanProperty(format).

org.apache.juneau.rest

  • MAJOR enhancements made to the REST API.

  • The RestRequest class functionality has been broken up into the following functional pieces to reduce its complexity:

    • RestRequest.getBody() - The request body.
    • RestRequest.getHeaders() - The request headers.
    • RestRequest.getQuery() - The request query parameters.
    • RestRequest.getFormData() - The request form data parameters.
    • RestRequest.getPathMatch() - The path variables and remainder.

    The following classes have been introduced:

    • RequestBody
    • RequestHeaders
    • RequestQuery
    • RequestFormData
    • RequestPath
  • The un-annotated parameter types that can be passed in through REST Java methods has been significantly expanded. For reference, the previous supported types were:

    • RestRequest - The request object.
    • javax.servlet.http.HttpServletRequest - The superclass of RestRequest.
    • RestResponse - The response object.
    • javax.servlet.http.HttpServletResponse - The superclass of RestResponse.

    The new supported types are:

    • Accept
    • AcceptCharset
    • AcceptEncoding
    • AcceptLanguage
    • Authorization
    • CacheControl
    • Connection
    • ContentLength
    • ContentType
    • Date
    • Expect
    • From
    • Host
    • IfMatch
    • IfModifiedSince
    • IfNoneMatch
    • IfRange
    • IfUnmodifiedSince
    • MaxForwards
    • Pragma
    • ProxyAuthorization
    • Range
    • Referer
    • TE
    • UserAgent
    • Upgrade
    • Via
    • Warning
    • TimeZone
    • InputStream
    • javax.servlet.ServletInputStream
    • Reader
    • OutputStream
    • javax.servlet.ServletOutputStream
    • Writer
    • ResourceBundle - Client-localized resource bundle.
    • MessageBundle - A resource bundle with additional features.
    • Locale - Client locale.
    • RequestHeaders - API for accessing request headers.
    • RequestQuery - API for accessing request query parameters.
    • RequestFormData - API for accessing request form data.
    • RequestPath - API for accessing path variables.
    • RequestBody - API for accessing request body.
    • HttpMethod - The method name matched (when using @RestMethod(name="*"))
    • Logger - The logger to use for logging.
    • JuneauLogger - Logger with additional features.
    • RestContext - The resource read-only context.
    • Parser - The parser matching the request content type.
    • Swagger - The auto-generated Swagger doc.
    • ConfigFile - The external config file for the resource.

    So, for example...

    /** Old way */ 
    @RestMethod(name="*", path="/example1/{a1}/{a2}/{a3}/*")
    public String example1(
    @Method String method,
    @Path("a1") String a1,
    @Path("a2") int a2,
    @Path("a3") UUID a3,
    @Query("p1") int p1,
    @Query("p2") String p2,
    @Query("p3") UUID p3,
    @Header("Accept-Language") String lang,
    @Header("Accept") String accept
    )

    /** New way */
    @RestMethod(name="*", path="/example2/{a1}/{a2}/{a3}/*")
    public String example2(
    HttpMethod httpMethod,
    RequestPathParams pathParams,
    RequestQuery query,
    AcceptLanguage acceptLanguage,
    Accept accept
    )
  • A new annotation @RestResource(paramResolvers) that allows you to define your own custom Java method parameter resolvers.

  • Fixed bug where Writer returned by RestResponse.getWriter() was not being flushed automatically at the end of the HTTP call.

  • New annotations added to @RestMethod:

    • RestMethod.defaultQuery()
    • RestMethod.defaultFormData()
    • bpIncludes()
    • bpExcludes()
  • Default values on header, query, and form-data annotations:

    • @Header(def) - Default header value.
    • @Query(def) - Default query parameter value.
    • @FormData(def) - Default form data parameter value.
  • New attributes on @RestResource:

    • serializerListener()
    • parserListener()
    • widgets()
    • swagger()
    • htmldoc()
  • New attributes on @RestMethod:

    • widgets()
    • RestMethod.swagger()
    • RestMethod.htmldoc()
  • New string vars:

    • UrlVar - Resolve "$U{...}" variables to URLs.
    • WidgetVar - Resolve "$W{...}" variables to widget contents.
  • New methods on RestConfig:

    • setHtmlTitle(String)
    • setHtmlDescription(String)
    • setHtmlBranding(String)
    • setHtmlHeader(String)
    • setHtmlLinks(String)
    • setHtmlNav(String)
    • setHtmlAside(String)
    • setHtmlFooter(String)
    • setHtmlCss(String)
    • setHtmlCssUrl(String)
    • setHtmlNoWrap(boolean)
    • setHtmlNoResultsMessage(String)
    • setHtmlTemplate(Class)
    • setHtmlTemplate(HtmlDocTemplate)
    • addWidget(Class)
  • New methods on RestResponse:

    • setHtmlTitle(Object)
    • setHtmlDescription(Object)
    • setHtmlBranding(Object)
    • setHtmlHeader(Object)
    • setHtmlLinks(Object)
    • setHtmlNav(Object)
    • setHtmlAside(Object)
    • setHtmlFooter(Object)
    • setHtmlCss(Object)
    • setHtmlCssUrl(Object)
    • setHtmlNoWrap(boolean)
    • setHtmlNoResultsMessage(Object)
    • setHtmlTemplate(Class)
    • setHtmlTemplate(HtmlDocTemplate)
  • &plainText=true parameter now works on byte-based serializers by converting the output to hex.

  • New classes for widget support:

    • Widget
    • PoweredByJuneauWidget
    • ContentTypeLinksColumnWidget
    • ContentTypeLinksRowWidget
    • QueryWidget
  • devops.css cleaned up.

  • Removed a bunch of URL-related methods from RestRequest. These all have equivalents in RestRequest.getUriContext().

  • New annotation attributes:

org.apache.juneau.rest.client

  • New Path annotation for specifying path variables on remoteable interfaces.

  • New @RequestBean annotation for specifying beans with remoteable annotations defined on properties.

  • The following annotations (and related methods on RestCall) can now take NameValuePairs and beans as input when using "*" as the name. FormData, FormDataIfNE, Query, QueryIfNE, Header, HeaderIfNE

org.apache.juneau.microservice

No changes listed in this release.

org.apache.juneau.examples.rest

  • Many code enhancements made to examples to reflect new functionality.

  • All pages now render aside comments to help explain what feature they're trying to explain using the new features that allow you to customize various elements of the page.

    Release Notes 6.3.0 Example