6.2.0 (Apr 28, 2017)

Juneau 6.2.0 is a major update.

##### org.apache.juneau

- Revamped the serializer, parser classes to use builders for creation. Serializers and parsers are now unmodifiable objects once they are created. This is a breaking code change that will require adoption.

  /* Creating a new serializer or parser */ // Old way WriterSerializer s = new JsonSerializer().setUseWhitespace(true).pojoSwaps(BSwap.class).lock(); // New way WriterSerializer s = JsonSerializer.create().ws().pojoSwaps(BSwap.class).build(); /* Cloning an existing serializer or parser */ // Old way WriterSerializer s = SimpleJsonSerializer.DEFAULT .clone().setUseWhitespace(true).pojoSwaps(BSwap.class).lock(); // New way WriterSerializer s = SimpleJsonSerializer.DEFAULT .builder().ws().pojoSwaps(BSwap.class).build();

- Also introduced the following builder classes and related architecture changes to make the built objects unmodifiable:
  - Builder
  - Builder
  - Builder
- Revamped the config file API to use a build: ConfigFileBuilder.
- Removed the Lockable interface.
- New addBeanTypeProperties setting added to serializers to override the SerializerContext.SERIALIZER_addBeanTypePropertiessetting for individual serializers in a serializer group:
  - HtmlSerializerContext.HTML_addBeanTypeProperties
  - JsonSerializerContext.JSON_addBeanTypeProperties
  - MsgPackSerializerContext.MSGPACK_addBeanTypeProperties
  - UonSerializerContext.UON_addBeanTypeProperties
  - XmlSerializerContext.XML_addBeanTypeProperties
  - RdfSerializerContext.RDF_addBeanTypeProperties
- UON notation serializers and parsers moved into the new org.apache.juneau.uon package.
- New {@link oaj.xml.annotation.XmlFormat#VOID} format to identify HTML void elements.
- Tweaks to HTML5 support.
  - Fixed handling of empty non-void elements in HTML serializer.
  - Added style() override methods to all elements.
- Improvements to Swagger support.
  - New {@link oaj.dto.swagger.SwaggerBuilder} class.
  - Fluent-style setters added to the Swagger beans.
  - Added Swagger examples here and in the swagger javadocs.
- Improvements to {@link oaj.svl.VarResolver}.
  - New {@link oaj.svl.vars.IfVar $IF} variable for if-else block logic.
  - $SWITCH variable for switch block logic.
  - Whitespace wasn't being ignored in some cases.
- {@link oaj.html.HtmlParser} can now parse full body contents generated by {@link oaj.html.HtmlDocSerializer}.
- Parse-args supported added to {@link oaj.msgpack.MsgPackParser} to allow it to be used in remoteable proxies.
- Added some convenience classes for constructing collections using a fluent interface:
  - AList
  - ASet
  - AMap
- New {@link oaj.annotation.Bean#typePropertyName @Bean(typePropertyName)} annotation allows you to specify the name of the "_type" property at the class level.
- New methods added to HTML5 container beans:
  - {@link oaj.dto.html5.HtmlElementContainer#getChild(int...)}
  - {@link oaj.dto.html5.HtmlElementMixed#getChild(int...)}
- New common serializer setting: SerializerContext.SERIALIZER_abridged.
- Support for defining interface proxies against 3rd-party REST interfaces.
  New package remoteablefor all remoteable proxy interface annotations.
  @Remoteable annotation has been moved to this package.
- Updated doc: 6 - Remoteable Services
- New doc: 6.1 - Interface proxies against 3rd-party REST interfaces
- New URL-encoding serializer setting: UrlEncodingSerializerContext.URLENC_paramFormat.
- New methods on {@link oaj.urlencoding.UrlEncodingSerializer.Builder}:
  - Builder.paramFormat(String)
  - Builder.plainTextParams()

##### org.apache.juneau.rest

- @RestResource annotation can now be applied to any class! You're no longer restricted to subclassing your resources from RestServlet.
  This is a major enhancement in the API. Anything you could do by subclassing from RestServlet should have an equivalent for non-RestServlet classes.
  The only restriction is that the top-level resource must subclass from RestServlet. Child resources do not.
  The majority of code has been split up into two separate classes:
  - RestConfig - A modifiable configuration of a resource. Subclasses from javax.servlet.ServletConfig.
  - {@link oajr.RestContext} - A read-only configuration that's the result of a snapshot of the config.
  The RestServletclass now has the following initialization method that allows you to override the config settings define via annotations:
  - RestServlet.init(RestConfig) - A modifiable configuration of a resource.
  Non-RestServlet classes must have one of the following to allow it to be instantiated:
  - A public T(RestConfig) constructor.
  - A public T() constructor.
  - The parent resource must have a customized RestResourceResolver for instantiating it.
  Non-RestServlet classes can optionally include the following init methods to gain access to the config and context:
  - public init(RestConfig)
  - public init(RestContext)
- New annotations added to @RestResourceto allow non-RestServlet resources to do the same as subclassing directly from RestServlet:
  - RestResource.resourceResolver() - Specify a RestResourceResolverclass for resolving child resources.
  - RestResource.callHandler() - Specify a RestCallHandlerclass for handling the lifecycle of a REST call.
  - RestResource.infoProvider() - Specify a RestInfoProviderclass for customizing title/description/Swagger information on a REST resource.
  - RestResource.logger() - Specify a RestLogger class for handling logging.
- New annotations added to @RestResource and RestMethod @RestMethod to simplify defining page title, text, and links on HTML views:
  - @RestResource(pageTitle)
  - @RestMethod(pageTitle)
  - @RestResource(pageText)
  - @RestMethod(pageText)
  - @RestResource(pageLinks)
  - @RestMethod(pageLinks)

  // Old method @RestResource( properties={ @Property(name=HTMLDOC_title, value="System properties resource"), @Property(name=HTMLDOC_description, value="REST interface for performing CRUD operations on system properties."), @Property(name=HTMLDOC_navlinks, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS'}") } ) // New method @RestResource( pageTitle="System properties resource", pageDescription="REST interface for performing CRUD operations on system properties.", pageLinks="{up:'$R{requestParentURI}',options:'?method=OPTIONS'}" )

  Typically you're going to simply want to use the title and description annotations which apply to both the page title/text and the swagger doc:

  @RestResource( title="System properties resource", description="REST interface for performing CRUD operations on system properties.", pageLinks="{up:'$R{requestParentURI}',options:'?method=OPTIONS'}" )

- RestResource.stylesheet() can now take in a comma-delimited list of stylesheet paths.
- StreamResource can now contain multiple sources from a variety of source types (e.g. byte[] arrays, InputStreams, Files, etc...) and is now immutable. It also includes a new StreamResourceBuilderclass.
- Simplified remoteable proxies using the @RestMethod(name="PROXY") annotation on REST methods. Used to expose interface proxies without the need for RemoteableServlet.

  // Server side @RestMethod(name="PROXY", path="/myproxy/*") public IAddressBook getProxy() { return addressBook; } // Client side RestClient client = RestClient.create().rootUrl(samplesUrl).build(); IAddressBook ab = client.getRemoteableProxy(IAddressBook.class, "/addressBook/myproxy");

  See RestMethod.name() @RestMethod(name)for more information.
- {@link oajr.RestRequest#toString()} can be called at any time to view the headers and content of the request without affecting functionality. Very useful for debugging.
- RestMethod.name() @RestMethod(name)annotation is now optional. Defaults to "GET".

##### org.apache.juneau.rest.client

- Revamped the client API to use builders.
- New doc: 1.5 - Debugging
- The RestClient class doX(Object url) methods now handle HttpClient URIBuilder instances.
- New methods added/updated to {@link oajrc.RestClient}:
  - RestClient.getRemoteableProxy(Class,Object)- For interface proxies defined using @RestMethod(name="PROXY").
  - RestClient.getRemoteableProxy(Class,Object,Serializer,Parser)- Same as above but overrides the serializer and parser defined on the client.
  - RestClient.doPost(Object)
  - RestClient.doCall(HttpMethod,Object,Object) - Can now pass in instances of NameValuePairsfor easy form posts.
    This extends to all methods that take in the input.
- New methods on RestCall:
  - RestCall.uri(Object) uri(Object)
  - query(String,Object,boolean,PartSerializer)
  - RestCall.query(String,Object) query(String,Object)
  - RestCall.queryIfNE(String,Object) queryIfNE(String,Object)
  - RestCall.query(Map) query(Map)
  - RestCall.queryIfNE(Map) queryIfNE(Map)
  - RestCall.query(String) query(String)
  - formData(String,Object,boolean,PartSerializer)
  - RestCall.formData(String,Object) formData(String,Object)
  - RestCall.formDataIfNE(String,Object) formDataIfNE(String,Object)
  - RestCall.formData(Map) formData(Map)
  - RestCall.formDataIfNE(Map) formDataIfNE(Map)
  - header(String,Object,boolean,PartSerializer)
  - RestCall.header(String,Object) header(String,Object)
  - RestCall.headerIfNE(String,Object) headerIfNE(String,Object)
  - RestCall.headers(Map) headers(Map)
  - RestCall.headersIfNE(Map) headersIfNE(Map)
  - RestCall.host(String) host(String)
  - RestCall.port(int) port(int)
  - RestCall.userInfo(String,String) userInfo(String,String)
  - RestCall.userInfo(String) userInfo(String)
  - RestCall.scheme(String) scheme(String)
- New methods added to {@link oajrc.RestClient.Builder}:
  - {@link oajrc.RestClient.Builder#executorService(ExecutorService,boolean) executorService(ExecutorService,boolean)}
  - Builder.paramFormat(String)
  - Builder.plainTextParams()
  - {@link oajrc.RestClient.Builder#noTrace() noTrace()} - Adds a No-Trace: true header on all requests to prevent the servlet from logging errors.
    Useful for testing scenarios when you don't want the console to end up showing errors done on purpose.
  - {@link oajrc.RestClient.Builder#debug() debug()} now adds a Debug: true header on all requests.
- New methods added/updated to RestCall:
  - RestCall.runFuture() runFuture()
  - RestCall.getResponseFuture(Class) getResponseFuture(Class)
  - oajrc.RestCall.getResponseFuture(Type,Type...) getResponseFuture(Type,Type...)
  - RestCall.getResponseAsStringFuture() getResponseAsStringFuture()
  - RestCall.serializer(Serializer) serializer(Serializer)- Override the serializer defined on the client for a single call.
  - RestCall.parser(Parser) parser(Parser) - Override the parser defined on the client for a single call.
  - input(Object)- Now accepts instances of NameValuePairs.
  - RestCall.getResponse(Class) getResponse(Class)- Can now pass in any of the following:
    - {@link org.apache.http.HttpResponse} - Returns the raw HttpResponse returned by the inner HttpClient.
    - {@link java.io.Reader} - Returns access to the raw reader of the response.
    - {@link java.io.InputStream} - Returns access to the raw input stream of the response.
- New methods added to NameValuePairs:
  - NameValuePairs.append(String,Object) append(String,Object)
  - append(String,Object,PartSerializer)
- RetryOnis now an abstract class with an additional method:
  - RetryOn.onResponse(HttpResponse) onResponse(HttpResponse)

##### org.apache.juneau.microservice

- "REST/port" configuration setting can now be a comma-limited list of port numbers to try.
  You can also specify one or more 0s to try a random port.
- Methods added to RestMicroserviceclass:
  - getPort()
  - getURI()
  - Override methods added from {@link oaj.microservice.Microservice} class for easier method chaining.