Apache Juneau Overview

- A universal toolkit for marshalling POJOs to a wide variety of content types using a common framework.
- A universal REST server API for creating Swagger-based self-documenting REST interfaces using POJOs, simply deployed as one or more top-level servlets in any Servlet 3.1 or above container.
- A universal REST client API for interacting with Juneau or 3rd-party REST interfaces using POJOs and proxy interfaces.
- A sophisticated configuration file API.
- A REST microservice API that combines all the features above with a simple configurable Jetty server for creating lightweight stand-alone REST interfaces that start up in milliseconds.
- Built on top of Servlet and Apache HttpClient APIs that allow you to use the newest HTTP/2 features such as request/response multiplexing and server push.

##### Table of Contents

## 1 - Introduction

Juneau is a single cohesive framework consisting of the following parts:

- A universal toolkit for marshalling POJOs to a wide variety of content types using a common framework.
- A universal REST server API for creating Swagger-based self-documenting REST interfaces using POJOs, simply deployed as one or more top-level servlets in any Servlet 3.1 or above container.
- A universal REST client API for interacting with Juneau or 3rd-party REST interfaces using POJOs and proxy interfaces.
- A sophisticated configuration file API.
- A REST microservice API that combines all the features above with a simple configurable Jetty server for creating lightweight stand-alone REST interfaces that start up in milliseconds.
- Built on top of Servlet and Apache HttpClient APIs that allow you to use the newest HTTP/2 features such as request/response multiplexing and server push.

Questions via email to dev@juneau.apache.org are always welcome.

Juneau is packed with features that may not be obvious at first. Users are encouraged to ask for code reviews by providing links to specific source files such as through GitHub. Not only can we help you with feedback, but it helps us understand usage patterns to further improve the product.

###### History

Juneau started off as a popular internal IBM toolkit called Juno. Originally used for serializing POJOs to and from JSON, it later expanded in scope to include a variety of content types, and then later REST servlet, client, and microservice APIs. It's use grew to more than 50 projects and was one of the most popular community source projects within IBM.

In June of 2016, the code was donated to the Apache Foundation under the project Apache Juneau where it has continued to evolve to where it is today.

### 1.1 - Features

- KISS is our mantra! No auto-wiring. No code generation. No dependency injection (but still compatible with). Just add it to your classpath and use it. Extremely simple unit testing!
- Extensive and extensible support for a large variety of POJOs, including structured data (beans) and unstructured data (`Maps` and `Collections`).
- Sophisticated configurable serializers and parsers.
  For example, the JSON serializers and parsers can handle strict or lax syntax, comments, concatenated strings, etc...
- Tiny - ~1MB
- Exhaustively tested

### 1.2 - Components

We've strived to keep prerequisites to an absolute minimum in order to make adoption as easy as possible.

The library consists of the following artifacts found in the Maven group `"org.apache.juneau"`:

Category | Maven Artifacts | Description | Prerequisites
--- | --- | --- | ---
juneau-core | juneau-marshall | Serializers and parsers for: JSON XML HTML UON URL-Encoding MessagePack SOAP/XML CSV BSON (coming soon) YAML (coming soon) Protobuf (coming soon) | Java 6
juneau-marshall-rdf | Serializers and parsers for: RDF/XML RDF/XML-Abbrev N-Triple Turtle N3 | Java 6 Apache Jena 2.7.1
juneau-dto | Data Transfer Objects for: HTML5 Atom Cognos JSON-Schema Swagger 2.0 | Java 6
juneau-svl | Simple Variable Language API | Java 6
juneau-config | Configuration file API | Java 6
juneau-rest | juneau-rest-server | REST Servlet API | Java 6 Servlet 3.1
juneau-rest-server-jaxrs | Optional JAX-RS support | Java 6 JAX-RS 2.0
juneau-rest-client | REST Client API | Java 6 Apache HttpClient 4.5.3
juneau-microservice | juneau-microservice-server | REST Microservice Server API | Java 8 Eclipse Jetty 9.4.3
juneau-microservice-template | Developer template project | Java 8 Eclipse Jetty 9.4.3
juneau-examples | juneau-examples-core | Core code examples |
juneau-examples-rest | REST code examples |
juneau-all | `juneau-all` | Combination of the following: juneau-marshall juneau-dto juneau-svl juneau-config juneau-rest-server juneau-rest-client | Java 6 Servlet 3.1 Apache HttpClient 4.5.3

Each component are also packaged as stand-alone OSGi modules.

## 2 - juneau-core

The core Maven artifacts of Juneau consist of the following:

- juneau-marshall - Serializers and parsers for converting POJOs to and from a wide variety of content types using a universal API.
- juneau-marshall-rdf - RDF serializers and parsers that use Apache Jena for marshalling.
- juneau-dto - Data transfer objects for a variety of languages.
- juneau-svl - A sophisticated yet simple variable language.
- juneau-config - A sophisticated configuration file API.

### 2.1 - juneau-marshall

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-marshall</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-marshall-7.0.0.jar

###### OSGi Module

org.apache.juneau.marshall_7.0.0.jar

The `juneau-marshall` artifact contains the API for defining serializers and parsers, and marshalling support for JSON, XML, HTML, URL-Encoding, UON and others.

It also defines many convenience utility classes used throughout the framework.

#### 2.1.1 - Serializers

One of the goals of Juneau was to make serialization as simple as possible. In a single line of code, you should be able to serialize and parse most POJOs. Despite this simplicity, Juneau provides lots of extensibility and configuration properties for tailoring how POJOs are serialized and parsed.

The built-in serializers in Juneau are fast, efficient, and highly configurable. They work by serializing POJOs directly to streams instead of using intermediate Document Object Model objects.

In most cases, you can serialize objects in one line of code by using one of the default serializers:

// A simple bean public class Person { public String name = "John Smith"; public int age = 21; } // Serialize to JSON, XML, or HTML Person p = new Person(); // Produces: // "{name:'John Smith',age:21}" String json = JsonSerializer.DEFAULT.serialize(p); // Produces: // <object> // <name>John Smith</name> // <age>21</age> // </object> String xml = XmlSerializer.DEFAULT.serialize(p); // Produces: // <table> // <tr><th>key</th><th>value</th></tr> // <tr><td>name</td><td>John Smith</td></tr> // <tr><td>age</td><td>21</td></tr> // </table> String html = HtmlSerializer.DEFAULT.serialize(p); // Produces: // "(name='John Smith',age=21)" String uon = UonSerializer.DEFAULT.serialize(p); // Produces: // "name='John+Smith'&age=21" String urlencoding = UrlEncodingSerializer.DEFAULT.serialize(p); // Produces: // 82 A4 6E 61 6D 65 AA 4A 6F 68 6E 20 53 6D 69 74 68 A3 61 67 65 15 byte[] b = MsgPackSerializer.DEFAULT.serialize(p);

In addition to the default serializers, customized serializers can be created using various built-in options:

// Use one of the default serializers to serialize a POJO String json = JsonSerializer.DEFAULT.serialize(someObject); // Create a custom serializer for lax syntax using single quote characters JsonSerializer serializer = JsonSerializer.create().simple().sq().build(); // Clone an existing serializer and modify it to use single-quotes JsonSerializer serializer = JsonSerializer.DEFAULT.builder().sq().build(); // Serialize a POJO to JSON String json = serializer.serialize(someObject);

Default serialization support is provided for Java primitives, `Maps`, `Collections`, beans, and arrays.
Extensible support for other data types such as `Calendars`, `Dates`, `Iterators` is available through the use of POJO swaps (described later).

###### Additional Information

- org.apache.juneau.serializer - Serializer API Javadoc

#### 2.1.2 - Parsers

Parsers work by parsing input directly into POJOs instead of having to create intermediate Document Object Models. This allows them to parse input with minimal object creation.

Like the serializers, you can often parse objects in one line of code by using one of the default parsers:

// Use one of the predefined parsers. Parser parser = JsonParser.DEFAULT; // Parse a JSON object as a bean. String json = "{name:'John Smith',age:21}"; Person p = parser.parse(json, Person.class); // Or parse it into a generic Map. Map m1 = parser.parse(json, Map.class); // Parse a JSON string. json = "'foobar'"; String s2 = parser.parse(json, String.class); // Parse a JSON number as a Long or Float. json = "123"; Long l3 = parser.parse(json, Long.class); Float f3 = parser.parse(json, Float.class); // Parse a JSON object as a HashMap<String,Person>. json = "{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"; Map<String,Person> m4 = parser.parse(json, HashMap.class, String.class, Person.class) // Parse a JSON object as a HashMap<String,LinkedList<Person>>. json = "{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"; Map<String,List<Person>> m5 = parser.parse(json, HashMap.class, String.class, LinkedList.class, Person.class) // Parse a JSON array of integers as a Collection of Integers or int[] array. json = "[1,2,3]"; List<Integer> l6 = parser.parse(json, LinkedList.class, Integer.class); int[] i7 = parser.parse(json, int[].class);

The parsers can also be used to populating existing bean and collection objects:

// Use one of the predefined parsers. Parser parser = JsonParser.DEFAULT; // Populate the properties on an existing bean from a JSON object. String json = "{name:'John Smith',age:21}"; Person p = new Person(); parser.parseIntoBean(json, p); // Populate an existing list from a JSON array of numbers. json = "[1,2,3]"; List<Integer> l2 = new LinkedList<Integer>(); parser.parseIntoCollection(json, l2, Integer.class); // Populate an existing map from a JSON object containing beans. json = "{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"; Map<String,Person> m3 = new TreeMap<String,Person>(); parser.parseIntoMap(json, m3, String.class, Person.class);

- In the example above, we're parsing "lax" JSON (single quotes, unquoted attributes). The JSON parser can handle any valid JSON syntax (such as quoted or unquoted attributes, single or double quotes).
  It can also handle JSON fragments and embedded Javascript comments. Many of the JSON examples provided will use lax syntax which is easier to read since we don't have to deal with escapes.

###### Additional Information

- org.apache.juneau.parser - Parser API Javadoc

#### 2.1.3 - SerializerGroups and ParserGroups

Above the serializers and parsers are the {@link org.apache.juneau.serializer.SerializerGroup} and {@link org.apache.juneau.parser.ParserGroup} classes. These classes allow serializers and parsers to be retrieved by W3C-compliant HTTP `Accept` and `Content-Type` values...

// Construct a new serializer group with configuration parameters that get applied to all serializers. SerializerGroup sg = SerializerGroup.create() .append(JsonSerializer.class, UrlEncodingSerializer.class); .ws // or .useWhitespace(true) .pojoSwaps(CalendarSwap.ISO8601DT.class) .build(); // Find the appropriate serializer by Accept type and serialize our POJO to the specified writer. sg.getSerializer("text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0") .serialize(myPersonObject, myWriter); // Construct a new parser group with configuration parameters that get applied to all parsers. ParserGroup pg = ParserGroup.create() .append(JsonSerializer.class, UrlEncodingSerializer.class); .pojoSwaps(CalendarSwap.ISO8601DT.class) .build(); Person p = pg.getParser("text/json").parse(myReader, Person.class);

The REST servlet API builds upon the `SerializerGroup` and `ParserGroup` classes to provide annotated REST servlets that automatically negotiate the HTTP media types and allow the developer to work with requests and responses as POJOs.

###### Additional Information

- {@link org.apache.juneau.serializer.SerializerGroup}
- {@link org.apache.juneau.parser.ParserGroup}

#### 2.1.4 - ObjectMap and ObjectList

The {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} classes are generic Java representations of JSON objects and arrays. These classes can be used to create "unstructured" models for serialization (as opposed to "structured" models consisting of beans). If you want to quickly generate JSON/XML/HTML from generic maps/collections, or parse JSON/XML/HTML into generic maps/collections, these classes work well.

These classes extend directly from the following JCF classes:

- {@link java.util.LinkedHashMap java.util.LinkedHashMap}
  - {@link org.apache.juneau.ObjectMap org.apache.juneau.ObjectMap}
- {@link java.util.LinkedList java.util.LinkedList}
  - {@link org.apache.juneau.ObjectMap org.apache.juneau.ObjectList}

The ObjectMap and ObjectList classes are very similar to the JSONObject and JSONArray classes found in other libraries. However, the names were chosen because the concepts of Maps and Lists are already familiar to Java programmers, and these classes can be used with any of the serializers or parsers.

These object can be serialized in one of two ways:

1. Using the provided {@link org.apache.juneau.ObjectMap#serializeTo(java.io.Writer)} or {@link org.apache.juneau.ObjectList#serializeTo(java.io.Writer)} methods.
2. Passing them to one of the {@link org.apache.juneau.serializer.Serializer} serialize methods.
3. Simply calling the {@link org.apache.juneau.ObjectMap#toString()} or {@link org.apache.juneau.ObjectList#toString()} methods which will serialize it as Simplified JSON.

Any valid JSON can be parsed into an unstructured model consisting of generic {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} objects.
(In theory, any valid XML can also be parsed into an unstructured model, although this has not been officially 'tested')

// Parse an arbitrary JSON document into an unstructered data model // consisting of ObjectMaps, ObjectLists, and java primitive objects. Parser parser = JsonParser.DEFAULT; String json = "{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"; ObjectMap m = parser.parse(json, ObjectMap.class); // Use ObjectMap API to extract data from the unstructured model. int johnSmithAge = m.getObjectMap("a").getInt("age"); // Convert it back into JSON. json = JsonSerializer.DEFAULT.serialize(m); // Or convert it to XML. String xml = XmlSerializer.DEFAULT.serialize(m); // Or just use toString(). json = m.toString();

The `ObjectMap` and `ObjectList` classes have many convenience features:

// Convert the map to a bean. MyBean m = objectMap.cast(MyBean.class); // Find entries by multiple keys. MyBean m = objectMap.find(MyBean.class, "key1", "key2"); // Fluent-style appenders. objectMap.append("key1", "val1").append("key2", "val2"); // REST-like functions for manipulating nodes in the data structure using URL-like notation. objectMap.getAt("foo/bar/myBean", MyBean.class); objectMap.putAt("foo/bar/myBean", MyBean.class); objectMap.postAt("foo/bar/myListOfBeans", MyBean.class); objectMap.deleteAt("foo/bar/myBean"); // Copy with inclusion or exclusion. ObjectMap m2 = objectMap.include("key1", "key2", "key3"); ObjectMap m3 = objectMap.exclude("key1", "key2", "key3"); // Serialize using another serializer. String xml = objectMap.serializeTo(XmlSerializer.DEFAULT); // Nested maps. objectMap.setInner(objectMapInner);

- As a general rule, if you do not specify a target type during parsing, or if the target type cannot be determined through reflection, the parsers automatically generate ObjectMaps and ObjectLists.

###### Additional Information

- {@link org.apache.juneau.ObjectMap}
- {@link org.apache.juneau.ObjectList}

#### 2.1.5 - Configurable Properties

Serializers and parsers have a wide variety of configurable properties.
For example, the following code shows how to configure a JSON serializer:

JsonSerializer s = JsonSerializer.create().simple().ws().sq().build();

However, each of the serializers and parsers already contain reusable instances with common configurations.
For example, JSON has the following predefined reusable serializers and parsers:

- {@link org.apache.juneau.json.JsonSerializer}
  - {@link org.apache.juneau.json.JsonSerializer#DEFAULT DEFAULT}
  - {@link org.apache.juneau.json.JsonSerializer#DEFAULT_LAX DEFAULT_LAX}
  - {@link org.apache.juneau.json.JsonSerializer#DEFAULT_READABLE DEFAULT_READABLE}
  - {@link org.apache.juneau.json.JsonSerializer#DEFAULT_LAX_READABLE DEFAULT_LAX_READABLE}
  - {@link org.apache.juneau.json.JsonSerializer#DEFAULT_LAX_READABLE_SAFE DEFAULT_LAX_READABLE_SAFE}
- {@link org.apache.juneau.json.JsonParser}
  - {@link org.apache.juneau.json.JsonParser#DEFAULT DEFAULT}
  - {@link org.apache.juneau.json.JsonParser#DEFAULT_STRICT DEFAULT_STRICT}

These can be used directly, as follows:

// Serialize a POJO to LAX JSON. String json = JsonSerializer.DEFAULT_LAX.serialize(myPojo);

For performance reasons, serializers and parsers are immutable. However, they can be 'copied' and modified using the `builder()` method.

// Clone and customize an existing serializer. JsonSerializer s = JsonSerializer.DEFAULT_LAX .builder() .quoteChar('"') // Use a different quote character. .build();

###### Additional Information

The following is a list of all configurable properties across all serializers and parsers.

- BeanContext - Properties associated with handling beans on serializers and parsers.
  - SerializerContext - Configurable properties common to all serializers.
    - HtmlSerializerContext - Configurable properties on the HTML serializer.
      - HtmlDocSerializerContext - Configurable properties on the HTML document serializer.
    - RdfCommonContext - Configurable properties common to the RDF serializers and parsers.
      - RdfSerializerContext - Configurable properties on the RDF serializers.
    - JsonSerializerContext - Configurable properties on the JSON serializer.
    - MsgPackSerializerContext - Configurable properties on the MessagePack serializer.
    - SoapXmlSerializerContext - Configurable properties on the SOAP/XML serializer.
    - UonSerializerContext - Configurable properties on the URL-Encoding and UON serializers.
    - XmlSerializerContext - Configurable properties on the XML serializer.
  - ParserContext - Configurable properties common to all parsers.
    - HtmlParserContext - Configurable properties on the HTML parser.
    - RdfCommonContext - Configurable properties common to the RDF serializers and parsers.
      - RdfParserContext - Configurable properties on the RDF parsers.
    - JsonParserContext - Configurable properties on the JSON parser.
    - MsgPackParserContext - Configurable properties on the MessagePack parser.
    - UonParserContext - Configurable properties on the URL-Encoding and UON parsers.
    - XmlParserContext - Configurable properties on the XML parser.
- RestContext - Configurable properties on the REST servlet.

#### 2.1.6 - Transforms

By default, the Juneau framework can serialize and parse a wide variety of POJOs out-of-the-box. However, two special classes are provided tailor how certain Java objects are handled by the framework. These classes are:

- {@link org.apache.juneau.transform.PojoSwap} - Tailor how specific non-bean classes are handled by the framework.
- {@link org.apache.juneau.transform.BeanFilter} - Tailor how specific bean classes are handled by the framework.

Annotations are also provided that allow you to use transformations directly on class definitions:

- {@link org.apache.juneau.annotation.Swap @Swap} - Used to tailor how non-bean POJOs get interpreted by the framework.
- {@link org.apache.juneau.annotation.Bean @Bean} - Used to tailor how beans get interpreted by the framework.
- {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor} - Maps constructor arguments to property names on beans with read-only properties.
- {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore} - Ignore classes, fields, and methods from being interpreted as bean or bean components.
- {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} - Used to tailor how bean properties get interpreted by the framework.
- {@link org.apache.juneau.annotation.NameProperty @NameProperty} - Identifies a setter as a method for setting the name of a POJO as it's known by its parent object.
- {@link org.apache.juneau.annotation.ParentProperty @ParentProperty} - Identifies a setter as a method for adding a parent reference to a child object.
- {@link org.apache.juneau.annotation.URI @URI} - Used to identify a class or bean property as a URI.

#### 2.1.6.1 - PojoSwaps

{@link org.apache.juneau.transform.PojoSwap PojoSwaps} are a critical component of Juneau. They allow the serializers and parsers to handle Java objects that wouldn't normally be serializable.

Swaps are very easy to understand. Simply put, they can be thought of as 'object swappers' that swap in serializable objects for non-serializable ones during serialization, and vis-versa during parsing.

Some examples of non-serializable POJOs are `File`, `Reader`, `Iterable`, etc... These are classes that aren't beans and cannot be represented as simple maps, collections, or primitives.

In the following example, we introduce a `PojoSwap` that will swap in ISO8601 strings for `Date` objects:

// Sample swap for converting Dates to ISO8601 strings. public class MyDateSwap extends PojoSwap<Date,String> { // ISO8601 formatter. private DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); /** Converts a Date object to an ISO8601 string. */ @Override public String swap(BeanSession session, Date o) { return format.format(o); } /** Converts an ISO8601 string to a Date object. */ @Override public Date unswap(BeanSession session, String o, ClassMeta hint) throws ParseException { try { return format.parse(o); } catch (java.text.ParseException e) { throw new ParseException(e); } } }

The swap can then be associated with serializers and parsers like so:

// Sample bean with a Date field. public class MyBean { public Date date = new Date(112, 2, 3, 4, 5, 6); } // Create a new JSON serializer, associate our date swap with it, and serialize a sample bean. Serializer serializer = JsonSerializer.create().pojoSwaps(MyDateSwap.class).build(); String json = serializer.serialize(new MyBean()); // == "{date:'2012-03-03T04:05:06-0500'}" // Create a JSON parser, associate our date swap with it, and reconstruct our bean (including the date). ReaderParser parser = JsonParser.create().pojoSwaps(MyDateSwap.class).build(); MyBean bean = parser.parse(json, MyBean.class); int day = bean.date.getDay(); // == 3

Several `PojoSwaps` are already provided for common Java objects:

- org.apache.juneau.transforms
  - {@link org.apache.juneau.transforms.ByteArrayBase64Swap}
  - {@link org.apache.juneau.transforms.CalendarSwap}
  - {@link org.apache.juneau.transforms.DateSwap}
  - {@link org.apache.juneau.transforms.EnumerationSwap}
  - {@link org.apache.juneau.transforms.IteratorSwap}
  - {@link org.apache.juneau.transforms.ReaderSwap}
  - {@link org.apache.juneau.transforms.XMLGregorianCalendarSwap}

In particular, the {@link org.apache.juneau.transforms.CalendarSwap} and {@link org.apache.juneau.transforms.DateSwap} transforms provide a large number of customized swaps to ISO, RFC, or localized strings.

Swaps can also be defined per-media-type. The {@link org.apache.juneau.transform.PojoSwap#forMediaTypes()} method can be overridden to provide a set of media types that the swap is invoked on. It's also possible to define multiple swaps against the same POJO as long as they're differentiated by media type. When multiple swaps are defined, the best-match media type is used.

In the following example, we define 3 swaps against the same POJO. One for JSON, one for XML, and one for all other types.

public class PojoSwapTest { public static class MyPojo {} public static class MyJsonSwap extends PojoSwap<MyPojo,String> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/json"); } public String swap(BeanSession session, MyPojo o) throws Exception { return "It's JSON!"; } } public static class MyXmlSwap extends PojoSwap<MyPojo,String> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/xml"); } public String swap(BeanSession session, MyPojo o) throws Exception { return "It's XML!"; } } public static class MyOtherSwap extends PojoSwap<MyPojo,String> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/*"); } public String swap(BeanSession session, MyPojo o) throws Exception { return "It's something else!"; } } @Test public void doTest() throws Exception { SerializerGroup g = SerializerGroup.create() .append(JsonSerializer.class, XmlSerializer.class, HtmlSerializer.class) .sq() .pojoSwaps(MyJsonSwap.class, MyXmlSwap.class, MyOtherSwap.class) .build(); MyPojo myPojo = new MyPojo(); String json = g.getWriterSerializer("text/json").serialize(myPojo); assertEquals("'It\\'s JSON!'", json); String xml = g.getWriterSerializer("text/xml").serialize(myPojo); assertEquals("<string>It's XML!</string>", xml); String html = g.getWriterSerializer("text/html").serialize(myPojo); assertEquals("<string>It's something else!</string>", html); } }

- The 'swapped' class type must be a serializable type.
  See the definition for Category 4 objects in POJO Categories.

#### 2.1.6.2 - @Swap annotation

{@link org.apache.juneau.annotation.Swap @Swap} can be used to associate a swap class using an annotation. This is often cleaner than using the builder `pojoSwaps()` method since you can keep your swap class near your POJO class.

@Swap(MyPojoSwap.class) public class MyPojo { ... } // Sample swap for converting MyPojo classes to a simple string. public class MyPojoSwap extends PojoSwap<MyPojo,String> { @Override public String swap(BeanSession session, MyPojo o) { return o.toSomeSerializableForm(); } }

Multiple swaps can be associated with a POJO by using the {@link org.apache.juneau.annotation.Swaps @Swaps} annotation:

@Swaps( { @Swap(MyJsonSwap.class), @Swap(MyXmlSwap.class), @Swap(MyOtherSwap.class) } ) public class MyPojo {}

`Readers` get serialized directly to the output of a serializer. Therefore it's possible to implement a swap that provides fully-customized output.

public class MyJsonSwap extends PojoSwap<MyPojo,Reader> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/json"); } public Reader swap(BeanSession session, MyPojo o) throws Exception { return new StringReader("{message:'Custom JSON!'}"); } }

#### 2.1.6.3 - Swap methods

Various methods can be defined on a class directly to affect how it gets serialized. This can often be simpler than using `PojoSwaps`.

Objects serialized as `Strings` can be parsed back into their original objects by implementing one of the following methods on the class:

- `public static T fromString(String)` method.
  Any of the following method names also work:
  - `valueOf(String)`
  - `parse(String)`
  - `parseString(String)`
  - `forName(String)`
  - `forString(String)`
- `public T(String)` constructor.

Note that these methods cover conversion from several built-in Java types, meaning the parsers can automatically construct these objects from strings:

- `fromString(String)` - {@link java.util.UUID}
- `valueOf(String)` - {@link java.lang.Boolean}, {@link java.lang.Byte}, {@link java.lang.Double}, {@link java.lang.Float}, {@link java.lang.Integer}, {@link java.lang.Long}, {@link java.lang.Short}, {@link java.sql.Date}, {@link java.sql.Time}, {@link java.sql.Timestamp}
- `parse(String)` - {@link java.text.DateFormat}, {@link java.text.MessageFormat}, {@link java.text.NumberFormat}, {@link java.util.Date}, {@link java.util.logging.Level}
- `parseString(String)` - {@link javax.xml.bind.DatatypeConverter}
- `forName(String)` - {@link java.lang.Class}

If you want to force a bean-like class to be serialized as a string, you can use the {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore} annotation on the class to force it to be serialized to a string using the `toString()` method.

Serializing to other intermediate objects can be accomplished by defining a swap method directly on the class:

- `public X swap(BeanSession)` method, where `X` is any serializable object.

The `BeanSession` parameter allows you access to various information about the current serialization session. For example, you could provide customized results based on the media type being produced ({@link org.apache.juneau.BeanSession#getMediaType()}).

The following example shows how an HTML5 form template object can be created that gets serialized as a populated HTML5 {@link org.apache.juneau.dto.html5.Form} bean.

import static org.apache.juneau.dto.html5.HtmlBuilder.*; /** * A simple HTML form template whose serialized form is an HTML5 Form object. */ public class FormTemplate { private String action; private int value1; private boolean value2; // Some constructor that initializes our fields. public FormTemplate(String action, int value1, boolean value2) { this.action = action; this.value1 = value1; this.value2 = value2; } // Special swap method that converts this template to a serializable bean public Form swap(BeanSession session) { return form(action, input("text").name("v1").value(value1), input("text").name("v2").value(value2) ); } }

Swapped objects can be converted back into their original form by the parsers by specifying one of the following methods:

- `public static T unswap(BeanSession, X)` method where `X` is the swap class type.
- `public T(X)` constructor where `X` is the swap class type.

The following shows how our form template class can be modified to allow the parsers to reconstruct our original object:

import static org.apache.juneau.dto.html5.HtmlBuilder.*; /** * A simple HTML form template whose serialized form is an HTML5 Form object. * This time with parsing support. */ @Bean(beanDictionary=HtmlBeanDictionary.class) public class FormTemplate { private String action; private int value1; private boolean value2; // Our 'unswap' constructor public FormTemplate(Form f) { this.action = f.getAttr("action"); this.value1 = f.getChild(Input.class, 0) .getAttr(int.class, "value"); this.value2 = f.getChild(Input.class, 1) .getAttr(boolean.class, "value"); } public FormTemplate(String action, int value1, boolean value2) { this.action = action; this.value1 = value1; this.value2 = value2; } public Form swap(BeanSession session) { return form(action, input("text").name("v1").value(value1), input("text").name("v2").value(value2) ); } }

#### 2.1.6.4 - BeanFilters and @Bean annotations

{@link org.apache.juneau.transform.BeanFilter BeanFilters} are used to control aspects of how beans are handled during serialization and parsing. They allow you to control various aspects of beans, such as...

- Which properties to include or exclude.
- Property order.
- Property naming conventions.
- Overriding reading and writing of properties.

In practice, however, it's simpler to use the {@link org.apache.juneau.annotation.Bean @Bean} and {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotations on your bean classes. The annotations are functionally equivalent to the bean filter class.

// Address class with only street/city/state properties (in that order). // All other properties are ignored. @Bean(properties="street,city,state") public class Address { ...

Bean filters are defined through {@link org.apache.juneau.transform.BeanFilterBuilder BeanFilterBuilders}. The programmatic equivalent to the the annotation above would be:

public class MyAddressBeanFilter extends BeanFilterBuilder { // Must provide a no-arg constructor! public MyAddressBeanFilter() { super(Address.class); // The bean class that this filter applies to. setIncludeProperties("street,city,state"); // The properties we want exposed. } }

Bean filters are added to serializers and parsers using the `*BeanFilters(Class...)` methods. For example:

// Create a new JSON serializer and associate a bean filter with it. Serializer serializer = JsonSerializer.create().beanFilters(MyAddressBeanFilter.class).build();

Note that if you use the annotation, you do NOT need to set anything on the serializers/parsers. The annotations will be detected and bean filters will automatically be created for them.

The `addBeanFilter(Class...)` method also allows you to pass in interfaces. Any class that's not a subclass of {@link org.apache.juneau.transform.BeanFilterBuilder} get interpreted as bean interface classes. These cause bean implementations of those interfaces to only expose the properties defined on the interface.

// An interface with the 3 properties we want serialized. public interface AddressInterface { public String getStreet(); public String getCity(); public String getState(); } // Our bean implementation. public class Address implements AddressInterface { ... } // Create a new JSON serializer that only exposes street,city,state on Address bean. Serializer serializer = JsonSerializer.create().beanFilters(AddressInterface.class).build();

###### Additional Information

- org.apache.juneau.transform

#### 2.1.6.5 - Serializing Readers and InputStreams

Juneau serializers treat instances of `Readers` and `InputStreams` special by simply serializing their contents directly to the output stream or writer. This allows you to embed fully customized serializer output.

public class MyBean { public Reader f1 = new StringReader("{'foo':'bar'}"); } // Produces "{f1:{'foo':'bar'}}" String json = JsonSerializer.DEFAULT_LAX.toString(new MyBean());

Note that if you're serializing Readers and InputStreams, it's up to you to make sure you're producing valid output (in this case JSON).

A more typical scenario where this is useful is by using swaps to convert POJOs to Readers whose contents are determined via the {@link org.apache.juneau.BeanSession#getMediaType()} method.
In the following example, we're customizing the JSON output for a particular bean type, but leaving all other renditions as-is:

@Swap(MyBeanSwapSometimes.class) public class MyBean {...} public class MyBeanSwapSometimes extends PojoSwap<MyBean,Object> { public Object swap(BeanSession session, MyPojo o) throws Exception { MediaType mt = session.getMediaType(); if (mt.hasSubType("json")) return new StringReader("{myPojo:'foobar'}"); // Custom JSON output return o; // Otherwise serialize it as a normal bean } }

- Due to the nature of the RDF serializers, Readers and InputStreams are serialized as literals, not as RDF text. This is due to the fact that the RDF serializers use a DOM for serialization, so we don't have access to the underlying stream.

#### 2.1.7 - Bean Names and Dictionaries

While parsing into beans, Juneau attempts to determine the class types of bean properties through reflection on the bean property getter or setter. Often this is insufficient if the property type is an interface or abstract class that cannot be instantiated. This is where bean names and dictionaries come into play.

Bean names and dictionary are used for identifying class types when they cannot be inferred through reflection.

Bean classes are given names through the {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} annotation. These names are then added to the serialized output as virtual "_type" properties (or element names in XML).

On the parsing side, these type names are resolved to classes through the use of bean dictionaries.

For example, if a bean property is of type `Object`, then the serializer will add "_type" attributes so that the class can be determined during parsing.

@Bean(typeName="foo") public class Foo { // A bean property where the object types cannot be inferred since it's an Object[]. @BeanProperty(beanDictionary={Bar.class,Baz.class}) public Object[] x = new Object[]{new Bar(), new Baz()}; } @Bean(typeName="bar") public class Bar {} @Bean(typeName="baz") public class Baz {}

When serialized as JSON, "_type" attributes would be added when needed to infer the type during parsing:

{ x: [ {_type:'bar'}, {_type:'baz'} ] }

Type names can be represented slightly differently in different languages. For example, the dictionary name is used as element names when serialized to XML. This allows the `typeName` annotation to be used as a shortcut for defining element names for beans.

When serialized as XML, the bean is rendered as:

<foo> <x> <bar/> <baz/> </x> </foo>

Bean dictionaries are defined at two levels:

- On individual bean properties through the {@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()} annotation.
- Globally for a parser using the {@link org.apache.juneau.parser.ParserBuilder#beanDictionary(Class...)} method.

- Type names do not need to be universally unique. However, they must be unique within a dictionary.
- The following reserved words cannot be used as type names: `object, array, number, boolean, null`.
- Serialized type names are DISABLED by default. They must be enabled on the serializer using the {@link org.apache.juneau.serializer.Serializer#SERIALIZER_addBeanTypeProperties} configuration property.
- The "_type" property name can be overridden using the {@link org.apache.juneau.BeanContext#BEAN_beanTypePropertyName} configuration property.

#### 2.1.7.1 - Bean Subtypes

In addition to the bean type name support described above, simplified support is provided for bean subtypes.

Bean subtypes are similar in concept to bean type names, except for the following differences:

- You specify the list of possible subclasses through an annotation on a parent bean class.
- You do not need to register the subtype classes on the bean dictionary of the parser.

In the following example, the abstract class has two subclasses:

// Abstract superclass @Bean( beanDictionary={A1.class, A2.class} ) public abstract class A { public String f0 = "f0"; } // Subclass 1 @Bean(typeName="A1") public class A1 extends A { public String f1; } // Subclass 2 @Bean(typeName="A2") public class A2 extends A { public String f2; }

When serialized, the subtype is serialized as a virtual "_type" property:

JsonSerializer s = JsonSerializer.DEFAULT_LAX; A1 a1 = new A1(); a1.f1 = "f1"; String r = s.serialize(a1); assertEquals("{_type:'A1',f1:'f1',f0:'f0'}", r);

The following shows what happens when parsing back into the original object.

JsonParser p = JsonParser.DEFAULT; A a = p.parse(r, A.class); assertTrue(a instanceof A1);

#### 2.1.8 - Virtual Beans

The {@link org.apache.juneau.BeanContext#BEAN_useInterfaceProxies} setting (enabled by default) allows the Juneau parsers to parse content into virtual beans (bean interfaces without implementation classes).

For example, the following code creates an instance of the specified unimplemented interface:

// Our unimplemented interface public interface Address { String getStreet(); void setStreet(String x); String getCity(); void setCity(String x); StateEnum getState(); void setState(StateEnum x); int getZip(); void setZip(int zip); } // Our code Address address = JsonParser.DEFAULT.parse( "{street:'123 Main St', city:'Anywhere', state:'PR', zip:12345}", Address.class ); int zip = address.getZip(); address.setState(StateEnum.NY);

Getter and setter values can be any parsable values, even other virtual beans.

Under-the-covers, a virtual bean is simply a proxy interface on top of an existing `BeanMap` instance. From a programmatic point-of-view, they're indistinguishable from real beans, and can be manipulated and serialized like any other bean.

Virtual beans can also be created programmatically using the `BeanContext` class:

Address address = BeanContext.DEFAULT.createSession().newBean(Address.class);

#### 2.1.9 - Comparison with Jackson

Juneau was developed independently from Jackson, but shares many of the same features and capabilities. Whereas Jackson was created to work primarily with JSON, Juneau was created to work for multiple languages. Therefore, the terminology and annotations in Juneau are similar, but language-agnostic.

The following charts describe equivalent features between the two libraries:

###### Annotations

Jackson | Juneau
--- | ---
@JsonGetter @JsonSetter | {@link org.apache.juneau.annotation.BeanProperty @BeanProperty}
@JsonAnyGetter @JsonAnySetter | {@link org.apache.juneau.annotation.BeanProperty#name() @BeanProperty(name="*")}
@JsonIgnore @JsonIgnoreType | {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore}
`@JsonIgnoreProperties({...})` | {@link org.apache.juneau.annotation.Bean#excludeProperties @Bean(excludeProperties="...")}
`@JsonAutoDetect(fieldVisibility=...)` | No equivalent annotation, but can be controlled via: {@link org.apache.juneau.BeanContext#BEAN_beanFieldVisibility} {@link org.apache.juneau.BeanContext#BEAN_methodVisibility} Future annotation support planned.
@JsonCreator @JsonProperty | {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor}
@JacksonInject | No equivalent. Future support planned.
@JsonSerialize @JsonDeserialize | Juneau uses swaps to convert non-serializable object to serializable forms: {@link org.apache.juneau.annotation.Swap @Swap}
@JsonInclude | No equivalent annotation, but can be controlled via various settings: {@link org.apache.juneau.BeanContext} {@link org.apache.juneau.serializer.SerializerContext} Future annotation support planned.
@JsonPropertyOrder | {@link org.apache.juneau.annotation.Bean#properties @Bean(properties="...")} {@link org.apache.juneau.annotation.Bean#sort @Bean(sort=x)}
@JsonValue @JsonRawValue | Can be replicated using swaps with `Reader` swapped values.

#### 2.1.10 - POJO Categories

The following chart shows POJOs categorized into groups and whether they can be serialized or parsed:

Group | Description | Examples | Can serialize? | Can parse?
--- | --- | --- | --- | ---
1 | Java primitives and primitive objects | {@code String} {@code Integer} {@code Float} {@code Boolean} | yes | yes
2 | Java Collections Framework objects and Java arrays |  |  |
2a | With standard keys/values Map keys are group [1, 4a, 6a] objects. Map, Collection, and array values are group [1, 2, 3ac, 4a, 6a] objects. | `HashSet<String,Integer>` `TreeMap<Integer,Bean>` `List<int[][]>` `Bean[]` | yes | yes
2b | With non-standard keys/values Map keys are group [2, 3, 4b, 5, 6b, 7] objects. Map, Collection, and array values are group [3b, 4b, 5, 6b, 7] objects. | `HashSet<Bean,Integer>` `TreeMap<Integer,Reader>` | yes | no
3 | Java Beans |  |  |
3a | With standard properties These are beans that have one or more properties defined by public getter or public fields. Properties can also be defined as final read-only fields and passed in as constructor args. Property values are group [1, 2, 3ac, 4a, 6a] objects. |  | yes | yes
3b | With non-standard properties or not true beans These include true beans that have one or more properties defined by getter and setter methods or properties, but property types include group [3b, 4b, 5, 6b, 7] objects. This also includes classes that look like beans but aren't true beans. For example, classes that have getters but not setters, or classes without no-arg constructors. |  | yes | no
3c | Virtual beans These are unimplemented bean interfaces with properties of type [1, 2, 3ac, 4a, 6a] objects. Parsers will automatically create interface proxies on top of BeanMap instances. |  | yes | yes
3d | Read-only beans without setters The same as 3a, but without property setters or constructor args. |  | yes | no
4 | Swapped objects These are objects that are not directly serializable, but have {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated with them. The purpose of a POJO swap is to convert an object to another object that is easier to serialize and parse. For example, the {@link org.apache.juneau.transforms.DateSwap.ISO8601DT} class can be used to serialize {@link java.util.Date} objects to ISO8601 strings, and parse them back into {@link java.util.Date} objects. |  |  |
4a | 2-way swapped to group [1, 2a, 3ac] objects For example, a swap that converts a {@code Date} to a {@code String}. | `java.util.Date` `java.util.GregorianCalendar` | yes | yes
4b | 1-way swapped to group [1, 2, 3] objects For example, a swap that converts an {@code Iterator} to a {@code List}. This would be one way, since you cannot reconstruct an {@code Iterator}. | `java.util.Iterator` | yes | no
5 | Readers and InputStreams Contents are serialized directly to the output stream or writer. Typically used for low-level language-specific replacement of POJOs using per-Media-Type POJO swaps. | {@code FileInputStream} {@code StringReader} | yes | no
6 | Non-serializable objects with standard methods for converting to a serializable form |  |  |
6a | Classes with a method that converts it to a serializable form: `public X swap(BeanSession);` where `X` is in groups [1, 2a, 3ac]. `public String toString();` where the string is any meaningful data. And a method that converts it back into the original object: `public static T fromString(String);` `public static T valueOf(String);` `public static T parse(String);` `public static T parseString(String);` `public static T forName(String);` `public static T forString(String);` `public T(X);` where `X` is in groups [1, 2a, 3ac]. `public static T unswap(BeanSession,X);` where `X` is in groups [1, 2a, 3ac]. | `java.lang.Class` `java.sql.Time` `java.sql.Timestamp` `java.text.MessageFormat` `java.text.NumberFormat` `java.util.Date` `java.util.UUID` `java.util.logging.Level` `javax.xml.bind.DatatypeConverter` | yes | yes
6b | Classes that only have a method to convert to a serializable form: `public X swap(BeanSession);` where `X` is in groups [1, 2, 3]. `public String toString();` where the string is any meaningful data. |  | yes | no
7 | All other objects Anything that doesn't fall into one of the groups above are simply converted to {@code Strings} using the {@code toString()} method. |  | yes | no

- Serializers are designed to work on tree-shaped POJO models. These are models where there are no referential loops (e.g. leaves with references to nodes, or nodes in one branch referencing nodes in another branch). There is a serializer setting {@code detectRecursions} to look for and handle these kinds of loops (by setting these references to null), but it is not enabled by default since it introduces a moderate performance penalty.

#### 2.1.11 - Best Practices

1. Reuse instances of serializers and parsers whenever possible.
   They are designed to be thread safe and maintain internal caches of bean metadata to increase performance.
2. The {@link org.apache.juneau.serializer.Serializer#SERIALIZER_detectRecursions SERIALIZER_detectRecursions} option on the {@link org.apache.juneau.serializer.Serializer} class can cause a performance penalty of around 20%. Therefore, it's recommended that this option be used only when necessary.
3. In general, JSON serialization and parsing is about 20% faster than XML. JSON is also more compact than XML. MessagePack is fastest and most compact of all.
4. The RDF parsers are SLOW. RDF simply isn't efficient with node traversal, so creating tree structures out of RDF models is highly inefficient.
5. The {@link org.apache.juneau.parser.Parser} methods that take in {@link org.apache.juneau.ClassMeta} parameters are slightly faster than methods that take in {@link java.lang.Class} or {@link java.lang.Object} parameters, since the latter methods involve hash lookups to resolve to {@link org.apache.juneau.ClassMeta} parameters.

#### 2.1.12 - Additional Information

Extensive javadocs exist for individual language support. Refer to these docs for language-specific information.

- org.apache.juneau.html - HTML support.
- org.apache.juneau.jena - RDF support.
- org.apache.juneau.jso - Java Serialized Object support.
- org.apache.juneau.json - JSON support.
- org.apache.juneau.msgpack - MessagePack support.
- org.apache.juneau.plaintext - Plain-text support.
- org.apache.juneau.soap - SOAP support.
- org.apache.juneau.urlencoding - URL-Encoding and UON support.
- org.apache.juneau.xml - XML support.
- org.apache.juneau.dto.atom - ATOM support.
- org.apache.juneau.dto.cognos - Cognos support.

### 2.2 - juneau-marshall-rdf

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-marshall-rdf</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-marshall-rdf-7.0.0.jar

###### OSGi Module

org.apache.juneau.marshall.rdf_7.0.0.jar

The `juneau-marshall-rdf` library provides additional serializers and parsers for RDF. These rely on the Apache Jena library to provide support for the following languages:

- RDF/XML
- RDF/XML-Abbrev
- N-Triple
- Turtle
- N3

The serializers and parsers work identically to those in `juneau-marshall`, but are packaged separately so that you don't need to pull in the Jena dependency unless you need it.

// A simple bean public class Person { public String name = "John Smith"; public int age = 21; } // Serialize a bean to JSON, XML, or HTML Person p = new Person(); // Produces: // <rdf:RDF // xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" // xmlns:jp="http://www.apache.org/juneaubp/" // xmlns:j="http://www.apache.org/juneau/"> // <rdf:Description> // <jp:name>John Smith</jp:name> // <jp:age>21</jp:age> // </rdf:Description> // </rdf:RDF> String rdfXml = RdfSerializer.DEFAULT_XMLABBREV.serialize(p); // Produces: // @prefix jp: <http://www.apache.org/juneaubp/> . // @prefix j: <http://www.apache.org/juneau/> . // [] jp:age "21" ; // jp:name "John Smith" . String rdfN3 = RdfSerializer.DEFAULT_N3.serialize(p); // Produces: // _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/name> "John Smith" . // _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/age> "21" . String rdfNTriple = RdfSerializer.DEFAULT_NTRIPLE.serialize(p);

###### Additional Information

- org.apache.juneau.jena - RDF support.

### 2.3 - juneau-dto

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-dto</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-dto-7.0.0.jar

###### OSGi Module

org.apache.juneau.dto_7.0.0.jar

The `juneau-dto` library contains several predefined POJOs for generating commonly-used document types. This section describes support for these POJOs.

#### 2.3.1 - HTML5

The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML serializers, or to other languages such as JSON using the JSON serializers.

The {@link org.apache.juneau.dto.html5.HtmlBuilder} class is a utility class with predefined static methods that allow you to easily construct DTO instances in a minimal amount of code.

The following examples show how to create HTML tables.

Java code | HTML
--- | ---
import static org.apache.juneau.dto.html5.HtmlBuilder.*; Object mytable = table( tr( th("c1"), th("c2") ), tr( td("v1"), td("v2") ) ); String html = HtmlSerializer.DEFAULT.serialize(mytable); | <table> <tr> <th>c1</th> <th>c2</th> </tr> <tr> <td>v1</td> <td>v2</td> </tr> </table>
import static org.apache.juneau.dto.html5.HtmlBuilder.*; Object mydiv = div().align("center").onmouseover("alert(\"boo!\");") .children( p("Juneau supports ", b(i("mixed")), " content!") ); String html = HtmlSerializer.DEFAULT.serialize(mydiv); | <div align='center' onmouseover='alert("boo!");'> <p>Juneau supports <b><i>mixed</i></b> content!</p> </table>
import static org.apache.juneau.dto.html5.HtmlBuilder.*; Object myform = form().action("/submit").method("POST") .children( "Position (1-10000): ", input("number").name("pos").value(1), br(), "Limit (1-10000): ", input("number").name("limit").value(100), br(), button("submit", "Submit"), button("reset", "Reset") ); String html = HtmlSerializer.DEFAULT.serialize(myform); | <form action='/submit' method='POST'> Position (1-10000): <input name='pos' type='number' value='1'/><br/> Limit (1-10000): <input name='pos' type='number' value='100'/><br/> <button type='submit'>Submit</button> <button type='reset'>Reset</button> </form>

Using the HTML5 DTOs, you should be able to construct any valid HTML5 from full document bodies to any possible fragments.

The {@link org.apache.juneau.html.HtmlParser} class can be used convert these HTML documents back into POJOs.

Other serializers and parsers (e.g. {@link org.apache.juneau.json.JsonSerializer}) can be used to represent these POJOs in languages other than HTML.

###### Additional Information

- org.apache.juneau.dto.html5 - HTML5 beans.

#### 2.3.2 - Atom

The Juneau ATOM feed DTOs are simply beans with fluent-style setters.
The following code shows a feed being created programmatically using the {@link org.apache.juneau.dto.atom.AtomBuilder} class.

import static org.apache.juneau.dto.atom.AtomBuilder.*; Feed feed = feed("tag:juneau.apache.org", "Juneau ATOM specification", "2016-01-02T03:04:05Z") .subtitle(text("html").text("Describes <em>stuff</em> about Juneau")) .links( link("alternate", "text/html", "http://juneau.apache.org").hreflang("en"), link("self", "application/atom+xml", "http://juneau.apache.org/feed.atom") ) .rights("Copyright (c) ...") .generator( generator("Juneau").uri("http://juneau.apache.org/").version("1.0") ) .entries( entry("tag:juneau.sample.com,2013:1.2345", "Juneau ATOM specification snapshot", "2016-01-02T03:04:05Z") .links( link"alternate", "text/html", "http://juneau.apache.org/juneau.atom"), link("enclosure", "audio/mpeg", "http://juneau.apache.org/audio/juneau_podcast.mp3").length(1337) ) .published("2016-01-02T03:04:05Z") .authors( person("Jane Smith").uri("http://juneau.apache.org/").email("janesmith@apache.org") ) .contributors( person("John Smith") ) .content( content("xhtml") .lang("en") .base("http://www.apache.org/") .text("<div><p><i>[Update: Juneau supports ATOM.]</i></p></div>") ) );

To serialize this to ATOM, use the {@link org.apache.juneau.xml.XmlSerializer} class:

###### Example with no namespaces

// Create a serializer with readable output, no namespaces yet. XmlSerializer s = XmlSerializer.create().sq().ws().build(); // Serialize to ATOM/XML String atomXml = s.serialize(feed);

###### Results

<feed> <id> tag:juneau.apache.org </id> <link href='http://juneau.apache.org/' rel='alternate' type='text/html' hreflang='en'/> <link href='http://juneau.apache.org/feed.atom' rel='self' type='application/atom+xml'/> <rights> Copyright (c) ... </rights> <title type='text'> Juneau ATOM specification </title> <updated>2016-01-02T03:04:05Z</updated> <generator uri='http://juneau.apache.org/' version='1.0'> Juneau </generator> <subtitle type='html'> Describes <em>stuff</em> about Juneau </subtitle> <entry> <author> <name>Jane Smith</name> <uri>http://juneau.apache.org/</uri> <email>janesmith@apache.org</email> </author> <contributor> <name>John Smith</name> </contributor> <id> tag:juneau.apache.org </id> <link href='http://juneau.apache.org/juneau.atom' rel='alternate' type='text/html'/> <link href='http://juneau.apache.org/audio/juneau_podcast.mp3' rel='enclosure' type='audio/mpeg' length='12345'/> <title> Juneau ATOM specification snapshot </title> <updated>2016-01-02T03:04:05Z</updated> <content base='http://www.apache.org/' lang='en' type='xhtml'> <div xmlns="http://www.w3.org/1999/xhtml" ><p><i>[Update: Juneau supports ATOM.]</i></p></div> </content> <published>2016-01-02T03:04:05Z</published> </entry> </feed>

The {@link org.apache.juneau.xml.XmlParser} class can be used convert these Atom documents back into POJOs.

Other serializers and parsers (e.g. {@link org.apache.juneau.json.JsonSerializer}) can be used to represent these POJOs in languages other than XML.

###### Additional Information

- org.apache.juneau.dto.atom - Atom DTOs.

#### 2.3.3 - Swagger

The Juneau Swagger DTOs are simply beans with fluent-style setters that allow you to quickly construct Swagger documents as Java objects. These object can then be serialized to JSON using one of the existing JSON serializers, or to other languages such as XML or HTML using the other serializers.

The {@link org.apache.juneau.dto.swagger.SwaggerBuilder} class is a utility class with predefined static methods that allow you to easily construct DTO instances in a minimal amount of code.

The following is an example Swagger document from the Swagger website.

{ "swagger": "2.0", "info": { "title": "Swagger Petstore", "description": "This is a sample server Petstore server.", "version": "1.0.0", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "apiteam@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "petstore.swagger.io", "basePath": "/v2", "tags": [ { "name": "pet", "description": "Everything about your Pets", "externalDocs": { "description": "Find out more", "url": "http://swagger.io" } } ], "schemes": [ "http" ], "paths": { "/pet": { "post": { "tags": [ "pet" ], "summary": "Add a new pet to the store", "description": "", "operationId": "addPet", "consumes": [ "application/json", "text/xml" ], "produces": [ "application/json", "text/xml" ], "parameters": [ { "in": "body", "name": "body", "description": "Pet object that needs to be added to the store", "required": true } ], "responses": { "405": { "description": "Invalid input" } } } } }, }

This document can be generated by the following Java code:

static import org.apache.juneau.dto.swagger.SwaggerBuilder.*; Swagger swagger = swagger() .swagger("2.0") .info( info("Swagger Petstore", "1.0.0") .description("This is a sample server Petstore server.") .termsOfService("http://swagger.io/terms/") .contact( contact().email("apiteam@swagger.io") ) .license( license("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0.html") ) ) .host("petstore.swagger.io") .basePath("/v2") .tags( tag("pet").description("Everything about your Pets") .externalDocs( externalDocumentation("http://swagger.io", "http://swagger.io") ) ) .schemes("http") .path("/pet", "post", operation() .tags("pet") .summary("Add a new pet to the store") .description("") .operationId("addPet") .consumes(MediaType.JSON, MediaType.XML) .produces(MediaType.JSON, MediaType.XML) .parameters( parameterInfo("body", "body") .description("Pet object that needs to be added to the store") .required(true) ) .response(405, responseInfo("Invalid input")) ); String swaggerJson = JsonSerializer.DEFAULT_READABLE.serialize(swagger);

Swagger docs can be parsed back into Swagger beans using the following code:

Swagger swagger = JsonParser.DEFAULT.parse(swaggerJson, Swagger.class);

#### 2.3.4 - JSON-Schema

TODO

### 2.4 - juneau-svl

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-svl</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-svl-7.0.0.jar

###### OSGi Module

org.apache.juneau.svl_7.0.0.jar

The `juneau-svl` library defines an API for a language called "Simple Variable Language". In a nutshell, Simple Variable Language (or SVL) is text that contains variables of the form "$varName{varKey}".

Variables can be recursively nested within the varKey (e.g. "$FOO{$BAR{xxx},$BAZ{xxx}}"). Variables can also return values that themselves contain more variables.

// Use the default variable resolver to resolve a string that contains $S (system property) variables String myProperty = VarResolver.DEFAULT.resolve("The Java home directory is $S{java.home}");

The following shows how variables can be arbitrarily nested...

// Look up a property in the following order: // 1) MYPROPERTY environment variable. // 2) 'my.property' system property if environment variable not found. // 3) 'not found' string if system property not found. String myproperty = VarResolver.DEFAULT.resolve("$E{MYPROPERTY,$S{my.property,not found}}");

SVL is a large topic on it's own. It is used extensively in the ConfigFile, REST and Microservice APIs.

###### Additional Information

- org.apache.juneau.svl - Simple Variable Language Javadocs.

### 2.5 - juneau-config

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-config</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-config-7.0.0.jar

###### OSGi Module

org.apache.juneau.config_7.0.0.jar

The `juneau-config` library contains a powerful API for creating and using INI-style config files.

An example of an INI file:

# Default section key1 = 1 key2 = true key3 = [1,2,3] key4 = http://foo # Section 1 [Section1] key1 = 2 key2 = false key3 = [4,5,6] key4 = http://bar

This class can be used to easily access contents of the file:

int key1; boolean key2; int[] key3; URL key4; // Load our config file ConfigFile f = ConfigFile.create().build("MyConfig.cfg"); // Read values from default section key1 = f.getInt("key1"); key2 = f.getBoolean("key2"); key3 = f.getObject(int[].class, "key3"); key4 = f.getObject(URL.class, "key4"); // Read values from section #1 key1 = f.getInt("Section1/key1"); key2 = f.getBoolean("Section1/key2"); key3 = f.getObject(int[].class, "Section1/key3"); key4 = f.getObject(URL.class, "Section1/key4");

The interface also allows a config file to be easily constructed programmatically:

// Construct the sample INI file programmatically ConfigFile cf = ConfigFile.create().build("MyConfig.cfg") .addLines(null, "# Default section", "key1 = 1", "key2 = true", "key3 = [1,2,3]", "key4 = http://foo", "") .addHeaderComments("Section1", "# Section 1") .addLines("Section1", "key1 = 2", "key2 = false", "key3 = [4,5,6]", "key4 = http://bar") .save();

The following is equivalent, except that it uses {@link org.apache.juneau.ini.ConfigFile#put(String, Object)} to set values:

// Construct the sample INI file programmatically ConfigFile cf = ConfigFile.create().build("MyConfig.cfg") .addLines(null, "# Default section") .addHeaderComments("section1", "# Section 1"); cf.put("key1", 1); cf.put("key2", true); cf.put("key3", new int[]{1,2,3}); cf.put("key4", new URL("http://foo")); cf.put("Section1/key1", 2); cf.put("Section1/key2", false); cf.put("Section1/key3", new int[]{4,5,6}); cf.put("Section1/key4", new URL("http://bar")); cf.save();

Values are LAX JSON (i.e. unquoted attributes, single quotes) except for top-level strings which are left unquoted. Any parsable object types are supported as values (e.g. arrays, collections, beans, swappable objects, enums, etc...).

The config file looks deceptively simple, the config file API is a very powerful feature with many capabilities, including:

- The ability to use variables to reference environment variables, system properties, other config file entries, and a host of other types.
- APIs for updating, modifying, and saving configuration files without losing comments or formatting.
- Extensive listener APIs.

###### Example:

#-------------------------- # My section #-------------------------- [MySection] # An integer anInt = 1 # A boolean aBoolean = true # An int array anIntArray = [1,2,3] # A POJO that can be converted from a String aURL = http://foo # A POJO that can be converted from JSON aBean = {foo:'bar',baz:123} # A system property locale = $S{java.locale, en_US} # An environment variable path = $E{PATH, unknown} # A manifest file entry mainClass = $MF{Main-Class} # Another value in this config file sameAsAnInt = $C{MySection/anInt} # A command-line argument in the form "myarg=foo" myArg = $ARG{myarg} # The first command-line argument firstArg = $ARG{0} # Look for system property, or env var if that doesn't exist, or command-line arg if that doesn't exist. nested = $S{mySystemProperty,$E{MY_ENV_VAR,$ARG{0}}} # A POJO with embedded variables aBean2 = {foo:'$ARG{0}',baz:$C{MySection/anInt}}

// Java code for accessing config entries above. ConfigFile cf = Microservice.getConfig(); int anInt = cf.getInt("MySection/anInt"); boolean aBoolean = cf.getBoolean("MySection/aBoolean"); int[] anIntArray = cf.getObject(int[].class, "MySection/anIntArray"); URL aURL = cf.getObject(URL.class, "MySection/aURL"); MyBean aBean = cf.getObject(MyBean.class, "MySection/aBean"); Locale locale = cf.getObject(Locale.class, "MySection/locale"); String path = cf.getString("MySection/path"); String mainClass = cf.getString("MySection/mainClass"); int sameAsAnInt = cf.getInt("MySection/sameAsAnInt"); String myArg = cf.getString("MySection/myArg"); String firstArg = cf.getString("MySection/firstArg");

Config files can also be used to directly populate beans using the {@link org.apache.juneau.ini.ConfigFile#getSectionAsBean(String,Class,boolean)}:

// Example config file [MyAddress] name = John Smith street = 123 Main Street city = Anywhere state = NY zip = 12345 // Example bean public class Address { public String name, street, city; public StateEnum state; public int zip; } // Example usage ConfigFile cf = ConfigFile.create().build("MyConfig.cfg"); Address myAddress = cf.getSectionAsBean("MySection", Address.class);

Config file sections can also be accessed via interface proxies using {@link org.apache.juneau.ini.ConfigFile#getSectionAsInterface(String,Class)}:

// Example config file [MySection] string = foo int = 123 enum = ONE bean = {foo:'bar',baz:123} int3dArray = [[[123,null],null],null] bean1d3dListMap = {key:[[[[{foo:'bar',baz:123}]]]]} // Example interface public interface MyConfigInterface { String getString(); void setString(String x); int getInt(); void setInt(int x); MyEnum getEnum(); void setEnum(MyEnum x); MyBean getBean(); void setBean(MyBean x); int[][][] getInt3dArray(); void setInt3dArray(int[][][] x); Map<String,List<MyBean[][][]>> getBean1d3dListMap(); void setBean1d3dListMap(Map<String,List<MyBean[][][]>> x); } // Example usage ConfigFile cf = ConfigFile.create().build("MyConfig.cfg"); MyConfigInterface ci = cf.getSectionAsInterface("MySection", MyConfigInterface.class); int myInt = ci.getInt(); ci.setBean(new MyBean()); cf.save();

###### Additional Information

- org.apache.juneau.ini - Config API Javadocs.

## 3 - juneau-rest

The REST Maven artifacts of Juneau consist of the following:

- juneau-rest-server - Server-side REST APIs built on top of Servlet 3.1+.
- juneau-rest-server-jaxrs - Optional APIs for using Juneau with JAX/RS.
- juneau-rest-client - Client-side REST APIs built on top of Apache HttpClient.

### 3.1 - juneau-rest-server

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-rest-server</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-rest-server-7.0.0.jar

###### OSGi Module

org.apache.juneau.rest.server_7.0.0.jar

The `juneau-rest-server` library provides servlet-based REST resources on top of existing POJOs.

The API automatically detects Content-Type and Accept headers of requests and performs automatic marshalling of POJOs to and from any of the supported languages. The toolkit is extensible and also allows for support of user-defined content types.

Automatic built-in support is provided for negotiation of response character sets and gzip encoding.

The following is an example of a REST API used to view and set JVM system properties.

@RestResource( path="/systemProperties", // Title and description that show up on HTML rendition page. // Also used in Swagger doc. title="System properties resource", description="REST interface for performing CRUD operations on system properties.", // Links on the HTML rendition page. // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI. htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ), // Properties that get applied to all serializers and parsers. properties={ // Use single quotes. @Property(name=SERIALIZER_quoteChar, value="'") }, // Our stylesheet for the HTML rendition. stylesheet="styles/devops.css", // Support GZIP encoding on Accept-Encoding header. encoders=GzipEncoder.class, // Swagger info. swagger=@ResourceSwagger( contact="{name:'John Smith',email:'john@smith.com'}", license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", version="2.0", termsOfService="You're on your own.", tags="[{name:'Java',description:'Java utility', externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]", externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" ) ) public class SystemPropertiesResource extends RestServletDefault { @RestMethod( name=GET, path="/", summary="Show all system properties", description="Returns all system properties defined in the JVM.", parameters={ @Parameter(in="query", name="sort", description="Sort results alphabetically.", _default="false") }, responses={ @Response(value=200, description="Returns a map of key/value pairs.") } ) public Map getSystemProperties(@Query("sort") boolean sort) throws Throwable { if (sort) return new TreeMap(System.getProperties()); return System.getProperties(); } @RestMethod( name=GET, path="/{propertyName}", summary="Get system property", description="Returns the value of the specified system property.", parameters={ @Parameter(in="path", name="propertyName", description="The system property name.") }, responses={ @Response(value=200, description="The system property value, or null if not found.") } ) public String getSystemProperty(@Path String propertyName) throws Throwable { return System.getProperty(propertyName); } @RestMethod( name=PUT, path="/{propertyName}", summary="Replace system property", description="Sets a new value for the specified system property.", guards=AdminGuard.class, parameters={ @Parameter(in="path", name="propertyName", description="The system property name."), @Parameter(in="body", description="The new system property value."), }, responses={ @Response(value=302, headers={ @Parameter(name="Location", description="The root URL of this resource.") } ), @Response(value=403, description="User is not an admin.") } ) public Redirect setSystemProperty(@Path String propertyName, @Body String value) { System.setProperty(propertyName, value); return new Redirect(); } @RestMethod( name=POST, path="/", summary="Add an entire set of system properties", description="Takes in a map of key/value pairs and creates a set of new system properties.", guards=AdminGuard.class, parameters={ @Parameter(in="path", name="propertyName", description="The system property key."), @Parameter(in="body", description="The new system property values.", schema="{example:{key1:'val1',key2:123}}"), }, responses={ @Response(value=302, headers={ @Parameter(name="Location", description="The root URL of this resource.") } ), @Response(value=403, description="Unauthorized: User is not an admin.") } ) public Redirect setSystemProperties(@Body java.util.Properties newProperties) { System.setProperties(newProperties); return new Redirect(); } @RestMethod( name=DELETE, path="/{propertyName}", summary="Delete system property", description="Deletes the specified system property.", guards=AdminGuard.class, parameters={ @Parameter(in="path", name="propertyName", description="The system property name."), }, responses={ @Response(value=302, headers={ @Parameter(name="Location", description="The root URL of this resource.") } ), @Response(value=403, description="Unauthorized: User is not an admin") } ) public Redirect deleteSystemProperty(@Path String propertyName) { System.clearProperty(propertyName); return new Redirect(); } @RestMethod( name=OPTIONS, path="/*", summary="Show resource options", description="Show resource options as a Swagger doc" ) public Swagger getOptions(RestRequest req) { return req.getSwagger(); } }

The resource above is deployed like any other servlet, in this way:

<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.3"> <servlet> <servlet-name>SystemPropertiesService</servlet-name> <servlet-class>org.apache.juneau.examples.rest.SystemPropertiesService</servlet-class> </servlet> <servlet-mapping> <servlet-name>SystemPropertiesService</servlet-name> <url-pattern>/systemProperties</url-pattern> </servlet-mapping> </web-app>

Pointing your browser to the resource renders the POJOs as HTML (since that's what the browser specifies in the `Accept` header).

One of the most useful aspects of using this API is the self-discovering, self-documenting OPTIONS pages. These are constructed automatically using reflection, augmented with information pulled from annotations (as shown above), resource bundles, or Swagger JSON files:

Arbitrarily complex POJO models can be serialized using any of the supported serializers, and content can be parsed using any of the supported parsers.

The juneau-examples-rest project contains various REST resource examples in an easy-to-use REST microservice. One of these is AddressBookResource which serializes AddressBook objects defined below (some code omitted):

/** package-info.java */ @XmlSchema( prefix="ab", xmlNs={ @XmlNs(prefix="ab", namespaceURI="http://www.apache.org/addressBook/"), @XmlNs(prefix="per", namespaceURI="http://www.apache.org/person/"), @XmlNs(prefix="addr", namespaceURI="http://www.apache.org/address/"), @XmlNs(prefix="mail", namespaceURI="http://www.apache.org/mail/") } )

package org.apache.juneau.examples.addressBook; import org.apache.juneau.xml.annotation.*; /** Address book bean */ @Bean(typeName="addressBook") public class AddressBook extends LinkedList<Person> {} /** Person bean */ @Xml(prefix="per") @Bean(typeName="person") public class Person { // Bean properties @Rdf(beanUri=true) public URI uri; public URI addressBookUri; public int id; public String name; @Swap(CalendarSwap.Medium.class) public Calendar birthDate; public LinkedList<Address> addresses; }

/** Address bean */ @Xml(prefix="addr") @Bean(typeName="address") public class Address { // Bean properties @Rdf(beanUri=true) public URI uri; public URI personUri; public int id; @Xml(prefix="mail") public String street, city, state; @Xml(prefix="mail") public int zip; public boolean isCurrent; }

The framework allows you to override header values through GET parameters, so that you can specify the ACCEPT header to see each type. Adding &plainText=true forces the response Content-Type to be text/plain.

###### HTML

Also, localization can be tested by passing in an Accept-Language header.

###### HTML/French

###### JSON

###### XML

###### Simple XML

###### URL-Encoding

###### RDF/XML

###### RDF/N3

###### RDF/N-Tuple

###### RDF/Turtle

The Server API is an exhaustive topic on its own. Refer to the additional information for an in-depth examination of the API.

###### Additional Information

- org.apache.juneau.rest - Juneau Server API Javadocs.

#### 3.1.1 - Remoteable Proxies

Juneau provides the capability of calling methods on POJOs on a server through client-side proxy interfaces. It offers a number of advantages over other similar remote proxy interfaces, such as being much simpler to define and use, and allowing much more flexibility in the types of objects serialized.

The remote proxy interface API allows you to invoke server-side POJO methods on the client side using REST as the communications protocol:

// Create a client with basic JSON support. RestClient client = RestClient.create().rootUrl("http://localhost/remoteable").build(); // Get an interface proxy. IAddressBook ab = client.getRemoteableProxy(IAddressBook.class); // Invoke a method on the server side and get the returned result. Person p = ab.createPerson( new Person( "John Smith", "Aug 1, 1999", new Address("My street", "My city", "My state", 12345, true) ) );

Under the covers, this method call gets converted to a REST POST.

HTTP POST http://localhost/remoteable/org.apache.juneau.examples.rest.IAddressBook/createPerson Accept: application/json Content-Type: application/json [ { "name":"John Smith", "birthDate":"Aug 1, 1999", "addresses":[ { "street":"My street", "city":"My city", "state":"My state", "zip":12345, "isCurrent":true } ] } ]

Note that the body of the request is an array. This array contains the serialized arguments of the method. The object returned by the method is then serialized as the body of the response.

To define a remoteable interface, simply add the {@link org.apache.juneau.remoteable.Remoteable @Remoteable} annotation to your interface class.

@Remoteable public interface IAddressBook {...}

This annotation tells the framework that all methods defined on this interface can be executed remotely. It can be applied to super-interfaces, super-classes, etc..., and exposes the methods at whatever level it is defined.

The {@link org.apache.juneau.remoteable.RemoteMethod @RemoteMethod} annotation can also be used on individual methods to tailor which methods are exposed or their paths.

There are two ways to expose remoteable proxies on the server side:

1. Extending from `RemoteableServlet`.
2. Using a `@RestMethod(name=PROXY)` annotation on a Java method.

The `RemoteableServlet` class is a simple specialized servlet with an abstract `getServiceMap()` method to define the server-side POJOs:

@RestResource( path="/remote" ) public class SampleRemoteableServlet extends RemoteableServlet { // Our server-side POJO. AddressBook addressBook = new AddressBook(); @Override /* RemoteableServlet */ protected Map<Class<?>,Object> getServiceMap() throws Exception { Map<Class<?>,Object> m = new LinkedHashMap<Class<?>,Object>(); // In this simplified example, we expose the same POJO service under two different interfaces. // One is IAddressBook which only exposes methods defined on that interface, and // the other is AddressBook itself which exposes all methods defined on the class itself (dangerous!). m.put(IAddressBook.class, addressBook); m.put(AddressBook.class, addressBook); return m; } }

The `@RestMethod(name=PROXY)` approach is easier if you only have a single interface you want to expose. You simply define a Java method whose return type is an interface, and return the implementation of that interface:

// Our exposed proxy object. @RestMethod(name=PROXY, path="/addressbookproxy/*") public IAddressBook getProxy() { return addressBook; }

In either case, the proxy communications layer is pure REST. Therefore, in cases where the interface classes are not available on the client side, the same method calls can be made through pure REST calls. This can also aid significantly in debugging, since calls to the remoteable service can be made directly from a browser with no coding involved.

The parameters and return types of the Java methods can be any of the supported serializable and parsable types in POJO Categories. This ends up being WAY more flexible than other proxy interfaces since Juneau can handle so may POJO types out-of-the-box. Most of the time you don't even need to modify your existing Java implementation code.

The `RemoteableServlet` class itself shows how sophisticated REST interfaces can be built on the Juneau RestServlet API using very little code. The class consists of only 53 lines of code, yet is a sophisticated discoverable and self-documenting REST interface. And since the remote proxy API is built on top of REST, it can be debugged using just a browser.

The requirements for a method to be callable through a remoteable service are:

- The method must be public.
- The parameter and return types must be serializable and parsable. Parameterized types are supported.
- Methods can throw `Throwables` with public no-arg or single-arg-string constructors which will be automatically recreated on the client side.

###### Additional Information

- org.apache.juneau.rest.remoteable - Juneau Remoteable API Javadocs.

#### 3.1.2 - Using with Spring or other Injection frameworks

The Juneau REST server API is compatible with dependency injection frameworks such as Spring.

The important class is the {@link org.apache.juneau.rest.RestResourceResolver} class which is used to resolve child servlet/resource implementation classes inside parent contexts. In other words, it's used for resolving {@link org.apache.juneau.rest.annotation.RestResource#children() @RestResource.children()} instances.

The general approach starts with defining a resolver that uses the Spring application context for resolution:

public class SpringRestResourceResolver extends RestResourceResolverSimple { private final ApplicationContext appContext; public SpringRestResourceResolver(ApplicationContext appContext) { this.appContext = appContext; } @Override /* RestResourceResolverSimple */ public Object resolve(Class<?> resourceType, RestConfig config) throws Exception { Object resource = appContext.getBean(type); // If Spring can't resolve it, use default resolution (just look for no-arg constructor). if (resource == null) { resource = super.resolve(resourceType, config); } return resource; } }

Next, define the Spring configuration to return our resolver:

@Configuration public abstract class MySpringConfiguration { @Autowired private static ApplicationContext appContext; public static ApplicationContext getAppContext(){ return appContext; } public static void setAppContext(ApplicationContext appContext){ MySpringConfiguration.appContext = appContext; } @Bean public RestResourceResolver restResourceResolver(ApplicationContext appContext) { return new SpringRestResourceResolver(appContext); } }

Finally, define your `Root` resource with a constructor that takes in our rest resource resolver and sets it on the config object during initialization.

@RestResource( children={ ... } ) public class Root extends RestServletGroupDefault { private final RestResourceResolver resolver; @Inject public Root(RestResourceResolver resolver) { this.resolver = resolver; } @RestHook(INIT) public void initSpring(RestConfig config) throws Exception { config.setResourceResolver(resolver); } }

After that, just define constructors on your child resources to take in Spring beans:

@RestResource( path="/child" ) public class MyChildResource extends RestServletDefault { private final Bean1 bean1; private final Bean2 bean2; private final Bean3 bean3; @Inject public MyChildResource(Bean1 bean1, Bean2 bean2, Bean3 bean3) { this.bean1 = bean1; this.bean2 = bean2; this.bean3 = bean3; }

#### 3.1.3 - Using HTTP/2 features

Juneau is built as a veneer on top of the Servlet API, allowing you to use low-level Servlet APIs whenever needed. This allows you to take advantage of the newest HTTP/2 features implemented in the new Servlet 4.0 specification.

Coming soon (sorry)

### 3.2 - juneau-rest-server-jaxrs

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-rest-server-jaxrs</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-rest-server-jaxrs-7.0.0.jar

###### OSGi Module

org.apache.juneau.rest.server_7.0.0.jar

The `juneau-rest-server-jaxrs` library provides an implementation of a `MessageBodyReader` and `MessageBodyWriter` to allow any of the Juneau serializers and parsers to be used in a JAX/RS environment.

###### Additional Information

- org.apache.juneau.rest.jaxrs - Juneau JAX/RS extensions.

### 3.3 - juneau-rest-client

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-rest-client</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-rest-client-7.0.0.jar

###### OSGi Module

org.apache.juneau.rest.client_7.0.0.jar

The REST client API provides the ability to access remote REST interfaces and transparently convert the input and output to and from POJOs using any of the provided serializers and parsers.

Built upon the Apache HttpClient libraries, it extends that API and provides specialized APIs for working with REST interfaces while maintaining all the functionality available in the HttpClient API.

// Create a reusable JSON client. RestClient client = RestClient.create().build(); // The address of the root resource. String url = "http://localhost:9080/sample/addressBook"; // Do a REST GET against a remote REST interface and convert // the response to an unstructured ObjectMap object. ObjectMap m1 = client.doGet(url).getResponse(ObjectMap.class); // Same as above, except parse the JSON as a bean. AddressBook a2 = client.doGet(url).getResponse(AddressBook.class); // Add a person to the address book. // Use XML as the transport medium. client = RestClient.create().serializer(XmlSerializer.class).parser(XmlSerializer.class).build(); Person p = new Person("Joe Smith", 21); int returnCode = client.doPost(url + "/entries", p).run();

The Client API is also an exhaustive topic on its own. Refer to the additional information for an in-depth examination of the API.

###### Additional Information

- org.apache.juneau.rest.client - Juneau Client API Javadocs.

#### 3.3.1 - Interface proxies against 3rd-party REST interfaces

The `juneau-rest-client` library can also be used to define interface proxies against 3rd-party REST interfaces. This is an extremely powerful feature that allows you to quickly define easy-to-use interfaces against virtually any REST interface.

Similar in concept to remoteable services defined above, but in this case we simply define our interface with special annotations that tell us how to convert input and output to HTTP headers, query parameters, form post parameters, or request/response bodies.

@Remoteable public interface MyProxyInterface { @RemoteMethod(httpMethod=POST, path="/method") String callMyMethod(@Header("E-Tag") UUID etag, @Query("debug") boolean debug, @Body MyPojo pojo); } RestClient client = RestClient.create().build(); MyProxyInterface p = client.getRemoteableProxy(MyProxyInterface.class, "http://hostname/some/rest/interface"); String response = p.callMyMethod(UUID.generate(), true, new MyPojo());

The Java method arguments can be annotated with any of the following:

- {@link org.apache.juneau.remoteable.Query @Query} - A URL query parameter.
  The argument can be any of the following types:
  - Any serializable POJO - Converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
  - `Map<String,Object>` - Individual name-value pairs.
    Values are converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
  - `String` - Treated as a query string.
- {@link org.apache.juneau.remoteable.QueryIfNE @QueryIfNE} - Same as @Query except skips the value if it's null/empty.
- {@link org.apache.juneau.remoteable.FormData @FormData} - A form-data parameter.
  Note that this is only available if the HTTP method is `POST`.
  The argument can be any of the following types:
  - Any serializable POJO - Converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
  - {@link org.apache.juneau.rest.client.NameValuePairs} - Individual name-value pairs.
  - `Map<String,Object>` - Individual name-value pairs.
    Values are converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
- {@link org.apache.juneau.remoteable.FormDataIfNE @FormDataIfNE} - Same as @FormData except skips the value if it's null/empty.
- {@link org.apache.juneau.remoteable.Header @Header} - A request header.
  The argument can be any of the following types:
  - Any serializable POJO - Converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
  - `Map<String,Object>` - Individual name-value pairs.
    Values are converted to text using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer#serializePart(Object, Boolean, Boolean)}.
- {@link org.apache.juneau.remoteable.HeaderIfNE @HeaderIfNE} - Same as @Header except skips the value if it's null/empty.
- {@link org.apache.juneau.remoteable.Body @Body} - The HTTP request body.
  The argument can be any of the following types:
  - Any serializable POJO - Converted to text/bytes using the {@link org.apache.juneau.serializer.Serializer} registered with the `RestClient`.
  - {@link java.io.Reader} - Raw contents of reader will be serialized to remote resource.
  - {@link java.io.InputStream} - Raw contents of input stream will be serialized to remote resource.
  - {@link org.apache.http.HttpEntity} - Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
  - {@link org.apache.juneau.rest.client.NameValuePairs} - Converted to a URL-encoded FORM post.

The return type of the Java method can be any of the following:

- void - Don't parse any response.
  Note that the method will still throw a runtime exception if an error HTTP status is returned.
- Any parsable POJO - The body of the response will be converted to the POJO using the parser defined on the `RestClient`.
- `HttpResponse` - Returns the raw `HttpResponse` returned by the inner `HttpClient`.
- {@link java.io.Reader} - Returns access to the raw reader of the response.
  Note that if you don't want your response parsed as a POJO, you'll want to get the response reader directly.
- {@link java.io.InputStream} - Returns access to the raw input stream of the response.

###### Additional Information

- org.apache.juneau.remoteable - Juneau Remoteable API Javadocs.

## 4 - juneau-microservice

The Microservice Maven artifacts of Juneau consist of the following:

- juneau-microservice-server - Microservice API built on top of Eclipse Jetty.
- juneau-microservice-template - Starting point project for developers to create their own microservices.

Microservices combine all the functionality of the core, server, and client APIs to provide truly powerful and easy-to-use REST interfaces with minimal overhead.

### 4.1 - juneau-microservice-server

###### Maven Dependency

<dependency> <groupId>org.apache.juneau</groupId> <artifactId>juneau-microservice-server</artifactId> <version>7.0.0</version> </dependency>

###### Java Library

juneau-microservice-server-7.0.0.jar

###### OSGi Module

org.apache.juneau.microservice.server_7.0.0.jar

The `juneau-microservice-server` library consists of the following classes used for constructing stand-alone microservices as executable jars or inside docker containers:

- {@link org.apache.juneau.microservice.Microservice} - Defines basic lifecycle methods for microservices in general.
  - {@link org.apache.juneau.microservice.RestMicroservice} - Defines additional lifecycle methods for REST microservices.
    Starts up an externally-configured Jetty server, registers servlets, and sets up other features such as logging.
- {@link org.apache.juneau.microservice.Resource} - A subclass of `RestServletDefault` with support for manfest-file and args variables and configured to use the external INI file.
- {@link org.apache.juneau.microservice.ResourceGroup} - A subclass of `RestServletGroupDefault` with support for manfest-file and args variables and configured to use the external INI file.

The following predefined resource classes are also provided for easy inclusion into your microservice:

- {@link org.apache.juneau.microservice.resources.ConfigResource} - View and modify the external INI config file.
- {@link org.apache.juneau.microservice.resources.DirectoryResource} - View and modify file system directories.
- {@link org.apache.juneau.microservice.resources.LogsResource} - View and control generated log files.
- {@link org.apache.juneau.microservice.resources.SampleRootResource} - A sample root resource class to get started from.
- {@link org.apache.juneau.microservice.resources.ShutdownResource} - Shutdown and/or restart the JVM.

###### Additional Information

- org.apache.juneau.microservice - Juneau Microservice API Javadocs.

### 4.2 - juneau-microservice-template

###### Archive File

my-microservice-7.0.0.zip

The `juneau-microservice-template` project creates an archive file containing an Eclipse project that can be loaded into an Eclipse workspace to quickly get a microservice project up-and-running.

###### Instructions on how to install template project

Download the `my-microservice-7.0.0.zip` file from the downloads page (located in the binaries) and import it into your workspace as an existing project:

Select the archive file and import the project:

Once loaded, you should see the following project structure:

The microservice can be started from the `my-microservice.launch` file. It will start up the microservice on port 10000 which you can then view through a browser:

Now play with it!

## 5 - juneau-examples

The Example Maven artifacts of Juneau consist of the following:

- juneau-examples-core - Examples for the core APIs.
- juneau-examples-rest - Examples for the REST server/client/microservice APIs.

### 5.1 - juneau-examples-core

###### Archive File

juneau-examples-core-7.0.0.zip

The `juneau-examples-core` project contains various code examples for using the core APIs.

The project project can be loaded into your workspace by importing the `juneau-examples-core-7.0.0.zip` file.

###### Instructions on how to install juneau-examples-core project

Download the `juneau-examples-core-7.0.0.zip` file from the downloads page (located in the binaries) and import it into your workspace as an existing project:

Select the archive file and import the project:

Once loaded, you should see the following project structure:

The Core library samples are currently a work-in-progress so there's not much here yet. This section will be updated as new code is added.

### 5.2 - juneau-examples-rest

###### Archive File

juneau-examples-rest-7.0.0.zip

The `juneau-examples-rest` project includes everything you need to start the Samples REST microservice in an Eclipse workspace.

This project is packaged as a Juneau Microservice project that allows REST resources to be started using embedded Jetty.

###### Instructions on how to install juneau-examples-rest project

Download the `juneau-examples-rest-7.0.0.zip` file from the downloads page (located in the binaries) and import it into your workspace as an existing project:

Select the archive file and import the project:

Once loaded, you should see the following project structure:

The microservice can be started from the `juneau-examples-rest.launch` file. It will start up the microservice on port 10000 which you can then view through a browser:

#### 5.2.1 - RootResources

The RootResources class is the main page for the REST microservice. It serves as the jumping-off point for the other resources.

The class hierarchy for this class is:

- {@link org.apache.juneau.rest.RestServlet org.apache.juneau.rest.RestServlet}
  Contains all the REST servlet logic.
  - {@link org.apache.juneau.rest.RestServletDefault org.apache.juneau.rest.RestServletDefault}
    Defines default serializers and parsers, and OPTIONs page logic.
    - {@link org.apache.juneau.rest.RestServletGroupDefault org.apache.juneau.rest.RestServletGroupDefault}
      Specialized subclass for grouping other resources
      - {@link org.apache.juneau.microservice.ResourceGroup org.apache.juneau.microservice.ResourceGroup}
        Specialized subclass when using the Microservice API.
        - `org.apache.juneau.rest.samples.RootResources`

Pointing a browser to the resource shows the following:

The RootResources class can also be defined as a servlet in a web.xml file:

<web-app version='2.3'> <servlet> <servlet-name>RootResources</servlet-name> <servlet-class>org.apache.juneau.rest.samples.RootResources</servlet-class> </servlet> <servlet-mapping> <servlet-name>RootResources</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>

The RootResources class consists entirely of annotations:

###### RootResources.java

/** * Sample REST resource showing how to implement a "router" resource page. */ @RestResource( path="/", messages="nls/RootResources", htmldoc=@HtmlDoc( navlinks={ "options: ?method=OPTIONS" } ), children={ HelloWorldResource.class, MethodExampleResource.class, RequestEchoResource.class, TempDirResource.class, AddressBookResource.class, SampleRemoteableServlet.class, PhotosResource.class, AtomFeedResource.class, JsonSchemaResource.class, SqlQueryResource.class, TumblrParserResource.class, CodeFormatterResource.class, UrlEncodedFormResource.class, SourceResource.class, ConfigResource.class, LogsResource.class, DockerRegistryResource.class, ShutdownResource.class } ) public class RootResources extends ResourceGroup { private static final long serialVersionUID = 1L; }

The resource bundle contains the localized strings for the resource:

###### RootResources.properties

#-------------------------------------------------------------------------------- # RootResources labels #-------------------------------------------------------------------------------- title = Root resources description = This is an example of a router resource that is used to access other resources.

The title and description keys identify the localized values return by the {@link org.apache.juneau.rest.RestRequest#getServletTitle()} and {@link org.apache.juneau.rest.RestRequest#getServletDescription()} methods.

The children annotation defines the child resources of this router resource. These are resources whose paths are relative to the parent resource.

Child resources must also be subclasses of {@link org.apache.juneau.rest.RestServlet}, and must specify a {@link org.apache.juneau.rest.annotation.RestResource#path()} annotation to identify the subpath of the child. For example, the HelloWorldResource class is annotated as follows:

###### HelloWorldResource.java

@RestResource(messages="nls/HelloWorldResource", path="/helloWorld") public class HelloWorldResource extends Resource {

It should be noted that child resources do not need to be defined this way. They could also be defined as servlets in the same way as the root resource. The children annotation approach simply makes it easier to define them without having to touch the web.xml file again. Child resources can also be defined programmatically by using the {@link org.apache.juneau.rest.RestConfig#addChildResources(Class[])} method.

Note that these router pages can be arbitrarily nested deep. You can define many levels of router pages for arbitrarily hierarchical REST interfaces.

- Let's step back and describe what's going on here:
  During servlet initialization of the RootResources object, the toolkit looks for the @RestResource.children() annotation. If it finds it, it instantiates instances of each class and recursively performs servlet initialization on them. It then associates the child resource with the parent by the name specified by the @RestResource.path() annotation on the child class. When a request for the child URL (/helloWorld) is received, the RootResources servlet gets the request and sees that the URL remainder matches one of its child resources. It then forwards the request to the child resource for processing. The request passed to the child resource is the same as if the child resource had been deployed independently (e.g. path-info, resource-URI, and so forth).

#### 5.2.2 - HelloWorldResource

The HelloWorldResource class is a simple resource that prints a "Hello world!" message.

###### HelloWorldResource.java

/** * Sample REST resource that prints out a simple "Hello world!" message. */ @RestResource( messages="nls/HelloWorldResource", path="/helloWorld", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class HelloWorldResource extends Resource { private static final long serialVersionUID = 1L; /** GET request handler */ @RestMethod(name=GET, path="/*") public String sayHello() { return "Hello world!"; } }

###### HelloWorldResource.properties

#-------------------------------------------------------------------------------- # HelloWorldResource labels #-------------------------------------------------------------------------------- title = Hello World sample resource description = Simplest possible resource sayHello.summary = Responds with "Hello world!"

The class hierarchy for this class is:

- {@link org.apache.juneau.rest.RestServlet org.apache.juneau.rest.RestServlet}
  Contains all the REST servlet logic.
  - {@link org.apache.juneau.rest.RestServletDefault org.apache.juneau.rest.RestServletDefault}
    Defines default serializers and parsers, and OPTIONs page logic.
    - {@link org.apache.juneau.microservice.Resource org.apache.juneau.microservice.Resource}
      Specialized subclass when using the Microservice API.
      - `org.apache.juneau.rest.samples.HelloWorldResource`

Pointing a browser to the resource shows the following:

Using the special &Accept=text/json and &plainText=true parameters allows us to see this page rendered as JSON:

#### 5.2.3 - MethodExampleResource

The MethodExampleResource class provides examples of the following:

- Using the {@link org.apache.juneau.rest.Redirect} object to perform redirections.
- Using the various Java method parameter annotations to retrieve request attributes, parameters, etc.
- Using the annotation programmatic equivalents on the {@link org.apache.juneau.rest.RestRequest} object.
- Setting response POJOs by either returning them or using the {@link org.apache.juneau.rest.RestResponse#setOutput(Object)} method.

The resource is provided to show how various HTTP entities (e.g. parameters, headers) can be accessed as either annotated Java parameters, or through methods on the RestRequest object.

###### MethodExampleResource.java

/** * Sample REST resource that shows how to define REST methods and OPTIONS pages */ @RestResource( path="/methodExample", messages="nls/MethodExampleResource", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class MethodExampleResource extends Resource { private static final long serialVersionUID = 1L; /** Example GET request that redirects to our example method */ @RestMethod(name=GET, path="/") public Redirect doExample() throws Exception { return new Redirect("example1/xxx/123/{0}/xRemainder?q1=123&q2=yyy", UUID.randomUUID()); } /** * Methodology #1 - GET request using annotated attributes. * This approach uses annotated parameters for retrieving input. */ @RestMethod(name=GET, path="/example1/{p1}/{p2}/{p3}/*") public String example1( @Method String method, // HTTP method. @Path String p1, // Path variables. @Path int p2, @Path UUID p3, @Query("q1") int q1, // Query parameters. @Query("q2") String q2, @Query("q3") UUID q3, @PathRemainder String remainder, // Path remainder after pattern match. @Header("Accept-Language") String lang, // Headers. @Header("Accept") String accept, @Header("DNT") int doNotTrack ) { // Send back a simple String response String output = String.format( "method=%s, p1=%s, p2=%d, p3=%s, remainder=%s, q1=%d, q2=%s, q3=%s, lang=%s, accept=%s, dnt=%d", method, p1, p2, p3, remainder, q1, q2, q3, lang, accept, doNotTrack); return output; } /** * Methodology #2 - GET request using methods on RestRequest and RestResponse. * This approach uses low-level request/response objects to perform the same as above. */ @RestMethod(name=GET, path="/example2/{p1}/{p2}/{p3}/*") public String example2( RestRequest req, // A direct subclass of HttpServletRequest. RestResponse res // A direct subclass of HttpServletResponse. ) { // HTTP method. String method = req.getMethod(); // Path variables. RequestPathMatch path = req.getPathMatch(); String p1 = path.get("p1", String.class); int p2 = path.get("p2", int.class); UUID p3 = path.get("p3", UUID.class); // Query parameters. RequestQuery query = req.getQuery(); int q1 = query.get("q1", 0, int.class); String q2 = query.get("q2", String.class); UUID q3 = query.get("q3", UUID.class); // Path remainder after pattern match. String remainder = req.getPathMatch().getRemainder(); // Headers. String lang = req.getHeader("Accept-Language"); String accept = req.getHeader("Accept"); int doNotTrack = req.getHeaders().get("DNT", int.class); // Send back a simple String response String output = String.format( "method=%s, p1=%s, p2=%d, p3=%s, remainder=%s, q1=%d, q2=%s, q3=%s, lang=%s, accept=%s, dnt=%d", method, p1, p2, p3, remainder, q1, q2, q3, lang, accept, doNotTrack); res.setOutput(output); // Or use getWriter(). } /** * Methodology #3 - GET request using special objects. * This approach uses intermediate-level APIs. * The framework recognizes the parameter types and knows how to resolve them. */ @RestMethod(name=GET, path="/example3/{p1}/{p2}/{p3}/*") public String example3( HttpMethod method, // HTTP method. RequestPathMatch path, // Path variables. RequestQuery query, // Query parameters. RequestHeaders headers, // Headers. AcceptLanguage lang, // Specific header classes. Accept accept ) { // Path variables. String p1 = path.get("p1", String.class); int p2 = path.get("p2", int.class); UUID p3 = path.get("p3", UUID.class); // Query parameters. int q1 = query.get("q1", 0, int.class); String q2 = query.get("q2", String.class); UUID q3 = query.get("q3", UUID.class); // Path remainder after pattern match. String remainder = path.getRemainder(); // Headers. int doNotTrack = headers.get("DNT", int.class); // Send back a simple String response String output = String.format( "method=%s, p1=%s, p2=%d, p3=%s, remainder=%s, q1=%d, q2=%s, q3=%s, lang=%s, accept=%s, dnt=%d", method, p1, p2, p3, remainder, q1, q2, q3, lang, accept, doNotTrack); res.setOutput(output); } }

The class consists of 4 methods:

- doExample()
  The root page.
  Performs a simple redirection to the doGetExample1() method using a {@link org.apache.juneau.rest.Redirect} object.
- example1()
  Shows how to use the following annotations:
  - {@link org.apache.juneau.rest.annotation.Path @Path}
  - {@link org.apache.juneau.rest.annotation.Query @Query}
  - {@link org.apache.juneau.rest.annotation.Header @Header}
  - {@link org.apache.juneau.rest.annotation.Method @Method}
  - {@link org.apache.juneau.rest.annotation.PathRemainder @PathRemainder}
  Method returns a POJO to be serialized as the output.
- example2()
  Identical to doGetExample1() but shows how to use the {@link org.apache.juneau.rest.RestRequest} and {@link org.apache.juneau.rest.RestResponse} objects:
  - {@link org.apache.juneau.rest.RestRequest#getPathMatch()}
  - {@link org.apache.juneau.rest.RestRequest#getQuery()}
  - {@link org.apache.juneau.rest.RestRequest#getFormData()}
  - {@link org.apache.juneau.rest.RestRequest#getHeaders()}
  - {@link org.apache.juneau.rest.RestRequest#getMethod()}
  - {@link org.apache.juneau.rest.RequestPathMatch#getRemainder()}
  Method sets the POJO to be serialized using the {@link org.apache.juneau.rest.RestResponse#setOutput(Object)} method.
- example3()
  Identical to doGetExample1() but uses automatically resolved parameters based on class type.
  Juneau automatically recognizes specific class types such as common header types and automatically resolves them to objects for you.
  See Rest Resources / Method Signature for the list of all automatically support parameter types, and {@link org.apache.juneau.rest.annotation.RestResource#paramResolvers() @RestResource.paramResolvers()} for defining your own custom parameter type resolvers.

There's a lot going on in this method. Notice how you're able to access URL attributes, parameters, headers, and content as parsed POJOs. All the input parsing is already done by the toolkit. You simply work with the resulting POJOs.

As you might notice, using annotations typically results in fewer lines of code and are therefore usually preferred over the API approach, but both are equally valid.

When you visit this page through the router page, you can see the following (after the automatic redirection occurs):

Notice how the conversion to POJOs is automatically done for us, even for non-standard POJOs such as UUID.

###### Self-documenting design through Swagger OPTIONS pages

One of the main features of Juneau is that it produces OPTIONS pages for self-documenting design (i.e. REST interfaces that document themselves).

Much of the information populated on the OPTIONS page is determined through reflection. This basic information can be augmented with information defined through:

- Annotations - An example of this was shown in the `SystemPropertiesResource` example above.
  Localized strings can be pulled from resource bundles using the `$L` localization variable.
- Resource bundle properties - Described in detail in this section.
- Swagger JSON files with the same name and location as the resource class (e.g. `MethodExampleResource.json`).
  Localized versions are defined by appending the locale to the file name (e.g. `MethodExampleResource_ja_JP.json`);

OPTIONS pages are simply serialized {@link org.apache.juneau.dto.swagger.Swagger} DTO beans. Localized versions of these beans are retrieved using the {@link org.apache.juneau.rest.RestRequest#getSwagger()} method.

To define an OPTIONS request handler, the {@link org.apache.juneau.rest.RestServletDefault} class defines the following Java method:

###### RestServletDefault.java

/** OPTIONS request handler */ @RestMethod(name=OPTIONS, path="/*") public Swagger getOptions(RestRequest req) { return req.getSwagger(); }

The OPTIONS link that you see on the HTML version of the page is created through a property defined by the {@link org.apache.juneau.html.HtmlDocSerializer} class and specified on the resource class annotation:

@RestResource( htmldoc=@HtmlDoc( navlinks={ "options: servlet:/?method=OPTIONS" } ) )

This simply creates a link that's the same URL as the resource URL appended with "?method=OPTIONS", which is a shorthand way that the framework provides of defining overloaded GET requests. Links using relative or absolute URLs can be defined this way.

Metadata about the servlet class is combined with localized strings from a properties file associated through a `@RestResource(messages="nls/MethodExampleResources")` annotation. The properties file contains localized descriptions for the resource, resource methods, and method parameters.

###### MethodExampleResource.properties

#-------------------------------------------------------------------------------- # MethodExampleResource labels #-------------------------------------------------------------------------------- title = A simple REST method example resource doGetExample.summary = Sample GET method doGetExample1.summary = Sample GET using annotations doGetExample1.req.path.a1.description = Sample variable doGetExample1.req.path.a2.description = Sample variable doGetExample1.req.path.a3.description = Sample variable doGetExample1.req.query.p1.description = Sample parameter doGetExample1.req.query.p2.description = Sample parameter doGetExample1.req.query.p3.description = Sample parameter doGetExample1.req.header.Accept-Language.description = Sample header doGetExample1.req.header.DNT.description = Sample header doGetExample2.summary = Sample GET using Java APIs doGetExample2.req.path.a1.description = Sample variable doGetExample2.req.path.a2.description = Sample variable doGetExample2.req.path.a3.description = Sample variable doGetExample2.req.query.p1.description = Sample parameter doGetExample2.req.query.p2.description = Sample parameter doGetExample2.req.query.p3.description = Sample parameter doGetExample2.req.header.Accept-Language.description = Sample header doGetExample2.req.header.DNT.description = Sample header getOptions.summary = View these options

Clicking the options link on the page presents you with information about how to use this resource:

This page (like any other) can also be rendered in JSON or XML by using the &Accept URL parameter.

#### 5.2.4 - UrlEncodedFormResource

The UrlEncodedFormResource class provides examples of the following:

- How to use form entry beans to process form POSTs.
- How to use the {@link org.apache.juneau.rest.RestRequest#getReaderResource(String)} method to serve up static files with embedded string variables.

The class is shown below:

###### UrlEncodedFormResource.java

/** * Sample REST resource for loading URL-Encoded form posts into POJOs. */ @RestResource( path="/urlEncodedForm", messages="nls/UrlEncodedFormResource" ) public class UrlEncodedFormResource extends Resource { private static final long serialVersionUID = 1L; /** GET request handler */ @RestMethod(name=GET, path="/") public ReaderResource doGet(RestRequest req) throws IOException { return req.getReaderResource("UrlEncodedForm.html", true); } /** POST request handler */ @RestMethod(name=POST, path="/") public Object doPost(@Body FormInputBean input) throws Exception { // Just mirror back the request return input; } public static class FormInputBean { public String aString; public int aNumber; @BeanProperty(pojoSwaps=CalendarSwap.ISO8601DT.class) public Calendar aDate; } }

The {@link org.apache.juneau.rest.RestRequest#getReaderResource(String,boolean)} method pulls in the following file located in the same package as the class:

###### UrlEncodedForm.html

TODO - Needs update

<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <style type='text/css'> @import '$R{servletURI}/style.css'; </style> <script type="text/javascript"> // Load results from IFrame into this document. function loadResults(buff) { var doc = buff.contentDocument || buff.contentWindow.document; var buffBody = doc.getElementById('data'); document.getElementById('results').innerHTML = buffBody.innerHTML; } </script> </head> <body> <h1>$R{servletTitle}</h1> <h2>$R{servletDescription}</h2> <div class='data'> <form id='form' action='$R{servletURI}' method='POST' target='buff'> <table> <tr> <th>$L{aString}</th> <td><input name="aString" type="text"></td> </tr> <tr> <th>$L{aNumber}</th> <td><input name="aNumber" type="number"></td> </tr> <tr> <th>$L{aDate}</th> <td><input name="aDate" type="datetime"> (ISO8601, e.g. "<code>2001-07-04T15:30:45Z</code>")</td> </tr> <tr> <td colspan='2' align='right'><button type="submit">$L{submit}</button></td> </tr> </table> </form> <br> <div id='results'> </div> </div> <iframe name='buff' style='display:none' onload="parent.loadResults(this)"></iframe> </body> </html>

The $L variables are string variable that pull in localized values from the resource bundle:

###### UrlEncodedFormResource.properties

#-------------------------------------------------------------------------------- # UrlEncodedFormResource labels #-------------------------------------------------------------------------------- title = URL-Encoded Form Post Example description = Shows how URL-Encoded form input can be loaded into POJOs. POJO is simply echoed back. aString = A String: aNumber = A Number: aDate = A Date: submit = submit

The $R variables are request string variables. In this case, $R{servletTitle} and $R{servletDescription} resolve to the values returned by {@link org.apache.juneau.rest.RestRequest#getServletTitle()} and {@link org.apache.juneau.rest.RestRequest#getServletDescription()}.

Pointing a browser to the resource shows the following:

Entering some values and clicking submit causes the form bean to be populated and returned back as a POJO response:

Another option is to construct the HTML form in Java using HTML5 beans. This is arguably a better approach since it's typically cleaner with less code, and the headers/links are already part of the page.

import static org.apache.juneau.dto.html5.HtmlBuilder.*; /** GET request handler */ @RestMethod(name=GET, path="/") public Div doGet(RestRequest req) { return div( script("text/javascript", "\n // Load results from IFrame into this document." +"\n function loadResults(buff) {" +"\n var doc = buff.contentDocument || buff.contentWindow.document;" +"\n var buffBody = doc.getElementById('data');" +"\n document.getElementById('results').innerHTML = buffBody.innerHTML;" +"\n }" ), form().id("form").action(req.getServletURI()).method(POST).target("buff").children( table( tr( th(req.getMessage("aString")), td(input().name("aString").type("text")) ), tr( th(req.getMessage("aNumber")), td(input().name("aNumber").type("number")) ), tr( th(req.getMessage("aDate")), td(input().name("aDate").type("datetime"), " (ISO8601, e.g. ", code("2001-07-04T15:30:45Z"), \" )") ), tr( td().colspan(2).style("text-align:right").children( button("submit", req.getMessage("submit")) ) ) ) ), br(), div().id("results"), iframe().name("buff").style("display:none").onload("parent.loadResults(this)") ); }

###### Additional Information

- {@link org.apache.juneau.rest.RestConfig#addVars(Class[])} - Servlet and request variables.
- {@link org.apache.juneau.rest.RestCallHandler#getSessionObjects(RestRequest)} - Var resolver session objects.

#### 5.2.5 - RequestEchoResource

The RequestEchoResource class shows how existing complex POJOs can be serialized to a variety of content types. The example simply takes the incoming HttpServletRequest object and serializes it.

It provides examples of the following:

- Using the {@link org.apache.juneau.rest.annotation.RestResource#properties() @RestResource.properties()} annotation to set serializer properties.
- Using the {@link org.apache.juneau.rest.annotation.RestResource#beanFilters() @RestResource.beanFilters()} and {@link org.apache.juneau.rest.annotation.RestResource#pojoSwaps() @RestResource.pojoSwaps()} annotations to set serializer transforms.
- Using the {@link org.apache.juneau.rest.annotation.Properties @Properties} annotation to set serializers properties programmatically on a request.

The class is shown below:

###### RequestEchoResource.java

/** * Sample REST resource for echoing HttpServletRequests back to the browser */ @RestResource( path="/echo", messages="nls/RequestEchoResource", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ), properties={ @Property(name=SERIALIZER_maxDepth, value="10"), @Property(name=SERIALIZER_detectRecursions, value="true") }, beanFilters={ // Interpret these as their parent classes, not subclasses HttpServletRequest.class, HttpSession.class, ServletContext.class, }, pojoSwaps={ // Add a special POJO swap for Enumerations EnumerationSwap.class } ) public class RequestEchoResource extends Resource { /** GET request handler */ @RestMethod(name=GET, path="/*", converters={Queryable.class,Traversable.class}) public HttpServletRequest doGet(RestRequest req, RestResponse res, @Properties ObjectMap properties) { // Set the HtmlDocSerializer title programmatically. res.setPageTitle(req.getPathInfo()); // Just echo the request back as the response. return req; } }

Again, there's a lot going on here that's new that requires some explanation. The HttpServletRequest object is not a tree-shaped POJO model. Instead, it contains lots of loops that can cause stack overflow errors if you were to try to serialize it as-is. Also, you want to look only at the properties defined on the HttpServletRequest class, not implementation-specific (i.e. WAS or Jetty) fields which can get messy.

The {@link org.apache.juneau.rest.annotation.RestResource#properties() @RestResource.properties()}, {@link org.apache.juneau.rest.annotation.RestResource#beanFilters() @RestResopurce.beanFilters()}, and {@link org.apache.juneau.rest.annotation.RestResource#pojoSwaps() @RestResopurce.pojoSwaps()} annotations are used to set behavior properties on the resource's underlying bean context, serializers, and parsers. You're using them here to modify the behavior of serialization for all content types. The annotations are functionally equivalent to using the {@link org.apache.juneau.rest.RestConfig} class, as follows:

###### Hypothetical RequestEchoResource.createSerializers() method

/** Override the default rest serializers to add some transforms through an INIT hook*/ @RestHook(INIT) public void init(RestConfig config) throws Exception { // Add bean filters for the HttpServletRequest, HttpSession, and ServletContext objects // so that you don't show vendor-specific properties on subclasses. // Add Enumeration POJO swap to be able to render the contents of Enumeration properties. // The max depth and detect recursion options prevent any possible runaway serializations. // This shouldn't happen, but future JEE APIs may introduce deep hierarchies or loops. config .addBeanFilters(HttpServletRequest.class, HttpSession.class, ServletContext.class) .addPojoSwaps(EnumerationSwap.class) .setProperty(SERIALIZER_maxDepth, 10) .setProperty(SERIALIZER_detectRecursions, true) .setPageLinks("{...}"); }

Note how the annotations generally require fewer lines of code.

Pointing a browser to the resource shows the following:

This gives you an idea of what kinds of POJO models can be serialized, since you are serializing a regular old HttpServletRequest object.

#### 5.2.6 - AddressBookResource

The AddressBookResource class is a proof-of-concept class that shows a true RESTful API using the Juneau REST toolkit. It provides examples of the following:

- How to create RESTful interfaces using only POJOs.
- How to use the {@link org.apache.juneau.xml.annotation.Xml @Xml} and {@link org.apache.juneau.xml.annotation.XmlSchema @XmlSchema} annotations to provide XML namespaces and alter how beans are handled by the XML serializer.
- How to use the {@link org.apache.juneau.jena.annotation.Rdf @Rdf} and {@link org.apache.juneau.xml.annotation.XmlSchema @RdfSchema} annotations to provide XML namespaces and alter how beans are handled by the Jena serializers.
- How to use the {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotation to alter how bean properties are handled by the serializers.
- How to use the {@link org.apache.juneau.rest.annotation.RestMethod#name() RestMethod.name()} annotation to create overloaded methods beyond the standard GET/PUT/POST/DELETE.
- How to augment data in the OPTIONS page.
- How to use the {@link org.apache.juneau.rest.client.RestClient} API to interact with the REST resource using the same POJOs used to create the server-side API.
- How to interact with the REST resource using only a browser.
- Using the {@link org.apache.juneau.rest.converters.Traversable} converter to drill down into POJO models.
- Using the {@link org.apache.juneau.rest.converters.Queryable} converter to provide search/view/sort functionality against POJOs.
- Using the {@link org.apache.juneau.rest.converters.Introspectable} converter to invoke methods on POJOs.
- Using proxy interfaces.

Pointing a browser to the resource shows the following:

#### 5.2.6.1 - Classes

The code is straightforward, consisting of the following classes:

- package-info.java - Used to define XML namespaces for POJOs in this package.
- IAddressBook - An interface describing the address book.
- AddressBook - A data structure consisting of a list of `Persons`.
- Person, Address - In-memory representations of people and addresses.
- CreatePerson, CreateAddress - POJOs for creating and updating people and address through the REST interface.
- AddressBookResource - The REST resource class.

- For the sake of brevity, bean properties are defined as public fields instead of the normal getters/setters. Also, the examples are not the most efficient design and are not thread safe.

The package-info.java file is used to define XML and RDF namespaces on beans and properties in this package. Here you define a default XML and RDF namespaces and URL mappings for namespace short-names used throughout this package. It should be noted that these features are entirely optional, and there are often several ways of defining these namespaces.

###### package-info.java

// XML and RDF namespaces used in this package @Xml(ns="ab", namespaces={ @XmlNs(name="ab", uri="http://www.apache.org/addressBook/"), @XmlNs(name="per", uri="http://www.apache.org/person/"), @XmlNs(name="addr", uri="http://www.apache.org/address/"), @XmlNs(name="mail", uri="http://www.apache.org/mail/") } ) @Rdf(ns="ab", namespaces={ @RdfNs(name="ab", uri="http://www.apache.org/addressBook/"), @RdfNs(name="per", uri="http://www.apache.org/person/"), @RdfNs(name="addr", uri="http://www.apache.org/address/"), @RdfNs(name="mail", uri="http://www.apache.org/mail/") } ) package org.apache.juneau.examples.addressBook; import org.apache.juneau.xml.annotation.*;

Our address book uses the following interface:

###### IAddressBook.java

/** * Interface used to help illustrate proxy interfaces. * See {@link SampleRemoteableServlet}. */ public interface IAddressBook { /** Return all people in the address book */ List<Person> getPeople(); /** Return all addresses in the address book */ List<Address> getAddresses(); /** Create a person in this address book */ Person createPerson(CreatePerson cp) throws Exception; /** Find a person by id */ Person findPerson(int id); /** Find an address by id */ Address findAddress(int id); /** Find a person by address id */ Person findPersonWithAddress(int id); /** Remove a person by id */ Person removePerson(int id); }

###### Notes

- You interface an interface for our address book so that you can later use it to demonstrate the proxy interface support.

The AddressBook class is our address book. It maintains a list of Person objects with some additional convenience methods:

###### AddressBook.java

/** Address book bean */ public class AddressBook extends LinkedList<Person> implements IAddressBook { // The URL of this resource private URI uri; /** Bean constructor - Needed for instantiating on client side */ public AddressBook () {} /** Normal constructor - Needed for instantiating on server side */ public AddressBook (URI uri) {...} @Override /* IAddressBook */ public List<Person> getPeople() { return this; } @Override /* IAddressBook */ public Person createPerson(CreatePerson cp) throws Exception { Person p = new Person(uri, cp); add(p); return p; } @Override /* IAddressBook */ public Person findPerson(int id) { for (Person p : this) if (p.id == id) return p; return null; } @Override /* IAddressBook */ public Address findAddress(int id) { for (Person p : this) for (Address a : p.addresses) if (a.id == id) return a; return null; } @Override /* IAddressBook */ public Person findPersonWithAddress(int id) { for (Person p : this) for (Address a : p.addresses) if (a.id == id) return p; return null; } @Override /* IAddressBook */ public List<Address> getAddresses() { Set<Address> s = new LinkedHashSet<Address>(); for (Person p : this) for (Address a : p.addresses) s.add(a); return new ArrayList<Address>(s); } @Override /* IAddressBook */ public Person removePerson(int id) { Person p = findPerson(id); if (p != null) remove(p); return p; } /** Utility method */ public static Calendar toCalendar(String birthDate) throws Exception { Calendar c = new GregorianCalendar(); c.setTime(DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse(birthDate)); return c; } }

###### Notes

- The `@Xml(elementName="addressBook")` annotation tells the toolkit that when serialized as XML, the element name is <addressBook>. Without this annotation, the element would revert to the generalized <array> tag.
- The separate constructors are implementation specific and are needed because you're going to be using this class in two ways, since you'll be demonstrating the client code as well as the server code, and it eliminates having to define separate client-side and server-side POJOs:
  1. The normal constructor is used to programmatically create this object in the REST servlet code.
  2. The no-arg constructor is used by the Juneau parsers to construct this object in our client side code.

The Person bean is defined as follows:

###### Person.java

/** Person bean */ @Xml(ns="per") @Rdf(prefix="per") @Bean(typeName="person") public class Person { private static int nextPersonId = 1; // Bean properties. @Rdf(beanUri=true) public URI uri; public URI addressBookUri; public String id; public String name; @BeanProperty(swap=CalendarSwap.Medium.class) public Calendar birthDate; public LinkedList<Address> addresses = new LinkedList<Address>(); /** Bean constructor - Needed for instantiating on server side */ public Person() {} /** Normal constructor - Needed for instantiating on client side */ public Person(URI addressBookUri, CreatePerson cp) throws Exception { this.id = nextPersonId++; this.addressBookUri = addressBookUri; if (addressBookUri != null) this.uri = addressBookUri.resolve("people/" + id); this.name = cp.name; this.birthDate = cp.birthDate; for (CreateAddress ca : cp.addresses) this.addresses.add(new Address(addressBookUri, uri, ca)); } /** Extra read-only bean property */ public int getAge() { return new GregorianCalendar().get(Calendar.YEAR) - birthDate.get(Calendar.YEAR); } /** Convenience method - Add an address for this person */ public Address createAddress(CreateAddress ca) throws Exception { Address a = new Address(addressBookUri, uri, ca); addresses.add(a); return a; } /** Extra method (for method invocation example) */ public String sayHello(String toPerson, int age) { return name + " says hello to " + toPerson + " who is " + age + " years old"; } }

###### Notes

- The ns="per" annotations override the default "ab" namespace defined on the package. It applies to this class and all properties of this class.
- The `@Rdf(beanUri=true)` annotation identifies the uri property as the resource URI for this resource. This property has special meaning for the RDF serializer. The RDF serializer uses this property for the value of the rdf:resource attribute.
- The `@BeanProperty(swap=CalendarSwap.Medium.class)` annotation causes the date field to be serialized in the format "MM dd, yyyy". This could have also been specified globally on the resource level through the {@link org.apache.juneau.rest.annotation.RestResource#properties} annotation.

The Address bean is defined as follows:

###### Address.java

/** * Address bean */ @Xml(prefix="addr") @Rdf(prefix="addr") @Bean(typeName="address") public class Address { private static int nextAddressId = 1; // Bean properties @Rdf(beanUri=true) public URI uri; public URI personUri; public int id; @Xml(prefix="mail") @Rdf(prefix="mail") public String street, city, state; @Xml(prefix="mail") @Rdf(prefix="mail") public int zip; public boolean isCurrent; /** Bean constructor - Needed for instantiating on client side */ public Address() {} /** Normal constructor - Needed for instantiating on server side */ public Address(URI addressBookUri, URI personUri, CreateAddress ca) throws Exception { this.id = nextAddressId++; if (addressBookUri != null) this.uri = addressBookUri.resolve("addresses/" + id); this.personUri = personUri; this.street = ca.street; this.city = ca.city; this.state = ca.state; this.zip = ca.zip; this.isCurrent = ca.isCurrent; } }

###### Notes

- This class shows how the namespace can be overridden at the property level through the `@Xml(ns="mail")` annotation.

The CreatePerson bean is used as the input data for creating a person.

###### CreatePerson.java

/** Bean for creating a new person */ @Xml(ns="per") @Rdf(ns="addr") @Bean(typeName="person") public class CreatePerson { // Bean properties public String name; @BeanProperty(swap=CalendarSwap.Medium.class) public Calendar birthDate; public LinkedList<CreateAddress> addresses; /** Bean constructor - Needed for instantiating on server side */ public CreatePerson() {} /** Normal constructor - Needed for instantiating on client side */ public CreatePerson(String name, Calendar birthDate, CreateAddress...addresses) {...} }

The CreateAddress bean is used as the input data for creating an address.

###### CreateAddress.java

/** Bean for creating a new address */ @Xml(ns="addr") @Rdf(ns="addr") @Bean(typeName="address") public class CreateAddress { // Bean properties @Xml(ns="mail") @Rdf(ns="mail") public String street, city, state; @Xml(ns="mail") @Rdf(ns="mail") public int zip; public boolean isCurrent; /** Bean constructor -Needed for instantiating on server side */ public CreateAddress() {} /** Normal constructor - Needed for instantiating on client side */ public CreateAddress(String street, String city, String state, int zip, boolean isCurrent) {...} }

The AddressBookResource class is our REST resource class.

###### AddressBookResource.java

/** * Proof-of-concept resource that shows off the capabilities of working with POJO resources. * Consists of an in-memory address book repository. */ @RestResource( path="/addressBook", messages="nls/AddressBookResource", // Links on the HTML rendition page. // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI. // "$C{...}" variables are pulled from the config file. htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS", "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java" } ), // Allow INIT as a method parameter. allowMethodParam="*", // Properties that get applied to all serializers and parsers. properties={ // Use single quotes. @Property(name=SERIALIZER_quoteChar, value="'"), // Make RDF/XML readable. @Property(name=RDF_rdfxml_tab, value="5"), // Make RDF parsable by adding a root node. @Property(name=RDF_addRootProperty, value="true"), // Make URIs absolute so that we can easily reference them on the client side. @Property(name=SERIALIZER_uriResolution, value="ABSOLUTE") // Make the anchor text on URLs be just the path relative to the servlet. @Property(name=HTML_uriAnchorText, value="SERVLET_RELATIVE") }, // Our stylesheet for the HTML rendition. stylesheet="styles/devops.css", // Support GZIP encoding on Accept-Encoding header. encoders=GzipEncoder.class, // Swagger info. contact="{name:'John Smith',email:'john@smith.com'}", license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", version="2.0", termsOfService="You're on your own.", tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page', url:'http://juneau.apache.org'}}]", externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" ) public class AddressBookResource extends ResourceJena { private static final long serialVersionUID = 1L; // The in-memory address book private AddressBook addressBook; @Override /* Servlet */ public void init() { try { // Create the address book addressBook = new AddressBook(java.net.URI.create("servlet:/")); // Add some people to our address book by default addressBook.createPerson( new CreatePerson( "Barack Obama", toCalendar("Aug 4, 1961"), new CreateAddress("1600 Pennsylvania Ave", "Washington", "DC", 20500, true), new CreateAddress("5046 S Greenwood Ave", "Chicago", "IL", 60615, false) ) ); addressBook.createPerson( new CreatePerson( "George Walker Bush", toCalendar("Jul 6, 1946"), new CreateAddress("43 Prairie Chapel Rd", "Crawford", "TX", 76638, true), new CreateAddress("1600 Pennsylvania Ave", "Washington", "DC", 20500, false) ) ); } catch (Exception e) { throw new RuntimeException(e); } } /** * [GET /] * Get root page. */ @RestMethod(name=GET, path="/", converters=Queryable.class ) public Link[] getRoot() throws Exception { return new Link[] { new Link("people", "people"), new Link("addresses", "addresses") }; } /** * [GET /people/*] * Get all people in the address book. * Traversable transforming enabled to allow nodes in returned POJO tree to be addressed. * Introspectable transforming enabled to allow public methods on the returned object to be invoked. */ @RestMethod(name=GET, path="/people/*", converters={Traversable.class,Queryable.class,Introspectable.class} ) public AddressBook getAllPeople() throws Exception { return addressBook; } /** * [GET /people/{id}/*] * Get a single person by ID. * Traversable transforming enabled to allow nodes in returned POJO tree to be addressed. * Introspectable transforming enabled to allow public methods on the returned object to be invoked. */ @RestMethod(name=GET, path="/people/{id}/*", converters={Traversable.class,Queryable.class,Introspectable.class} ) public Person getPerson(@Path int id) throws Exception { return findPerson(id); } /** * [GET /addresses/*] * Get all addresses in the address book. */ @RestMethod(name=GET, path="/addresses/*", converters={Traversable.class,Queryable.class} ) public List<Address> getAllAddresses() throws Exception { return addressBook.getAddresses(); } /** * [GET /addresses/{id}/*] * Get a single address by ID. */ @RestMethod(name=GET, path="/addresses/{id}/*", converters={Traversable.class,Queryable.class} ) public Address getAddress(@Path int id) throws Exception { return findAddress(id); } /** * [POST /people] * Create a new Person bean. */ @RestMethod(name=POST, path="/people", guards=AdminGuard.class ) public Redirect createPerson(@Body CreatePerson cp) throws Exception { Person p = addressBook.createPerson(cp); return new Redirect("people/{0}", p.id); } /** * [POST /people/{id}/addresses] * Create a new Address bean. */ @RestMethod(name=POST, path="/people/{id}/addresses", guards=AdminGuard.class ) public Redirect createAddress(@Path int id, @Body CreateAddress ca) throws Exception { Person p = findPerson(id); Address a = p.createAddress(ca); return new Redirect("addresses/{0}", a.id); } /** * [DELETE /people/{id}] * Delete a Person bean. */ @RestMethod(name=DELETE, path="/people/{id}", guards=AdminGuard.class, ) public String deletePerson(@Path int id) throws Exception { addressBook.removePerson(id); return "DELETE successful"; } /** * [DELETE /addresses/{id}] * Delete an Address bean. */ @RestMethod(name=DELETE, path="/addresses/{id}", guards=AdminGuard.class ) public String deleteAddress(@Path int addressId) throws Exception { Person p = addressBook.findPersonWithAddress(addressId); if (p == null) throw new RestException(SC_NOT_FOUND, "Person not found"); Address a = findAddress(addressId); p.addresses.remove(a); return "DELETE successful"; } /** * [PUT /people/{id}/*] * Change property on Person bean. */ @RestMethod(name=PUT, path="/people/{id}/*", guards=AdminGuard.class ) public String updatePerson(RestRequest req, @Path int id, @PathRemainder String remainder) throws Exception { try { Person p = findPerson(id); PojoRest r = new PojoRest(p); ClassMeta<?> cm = r.getClassMeta(remainder); Object in = req.getBody().asType(cm); r.put(remainder, in); return "PUT successful"; } catch (Exception e) { throw new RestException(SC_BAD_REQUEST, "PUT unsuccessful").initCause(e); } } /** * [PUT /addresses/{id}/*] * Change property on Address bean. */ @RestMethod(name=PUT, path="/addresses/{id}/*", guards=AdminGuard.class ) public String updateAddress(RestRequest req, @Path int id, @PathRemainder String remainder) throws Exception { try { Address a = findAddress(id); PojoRest r = new PojoRest(a); ClassMeta<?> cm = r.getClassMeta(remainder); Object in = req.getBody().asType(cm); r.put(remainder, in); return "PUT successful"; } catch (Exception e) { throw new RestException(SC_BAD_REQUEST, "PUT unsuccessful").initCause(e); } } /** * [INIT /] * Reinitialize this resource. */ @RestMethod(name="INIT", path="/", guards=AdminGuard.class ) public String doInit() throws Exception { init(); return "OK"; } /** * [GET /cognos] * Get data in Cognos/XML format */ @RestMethod(name=GET, path="/cognos") public DataSet getCognosData() throws Exception { // The Cognos metadata Column[] items = { new Column("name", "xs:String", 255), new Column("age", "xs:int"), new Column("numAddresses", "xs:int") .addPojoSwap( new PojoSwap<Person,Integer>() { @Override /* PojoSwap */ public Integer swap(BeanSession session, Person p) { return p.addresses.size(); } } ) }; return new DataSet(items, addressBook, this.getBeanContext()); } /** * [OPTIONS /*] * View resource options */ @Override /* RestServletDefault */ @RestMethod(name=OPTIONS, path="/*") public Swagger getOptions(RestRequest req) { return req.getSwagger(); } /** Convenience method - Find a person by ID */ private Person findPerson(int id) throws RestException { Person p = addressBook.findPerson(id); if (p == null) throw new RestException(SC_NOT_FOUND, "Person not found"); return p; } /** Convenience method - Find an address by ID */ private Address findAddress(int id) throws RestException { Address a = addressBook.findAddress(id); if (a == null) throw new RestException(SC_NOT_FOUND, "Address not found"); return a; } }

###### Notes

- The @RestResource.messages() annotation identifies org/apache/juneau/samples/addressbook/nls/AddressBookResource.properties as the resource bundle for localized message for this class.
- You are setting XML_enableNamespaces to true to enable XML namespaces. By default, XML namespace support is disabled per {@link org.apache.juneau.xml.XmlSerializer#XML_enableNamespaces}, so you have to explicitly enable it on our serializers.
- The XML_autoDetectNamespaces setting is needed to get the XML serializer to add xmlns attributes to the root elements. This causes the XML serializer to scan the POJO objects for namespaces in order to populate the root element. There are other ways to do this, such as explicitly specifying the XML_defaultNamespaceUris setting at either the resource or method level, which might be preferred in high-performance environments. However, XML_autoDetectNamespaces produces the simplest code for our example.
- The updatePerson() and updateAddress() methods use a guard to only allow administrators access. For the sample code, the guard does nothing. It's up to the implementer to decide how to restrict access.
- The updatePerson() and updateAddress() methods use the {@link org.apache.juneau.utils.PojoRest} class to locate and update individual nodes in a POJO tree using the path remainder on the request.
- The doInit() method shows an example of an overloaded method using the @RestMethod(name=INIT) annotation.
- The getOptions() method shows the default OPTIONS page augmented with some additional information.

The OPTIONS page uses the servlet resource bundle to specify the labels so that they're globalizable.

###### AddressBookResource.properties

title = AddressBook sample resource description = Proof-of-concept resource that shows off the capabilities of working with POJO resources getRoot.summary = Get root page getRoot.description = Jumping off page for top-level Person and Address beans. doInit.summary = Reinitialize this resource doInit.description = Resets the address book to the original contents. doInit.res.200.description = Returns the string "OK" getAllPeople.summary = Get all people in the address book getAllPeople.res.200.description = Returns a serialized List<Person> getAllPeople.res.200.examples = {'text/json':"[\n\t{\n\t\turi:'http://hostname/addressBook/person/1',\n\t\taddressBookUri:'http://localhost/addressBook',\n\t\tid:1,\n\t\tname:'John Smith',\n\t\tbirthDate:'Jan 1, 2000',\n\t\taddresses:[\n\t\t\t{\n\t\t\t\turi:'http://localhost/addressBook/addresses/1',\n\t\t\t\tpersonUri:'http://localhost/addressBook/people/1',\n\t\t\t\tid:1,\n\t\t\t\tstreet:'101 Main St',\n\t\t\t\tcity:'Anywhere',\n\t\t\t\tstate:'NY',\n\t\t\t\tzip:12345,\n\t\t\t\tisCurrent:true\n\t\t\t}\n\t\t]\n\t}\n]"} getPerson.summary = Get a single person by ID getPerson.req.path.id.description = Person ID getPerson.req.path.id.type = integer getPerson.res.200.description = Returns a serialized Person bean getPerson.res.200.examples = {'text/json':"{\n\turi:'http://hostname/addressBook/person/1',\n\taddressBookUri:'http://localhost/addressBook',\n\tid:1,\n\tname:'John Smith',\n\tbirthDate:'Jan 1, 2000',\n\taddresses:[\n\t\t{\n\t\t\turi:'http://localhost/addressBook/addresses/1',\n\t\t\tpersonUri:'http://localhost/addressBook/people/1',\n\t\t\tid:1,\n\t\t\tstreet:'101 Main St',\n\t\t\tcity:'Anywhere',\n\t\t\tstate:'NY',\n\t\t\tzip:12345,\n\t\t\tisCurrent:true\n\t\t}\n\t]\n\}"} getPerson.res.404.description = Person ID not found getAllAddresses.summary = Get all addresses in the address book getAllAddresses.res.200.description = Returns a serialized List<Address> getAllAddresses.res.200.examples = {'text/json':"[\n\t{\n\t\turi:'http://localhost/addressBook/addresses/1',\n\t\tpersonUri:'http://localhost/addressBook/people/1',\n\t\tid:1,\n\t\tstreet:'101 Main St',\n\t\tcity:'Anywhere',\n\t\tstate:'NY',\n\t\tzip:12345,\n\t\tisCurrent:true\n\t}\n]"} getAddress.summary = Get a single address by ID getAddress.req.path.id.description = Address ID getAddress.req.path.id.type = integer getAddress.res.200.description = Returns a serialized Address bean getAddress.res.200.examples = {'text/json':"{\n\turi:'http://localhost/addressBook/addresses/1',\n\tpersonUri:'http://localhost/addressBook/people/1',\n\tid:1,\n\tstreet:'101 Main St',\n\tcity:'Anywhere',\n\tstate:'NY',\n\tzip:12345,\n\tisCurrent:true\n}"} getAddress.res.404.description = Address ID not found createPerson.summary = Create a new Person bean createPerson.req.body.description = Serialized CreatePerson bean createPerson.req.body.schema = {example:"{\n\tname:'John Smith',\n\tbirthDate:'Jan 1, 2000',\n\taddresses:[\n\t\t{\n\t\t\tstreet:'101 Main St',\n\t\t\tcity:'Anywhere',\n\t\t\tstate:'NY',\n\t\t\tzip:12345,\n\t\t\tisCurrent:true\n\t\t}\n\t]\n\}"} createPerson.res.307.header.Location.description = URL of new person createAddress.summary = Create a new Address bean createAddress.req.path.id.description = Person ID createAddress.req.path.id.type = integer createAddress.req.body.schema = {example:"{\n\tstreet:'101 Main St',\n\tcity:'Anywhere',\n\tstate:'NY',\n\tzip:12345,\n\tisCurrent:true\n}"} createAddress.res.307.header.Location.description = URL of new address deletePerson.summary = Delete a Person bean deletePerson.req.path.id.description = Person ID deletePerson.req.path.id.type = integer deletePerson.res.200.description = Returns the string "DELETE successful" deletePerson.res.404.description = Person ID not found deleteAddress.summary = Delete an Address bean deleteAddress.req.path.id.description = Address ID deleteAddress.res.200.description = Returns the string "DELETE successful" deleteAddress.res.404.description = Address ID not found updatePerson.summary = Change property on Person bean updatePerson.req.path.id.description = Person ID updatePerson.req.path.id.type = integer updatePerson.req.body.description = Any object matching the field updatePerson.res.200.description = Returns the string "PUT successful" updatePerson.res.400.description = Invalid object type used updatePerson.res.404.description = Person ID not found updateAddress.summary = Change property on Address bean updateAddress.req.path.id.description = Address ID updateAddress.req.path.id.type = integer updateAddress.req.body.description = Any object matching the field updateAddress.res.200.description = Returns the string "PUT successful" updateAddress.res.400.description = Invalid object type used updateAddress.res.404.description = Address ID not foundv getOptions.summary = View resource options getCognosData.summary = Get data in Cognos/XML format getCognosData.res.200.description = Returns a serialized DataSet otherNotes = GZip support enabled. Public methods can be invoked by using the &Method URL parameter. 'text/cognos+xml' support available under root resource only

#### 5.2.6.2 - Demo

Pointing a browser to the resource shows the results of running the getRoot() method:

Clicking the people link shows you the result of running the getAllPeople() method:

Notice how the URI properties automatically became hyperlinks.

Also notice how the dates are formatted as readable strings. This was from the transform you added to the Calendar property.

Let's see what the output looks like in other formats:

###### JSON

###### Lax JSON

###### XML

Notice how our XML_enableNamespaces and XML_autoDetectNamespaces settings result in namespaces being used.

Also notice how the `@BeanProperty(uri=true)` annotations caused the uri properties to become XML attributes instead of elements.

###### RDF/XML

Notice how the `@BeanProperty(uri=true)` annotations are used to identify values for rdf:about values.

Also notice how URI properties are serialized as rdf:resource attributes.

Now lets look at the schema outputs that can be rendered that show information about the POJO classes themselves.

###### HTML Schema

###### JSON Schema

###### XML Schema

Now let's see what else you can do.

Clicking on the first personUri link executes the getPerson() method, which renders a serialized Person object:

Clicking on the OPTIONS link on the page shows you the Swagger doc generated from our annotations and resource bundle properties:

#### 5.2.6.3 - Traversable

Because you added the Traversable converter to the getPerson method, you can also address child nodes in the POJO model through path remainders:

#### 5.2.6.4 - Queryable

The Queryable converter on the getAllPeople() method allows us to perform search/view/sort functions against the data structure before serialization:

###### Show only the name and addresses columns

###### Show only names that start with 'B*'

###### Show only entries with age greater than 60

#### 5.2.6.5 - Introspectable

The Introspectable converter on the getPerson method allows us to invoke public methods on the addressed POJO (in this case, public methods on the String class):

#### 5.2.6.6 - ClientTest

The ClientTest class is provided to demonstrate how POJOs can be serialized and parsed through the REST interface using the RestClient class.

You'll notice that the class is a stand-alone executable that can be invoked as a plain Java process.

###### ClientTest.java

/** * Sample client code for interacting with AddressBookResource */ public class ClientTest { public static void main(String[] args) { try { System.out.println("Running client test..."); // Create a client to handle XML requests and responses. RestClient client = RestClient.create().build(); RestClient xmlClient = RestClient.create().serializer(XmlSerializer.DEFAULT) .parser(XmlParser.DEFAULT).build(); String root = "http://localhost:10000/addressBook"; // Get the current contents of the address book AddressBook ab = client.doGet(root + "/people").getResponse(AddressBook.class); System.out.println("Number of entries = " + ab.getPeople().size()); // Same, but use XML as the protocol both ways ab = xmlClient.doGet(root + "/people").getResponse(AddressBook.class); System.out.println("Number of entries = " + ab.getPeople().size()); // Delete the existing entries for (Person p : ab.getPeople()) { String r = client.doDelete(p.uri).getResponse(String.class); System.out.println("Deleted person " + p.name + ", response = " + r); } // Make sure they're gone ab = client.doGet(root + "/people").getResponse(AddressBook.class); System.out.println("Number of entries = " + ab.getPeople().size()); // Add 1st person again CreatePerson cp = new CreatePerson( "Barack Obama", toCalendar("Aug 4, 1961"), new CreateAddress("1600 Pennsylvania Ave", "Washington", "DC", 20500, true), new CreateAddress("5046 S Greenwood Ave", "Chicago", "IL", 60615, false) ); Person p = client.doPost(root + "/people", cp).getResponse(Person.class); System.out.println("Created person " + p.name + ", uri = " + p.uri); // Add 2nd person again, but add addresses separately cp = new CreatePerson( "George Walker Bush", toCalendar("Jul 6, 1946") ); p = client.doPost(root + "/people", cp).getResponse(Person.class); System.out.println("Created person " + p.name + ", uri = " + p.uri); // Add addresses to 2nd person CreateAddress ca = new CreateAddress("43 Prairie Chapel Rd", "Crawford", "TX", 76638, true); Address a = client.doPost(p.uri + "/addresses", ca).getResponse(Address.class); System.out.println("Created address " + a.uri); ca = new CreateAddress("1600 Pennsylvania Ave", "Washington", "DC", 20500, false); a = client.doPost(p.uri + "/addresses", ca).getResponse(Address.class); System.out.println("Created address " + a.uri); // Find 1st person, and change name Person[] pp = client.doGet(root + "/people?q=(name='Barack+Obama')").getResponse(Person[].class); String r = client.doPut(pp[0].uri + "/name", "Barack Hussein Obama").getResponse(String.class); System.out.println("Changed name, response = " + r); p = client.doGet(pp[0].uri).getResponse(Person.class); System.out.println("New name = " + p.name); } catch (Exception e) { e.printStackTrace(); } } // Utility method public static Calendar toCalendar(String birthDate) throws Exception { Calendar c = new GregorianCalendar(); c.setTime(DateFormat.getDateInstance(DateFormat.MEDIUM).parse(birthDate)); return c; } }

The output from running this code is the following:

Running client test... Number of entries = 2 Deleted person Barack Obama, response = DELETE successful Deleted person George Walker Bush, response = DELETE successful Number of entries = 0 Created person Barack Obama, uri = http://localhost:9081/sample/addressBook/people/3 Created person George Walker Bush, uri = http://localhost:9081/sample/addressBook/people/4 Created address http://localhost:9081/sample/addressBook/addresses/7 Created address http://localhost:9081/sample/addressBook/addresses/8 Changed name, response = PUT successful New name = Barack Hussein Obama

#### 5.2.6.7 - Browser Tips

The Juneau architecture is designed to make it easy to debug REST resources using nothing more than a browser. The same actions done programmatically in the last section can also be done using URLs. By default, you can override the HTTP Method and Content through GET parameters, as shown below:

// Delete the existing entries http://localhost:10000/addressBook/people/1?method=DELETE http://localhost:10000/addressBook/people/2?method=DELETE // Add 1st person again http://localhost:10000/addressBook/people?method=POST&content={name:'Barack Obama',birthDate:'Aug 4, 1961',addresses:[{street:'1600 Pennsylvania Ave',city:'Washington',state:'DC',zip:20500,isCurrent:true},{street:'5046 S Greenwood Ave',city:'Chicago',state:'IL',zip:60615,isCurrent:false}]} // Add 2nd person again http://localhost:10000/addressBook/people?method=POST&content={name:'George Walker Bush',birthDate:'Jul 6, 1946'} http://localhost:10000/addressBook/people/4/addresses?method=POST&content={street:'43 Prairie Chapel Rd',city:'Crawford',state:'TX',zip:76638,isCurrent:true} http://localhost:10000/addressBook/people/4/addresses?method=POST&content={street:'1600 Pennsylvania Ave',city:'Washington',state:'DC',zip:20500,isCurrent:false} // Change name of 1st person http://localhost:10000/addressBook/people/3/name?method=PUT&content="'Barack Hussein Obama'"

The ability to overload methods is enabled through the {@link org.apache.juneau.rest.annotation.RestResource#allowMethodParam()} setting.

#### 5.2.7 - SampleRemoteableServlet

The SampleRemoteableServlet class shows examples of the following:

- Extending the {@link org.apache.juneau.rest.remoteable.RemoteableServlet} class to create a proxy service.
- Using the {@link org.apache.juneau.rest.client.RestClient} class to create remoteable proxy interfaces.

The RemoteableServlet class has a single abstract method, {@link org.apache.juneau.rest.remoteable.RemoteableServlet#getServiceMap()}, that defines interface keys and POJO values.

The SampleRemoteableServlet exposes the AddressBook bean from the previous example as a service.

@RestResource( path="/remoteable", messages="nls/SampleRemoteableServlet", title="Remoteable Service Proxy API", description="Sample class showing how to use remoteable proxies. The list below are exposed services that can be retrieved using RestClient.getProxyInterface(Class).", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ), // Allow us to use method=POST from a browser. allowMethodParam="*" ) public class SampleRemoteableServlet extends RemoteableServlet { AddressBook addressBook = new AddressBook(); @Override /* RemoteableServlet */ protected Map<Class<?>,Object> getServiceMap() throws Exception { Map<Class<?>,Object> m = new LinkedHashMap<Class<?>,Object>(); // In this simplified example, you expose the same POJO service under two different interfaces. // One is IAddressBook which only exposes methods defined on that interface, and // the other is AddressBook itself which exposes all methods defined on the class itself. m.put(IAddressBook.class, addressBook); m.put(AddressBook.class, addressBook); return m; } }

Pointing a browser to the resource shows the following:

Clicking the hyperlinks on each shows you the list of methods that can be invoked on that service. Note that the IAddressBook link shows that you can only invoke methods defined on that interface, whereas the AddressBook link shows ALL public methods defined on that class. Since AddressBook extends from LinkedList, you may notice familiar collections framework methods listed.

- As good practice, you'll want to use interfaces to prevent all public methods from being exposed.

Proxy interfaces are then retrieved using the {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class)} method.

The client side code for invoking this method is shown below:

// Create a RestClient using JSON for serialization, and point to the server-side remoteable servlet. RestClient client = RestClient.create() .rootUrl("http://localhost:10000/remoteable") .build(); // Create a proxy interface. IAddressBook ab = client.getRemoteableProxy(IAddressBook.class); // Invoke a method on the server side and get the returned result. Person p = ab.createPerson( new CreatePerson("Test Person", AddressBook.toCalendar("Aug 1, 1999"), new CreateAddress("Test street", "Test city", "Test state", 12345, true)) );

###### Additional Information

- org.apache.juneau.rest.remoteable - Remoteable API Javadoc
- {@link org.apache.juneau.rest.remoteable.RemoteableServlet}
- {@link org.apache.juneau.rest.client.RestClient}
  - {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class) getRemoteableProxy(Class)}
  - {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class,Object) getRemoteableProxy(Class,Object)}

#### 5.2.8 - TempDirResource

The TempDirResource class shows examples of the following:

- Extending the {@link org.apache.juneau.microservice.resources.DirectoryResource} class.
- Using the Apache ServletFileUpload class to handle multi-part form posts.
- Using a system property string variable.
- Using {@link org.apache.juneau.rest.RestMatcher RestMatchers}.

Pointing a browser to the resource shows the following:

Pointing a browser to the upload link shows a form entry page:

###### TempDirResource.java

/** * Sample resource that extends DirectoryResource to open up the temp directory as a REST resource. */ @RestResource( path="/tempDir", messages="nls/TempDirResource", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS", "upload: servlet:/upload" } ), properties={ @Property(name="DirectoryResource.rootDir", value="$S{java.io.tmpdir}"), @Property(name="DirectoryResource.allowViews", value="true"), @Property(name="DirectoryResource.allowDeletes", value="true"), @Property(name="DirectoryResource.allowPuts", value="false") }, stylesheet="styles/devops.css" ) public class TempDirResource extends DirectoryResource { private static final long serialVersionUID = 1L; /** * [GET /upload] - Display the form entry page for uploading a file to the temp directory. */ @RestMethod(name=GET, path="/upload") public ReaderResource getUploadPage(RestRequest req) throws IOException { return req.getReaderResource("TempDirUploadPage.html", true); } /** * [POST /upload] - Upload a file as a multipart form post. * Shows how to use the Apache Commons ServletFileUpload class for handling multi-part form posts. */ @RestMethod(name=POST, path="/upload", matchers=TempDirResource.MultipartFormDataMatcher.class) public Redirect uploadFile(RestRequest req) throws Exception { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(req); while (iter.hasNext()) { FileItemStream item = iter.next(); if (item.getFieldName().equals("contents")) { File f = new File(getRootDir(), item.getName()); IOPipe.create(item.openStream(), new FileOutputStream(f)).closeOut().run(); } } return new Redirect(); // Redirect to the servlet root. } /** Causes a 404 if POST isn't multipart/form-data */ public static class MultipartFormDataMatcher extends RestMatcher { @Override /* RestMatcher */ public boolean matches(RestRequest req) { String contentType = req.getContentType(); return contentType != null && contentType.startsWith("multipart/form-data"); } } }

###### TempDirResource.properties

#-------------------------------------------------------------------------------- # TempDirResource labels #-------------------------------------------------------------------------------- title = Temp Directory View Service description = View and download files in the '$S{java.io.tmpdir}' directory.

Note how a system property variable can be defined in the properties file.

###### TempDirUploadPage.html

TODO - Needs update

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type='text/css'> @import '$R{servletURI}/style.css'; </style> </head> <body> <h1>$R{servletTitle}</h1> <h2>$R{servletDescription}</h2> <div class='data'> <form id='form' action='$R{servletURI}/upload' method='POST' target='buff' enctype="multipart/form-data"> <input name="contents" type="file"><button type="submit">Submit</button> </form> </div> </body> </html>

Note how the HTML file contains localized variables for the servlet label and description.

###### Additional Information

- {@link org.apache.juneau.microservice.resources.DirectoryResource}

#### 5.2.9 - AtomFeedResource

The AtomFeedResource class shows examples of the following:

- Using the ATOM Feed DTO API.

Pointing a browser to the resource shows the following:

True ATOM feeds require using an Accept:text/xml header:

Other languages, such as JSON are also supported:

###### AtomFeedResource.java

/** * Sample resource that shows how to generate ATOM feeds. */ @RestResource( path="/atom", messages="nls/AtomFeedResource", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ), properties={ @Property(name=SERIALIZER_quoteChar, value="'"), @Property(name=RDF_rdfxml_tab, value="5"), @Property(name=RDF_addRootProperty, value="true") }, encoders=GzipEncoder.class ) public class AtomFeedResource extends ResourceJena { private static final long serialVersionUID = 1L; private Feed feed; // The root resource object @Override /* Servlet */ public void init() { try { feed = new Feed() .setTitle(new Text("text", "Juneau ATOM specification")) .setSubTitle(new Text("html", "Decribes <em>stuff</em> about Juneau")) .setUpdated(parseDateTime("2016-01-02T03:04:05Z")) .setId(new Id("tag:juneau.apache.org")) .addLinks( new Link("alternate", "text/html", "http://juneau.apache.org/").setHreflang("en"), new Link("self", "application/atom+xml", "http://juneau.apache.org/feed.atom") ) .setRights(new Text("Copyright (c) ...")) .setGenerator(new Generator("Juneau").setUri(new URI("http://juneau.apache.org/")).setVersion("1.0")) .addEntries( new Entry() .setTitle(new Text("Juneau ATOM specification snapshot")) .addLinks( new Link("alternate", "text/html", "http://juneau.apache.org/juneau.atom"), new Link("enclosure", "audio/mpeg", "http://juneau.apache.org/audio/juneau_podcast.mp3").setLength(12345) ) .setId(new Id("tag:juneau.apache.org")) .setUpdated(parseDateTime("2016-01-02T03:04:05Z")) .setPublished(parseDateTime("2016-01-02T03:04:05Z")) .addAuthors(new Person("James Bognar").setUri(new URI("http://juneau.apache.org/")).setEmail("james.bognar@apache.org")) .addContributors( new Person("Barry M. Caceres") ) .setContent( new Content() .setLang("en") .setBase(new URI("http://www.apache.org/")) .setType("xhtml") .setText("<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><i>[Update: Juneau supports ATOM.]</i></p></div>") ) ); } catch (Exception e) { throw new RuntimeException(e); } } /** * GET request handler */ @RestMethod(name=GET, path="/") public Feed getFeed() throws Exception { return feed; } /** * PUT request handler. * Replaces the feed with the specified content, and then mirrors it as the response. */ @RestMethod(name=PUT, path="/") public Feed setFeed(@org.apache.juneau.rest.annotation.Content Feed feed) throws Exception { this.feed = feed; return feed; } }

###### Additional Information

- org.apache.juneau.dto.atom - ATOM Feed DTO Javadocs.

#### 5.2.10 - DockerRegistryResource

The DockerRegistryResource class shows examples of the following:

- Accessing a docker registry REST API as POJOs using {@link org.apache.juneau.rest.client.RestClient}.
- Using the {@link org.apache.juneau.rest.labels.ResourceDescription} class to implement a top-level 'router' page.
- Using the {@link org.apache.juneau.rest.RestContext#getConfigFile()} method to access external configuration file values.

Pointing a browser to the resource shows the following:

Clicking the search link provides you with the search results against the Docker registry:

###### DockerRegistryResource.java

/** * Sample resource that shows how to mirror query results from a Docker registry. */ @RestResource( path="/docker", title="Sample Docker resource", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class DockerRegistryResource extends Resource { private static final long serialVersionUID = 1L; // Get registry URL from examples.cfg file. private String registryUrl = getConfig().getString("DockerRegistry/url"); RestClient rc = RestClient.create().build(); /** [GET /] - Show child resources. */ @SuppressWarnings("nls") @RestMethod(name=GET, path="/") public ResourceDescription[] getChildren(RestRequest req) { return new ResourceDescription[] { new ResourceDescription(req, "search", "Search Registry") }; } /** * PUT request handler. * Replaces the feed with the specified content, and then mirrors it as the response. */ @RestMethod(name=GET, path="/search") public QueryResults query(@Query("q") String q) throws Exception { String url = registryUrl + "/search" + (q == null ? "" : "?q=" + q); return rc.doGet(url).getResponse(QueryResults.class); } public static class QueryResults { public int num_results; public String query; public List<DockerImage> results; } public static class DockerImage { public String name, description; } }

The Docker registry URL is specified in the examples.cfg file:

###### examples.cfg

#================================================================================ # DockerRegistryResource properties #================================================================================ [DockerRegistry] url = http://clmdocker02.ratl.swg.usma.apache.org:5000/v1

###### Additional Information

- {@link org.apache.juneau.rest.labels.ResourceDescription}
- {@link org.apache.juneau.rest.RestContext#getConfigFile()}

#### 5.2.11 - TumblrParserResource

The TumblrParserResource class shows examples of the following:

- Using {@link org.apache.juneau.rest.client.RestClient} to retrieve information from other REST resources.
- Using {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} to produce generalized POJO models.

Pointing a browser at a Tumblr blog name, such as ibmblr causes a REST call to be make to the Tumblr blog and the results to be parsed:

###### TumblrParserResource.java

@RestResource( path="/tumblrParser", messages="nls/TumblrParserResource", title="Tumblr parser service", description="Specify a URL to a Tumblr blog and parse the results.", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class TumblrParserResource extends Resource { private static final long serialVersionUID = 1L; @RestMethod(name=GET, path="/") public String getInstructions() throws Exception { return "Append the Tumblr blog name to the URL above (e.g. /tumblrParser/mytumblrblog)"; } @RestMethod(name=GET, path="/{blogName}") public ObjectList parseBlog(@Path String blogName) throws Exception { ObjectList l = new ObjectList(); RestClient rc = RestClient.create().build(); String site = "http://" + blogName + ".tumblr.com/api/read/json"; ObjectMap m = rc.doGet(site).getResponse(ObjectMap.class); int postsTotal = m.getInt("posts-total"); for (int i = 0; i < postsTotal; i += 20) { m = rc.doGet(site + "?start=" + i + "&num=20&transform=text").getResponse(ObjectMap.class); ObjectList ol = m.getObjectList("posts"); for (int j = 0; j < ol.size(); j++) { ObjectMap om = ol.getObjectMap(j); String type = om.getString("type"); Entry e = new Entry(); e.date = om.getString("date"); if (type.equals("link")) e.entry = new Link(om.getString("link-text"), om.getString("link-url")); else if (type.equals("audio")) e.entry = new ObjectMap().append("type","audio").append("audio-caption", om.getString("audio-caption")); else if (type.equals("video")) e.entry = new ObjectMap().append("type","video").append("video-caption", om.getString("video-caption")); else if (type.equals("quote")) e.entry = new ObjectMap().append("type","quote").append("quote-source", om.getString("quote-source")).append("quote-text", om.getString("quote-text")); else if (type.equals("regular")) e.entry = om.getString("regular-body"); else if (type.equals("photo")) e.entry = new Img(om.getString("photo-url-250")); else e.entry = new ObjectMap().append("type", type); l.add(e); } } return l; } public static class Entry { public String date; public Object entry; } }

#### 5.2.12 - PhotosResource

The PhotosResource class shows examples of the following:

- How to define custom serializers and parsers at the method level. In this case, you define a serializer and parser to handle images.

The resource consists of a simple registry of images with integer IDs.

It is initialized with a single entry, which can be accessed through a GET request.

###### PhotosResource.java

/** * Sample resource that allows images to be uploaded and retrieved. */ @RestResource( path="/photos", messages="nls/PhotosResource", title="Photo REST service", description="Use a tool like Poster to upload and retrieve jpeg and png images.", htmldoc=@HtmlDoc( navlinks={ "options: servlet:/?method=OPTIONS" } ) ) public class PhotosResource extends RestServletDefault { // Our cache of photos private Map<Integer,Photo> photos = new TreeMap<Integer,Photo>(); @Override /* Servlet */ public void init() { try { // Preload an image. InputStream is = getClass().getResourceAsStream("averycutedog.jpg"); BufferedImage image = ImageIO.read(is); Photo photo = new Photo(0, image); photos.put(photo.id, photo); } catch (IOException e) { throw new RuntimeException(e); } } /** Bean class for storing photos */ public static class Photo { private int id; BufferedImage image; Photo(int id, BufferedImage image) { this.id = id; this.image = image; } public URI getURI() throws URISyntaxException { return new URI("photos/"+id); } public int getID() { return id; } } /** GET request handler for list of all photos */ @RestMethod(name=GET, path="/") public Collection<Photo> getAllPhotos(RestRequest req, RestResponse res) throws Exception { res.setPageTitle("Photo REST service"); res.setPageText("Use a tool like Poster to upload and retrieve jpeg and png images."); return photos.values(); } /** GET request handler for single photo */ @RestMethod(name=GET, path="/{id}", serializers=ImageSerializer.class) public BufferedImage getPhoto(RestRequest req, @Path int id) throws Exception { Photo p = photos.get(id); if (p == null) throw new RestException(SC_NOT_FOUND, "Photo not found"); return p.image; } /** PUT request handler */ @RestMethod(name=PUT, path="/{id}", parsers=ImageParser.class) public String addPhoto(RestRequest req, @Path int id, @Body BufferedImage image) throws Exception { photos.put(id, new Photo(id, image)); return "OK"; } /** POST request handler */ @RestMethod(name=POST, path="/", parsers=ImageParser.class) public Photo setPhoto(RestRequest req, @Body BufferedImage image) throws Exception { int id = photos.size(); Photo p = new Photo(id, image); photos.put(id, p); return p; } /** DELETE request handler */ @RestMethod(name=DELETE, path="/{id}") public String deletePhoto(RestRequest req, @Path int id) throws Exception { Photo p = photos.remove(id); if (p == null) throw new RestException(SC_NOT_FOUND, "Photo not found"); return "OK"; } /** OPTIONS request handler */ @RestMethod(name=OPTIONS, path="/*") public Swagger getOptions(RestRequest req) { return req.getSwagger(); } /** Serializer for converting images to byte streams */ @Produces("image/png,image/jpeg") public static class ImageSerializer extends OutputStreamSerializer { @Override public void serialize(Object o, OutputStream out, SerializerSession session) throws IOException, SerializeException { RenderedImage image = (RenderedImage)o; String mediaType = ctx.getMediaType(); ImageIO.write(image, mediaType.substring(mediaType.indexOf('/')+1), out); } } /** Parser for converting byte streams to images */ @Consumes("image/png,image/jpeg") public static class ImageParser extends InputStreamParser { @Override public <T> T parse(InputStream in, ClassMeta<T> type, ParserSession session) throws ParseException, IOException { BufferedImage image = ImageIO.read(in); return (T)image; } } }

#### 5.2.13 - JsonSchemaResource

The JsonSchemaResource class shows examples of the following:

- Using the JSON Schema DTO API.

The resource consists of a pre-initialized {@link org.apache.juneau.dto.jsonschema.Schema} object. Pointing a browser to the resource shows the following:

For true JSON-Schema, you need to specify the header Accept: text/json:

###### JsonSchemaResource.java

/** * Sample resource that shows how to serialize JSON-Schema documents. */ @RestResource( path="/jsonSchema", messages="nls/JsonSchemaResource", title="Sample JSON-Schema document", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class JsonSchemaResource extends ResourceJena { private static final long serialVersionUID = 1L; private Schema schema; // The schema document @Override /* Servlet */ public void init() { try { schema = new Schema() .setId("http://example.com/sample-schema#") .setSchemaVersionUri("http://json-schema.org/draft-04/schema#") .setTitle("Example Schema") .setType(JsonType.OBJECT) .addProperties( new SchemaProperty("firstName", JsonType.STRING), new SchemaProperty("lastName", JsonType.STRING), new SchemaProperty("age", JsonType.INTEGER) .setDescription("Age in years") .setMinimum(0) ) .addRequired("firstName", "lastName"); } catch (Exception e) { throw new RuntimeException(e); } } /** GET request handler */ @RestMethod(name=GET, path="/") public Schema getSchema() throws Exception { return schema; } /** * PUT request handler. * Replaces the schema document with the specified content, and then mirrors it as the response. */ @RestMethod(name=PUT, path="/") public Schema setSchema(@Body Schema schema) throws Exception { this.schema = schema; return schema; } }

#### 5.2.14 - SqlQueryResource

The SqlQueryResource class shows examples of the following:

- Using the {@link org.apache.juneau.dto.ResultSetList} to serialize database result sets.
- Using {@link org.apache.juneau.rest.RestContext#getConfigFile()} to access config properties.
- Using form entry beans.

The example uses embedded Derby to create a database whose name is defined in the external configuration files.

Pointing a browser to the resource shows the following:

Running a query results in the following output:

###### SqlQueryResource.java

/** * Sample resource that shows how Juneau can serialize ResultSets. */ @RestResource( path="/sqlQuery", messages="nls/SqlQueryResource", title="SQL query service", description="Executes queries against the local derby '$C{SqlQueryResource/connectionUrl}' database", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS" } ) ) public class SqlQueryResource extends Resource { private static final long serialVersionUID = 1L; private ConfigFile cf = getConfig(); private String driver = cf.getString("SqlQueryResource/driver"); private String connectionUrl = cf.getString("SqlQueryResource/connectionUrl"); private boolean allowUpdates = cf.getBoolean("SqlQueryResource/allowUpdates", false), allowTempUpdates = cf.getBoolean("SqlQueryResource/allowTempUpdates", false), includeRowNums = cf.getBoolean("SqlQueryResource/includeRowNums", false); @Override /* Servlet */ public void init() { try { Class.forName(driver).newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } /** GET request handler - Display the query entry page. */ @RestMethod(name=GET, path="/") public ReaderResource doGet(RestRequest req) throws IOException { return req.getReaderResource("SqlQueryResource.html", true); } /** POST request handler - Execute the query. */ @RestMethod(name=POST, path="/") public List<Object> doPost(@Body PostInput in) throws Exception { List<Object> results = new LinkedList<Object>(); // Don't try to submit empty input. if (StringUtils.isEmpty(in.sql)) return results; if (in.pos < 1 || in.pos > 10000) throw new RestException(SC_BAD_REQUEST, "Invalid value for position. Must be between 1-10000"); if (in.limit < 1 || in.limit > 10000) throw new RestException(SC_BAD_REQUEST, "Invalid value for limit. Must be between 1-10000"); // Create a connection and statement. // If these fails, let the exception transform up as a 500 error. Connection c = DriverManager.getConnection(connectionUrl); c.setAutoCommit(false); Statement st = c.createStatement(); String sql = null; try { for (String s : in.sql.split(";")) { sql = s.trim(); if (! sql.isEmpty()) { Object o = null; if (allowUpdates || (allowTempUpdates && ! sql.matches("(?:i)commit.*"))) { if (st.execute(sql)) { ResultSet rs = st.getResultSet(); o = new ResultSetList(rs, in.pos, in.limit, includeRowNums); } else { o = st.getUpdateCount(); } } else { ResultSet rs = st.executeQuery(sql); o = new ResultSetList(rs, in.pos, in.limit, includeRowNums); } results.add(o); } } if (allowUpdates) c.commit(); else if (allowTempUpdates) c.rollback(); } catch (SQLException e) { c.rollback(); throw new RestException(SC_BAD_REQUEST, "Invalid query: {0}", sql).initCause(e); } finally { c.close(); } return results; } /** The parsed form post */ public static class PostInput { public String sql; public int pos = 1, limit = 100; } }

###### SqlQueryResource.html

TODO - Needs update

<html> <head> <style type='text/css'> @import '$R{servletURI}/style.css'; </style> <script> // Quick and dirty function to allow tabs in textarea. function checkTab(e) { if (e.keyCode == 9) { var t = e.target; var ss = t.selectionStart, se = t.selectionEnd; t.value = t.value.slice(0,ss).concat('\t').concat(t.value.slice(ss,t.value.length)); e.preventDefault(); } } // Load results from IFrame into this document. function loadResults(b) { var doc = b.contentDocument || b.contentWindow.document; var data = doc.getElementById('data') || doc.getElementsByTagName('body')[0]; document.getElementById('results').innerHTML = data.innerHTML; } </script> </head> <body> <h1>SQL Query API</h1> <div class='data'> <form action='sqlQuery' method='POST' target='buf'> <table> <tr> <th>Position (1-10000):</th> <td><input name='pos' type='number' value='1'></td> <th>Limit (1-10000):</th> <td><input name='limit' type='number' value='100'></td> <td><button type='submit'>Submit</button><button type='reset'>Reset</button></td> </tr> <tr> <td colspan="5"> <textarea name='sql' style='width:100%;height:200px;font-family:Courier;font-size:9pt;' onkeydown='checkTab(event)'></textarea> </td> </tr> </table> </form> <br> <div id='results'> </div> </div> <iframe name='buf' style='display:none' onload="parent.loadResults(this)"></iframe> </body> </html>

###### samples.cfg

#================================================================================ # SqlQueryResource properties #================================================================================ [SqlQueryResource] driver = org.apache.derby.jdbc.EmbeddedDriver connectionUrl = jdbc:derby:C:/testDB;create=true allowTempUpdates = true includeRowNums = true

#### 5.2.15 - ConfigResource

The {@link org.apache.juneau.microservice.resources.ConfigResource} class is a reusable resource defined in the org.apache.juneau.microservice API. It provides a REST interface for reading and altering the microservice config file.

Pointing a browser to the resource shows the following:

An edit page is provided for altering the raw config file:

The {@link org.apache.juneau.ini.ConfigFile} class is a serializable POJO, which makes the resource relatively straightforward to implement.

###### ConfigResource.java

/** * Shows contents of the microservice configuration file. */ @RestResource( path="/config", title="Configuration", description="Contents of configuration file.", htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS", "edit: servlet:/edit" } ) ) public class ConfigResource extends Resource { private static final long serialVersionUID = 1L; /** * [GET /] - Show contents of config file. * * @return The config file. * @throws Exception */ @RestMethod(name=GET, path="/", description="Show contents of config file.") public ConfigFile getConfigContents() throws Exception { return getConfig(); } /** * [GET /edit] - Show config file edit page. * * @param req The HTTP request. * @return The config file as a reader resource. * @throws Exception */ @RestMethod(name=GET, path="/edit", description="Show config file edit page.") public ReaderResource getConfigEditPage(RestRequest req) throws Exception { // Note that you don't want variables in the config file to be resolved, // so you need to escape any $ characters that you see. req.setAttribute("contents", getConfig().toString().replaceAll("\\$", "\\\\\\$")); return req.getReaderResource("ConfigEdit.html", true); } /** * [GET /{section}] - Show config file section. * * @param section The section name. * @return The config file section. * @throws Exception */ @RestMethod(name=GET, path="/{section}", description="Show config file section.", parameters={ @Parameter(in="path", name="section", description="Section name.") } ) public ObjectMap getConfigSection(@Path("section") String section) throws Exception { return getSection(section); } /** * [GET /{section}/{key}] - Show config file entry. * * @param section The section name. * @param key The section key. * @return The value of the config file entry. * @throws Exception */ @RestMethod(name=GET, path="/{section}/{key}", description="Show config file entry.", parameters={ @Parameter(in="path", name="section", description="Section name."), @Parameter(in="path", name="key", description="Entry name.") } ) public String getConfigEntry(@Path("section") String section, @Path("key") String key) throws Exception { return getSection(section).getString(key); } /** * [POST /] - Sets contents of config file from a FORM post. * * @param contents The new contents of the config file. * @return The new config file contents. * @throws Exception */ @RestMethod(name=POST, path="/", description="Sets contents of config file from a FORM post.", parameters={ @Parameter(in="formData", name="contents", description="New contents in INI file format.") } ) public ConfigFile setConfigContentsFormPost(@FormData("contents") String contents) throws Exception { return setConfigContents(new StringReader(contents)); } /** * [PUT /] - Sets contents of config file. * * @param contents The new contents of the config file. * @return The new config file contents. * @throws Exception */ @RestMethod(name=PUT, path="/", description="Sets contents of config file.", parameters={ @Parameter(in="body", description="New contents in INI file format.") } ) public ConfigFile setConfigContents(@Body Reader contents) throws Exception { ConfigFile cf2 = ConfigFile.create().build().load(contents); return getConfig().merge(cf2).save(); } /** * [PUT /{section}] - Add or overwrite a config file section. * * @param section The section name. * @param contents The new contents of the config file section. * @return The new section. * @throws Exception */ @RestMethod(name=PUT, path="/{section}", description="Add or overwrite a config file section.", parameters={ @Parameter(in="path", name="section", description="Section name."), @Parameter(in="body", description="New contents for section as a simple map with string keys and values.") } ) public ObjectMap setConfigSection(@Path("section") String section, @Body Map<String,String> contents) throws Exception { getConfig().setSection(section, contents); return getSection(section); } /** * [PUT /{section}/{key}] - Add or overwrite a config file entry. * * @param section The section name. * @param key The section key. * @param value The new value. * @return The new value. * @throws Exception */ @RestMethod(name=PUT, path="/{section}/{key}", description="Add or overwrite a config file entry.", parameters={ @Parameter(in="path", name="section", description="Section name."), @Parameter(in="path", name="key", description="Entry name."), @Parameter(in="body", description="New value as a string.") } ) public String setConfigSection(@Path("section") String section, @Path("key") String key, @Body String value) throws Exception { getConfig().put(section, key, value, false); return getSection(section).getString(key); } private ObjectMap getSection(String name) { ObjectMap m = getConfig().getSectionMap(name); if (m == null) throw new RestException(SC_NOT_FOUND, "Section not found."); return m; } }

###### ConfigEdit.html

TODO - Needs update

<html> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> <style type='text/css'> @import '$R{servletURI}/style.css'; </style> </head> <body> <h1>$R{servletTitle}</h1> <h2>Edit config file</h2> <p class='links'><a href='$R{requestParentURI}'>up</a> - <a href='$R{servletURI}?method=OPTIONS'>options</a></p> <form id='form' action='$R{servletURI}' method='POST' enctype='application/x-www-form-urlencoded'> <div class='data'> <table> <tr><td colspan='2' align='right'><button type='submit'>Submit</button><button type='reset'>Reset</button></td></tr> <tr><th colspan='2'>Contents</th></tr> <tr><td colspan='2'><textarea name='contents' rows='40' cols='120' style='white-space: pre; word-wrap: normal; overflow-x: scroll;'>$SA{contents}</textarea></td></tr> </table> </div> </form> </body> </html>

#### 5.2.16 - LogsResource

The {@link org.apache.juneau.microservice.resources.LogsResource} class is a reusable resource defined in the org.apache.juneau.microservice API. It provides a REST interface for the log files generated by the microservice.

Pointing a browser to the resource shows the following:

The highlighted links show the contents of the log file with color highlighting:

The parsed links parse the log file and return the entries as serialized POJOs:

## 6 - Security Best-Practices

Security is always an ongoing concern in any library. If you discover any security vulnerabilities in this code, please refer to the instructions found here:

- SECURITY

### 6.1 - juneau-marshall

###### Demarshalling vulnerabilities

One common security vulnerability is the ability to create arbitrary Java object instances through crafted user input. For example, support for constructing POJOs based on an input attribute defining a fully-qualified class name like "{class:'com.foo.MyBean',...}"

Fortunately, Juneau does not support an open-ended "class attribute. As a rule, it should not be possible to create arbitrary POJOs by any of the parsers. The demarshalled object types are inferred via reflection of the class objects passed in through the parser method (e.g. `JsonParser.DEFAULT.parse(input, MyBean.class)`). As long as the `Class` object passed into this method is not constructed from user-generated input, it should be free from demarshalling vulnerabilities.

The following example shows a potential vector that circumvents the restriction above:

// Don't do this! Class c = Class.forName(someUserInputString); JsonParser.DEFAULT.parse(input, c); // Oops! Security hole!

Juneau does support something similar to a "class" attribute that allows you to define the POJO type at runtime. This is the "type" attribute. The difference is that it's not possible to specify fully-qualified class names in "type" attributes, and instead can only specify type keys defined through bean dictionaries. Instead of serializing the fully-qualified class names in the output, we instead serialize type names that represent those POJO types.
i.e. instead of "class='com.foo.MyBean'", we instead serialize "type='MyBeanIdentifier'".
Since bean types are defined at compile time, it's impossible to instantiate arbitrary POJOs.

POJO types of generalized input are also inferred through swaps. Again, since the POJO types are hardcoded at compile time, these should not be subject to demarshalling vulnerabilities. However, it is possible to circumvent this through your swap implementation as shown below:

// Don't do this! public class MyInsecureSwap extends PojoSwap<ObjectMap,Object> { public Object swap(BeanSession session, ObjectMap input) throws Exception { // Security hole! return Class.forName(input.getString("class")).newInstance(); } }

Note that the {@link org.apache.juneau.jso.JsoParser}, a thin layer of the Juneau Parser API written on top of plain-old Java Object Serialization which itself is vulnerable to demarshalling issues. Due to this, the JSO parser is not included in any of the default REST servlet implementations. Be especially careful when using this parser, particularly if you want to use it for handing `application/x-java-serialized-object` input through REST servlets.

All other parsers (JSON, URL-Encoding, MessagePack, etc...) work the same way in determining POJO types, so should be safe from demarshalling vulnerabilities.

###### Dependent libraries

When accessing security vulnerabilities of any library, dependent libraries must also be taken into account:

- The JSON, HTML, MsgPack, URL-Encoding, and UON parsers are written from scratch and do not rely on any other parsing technologies.
- The XML and HTML parsers uses the built-in Java StAX parser. This *should* be free from vulnerabilities.
- The RDF parsers rely on Apache Jena 2.7.1. As of `7.0.1`, no known security vulnerabilities exist that affect Juneau at this time.

### 6.2 - juneau-svl

Care must be used when defining new {@link org.apache.juneau.svl.Var Vars} using the SVL API since mistakes could potentially expose system properties, environment variables, or even file system files.

For recap, the SVL support allows you to embed variables of the form "$X{key}" inside strings that get resolved to other strings. The resolved strings themselves can also contain variables that also get recursively resolved.

An example of a potential security hole is shown below that could potentially expose any file on a file system through a REST request:

public String doUnsafeGet(RestRequest req) { // Security hole! return req.getVarResolver().resolve("$R{Query.foo}"); }

This code is simply echoing the value of the `foo` query parameter. Now say for example that a bad actor passes in the query string "foo=$F{/some/file/on/file/system}". The `$F` variable allows you to resolve the contents of files using SVL, and is provided by default using the built-in variable resolver returned by the `RestRequest` object. You've potentially just exposed the contents of that file through your REST interface.

In reality, the above security hole does not exist because of the following restrictions:

- `Vars` have two methods {@link org.apache.juneau.svl.Var#allowNested()} and {@link org.apache.juneau.svl.Var#allowRecurse()} that can be overridden to prevent recursive processing of string variables. These are both false for the `$R` variable, so the `$F` variable in the result will never get processed and instead be treated as plain text.
- The `$F` variable only allows you to retrieve files within the JVM starting directory.

Even though the built-in Juneau variables are safe, special care is needed when defining your own custom variables. If your variable resolves user input in any way, it's HIGHLY recommended that you override the {@link org.apache.juneau.svl.Var#allowNested()} and {@link org.apache.juneau.svl.Var#allowRecurse()} methods to prevent recursive handling of variables.

### 6.3 - juneau-rest-server

Denial of service attacks can be alleviated through the {@link org.apache.juneau.rest.annotation.RestResource#maxInput() maxInput()} setting. Arbitrarily-large input will trigger an exception before causing out-of-memory errors. The default value for this setting is 100MB.

Since the parsers do not use intermediate DOMs and instead parse directly into Java objects, deeply nested data structures will almost always trigger stack overflow errors long before memory consumption becomes an issue. However, this is NOT true of the RDF parsers that use an intermediate DOM. If parsing RDF, you may want to consider lowering the max-input value above.

## 7 - Release Notes

##### What's new in each release

### 7.0.1 (TBD)

This release is a minor update. It includes the following prereq updates:

- Apache HttpClient: 4.5.3 to 4.5.4
- Eclipse Jetty: 9.4.6.v20170531 to 9.4.8.v20171121

###### juneau-marshall

- New static `create()` methods for builders on serializers and parsers.
  This simplifies the syntax of creation of serializers and parsers by scratch.

  // Old way JsonSerializer s1 = new JsonSerializerBuilder().ws().build(); // New way JsonSerializer s2 = JsonSerializer.create().ws().build();

  The same static create methods have also been added to the following classes:
  - {@link org.apache.juneau.serializer.SerializerGroup#create()}
  - {@link org.apache.juneau.parser.ParserGroup#create()}
  - {@link org.apache.juneau.encoders.EncoderGroup#create()}
  - {@link org.apache.juneau.rest.client.RestClient#create()}
  - {@link org.apache.juneau.ini.ConfigFile#create()}
- The order of the parameters in {@link org.apache.juneau.serializer.SerializerSession#serialize(Object,Object)} has been change to match {@link org.apache.juneau.serializer.Serializer#serialize(Object,Object)}.
- Fixed some bugs in the XML parser related to whitespace and comments.

###### juneau-marshall-rdf

###### juneau-svl

- New methods on {@link org.apache.juneau.svl.Var} class to restrict when nested and embedded variables are resolved.
  - {@link org.apache.juneau.svl.Var#allowNested()}
  - {@link org.apache.juneau.svl.Var#allowRecurse()}

###### juneau-rest-server

- New {@link org.apache.juneau.rest.annotation.RestResource#maxInput() @RestResource.maxInput()} and {@link org.apache.juneau.rest.annotation.RestMethod#maxInput() @RestMethod.maxInput()} for alleviating potential DoS attacks.

###### juneau-microservice-server

- New pluggable console commands.
  When you start up the microservice, you'll now see the following:

  Running class 'RestMicroservice' using config file 'examples.cfg'. Server started on port 10000 List of available commands: exit -- Shut down service restart -- Restarts service help -- Commands help echo -- Echo command > help help NAME help -- Commands help SYNOPSIS help [command] DESCRIPTION When called without arguments, prints the descriptions of all available commands. Can also be called with one or more arguments to get detailed information on a command. EXAMPLES List all commands: > help List help on the help command: > help help >

  Commands are pluggable and extensible through the config file.

  #======================================================================================================================= # Console settings #======================================================================================================================= [Console] enabled = true # List of available console commands. # These are classes that implements ConsoleCommand that allow you to submit commands to the microservice via # the console. # When listed here, the implementations must provide a no-arg constructor. # They can also be provided dynamically by overriding the Microservice.createConsoleCommands() method. commands = org.apache.juneau.microservice.console.ExitCommand, org.apache.juneau.microservice.console.RestartCommand, org.apache.juneau.microservice.console.HelpCommand

  - New classes:
    - {@link org.apache.juneau.microservice.console.ConsoleCommand}
    - {@link org.apache.juneau.microservice.console.ExitCommand}
    - {@link org.apache.juneau.microservice.console.RestartCommand}
    - {@link org.apache.juneau.microservice.console.HelpCommand}
  - New methods on {@link org.apache.juneau.microservice.Microservice}
    - {@link org.apache.juneau.microservice.Microservice#startConsole() startConsole()}
    - {@link org.apache.juneau.microservice.Microservice#createConsoleCommands() createConsoleCommands()}
    - {@link org.apache.juneau.microservice.Microservice#getConsoleReader() getConsoleReader()}
    - {@link org.apache.juneau.microservice.Microservice#getConsoleWriter() getConsoleWriter()}
- Console input reader and output writer can now be overridden.
- Console strings are now internationalized.

### 7.0.0 (Oct 25, 2017)

This release ups the Java prerequisite to Java 7.

###### juneau-marshall

- New class {@link org.apache.juneau.http.HttpMethodName} with valid static string HTTP method names.

###### juneau-dto

- Class `org.apache.juneau.dto.Link` renamed to {@link org.apache.juneau.dto.LinkString}. Helps avoid confusion since there are other Link classes in the library.

###### juneau-rest-server

- Annotation `@HtmlDoc(links)` renamed to {@link org.apache.juneau.rest.annotation.HtmlDoc#navlinks() navlinks}.
- New annotation {@link org.apache.juneau.rest.annotation.HtmlDoc#head()}.
  Allows you to specify arbitrary HTML content in the <head> section of the page.
- Removed annotation `@HtmlDoc(favIcon)`.
  This was a discouraged way of defining fav-icons anyway, and with the addition of `@HtmlDoc(head)`, you can define them using:

  head={ "<link rel='icon' href='$U{servlet:/htdocs/juneau.png}'/>" }

- Removed several of the HTMLDOC-related methods from the `RestResponse/RestConfig/RestContext` classes and moved it into the new {@link org.apache.juneau.rest.HtmlDocBuilder} class.

### 6.4.0 (Oct 5, 2017)

The major change in this release is the project structure.

The library now consists of the following artifacts found in the Maven group `"org.apache.juneau"`:

Category | Maven Artifacts | Description | Prereqs
--- | --- | --- | ---
Juneau Core | juneau-marshall | Serializers and parsers for: JSON XML HTML UON URL-Encoding MessagePack SOAP/XML CSV BSON (coming soon) YAML (coming soon) Protobuf (coming soon) | Java 6
juneau-marshall-rdf | Serializers and parsers for: RDF/XML RDF/XML-Abbrev N-Triple Turtle N3 | Java 6 Apache Jena 2.7.1
juneau-dto | Data Transfer Objects for: HTML5 Atom Cognos JSON-Schema Swagger 2.0 | Java 6
juneau-svl | Simple Variable Language API | Java 6
juneau-config | Configuration file API | Java 6
Juneau REST | juneau-rest-server | REST Servlet API | Java 6 Servlet 3.1
juneau-rest-server-jaxrs | Optional JAX-RS support | Java 6 JAX-RS 2.0
juneau-rest-client | REST Client API | Java 6 Apache HttpClient 4.5
Juneau Microservice | juneau-microservice-server | REST Microservice Server API | Java 8 Eclipse Jetty 9.4.3
juneau-microservice-template | Developer template project | Java 8 Eclipse Jetty 9.4.3
Examples | `juneau-examples-core` | Core code examples |
`juneau-examples-rest` | REST code examples |
Juneau All | `juneau-all` | Combination of the following: juneau-marshall juneau-dto juneau-svl juneau-config juneau-rest-server juneau-rest-client | Java 6 Servlet 3.1 Apache HttpClient 4.5

###### juneau-marshall

- Improvements to swap support.
  - New {@link org.apache.juneau.annotation.Swap @Swap} annotation.
    Replaces the `@Pojo` and `@BeanProperty.swap()` annotations.
  - Support for per-media-type swaps.
    Programmatic example:

    @Swap(MyJsonOnlySwap.class) public class MyPojo {} public class MyJsonOnlySwap extends PojoSwap<MyPojo,String> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/json"); } public String swap(BeanSession session, MyPojo o) throws Exception { return "It's JSON!"; }

    Annotated example:

    @Swap(impl=ToStringSwap.class, mediaTypes="*/json") public class MyBean { ... } public class ToStringSwap extends PojoSwap<Object,String> { public String swap(BeanSession session, Object o) throws Exception { return o.toString(); } }

  - Support for templated swaps which provide additional context information for a swap.
    The following is an example of a templated swap class used to serialize POJOs to HTML using FreeMarker:

    // Our abstracted templated swap class. public abstract class FreeMarkerSwap extends PojoSwap<Object,Reader> { public MediaType[] forMediaTypes() { return MediaType.forStrings("*/html"); } public Reader swap(BeanSession session, Object o, String template) throws Exception { return getFreeMarkerReader(template, o); // Some method that creates raw HTML. } }

    @Swap(impl=FreeMarkerSwap.class, template="MyPojo.div.ftl") public class MyPojo {}

  - New {@link org.apache.juneau.annotation.Swaps @Swaps} annotation for defining multiple swaps against the same POJO when they're differentiated by media types:

    @Swaps( { @Swap(MyJsonSwap.class), @Swap(MyXmlSwap.class), @Swap(MyOtherSwap.class) } ) public class MyPojo {}

- New {@link org.apache.juneau.transform.Surrogate} interface for identifying surrogate classes.
- Serializers can now serialize to {@link java.util.StringBuilder StringBuilders}.
- Serializers now serialize the contents of {@link java.io.Reader Readers} and {@link java.io.InputStream InputStreams} directly to the output stream or writer.
  When used with conjunction with `PojoSwaps`, this can be used to provide customized output for specific content types.

  @Pojo(swap=MyBeanSwap.class) public class MyBean {...} public class MyBeanSwap extends PojoSwap<MyBean,Object> { public Object swap(BeanSession session, MyPojo o) throws Exception { MediaType mt = session.getMediaType(); if (mt.hasSubType("json")) return new StringReader("{foo:'bar'}"); // Custom JSON output return o; // Otherwise treat as normal bean } } // Produces "{foo:'bar'}" String json = JsonSerializer.DEFAULT_LAX.toString(new MyBean());

  This feature helps with the implementation of language-agnostic template support such as for using FreeMaker to serialize POJOs to HTML.
- {@link org.apache.juneau.serializer.SerializerSession} and {@link org.apache.juneau.parser.ParserSession} objects are now reusable if used within the same thread.

  // Old way (still works) JsonSerializer.DEFAULT.serialize(writer1, pojo1); JsonSerializer.DEFAULT.serialize(writer2, pojo2); // Same, but using a session object SerializerSession session = JsonSerializer.DEFAULT.createSession(); try { session.serialize(writer1, pojo1); session.serialize(writer2, pojo2); } finally { session.close(); }

  This is mostly an internal change and doesn't affect the existing APIs.
- {@link org.apache.juneau.transform.PojoSwap#swap(BeanSession,Object)} and {@link org.apache.juneau.transform.PojoSwap#unswap(BeanSession,Object,ClassMeta)} can now throw arbitrary exceptions instead of having to wrap them in `SerializeException`/`ParseException`.
- New {@link org.apache.juneau.utils.CalendarUtils} class that encapsulates serialization/parsing logic from {@link org.apache.juneau.transforms.CalendarSwap} and {@link org.apache.juneau.transforms.DateSwap}.
- New annotation {@link org.apache.juneau.html.annotation.Html#anchorText}.
- New methods on {@link org.apache.juneau.ObjectList}:
  - {@link org.apache.juneau.ObjectList#get(int,Class) get(int,Class)}
  - {@link org.apache.juneau.ObjectList#get(int,Type,Type...) get(int,Type,Type...)}
  - {@link org.apache.juneau.ObjectList#getMap(int,Class,Class) getMap(int,Class,Class)}
  - {@link org.apache.juneau.ObjectList#getList(int,Class) getList(int,Class)}
- New methods on {@link org.apache.juneau.ObjectMap}:
  - {@link org.apache.juneau.ObjectMap#get(String,Class) get(String,Class)}
  - {@link org.apache.juneau.ObjectMap#get(String,Type,Type...) get(String,Type,Type...)}
  - {@link org.apache.juneau.ObjectMap#getWithDefault(String,Object) getWithDefault(String,Object)}
  - {@link org.apache.juneau.ObjectMap#getWithDefault(String,Object,Class) getWithDefault(String,Object,Class)}
  - {@link org.apache.juneau.ObjectMap#getWithDefault(String,Object,Type,Type...) getWithDefault(String,Object,Type,Type...)}
  - {@link org.apache.juneau.ObjectMap#getSwapped(String,PojoSwap) getSwapped(String,PojoSwap)}
  - {@link org.apache.juneau.ObjectMap#getAt(String,Class) getAt(String,Class)}
  - {@link org.apache.juneau.ObjectMap#getAt(String,Type,Type...) getAt(String,Type,Type...)}
  - {@link org.apache.juneau.ObjectMap#getMap(String,Class,Class,Map) getMap(String,Class,Class,Map)}
  - {@link org.apache.juneau.ObjectMap#getList(String,Class,List) getList(String,Class,List)}
- New methods on {@link org.apache.juneau.utils.PojoRest}:
  - {@link org.apache.juneau.utils.PojoRest#get(String,Class) get(String,Class)}
  - {@link org.apache.juneau.utils.PojoRest#get(String,Type,Type...) get(String,Type,Type...)}
  - {@link org.apache.juneau.utils.PojoRest#getWithDefault(String,Object) getWithDefault(String,Object)}
  - {@link org.apache.juneau.utils.PojoRest#getWithDefault(String,Object,Class) getWithDefault(String,Object,Class)}
  - {@link org.apache.juneau.utils.PojoRest#getWithDefault(String,Object,Type,Type...) getWithDefault(String,Object,Type,Type...)}
- Fixed bug where {@link org.apache.juneau.BeanSession#getMediaType()} wasn't returning a value.
- Eliminated the @Consumes and @Produces annotations.
  The supported media types are now passed in through the constructors.
  This was changed to eliminate a performance issue where a field could not be set as final because the call to `getClass()` to retrieve the annotation value could not be called before calling the `super()` method.
- New class: {@link org.apache.juneau.utils.PojoMerge}
- New doc: 2.6.2 - @Pojo annotation
- New doc: 2.6.5 - Serializing Readers and InputStreams

###### juneau-dto

- {@link org.apache.juneau.dto.html5.HtmlElementMixed#children(Object...)} can now take in collections of objects.
- The DTO beans can now be serialized to strings of their typical language by calling the `toString()` method.
  For example, `Swagger.toString()` produces JSON and the HTML5 `Form.toString()` produces HTML.

###### juneau-rest-server

- Revamped and simplified servlet and REST-call lifecycle handling through new {@link org.apache.juneau.rest.annotation.RestHook @RestHook} annotation.
  - The {@link org.apache.juneau.rest.RestServlet#init(ServletConfig)} method is now final and can no longer be extended.
    Instead, use {@link org.apache.juneau.rest.annotation.HookEvent#INIT} or {@link org.apache.juneau.rest.annotation.HookEvent#POST_INIT} for initialization.
  - The following methods on {@link org.apache.juneau.rest.RestServlet} have been removed:
    - `init(RestConfig)` - Use {@link org.apache.juneau.rest.annotation.HookEvent#INIT} instead.
    - `onSuccess(RestRequest, RestResponse, long)` - Use {@link org.apache.juneau.rest.annotation.HookEvent#END_CALL} instead.
    - `onPreCall(RestRequest)` - Use {@link org.apache.juneau.rest.annotation.HookEvent#PRE_CALL} instead.
    - `onPostCall(RestRequest, RestResponse)` - Use {@link org.apache.juneau.rest.annotation.HookEvent#POST_CALL} instead.
- Simplified {@link org.apache.juneau.rest.widget.MenuItemWidget}.
  Exposes an abstract method {@link org.apache.juneau.rest.widget.MenuItemWidget#getContent(RestRequest)} that can return raw HTML via readers or char-sequences, or any other object (such as HTML5 beans) that will get converted to HTML using {@link org.apache.juneau.html.HtmlSerializer#DEFAULT}.
- {@link org.apache.juneau.rest.RestResourceResolver} instances are now inherited from parent resources to child resources unless explicitly overridden at the child level.
  It's also been changed to an interface.
- New annotations on {@link org.apache.juneau.rest.annotation.RestResource @RestResource}:
  - {@link org.apache.juneau.rest.annotation.RestResource#resourceResolver() resourceResolver()}
    Allows you to specify a resource resolver on the servlet context to make it easier to work with dependency injection frameworks.
  - {@link org.apache.juneau.rest.annotation.RestResource#contextPath() contextPath()} -
    Allows you to override the context path value inherited from the servlet container.
  - {@link org.apache.juneau.rest.annotation.RestResource#allowHeaderParams() allowHeaderParams()} -
    Replaces the `RestContext.REST_allowHeaderParams` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#allowMethodParam() allowMethodParam()} -
    Replaces the `RestContext.REST_allowMethodParam` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#allowBodyParam() allowBodyParam()} -
    Replaces the `RestContext.REST_allowBodyParam` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#renderResponseStackTraces() renderResponseStackTraces()} -
    Replaces the `RestContext.REST_xxx` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#useStackTraceHashes() useStackTraceHashes()} -
    Replaces the `RestContext.REST_useStackTraceHashes` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#defaultCharset() defaultCharset()} -
    Replaces the `RestContext.REST_defaultCharset` setting.
  - {@link org.apache.juneau.rest.annotation.RestResource#paramFormat() paramFormat()} -
    Replaces the `RestContext.REST_paramFormat` setting.
- New annotations on {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod}:
  - {@link org.apache.juneau.rest.annotation.RestMethod#defaultCharset() defaultCharset()} -
    Replaces the `RestContext.REST_defaultCharset` setting.
  - {@link org.apache.juneau.rest.annotation.RestMethod#paramFormat() paramFormat()} -
    Replaces the `RestContext.REST_paramFormat` setting.
- The following implementation classes can now be defined as non-static inner classes of servlets/resources:
  - {@link org.apache.juneau.rest.widget.Widget}
  - {@link org.apache.juneau.rest.RestConverter}
  - {@link org.apache.juneau.rest.RestGuard}
  - {@link org.apache.juneau.rest.ResponseHandler}
  - {@link org.apache.juneau.rest.RestCallHandler}
  - {@link org.apache.juneau.rest.RestInfoProvider}
  - {@link org.apache.juneau.rest.RestResourceResolver}
  - {@link org.apache.juneau.rest.RestLogger}
  - {@link org.apache.juneau.html.HtmlDocTemplate}
- New tooltip template: {@link org.apache.juneau.rest.widget.Tooltip}
- New dark theme:
- Stylesheet selection now stored in HTTP session when passed in via `?stylesheet` query parameter.
- New doc: Lifecycle Hooks
- Eliminated the `RestServletJenaDefault` class to remove the Jena dependency class on the `juneau-rest-server` artifact.
  It's simple enough to simply extend `RestServletDefault` and add the RDF serializers and parsers.

###### juneau-microservice

- The microservice has been significantly modified to be configured via a `jetty.xml` file for maximum flexibility instead of the hodge-podge of support in the config file.
  Top-level servlets should now be defined in the provided `jetty.xml` file.
- New methods on {@link org.apache.juneau.microservice.RestMicroservice}:
  - {@link org.apache.juneau.microservice.RestMicroservice#addServlet(Servlet,String) addServlet(Servlet,String)}
  - {@link org.apache.juneau.microservice.RestMicroservice#addServletAttribute(String,Object) addServletAttribute(String,Object)}
  - {@link org.apache.juneau.microservice.RestMicroservice#getServer() getServer()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getInstance() getInstance()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getPort() getPort()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getContextPath() getContextPath()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getProtocol() getProtocol()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getHostName() getHostName()}
- New methods on {@link org.apache.juneau.microservice.Microservice}:
  - {@link org.apache.juneau.microservice.Microservice#getInstance() getInstance()}
- New class {@link org.apache.juneau.microservice.JettyLogger} for directing Jetty logging to the java.util.logging framework.
- New class {@link org.apache.juneau.microservice.resources.DebugResource} for viewing and generating Jetty thread dumps through REST calls.

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

- New example of adding a menu-item widget to the Pet Store resource (including tooltips):

### 6.3.1 (Aug 1, 2017)

Juneau 6.3.1 is a minor release.

###### org.apache.juneau

- {@link org.apache.juneau.utils.PojoQuery} improvements.
- New {@link org.apache.juneau.remoteable.RemoteMethod#returns()} annotation.
  Allows you to specify whether the remote method returns the HTTP body or status code.
- Fixed bugs with {@link org.apache.juneau.BeanContext#BEAN_includeProperties} and {@link org.apache.juneau.BeanContext#BEAN_excludeProperties} settings.
- New/modified settings in {@link org.apache.juneau.html.HtmlDocSerializerContext}:
  - `HTMLDOC_script`
  - `HTMLDOC_style` - Was HTMLDOC_css.
  - `HTMLDOC_stylesheet` - Was HTMLDOC_cssUrl. Now an array.
- New {@link org.apache.juneau.utils.ResourceFinder} utility class. Allows you to search for resources up the parent hierarchy chain. Also allows you to search for localized resources.
- Eliminated the following properties from {@link org.apache.juneau.html.HtmlDocSerializerContext}: HTMLDOC_title, HTMLDOC_description, HTMLDOC_description
  See below on changes to simplify HTML headers.
- {@link org.apache.juneau.svl.Var} implementations can now throw exceptions and will be converted to ""{exceptionMessage}" values.

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

- New 'light' stylesheet:
  Compared with previous 'devops':
  For those nolstalgic for old times, there's also 'original':
- Simplified the stylesheets and HTML code.
  For example, the nav links are now an ordered list of elements which makes rendering as as side-bar (for example) easier to do in CSS.
- Modifications to the following @HtmlDoc annotations:
  - {@link org.apache.juneau.rest.annotation.HtmlDoc#navlinks() navlinks()} - Now an array of strings instead of a JSON object. Simplified syntax.
    For example:

    // Old syntax htmldoc=@HtmlDoc( links="{" + "up:'request:/..'," + "options:'servlet:/?method=OPTIONS'," + "contentTypes:'$W{ContentTypeMenuItem}'," + "styles:'$W{StyleMenuItem}'," + "source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PetStoreResource.java'" + "}" ) // New syntax htmldoc=@HtmlDoc( navlinks={ "up: request:/..", "options: servlet:/?method=OPTIONS", "$W{ContentTypeMenuItem}", "$W{StyleMenuItem}", "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/PetStoreResource.java" } )

    Previous syntax will still work, but you're encouraged to use the simplified syntax.
  - Several annotations are now arrays of strings instead of simple strings. Values are simply concatenated with newlines which makes multi-line values cleaner.
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#header() header()}
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#nav() nav()}
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#aside() aside()}
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#footer() footer()}
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#script() script()}
    - {@link org.apache.juneau.rest.annotation.HtmlDoc#style() style()}
    Additionally, the "INHERIT" string literal can be used to combine the value with the value defined on the servlet or parent class. Links can also be inserted at specific index positions.
- Improvements made to the {@link org.apache.juneau.rest.widget.Widget} API.
  - You can now add arbitrary CSS and Javascript along with your widgets through new methods:
    - {@link org.apache.juneau.rest.widget.Widget#getHtml(RestRequest)}
    - {@link org.apache.juneau.rest.widget.Widget#getScript(RestRequest)}
    - {@link org.apache.juneau.rest.widget.Widget#getStyle(RestRequest)}
  - Declaration of widgets moved to {@link org.apache.juneau.rest.annotation.HtmlDoc#widgets() @HtmlDoc.widgets()} instead of separately on @RestResource and @RestMethod annotations.
  - {@link org.apache.juneau.rest.widget.Widget#getName()} now defaults to the simple class name.
    So now you can just refer to the class name: "$W{ContentTypeMenuItem}".
  - Renamed widgets:
    - `PoweredByApacheWidget` -> `PoweredByApache`
    - `PoweredByJuneauWidget` -> `PoweredByJuneau`
  - New {@link org.apache.juneau.rest.widget.MenuItemWidget} can be used as a starting point for creatint pull-down menu items.
  - New {@link org.apache.juneau.rest.widget.ContentTypeMenuItem} widget that provides a pull-down menu with hyperlinks for all supported languages for that page:
  - Improved {@link org.apache.juneau.rest.widget.QueryMenuItem} widget that provides a pull-down menu of a search/view/order-by/page form:
    Fields are now pre-filled with current query parameters.
  - New {@link org.apache.juneau.rest.widget.StyleMenuItem} widget that provides a pull-down menu with hyperlinks to show the content in the default stylesheets:
- New/modified annotations on {@link org.apache.juneau.rest.annotation.HtmlDoc @HtmlDoc}:
  - {@link org.apache.juneau.rest.annotation.HtmlDoc#style() style()} - Renamed from `css()`.
  - {@link org.apache.juneau.rest.annotation.HtmlDoc#stylesheet() stylesheet()} - Renamed from `cssUrl()`.
    Can now be a comma-delimited list of URLs.
  - {@link org.apache.juneau.rest.annotation.HtmlDoc#script() script()} - Add arbitrary Javascript to page header.
- Bug fix with {@link org.apache.juneau.rest.annotation.HtmlDoc#nowrap()} so that the setting only applies to the data contents, not the whole page.
- Two convenience methods added to {@link org.apache.juneau.rest.RestRequest}:
  - {@link org.apache.juneau.rest.RestRequest#attr(String,Object) attr(String,Object)}
  - {@link org.apache.juneau.rest.RestRequest#prop(String,Object) prop(String,Object)}
- Annotations added:
  - {@link org.apache.juneau.rest.annotation.RestResource#siteName()}
  - {@link org.apache.juneau.rest.annotation.RestResource#flags()}
  - {@link org.apache.juneau.rest.annotation.RestMethod#flags()}
- Eliminated the `@RestResource.stylesheet()` annotation. It's no longer needed now that you can easily specify styles via @Htmldoc.
- Eliminated the following annotations since they are now redundant with {@link org.apache.juneau.rest.annotation.HtmlDoc#header()}:
  - `title()`
  - `description()`
  - `branding()`
  Instead, the {@link org.apache.juneau.rest.RestServletDefault} class defines the following default header that can be easily overridden:

  htmldoc=@HtmlDoc( header={ "<h1>$R{servletTitle}</h1>", "<h2>$R{methodSummary,$R{servletDescription}}</h2>", "<a href='http://juneau.apache.org'><img src='$U{servlet:/htdocs/juneau.png}' style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/></a>" } )

  Note that the subtitle first tries using the method summary and then the servlet description.
- New {@link org.apache.juneau.rest.vars.FileVar $F} variable resolver for resolving the contents of files in the classpath.
  The `DockerRegistryResource` examples shows how it can be used to pull in a localized file from the classpath to populate the aside section of a page.

  htmldoc=@HtmlDoc( // Pull in aside contents from file. aside="$F{resources/DockerRegistryResourceAside.html}" )

- New {@link org.apache.juneau.rest.ReaderResource#toCommentStrippedString()} method.
- The `bpIncludes()` and `bpExcludes()` annotations on @RestMethod has been replaced with the following:
  - {@link org.apache.juneau.rest.annotation.RestMethod#bpi() bpi()} - Now an array of simplified values instead of LAX JSON.
  - {@link org.apache.juneau.rest.annotation.RestMethod#bpx() bpx()} - Now an array of simplified values instead of LAX JSON.
- Two new variables added to `$R` variable: "$R{servletClass}", "$R{servletClassSimple}"

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

- Added CONTENT-TYPE and STYLES menu items to most pages.
- Added improved QUERY menu item to PetStore page.

### 6.3.0 (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: {@link org.apache.juneau.http}.
- Support for dynamic beans. See {@link org.apache.juneau.annotation.BeanProperty#name() @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 {@link org.apache.juneau.ini.ConfigFile}:
  - {@link org.apache.juneau.ini.ConfigFile#put(String,String,String,boolean) put(String,String,String,boolean)}
  - {@link org.apache.juneau.ini.ConfigFile#put(String,String,Object,Serializer,boolean,boolean) put(String,String,Object,boolean,boolean)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,Type,Type...) getObject(String,Type,Type...)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,Parser,Type,Type...) getObject(String,Parser,Type,Type...)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,Class) getObject(String,Class)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,Parser,Class) getObject(String,Parser,Class)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,String,Type,Type...) getObject(String,String,Type,Type...)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,String,Parser,Type,Type...) getObject(String,String,Parser,Type,Type...)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,String,Class) getObject(String,String,Class)}
  - {@link org.apache.juneau.ini.ConfigFile#getObject(String,String,Parser,Class) getObject(String,String,Parser,Class)}
  - {@link org.apache.juneau.ini.ConfigFile#getObjectWithDefault(String,Object,Type,Type...) getObjectWithDefault(String,Object,Type,Type)}
  - {@link org.apache.juneau.ini.ConfigFile#getObjectWithDefault(String,Parser,Object,Type,Type...) getObjectWithDefault(String,Parser,Object,Type,Type)}
  - {@link org.apache.juneau.ini.ConfigFile#getObjectWithDefault(String,Object,Class) getObjectWithDefault(String,Object,Class)}
  - {@link org.apache.juneau.ini.ConfigFile#getObjectWithDefault(String,Parser,Object,Class) getObjectWithDefault(String,Parser,Object,Class)}
- New ability to interact with config file sections with proxy interfaces with new method {@link org.apache.juneau.ini.ConfigFile#getSectionAsInterface(String,Class)}.
- {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotation can now be applied to getters and setters defined on interfaces.
- New methods on {@link org.apache.juneau.serializer.SerializerSession} and {@link org.apache.juneau.parser.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 {@link org.apache.juneau.serializer.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:
  - {@link org.apache.juneau.rest.client.RestClientBuilder#partSerializer(Class)}
  - {@link org.apache.juneau.remoteable.Path#serializer}
  - {@link org.apache.juneau.remoteable.Query#serializer}
  - {@link org.apache.juneau.remoteable.QueryIfNE#serializer}
  - {@link org.apache.juneau.remoteable.FormData#serializer}
  - {@link org.apache.juneau.remoteable.FormDataIfNE#serializer}
  - {@link org.apache.juneau.remoteable.Header#serializer}
  - {@link org.apache.juneau.remoteable.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 {@link org.apache.juneau.annotation.URI @URI}.
  - New classes:
    - {@link org.apache.juneau.UriContext}
    - {@link org.apache.juneau.UriRelativity}
    - {@link org.apache.juneau.UriResolution}
    - {@link org.apache.juneau.UriResolver}
  - New configuration properties:
  - `SerializerContext.SERIALIZER_uriContext`
  - `SerializerContext.SERIALIZER_uriRelativity`
  - `SerializerContext.SERIALIZER_uriResolution`
  - `SerializerContext.SERIALIZER_maxIndent`
- New annotation property: {@link org.apache.juneau.annotation.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:
  - {@link org.apache.juneau.serializer.SerializerListener}
  - {@link org.apache.juneau.serializer.SerializerBuilder#listener(Class)}
  - {@link org.apache.juneau.rest.annotation.RestResource#serializerListener()}
  - {@link org.apache.juneau.rest.RestConfig#serializerListener(Class)}
  - {@link org.apache.juneau.parser.ParserListener}
  - {@link org.apache.juneau.parser.ParserBuilder#listener(Class)}
  - {@link org.apache.juneau.rest.annotation.RestResource#parserListener()}
  - {@link org.apache.juneau.rest.RestConfig#parserListener(Class)}
  - {@link org.apache.juneau.rest.client.RestClientBuilder#listeners(Class,Class)}
- The {@link org.apache.juneau.BeanContext#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 {@link org.apache.juneau.html.annotation.Html#render() @Html.render()} annotation and {@link org.apache.juneau.html.HtmlRender} class that allows you to customize the HTML output and CSS style on bean properties:
    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 {@link org.apache.juneau.html.HtmlDocTemplate} that allows full control over rendering of HTML produced by {@link org.apache.juneau.html.HtmlDocSerializer}.
- {@link org.apache.juneau.annotation.NameProperty @NameProperty} and {@link org.apache.juneau.annotation.ParentProperty @ParentProperty} can now be applied to fields.
- New properties on {@link org.apache.juneau.BeanContext}:
  - {@link org.apache.juneau.BeanContext#BEAN_includeProperties BEAN_includeProperties}
  - {@link org.apache.juneau.BeanContext#BEAN_excludeProperties BEAN_excludeProperties}
- New annotation property: {@link org.apache.juneau.annotation.BeanProperty#format()}.

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

- MAJOR enhancements made to the REST API.
- The {@link org.apache.juneau.rest.RestRequest} class functionality has been broken up into the following functional pieces to reduce its complexity:
  - {@link org.apache.juneau.rest.RestRequest#getBody()} - The request body.
  - {@link org.apache.juneau.rest.RestRequest#getHeaders()} - The request headers.
  - {@link org.apache.juneau.rest.RestRequest#getQuery()} - The request query parameters.
  - {@link org.apache.juneau.rest.RestRequest#getFormData()} - The request form data parameters.
  - {@link org.apache.juneau.rest.RestRequest#getPathMatch()} - The path variables and remainder.
  The following classes have been introduced:
  - {@link org.apache.juneau.rest.RequestBody}
  - {@link org.apache.juneau.rest.RequestHeaders}
  - {@link org.apache.juneau.rest.RequestQuery}
  - {@link org.apache.juneau.rest.RequestFormData}
  - {@link org.apache.juneau.rest.RequestPathMatch}
- 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:
  - {@link org.apache.juneau.rest.RestRequest} - The request object.
  - {@link javax.servlet.http.HttpServletRequest} - The superclass of `RestRequest`.
  - {@link org.apache.juneau.rest.RestResponse} - The response object.
  - {@link javax.servlet.http.HttpServletResponse} - The superclass of `RestResponse`.
  The new supported types are:
  - {@link org.apache.juneau.http.Accept}
  - {@link org.apache.juneau.http.AcceptCharset}
  - {@link org.apache.juneau.http.AcceptEncoding}
  - {@link org.apache.juneau.http.AcceptLanguage}
  - {@link org.apache.juneau.http.Authorization}
  - {@link org.apache.juneau.http.CacheControl}
  - {@link org.apache.juneau.http.Connection}
  - {@link org.apache.juneau.http.ContentLength}
  - {@link org.apache.juneau.http.ContentType}
  - {@link org.apache.juneau.http.Date}
  - {@link org.apache.juneau.http.Expect}
  - {@link org.apache.juneau.http.From}
  - {@link org.apache.juneau.http.Host}
  - {@link org.apache.juneau.http.IfMatch}
  - {@link org.apache.juneau.http.IfModifiedSince}
  - {@link org.apache.juneau.http.IfNoneMatch}
  - {@link org.apache.juneau.http.IfRange}
  - {@link org.apache.juneau.http.IfUnmodifiedSince}
  - {@link org.apache.juneau.http.MaxForwards}
  - {@link org.apache.juneau.http.Pragma}
  - {@link org.apache.juneau.http.ProxyAuthorization}
  - {@link org.apache.juneau.http.Range}
  - {@link org.apache.juneau.http.Referer}
  - {@link org.apache.juneau.http.TE}
  - {@link org.apache.juneau.http.UserAgent}
  - {@link org.apache.juneau.http.Upgrade}
  - {@link org.apache.juneau.http.Via}
  - {@link org.apache.juneau.http.Warning}
  - {@link java.util.TimeZone}
  - {@link java.io.InputStream}
  - {@link javax.servlet.ServletInputStream}
  - {@link java.io.Reader}
  - {@link java.io.OutputStream}
  - {@link javax.servlet.ServletOutputStream}
  - {@link java.io.Writer}
  - {@link java.util.ResourceBundle} - Client-localized resource bundle.
  - {@link org.apache.juneau.utils.MessageBundle} - A resource bundle with additional features.
  - {@link java.util.Locale} - Client locale.
  - {@link org.apache.juneau.rest.RequestHeaders} - API for accessing request headers.
  - {@link org.apache.juneau.rest.RequestQuery} - API for accessing request query parameters.
  - {@link org.apache.juneau.rest.RequestFormData} - API for accessing request form data.
  - {@link org.apache.juneau.rest.RequestPathMatch} - API for accessing path variables.
  - {@link org.apache.juneau.rest.RequestBody} - API for accessing request body.
  - {@link org.apache.juneau.http.HttpMethod} - The method name matched (when using `@RestMethod(name="*")`)
  - {@link java.util.logging.Logger} - The logger to use for logging.
  - {@link org.apache.juneau.internal.JuneauLogger} - Logger with additional features.
  - {@link org.apache.juneau.rest.RestContext} - The resource read-only context.
  - {@link org.apache.juneau.parser.Parser} - The parser matching the request content type.
  - {@link org.apache.juneau.dto.swagger.Swagger} - The auto-generated Swagger doc.
  - {@link org.apache.juneau.ini.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 String a1, @Path int a2, @Path 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 {@link org.apache.juneau.rest.annotation.RestResource#paramResolvers() @RestResource.paramResolvers()} that allows you to define your own custom Java method parameter resolvers.
- Fixed bug where Writer returned by {@link org.apache.juneau.rest.RestResponse#getWriter()} was not being flushed automatically at the end of the HTTP call.
- New annotations added to {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod}:
  - {@link org.apache.juneau.rest.annotation.RestMethod#defaultQuery() defaultQuery()}
  - {@link org.apache.juneau.rest.annotation.RestMethod#defaultFormData() defaultFormData()}
  - `bpIncludes()`
  - `bpExcludes()`
- Default values on header, query, and form-data annotations:
  - {@link org.apache.juneau.rest.annotation.Header#def @Header.def()} - Default header value.
  - {@link org.apache.juneau.rest.annotation.Query#def @Query.def()} - Default query parameter value.
  - {@link org.apache.juneau.rest.annotation.FormData#def @FormData.def()} - Default form data parameter value.
- New attributes on {@link org.apache.juneau.rest.annotation.RestResource @RestResource}:
  - {@link org.apache.juneau.rest.annotation.RestResource#serializerListener() serializerListener()}
  - {@link org.apache.juneau.rest.annotation.RestResource#parserListener() parserListener()}
  - `widgets()`
  - {@link org.apache.juneau.rest.annotation.RestResource#swagger() swagger()}
  - {@link org.apache.juneau.rest.annotation.RestResource#htmldoc() htmldoc()}
- New attributes on {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod}:
  - `widgets()`
  - {@link org.apache.juneau.rest.annotation.RestMethod#swagger() swagger()}
  - {@link org.apache.juneau.rest.annotation.RestMethod#htmldoc() htmldoc()}
- New string vars:
  - {@link org.apache.juneau.rest.vars.UrlVar} - Resolve "$U{...}" variables to URLs.
  - {@link org.apache.juneau.rest.vars.WidgetVar} - Resolve "$W{...}" variables to widget contents.
- New methods on {@link org.apache.juneau.rest.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 {@link org.apache.juneau.rest.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:
  - {@link org.apache.juneau.rest.widget.Widget}
  - `PoweredByJuneauWidget`
  - `ContentTypeLinksColumnWidget`
  - `ContentTypeLinksRowWidget`
  - `QueryWidget`
- `devops.css` cleaned up.
- Removed a bunch of URL-related methods from {@link org.apache.juneau.rest.RestRequest}. These all have equivalents in {@link org.apache.juneau.rest.RestRequest#getUriContext()}.
- New annotation attributes:
  - {@link org.apache.juneau.rest.annotation.Query#name() @Query.name()}
  - {@link org.apache.juneau.rest.annotation.FormData#name() @FormData.name()}
  - {@link org.apache.juneau.rest.annotation.Header#name() @Header.name()}
  - {@link org.apache.juneau.rest.annotation.Path#name() @Path.name()}
  - {@link org.apache.juneau.rest.annotation.HasQuery#name() @HasQuery.name()}
  - {@link org.apache.juneau.rest.annotation.HasFormData#name() @HasFormData.name()}

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

- New {@link org.apache.juneau.remoteable.Path @Path} annotation for specifying path variables on remoteable interfaces.
- New {@link org.apache.juneau.remoteable.RequestBean @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.
  {@link org.apache.juneau.remoteable.FormData @FormData},{@link org.apache.juneau.remoteable.FormDataIfNE @FormDataIfNE}, {@link org.apache.juneau.remoteable.Query @Query},{@link org.apache.juneau.remoteable.QueryIfNE @QueryIfNE}, {@link org.apache.juneau.remoteable.Header @Header},{@link org.apache.juneau.remoteable.HeaderIfNE @HeaderIfNE},

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

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

- Many code enhancements make 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.

### 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 = JsonSerializer.DEFAULT_LAX.clone().setUseWhitespace(true).pojoSwaps(BSwap.class).lock(); // New way WriterSerializer s = JsonSerializer.DEFAULT_LAX.builder().ws().pojoSwaps(BSwap.class).build();

- Also introduced the following builder classes and related architecture changes to make the built objects unmodifiable:
  - {@link org.apache.juneau.serializer.SerializerGroupBuilder}
  - {@link org.apache.juneau.parser.ParserGroupBuilder}
  - {@link org.apache.juneau.encoders.EncoderGroupBuilder}
- Revamped the config file API to use a build: {@link org.apache.juneau.ini.ConfigFileBuilder}.
- Removed the `Lockable` interface.
- New `addBeanTypeProperties` setting added to serializers to override the `SerializerContext.SERIALIZER_addBeanTypeProperties` setting 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 org.apache.juneau.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 org.apache.juneau.dto.swagger.SwaggerBuilder} class.
  - Fluent-style setters added to the Swagger beans.
  - Added Swagger examples here and in the org.apache.juneau.dto.swagger javadocs.
- Improvements to {@link org.apache.juneau.svl.VarResolver}.
  - New {@link org.apache.juneau.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 org.apache.juneau.html.HtmlParser} can now parse full body contents generated by {@link org.apache.juneau.html.HtmlDocSerializer}.
- Parse-args supported added to {@link org.apache.juneau.msgpack.MsgPackParser} to allow it to be used in remoteable proxies.
- Added some convenience classes for constructing collections using a fluent interface:
  - {@link org.apache.juneau.utils.AList}
  - {@link org.apache.juneau.utils.ASet}
  - {@link org.apache.juneau.utils.AMap}
- New {@link org.apache.juneau.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 org.apache.juneau.dto.html5.HtmlElementContainer#getChild(int...)}
  - {@link org.apache.juneau.dto.html5.HtmlElementMixed#getChild(int...)}
- New common serializer setting: `SerializerContext.SERIALIZER_abridged`.
- Support for defining interface proxies against 3rd-party REST interfaces.
  New package {@link org.apache.juneau.remoteable} for 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 org.apache.juneau.urlencoding.UrlEncodingSerializerBuilder}:
  - {@link org.apache.juneau.urlencoding.UrlEncodingSerializerBuilder#paramFormat(String) paramFormat(String)}
  - `UrlEncodingSerializerBuilder.plainTextParams()`

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

- {@link org.apache.juneau.rest.annotation.RestResource @RestResource} annotation can now be applied to any class! You're no longer restricted to subclassing your resources from {@link org.apache.juneau.rest.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:
  - {@link org.apache.juneau.rest.RestConfig} - A modifiable configuration of a resource. Subclasses from {@link javax.servlet.ServletConfig}.
  - {@link org.apache.juneau.rest.RestContext} - A read-only configuration that's the result of a snapshot of the config.
  The {@link org.apache.juneau.rest.RestServlet} class 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 {@link org.apache.juneau.rest.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 {@link org.apache.juneau.rest.annotation.RestResource @RestResource} to allow non-`RestServlet` resources to do the same as subclassing directly from `RestServlet`:
  - {@link org.apache.juneau.rest.annotation.RestResource#resourceResolver() resourceResolver()} - Specify a {@link org.apache.juneau.rest.RestResourceResolver} class for resolving child resources.
  - {@link org.apache.juneau.rest.annotation.RestResource#callHandler() callHandler()} - Specify a {@link org.apache.juneau.rest.RestCallHandler} class for handling the lifecycle of a REST call.
  - {@link org.apache.juneau.rest.annotation.RestResource#infoProvider() infoProvider()} - Specify a {@link org.apache.juneau.rest.RestInfoProvider} class for customizing title/description/Swagger information on a REST resource.
  - {@link org.apache.juneau.rest.annotation.RestResource#logger() logger()} - Specify a {@link org.apache.juneau.rest.RestLogger} class for handling logging.
- New annotations added to {@link org.apache.juneau.rest.annotation.RestResource @RestResource} and {@link org.apache.juneau.rest.annotation.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.
- {@link org.apache.juneau.rest.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 {@link org.apache.juneau.rest.StreamResource.Builder} class.
- Simplified remoteable proxies using the `@RestMethod(name="PROXY")` annotation on REST methods. Used to expose interface proxies without the need for {@link org.apache.juneau.rest.remoteable.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 {@link org.apache.juneau.rest.annotation.RestMethod#name()} for more information.
- {@link org.apache.juneau.rest.RestRequest#toString()} can be called at any time to view the headers and content of the request without affecting functionality. Very useful for debugging.
- You can now use numeric values in path annotations.
  When using numeric variable names, you don't need to specify the variable name in the @Path annoation:

  @RestMethod(name="GET", path="/myurl/{0}/{1}/{2}/*") public void doGet(RestRequest req, RestResponse res, @Path String foo, @Path int bar, @Path UUID baz) { ... }

- {@link org.apache.juneau.rest.annotation.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 org.apache.juneau.rest.client.RestClient}:
  - {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class,Object) getRemoteableProxy(Class,Object)} - For interface proxies defined using `@RestMethod(name="PROXY")`.
  - {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class,Object,Serializer,Parser) getRemoteableProxy(Class,Object,Serializer,Parser)} - Same as above, but overrides the serializer and parser defined on the client.
  - {@link org.apache.juneau.rest.client.RestClient#doPost(Object) doPost(Object)}
  - {@link org.apache.juneau.rest.client.RestClient#doCall(HttpMethod,Object,Object) doCall(HttpMethod,Object,Object)} - Can now pass in instances of {@link org.apache.juneau.rest.client.NameValuePairs} for easy form posts.
    This extends to all methods that take in the input.
- New methods on {@link org.apache.juneau.rest.client.RestCall}:
  - {@link org.apache.juneau.rest.client.RestCall#uri(Object) uri(Object)}
  - {@link org.apache.juneau.rest.client.RestCall#query(String,Object,boolean,PartSerializer) query(String,Object,boolean,PartSerializer)}
  - {@link org.apache.juneau.rest.client.RestCall#query(String,Object) query(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#queryIfNE(String,Object) queryIfNE(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#query(Map) query(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#queryIfNE(Map) queryIfNE(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#query(String) query(String)}
  - {@link org.apache.juneau.rest.client.RestCall#formData(String,Object,boolean,PartSerializer) formData(String,Object,boolean,PartSerializer)}
  - {@link org.apache.juneau.rest.client.RestCall#formData(String,Object) formData(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#formDataIfNE(String,Object) formDataIfNE(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#formData(Map) formData(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#formDataIfNE(Map) formDataIfNE(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#header(String,Object,boolean,PartSerializer) header(String,Object,boolean,PartSerializer)}
  - {@link org.apache.juneau.rest.client.RestCall#header(String,Object) header(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#headerIfNE(String,Object) headerIfNE(String,Object)}
  - {@link org.apache.juneau.rest.client.RestCall#headers(Map) headers(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#headersIfNE(Map) headersIfNE(Map)}
  - {@link org.apache.juneau.rest.client.RestCall#host(String) host(String)}
  - {@link org.apache.juneau.rest.client.RestCall#port(int) port(int)}
  - {@link org.apache.juneau.rest.client.RestCall#userInfo(String,String) userInfo(String,String)}
  - {@link org.apache.juneau.rest.client.RestCall#userInfo(String) userInfo(String)}
  - {@link org.apache.juneau.rest.client.RestCall#scheme(String) scheme(String)}
- New methods added to {@link org.apache.juneau.rest.client.RestClientBuilder}:
  - {@link org.apache.juneau.rest.client.RestClientBuilder#executorService(ExecutorService,boolean) executorService(ExecutorService,boolean)}
  - {@link org.apache.juneau.rest.client.RestClientBuilder#paramFormat(String) paramFormat(ExecutorService,boolean)}
  - `RestClientBuilder.plainTextParams()`
  - {@link org.apache.juneau.rest.client.RestClientBuilder#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 org.apache.juneau.rest.client.RestClientBuilder#debug() debug()} now adds a `Debug: true` header on all requests.
- New methods added/updated to {@link org.apache.juneau.rest.client.RestCall}:
  - {@link org.apache.juneau.rest.client.RestCall#runFuture() runFuture()}
  - {@link org.apache.juneau.rest.client.RestCall#getResponseFuture(Class) getResponseFuture(Class)}
  - {@link org.apache.juneau.rest.client.RestCall#getResponseFuture(Type,Type...) getResponseFuture(Type,Type...)}
  - {@link org.apache.juneau.rest.client.RestCall#getResponseAsStringFuture() getResponseAsStringFuture()}
  - {@link org.apache.juneau.rest.client.RestCall#serializer(Serializer) serializer(Serializer)} - Override the serializer defined on the client for a single call.
  - {@link org.apache.juneau.rest.client.RestCall#parser(Parser) parser(Parser)} - Override the parser defined on the client for a single call.
  - {@link org.apache.juneau.rest.client.RestCall#input(Object) input(Object)} - Now accepts instances of {@link org.apache.juneau.rest.client.NameValuePairs}.
  - {@link org.apache.juneau.rest.client.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 {@link org.apache.juneau.rest.client.NameValuePairs}:
  - {@link org.apache.juneau.rest.client.NameValuePairs#append(String,Object) append(String,Object)}
  - {@link org.apache.juneau.rest.client.NameValuePairs#append(String,Object,PartSerializer) append(String,Object,PartSerializer)}
- {@link org.apache.juneau.rest.client.RetryOn} is now an abstract class with an additional method:
  - {@link org.apache.juneau.rest.client.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 `0`s to try a random port.
- Methods added to {@link org.apache.juneau.microservice.RestMicroservice} class:
  - {@link org.apache.juneau.microservice.RestMicroservice#getPort()}
  - {@link org.apache.juneau.microservice.RestMicroservice#getURI()}
  - Override methods added from {@link org.apache.juneau.microservice.Microservice} class for easier method chaining.

### 6.1.0 (Feb 25, 2017)

Juneau 6.1.0 is a major update.

In particular, this release cleans up the {@link org.apache.juneau.BeanContext} API to match the {@link org.apache.juneau.PropertyStore}/{@link org.apache.juneau.Context}/{@link org.apache.juneau.Session} paradigm previously used in the serializer and parser APIs. It also makes several improvements to the HTML and XML serialization support and introduces HTML5 DTO beans.

###### org.apache.juneau

- Improvements to XML serialization support.
  - New supported XML formats:
    - {@link org.apache.juneau.xml.annotation.XmlFormat#ATTRS} format can now be applied to bean classes to have all bean properties serialized as attributes instead of elements by default.
    - {@link org.apache.juneau.xml.annotation.XmlFormat#ELEMENT} format can now be applied to bean properties to override the {@link org.apache.juneau.xml.annotation.XmlFormat#ATTRS} setting above on specific bean properties.
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#ELEMENTS} format can be applied to a bean property of type array/Collection to represent the child elements.
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED} format can be applied to a bean property of type array/Collection to represent mixed content (text + child elements).
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED_PWS} format. Identical to MIXED except preserves whitespace.
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT} format can be applied to a bean property of a single object to represent a text node as a child.
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT_PWS} format. Identical to TEXT except preserves whitespace.
    - New {@link org.apache.juneau.xml.annotation.XmlFormat#XMLTEXT} format that's identical to {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT} except XML content is not escaped and serialized directly as the child content. The parser will reconvert this to the original XML text during parsing.
  - New support methodology and other improvements to org.apache.juneau.xml documentation.
  - Eliminated unnecessary <string> elements.
  - Eliminated `XmlContentHandler` class.
  - Parser efficiency improvements through reuse of string builders.
  - Reworked and simplified the default XML serializers. The {@link org.apache.juneau.xml.XmlSerializer#DEFAULT} serializer now has namespaces disabled, and {@link org.apache.juneau.xml.XmlSerializer#DEFAULT_NS} has namespaces enabled. The 'XML-JSON' serializers have been eliminated.
  - Eliminated the `addJsonTypeAttrs` and `addJsonStringTypeAttrs` settings.
  - Namespace support is now disabled by default.
- Significant modifications and improvements to HTML serialization support.
  - Parser converted from `XMLEventReader`-based to `XMLStreamReader`.
  - Eliminated many unnecessary type tags and <string> elements and improved the readable layout. The new format is much leaner.
  - New exhaustive support methodology section added to org.apache.juneau.html documentation.
- New HTML5 DTO support: org.apache.juneau.dto.html5.
- {@link org.apache.juneau.BeanContext} class split into separate {@link org.apache.juneau.BeanContext} and {@link org.apache.juneau.BeanSession} classes.
  - Session object meant to be single-use that can be discarded after use and contains session-level object cache and overridable Locale and TimeZone.
- {@link org.apache.juneau.serializer.SerializerContext} and {@link org.apache.juneau.parser.ParserContext} now extend directly from {@link org.apache.juneau.BeanContext}.
- {@link org.apache.juneau.serializer.SerializerSession} and {@link org.apache.juneau.parser.ParserSession} now extend directly from {@link org.apache.juneau.BeanSession}.
- New settings in {@link org.apache.juneau.BeanContext}:
  - {@link org.apache.juneau.BeanContext#BEAN_debug} - Debug setting. Replaces individual debug properties in the serializer and parser contexts.
  - {@link org.apache.juneau.BeanContext#BEAN_locale} - Specifies a default locale at the context level.
  - {@link org.apache.juneau.BeanContext#BEAN_timeZone} - Specifies a default timezone at the context level.
  - {@link org.apache.juneau.BeanContext#BEAN_mediaType} - Specifies a default media type at the context level.
- Improvements to Parser class:
  - Simplified the parse methods (e.g. `parseMap()`, `parseCollection()`) by replacing them with two simple methods:
    - {@link org.apache.juneau.parser.Parser#parse(Object,Class)} - Normal method.
    - {@link org.apache.juneau.parser.Parser#parse(Object,Type,Type...)} - Method for parsing into parameterized maps and collections.
    Using these methods, you can construct arbitrarily complex objects consisting of maps and collections. You could do this before, but it required constructing a `ClassMeta` object.
    For example:

    // Old way: ClassMeta<?> cm = parser.getMapClassMeta( HashMap.class, String.class, parser.getCollectionClassMeta( LinkedList.class, MyBean.class ) ); Map<String,List<MyBean>> map = (Map<String,List<MyBean>>)parser.parse(input, cm); // New way: Map<String,List<MyBean>> map = parser.parse(input, HashMap.class, String.class, LinkedList.class, MyBean.class);

  - Arbitrarily-complex parameterized maps and collections can now be parsed without the need for creating intermediate `ClassMeta` objects.
  - No need for casting anymore if you were using the old `parseMap()` and `parseCollection()` methods!
  - Changes allow me to eliminate `BeanContext.normalizeClassMeta()` method.
  - Convenience methods added for setting parser properties:

    // Old way: new JsonParser().setProperty(PARSER_strict, true).setProperty(BEAN_locale, mylocale); // New way: new JsonParser().setStrict(true).setLocale(mylocale);

- Improvements to Serializer class:
  - Convenience methods added for setting serializer properties:

    // Old way: new JsonSerializer().setProperty(JSON_simpleMode, true).setProperty(SERIALIZER_quoteChar, '"'); // New way: new JsonSerializer().setSimpleMode(true).setQuoteChar('"');

- Simplified {@link org.apache.juneau.transform.PojoSwap} class. Now just two methods:
  - {@link org.apache.juneau.transform.PojoSwap#swap(BeanSession,Object)}
  - {@link org.apache.juneau.transform.PojoSwap#unswap(BeanSession,Object,ClassMeta)}
- General code improvements made to {@link org.apache.juneau.ClassMeta} class.
  - All fields are now final which should improve overall performance.
  - Replaced support for `toObjectMap()` and `fromObjectMap()/T(ObjectMap)` methods with generalized `swap(BeanSession)`/`unswap(BeanSession,X)`/`T(BeanSession,X)` methods.
    See new section Swap methods for information.
- Session-level media type now available through {@link org.apache.juneau.BeanSession#getMediaType()} method. Allows for swaps and serializer/parser behavior to be tailored to individual media types.
- Several new {@link java.util.Calendar} and {@link java.util.Date} swaps:
  - {@link org.apache.juneau.transforms.CalendarSwap.ToString},{@link org.apache.juneau.transforms.DateSwap.ToString} - To {@link java.lang.String Strings} using the {@code Date.toString()} method.
  - {@link org.apache.juneau.transforms.CalendarSwap.ISO8601DT},{@link org.apache.juneau.transforms.DateSwap.ISO8601DT} - To ISO8601 date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.ISO8601DTZ},{@link org.apache.juneau.transforms.DateSwap.ISO8601DTZ} - Same as ISO8601DT, except always serializes in GMT.
  - {@link org.apache.juneau.transforms.CalendarSwap.ISO8601DTP},{@link org.apache.juneau.transforms.DateSwap.ISO8601DTP} - Same as ISO8601DT except with millisecond precision.
  - {@link org.apache.juneau.transforms.CalendarSwap.ISO8601DTPZ},{@link org.apache.juneau.transforms.DateSwap.ISO8601DTPZ} - Same as ISO8601DTZ except with millisecond precision.
  - {@link org.apache.juneau.transforms.CalendarSwap.RFC2822DT},{@link org.apache.juneau.transforms.DateSwap.RFC2822DT} - To RFC2822 date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.RFC2822DTZ},{@link org.apache.juneau.transforms.DateSwap.RFC2822DTZ} - Same as RFC2822DT, except always serializes in GMT.
  - {@link org.apache.juneau.transforms.CalendarSwap.RFC2822D},{@link org.apache.juneau.transforms.DateSwap.RFC2822D} - To RFC2822 date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateTimeSimple},{@link org.apache.juneau.transforms.DateSwap.DateTimeSimple} - To simple "yyyy/MM/dd HH:mm:ss" date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateSimple},{@link org.apache.juneau.transforms.DateSwap.DateSimple} - To simple "yyyy/MM/dd" date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.TimeSimple},{@link org.apache.juneau.transforms.DateSwap.TimeSimple} - To simple "HH:mm:ss" time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateFull},{@link org.apache.juneau.transforms.DateSwap.DateFull} - To {@link java.text.DateFormat#FULL} date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateLong},{@link org.apache.juneau.transforms.DateSwap.DateLong} - To {@link java.text.DateFormat#LONG} date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateMedium},{@link org.apache.juneau.transforms.DateSwap.DateMedium} - To {@link java.text.DateFormat#MEDIUM} date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateShort},{@link org.apache.juneau.transforms.DateSwap.DateShort} - To {@link java.text.DateFormat#SHORT} date strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.TimeFull},{@link org.apache.juneau.transforms.DateSwap.TimeFull} - To {@link java.text.DateFormat#FULL} time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.TimeLong},{@link org.apache.juneau.transforms.DateSwap.TimeLong} - To {@link java.text.DateFormat#LONG} time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.TimeMedium},{@link org.apache.juneau.transforms.DateSwap.TimeMedium} - To {@link java.text.DateFormat#MEDIUM} time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.TimeShort},{@link org.apache.juneau.transforms.DateSwap.TimeShort} - To {@link java.text.DateFormat#SHORT} time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateTimeFull},{@link org.apache.juneau.transforms.DateSwap.DateTimeFull} - To {@link java.text.DateFormat#FULL} date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateTimeLong},{@link org.apache.juneau.transforms.DateSwap.DateTimeLong} - To {@link java.text.DateFormat#LONG} date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateTimeMedium},{@link org.apache.juneau.transforms.DateSwap.DateTimeMedium} - To {@link java.text.DateFormat#MEDIUM} date-time strings.
  - {@link org.apache.juneau.transforms.CalendarSwap.DateTimeShort},{@link org.apache.juneau.transforms.DateSwap.DateTimeShort} - To {@link java.text.DateFormat#SHORT} date-time strings.
- New method {@link org.apache.juneau.serializer.SerializerGroup#getSerializerMatch(String)} that returns the matched serializer and media type.
- New method {@link org.apache.juneau.parser.ParserGroup#getParserMatch(String)} that returns the matched parser and media type.
- New method {@link org.apache.juneau.encoders.EncoderGroup#getEncoderMatch(String)} that returns the matched encoder and encoding.
- General improvements to Bean Dictionary support.
  - New {@link org.apache.juneau.BeanDictionaryList} class can be used for defining reusable sets of bean dictionaries consisting of classes annotated with {@link org.apache.juneau.annotation.Bean#typeName()}.
  - New {@link org.apache.juneau.BeanDictionaryMap} class can be used for defining reusable sets of bean dictionaries consisting of classes not annotated with {@link org.apache.juneau.annotation.Bean#typeName()}.
  - New {@link org.apache.juneau.annotation.Bean#beanDictionary()} annotation.
- Removed restriction on getters and setters to be prefixed with "getX/setX/isX" if a {@link org.apache.juneau.annotation.BeanProperty#name()} annotation is used.
- Improvements to ATOM DTO:
  - New {@link org.apache.juneau.dto.atom.AtomBuilder} class.
  - New setter method names for a better fluent design.
  - Updated org.apache.juneau.dto.atom documentation.
- New {@link org.apache.juneau.transform.MapSwap} and {@link org.apache.juneau.transform.StringSwap} classes.
- New {@link org.apache.juneau.serializer.WriterSerializer#println(Object)} method. Useful for debugging purposes.
- New {@link org.apache.juneau.BeanContext#getClassMeta(Type,Type...)} and {@link org.apache.juneau.BeanSession#getClassMeta(Type,Type...)} methods for retrieving Map and Collection class metas. Replaces the various `getMapClassMeta()`/`getCollectionClassMeta()` methods.
- New section added to this document: Juneau Data Transfer Objects (org.apache.juneau.dto)
- Modified the UON specification to work with mixed content.
  - The new specification is considerably cleaner and eliminates the need for separate normal/simple modes.
    It also allows for arbitrary whitespace to be added to the output without any confusion.
  - Eliminated the `UonParser.DEFAULT_WS_AWARE` and `UrlEncodingParser.DEFAULT_WS_AWARE` parsers.
    The normal {@link org.apache.juneau.uon.UonParser#DEFAULT} and {@link org.apache.juneau.urlencoding.UrlEncodingParser#DEFAULT} parsers will now handle whitespace.
  - Eliminated the `UonParserContext.UON_whitespaceAware` configuration setting.
  - Eliminated the `UonSerializer.DEFAULT_SIMPLE`, `UonSerializer.DEFAULT_SIMPLE_ENCODING` and `UrlEncodingSerializer.DEFAULT_SIMPLE` serializers since there is no separate simple mode anymore.
  - Eliminated the `UonParserContext.UON_simpleMode` configuration setting.
- Added new {@link org.apache.juneau.serializer.OutputStreamSerializer#serializeToHex(Object)} method.
  Useful mostly for testing purposes.
  Equivalently, the {@link org.apache.juneau.parser.InputStreamParser#parse(Object,Class)} method can now read the output from this method.
- Eliminated the `@Bean(subTypeProperty)` and `@Bean(subTypes)` annotations and replaced them with the ability to define subtypes using the existing {@link org.apache.juneau.annotation.Bean#beanDictionary() @Bean.beanDictionary()} annotation on parent classes and interfaces.
  This has the added benefit of simplifying the overall code.
- The `SerializerContext.SERIALIZER_addBeanTypeProperties` setting is now enabled by default.
- Combined the `SERIALIZER_addIndentation`/`JSON_addWhitespace`/`UON_addWhitespace` properties into a single `SerializerContext.SERIALIZER_useWhitespace` setting.

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

- {@link org.apache.juneau.rest.RestRequest} now passes locale and timezone to serializers/parsers/transforms.
- `RestRequest.getTimeZone()` method.
- Standardized the following methods in {@link org.apache.juneau.rest.RestRequest} to remove dependency on `ClassMeta` objects and eliminate the need for casts:
  - `RestRequest.getHeader(String,Class)`
  - `RestRequest.getHeader(String,Object,Class)`
  - `RestRequest.getHeader(String,Type,Type...)`
  - `RestRequest.getQueryParameter(String,Class)`
  - `RestRequest.getQueryParameter(String,Object,Class)`
  - `RestRequest.getQueryParameter(String,Type,Type...)`
  - `RestRequest.getQueryParameter(String,Object,Type,Type...)`
  - `RestRequest.getQueryParameters(String,Class)`
  - `RestRequest.getQueryParameters(String,Type,Type...)`
  - `RestRequest.getFormDataParameter(String,Class)`
  - `RestRequest.getFormDataParameter(String,Object,Class)`
  - `RestRequest.getFormDataParameters(String,Class)`
  - `RestRequest.getFormDataParameter(String,Type,Type...)`
  - `RestRequest.getFormDataParameters(String,Type,Type...)`
  - `RestRequest.getPathParameter(String,Class)`
  - `RestRequest.getPathParameter(String,Type,Type...)`
  - `RestRequest.getBody(Class)`
  - `RestRequest.getBody(Type,Type...)`
- New methods on {@link org.apache.juneau.rest.client.NameValuePairs}
- Fixed issue where whitespace was not added to UON/URL-Encoding output when `&plainText=true` specified.

### 6.0.1 (Jan 3, 2017)

Juneau 6.0.1 is a minor update.

###### org.apache.juneau

- General improvements to JSON parser.
  - Several fixes to handle obscure edge cases.
- New properties in {@link org.apache.juneau.parser.ParserContext}.
  - `ParserContext.PARSER_strict`
  - `ParserContext.PARSER_inputStreamCharset`
  - `ParserContext.PARSER_fileCharset`
- Removed `JsonParserContext.JSON_strictMode`. Replaced by `PARSER_strict`.
- `byte[]` arrays can now be passed to {@link org.apache.juneau.parser.Parser#parse(Object,Class)} for reader-based parsers.

### 6.0.0 (Oct 3, 2016)

Juneau 6.0.0 is a major update.

The major change is rebranding from "Juno" to "Juneau" in preparation for donation to the Apache Foundation.

###### org.apache.juneau

- Major changes around how serializer and parser class properties are defined to improve performance and concurrency.
  - New {@link org.apache.juneau.PropertyStore} class - Used for creating context objects.
  - New {@link org.apache.juneau.Context} class - Read-only configurations for serializers and parsers.
  - New {@link org.apache.juneau.Session} class - One-time use objects used by serializers and parsers.
  - All context context properties can now also be specified via system properties.
- Refactored serializer and parser APIs for more consistency between stream-based and character-based serializers and parsers.
  - More consistent handling of exceptions.
  - More consistent method declarations.
- Refactored var resolver API and added them to a new package - org.apache.juneau.svl.
  - Support for stream-based variables - {@link org.apache.juneau.svl.StreamedVar}.
  - Added support for context and session objects.
- Eliminated "_class" properties and replaced them with "_type" properties. The class properties were a little-used feature where we would serialize fully-qualified class names when the class type could not be inferred through reflection. It's been replaced with bean type names and bean dictionaries. Instead of class names, we serialize "_type" properties whose name is the type name defined on the bean being serialized. The parsers use a 'dictionary' of bean classes to resolve those names to actual bean classes. The following features were added to enable this support:
  - {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} - Annotation that defines an identifying name for a bean class.
  - {@link org.apache.juneau.transform.BeanFilterBuilder#typeName(String)} - Programmatic equivalent to annotation above.
  - {@link org.apache.juneau.BeanContext#BEAN_beanDictionary} - List of bean classes that make up the bean dictionary for lookup during parsing.
  - {@link org.apache.juneau.BeanContext#BEAN_beanTypePropertyName} - The overridable type property name. Default is "_type".
  - {@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()} - Define a type dictionary for a particular bean property value. This overrides the value specified using {@link org.apache.juneau.BeanContext#BEAN_beanDictionary}.
  - `SerializerContext.SERIALIZER_addBeanTypeProperties` - Controls whether type properties are serialized.
  In addition, the {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} value replaces the `@Xml.name()` annotation, and the "type" and "_class" attributes in the XML and HTML serializers have been standardized on a single "_type" attribute.
- Refactor bean filter support to use {@link org.apache.juneau.transform.BeanFilterBuilder} class. Allows the `BeanFilter` class to use final fields.
- {@link org.apache.juneau.msgpack MessagePack} support.
- Serializers can now serialize directly to {@link java.io.File Files}. See {@link org.apache.juneau.serializer.Serializer#serialize(Object,Object)}
- Parsers can now parse directly from {@link java.io.File Files} and other types. See {@link org.apache.juneau.parser.Parser#parse(Object,ClassMeta)}
- Parsers will automatically covert numeric input to POJOs that have numeric constructors (e.g. `java.util.Date`).
- Renamed 'Filters' to 'BeanFilters' and 'PojoSwaps'. Filters is just too overloaded a term.
- Internal utility classes moved to a new `org.apache.juneau.internal` package. These internal utility classes are not meant for consumption outside the Juneau codebase.
- New methods on {@link org.apache.juneau.parser.Parser}:
  - `org.apache.juneau.parser.Parser.createSession(ObjectMap,Method,Object)`
  - `Parser.getMediaRanges()`
- New methods on {@link org.apache.juneau.serializer.Serializer}:
  - `org.apache.juneau.serializer.Serializer.createSession(ObjectMap,Method)`
  - `Serializer.getMediaRanges()`
- New {@link org.apache.juneau.annotation.Bean#sort() @Bean.sort()} annotation.
- Added @Bean.properties annotations on various DTO beans to make the ordering consistent between IBM and Oracle JVMs.
  IBM JVMs maintain the order of methods in a class, whereas Oracle JVMs do not.
- Serializers and parsers now automatically convert {@link java.lang.Class} objects to readable names via {@link org.apache.juneau.internal.ClassUtils#getReadableClassName(Class)}.
- Eliminated the `ClassFilter` class since it's no longer needed.
- Code and concurrency improvements to {@link org.apache.juneau.serializer.SerializerGroup} and {@link org.apache.juneau.parser.ParserGroup}.
- Various enhancements to `BeanContext.convertToType(Object,Class)`.
- New properties on {@link org.apache.juneau.html.HtmlSerializer}:
  - `HtmlSerializerContext.HTML_detectLinksInStrings` - Automatically detect hyperlinks in strings.
  - `HtmlSerializerContext.HTML_lookForLabelParameters` - Specify anchor text by appending `&label=MyLabel` to URL.
  - `HtmlSerializerContext.HTML_labelParameter` - Specify what URL parameter to use as the anchor text label.
  - `HtmlSerializerContext.URI_ANCHOR` option for `HtmlSerializerContext.HTML_uriAnchorText`.
- Removed generics from {@link org.apache.juneau.BeanPropertyMeta}.
- Introduced new classes to eliminate the references to language-specific metadata in the core metadata classes:
  - {@link org.apache.juneau.ClassMetaExtended} / {@link org.apache.juneau.ClassMeta#getExtendedMeta(Class)}
  - {@link org.apache.juneau.BeanMetaExtended} / {@link org.apache.juneau.BeanMeta#getExtendedMeta(Class)}
  - {@link org.apache.juneau.BeanPropertyMetaExtended} / {@link org.apache.juneau.BeanPropertyMeta#getExtendedMeta(Class)}
- Renamed `@Transform` annotation to `@Pojo` so that it can be used for various POJO-related behavior, not just associating transforms.
- Introduced {@link org.apache.juneau.dto.swagger Swagger DTOs}.

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

- OPTIONS pages replaced with Swagger documents. Lots of changes related to supporting Swagger.
  - Annotation name changes to conform to Swagger specs: @Attr->@Path, @QParam->@Query, @Param->@FormData, @Content->@Body
  - Eliminated `ResourceOptions` and related code.
  - New annotations and related methods:
    - {@link org.apache.juneau.rest.annotation.RestResource#title() @RestResource.title()} / {@link org.apache.juneau.rest.RestInfoProvider#getTitle(RestRequest)}
    - {@link org.apache.juneau.rest.annotation.RestResource#description() @RestResource.description()} / {@link org.apache.juneau.rest.RestInfoProvider#getDescription(RestRequest)}
    - `@RestResource.termsOfService()` / {@link org.apache.juneau.rest.RestInfoProvider#getTermsOfService(RestRequest)}
    - `@RestResource.contact()` / {@link org.apache.juneau.rest.RestInfoProvider#getContact(RestRequest)}
    - `@RestResource.license()` / {@link org.apache.juneau.rest.RestInfoProvider#getLicense(RestRequest)}
    - `@RestResource.version()` / {@link org.apache.juneau.rest.RestInfoProvider#getVersion(RestRequest)}
    - `@RestResource.tags()` / {@link org.apache.juneau.rest.RestInfoProvider#getTags(RestRequest)}
    - `@RestResource.externalDocs()` / {@link org.apache.juneau.rest.RestInfoProvider#getExternalDocs(RestRequest)}
    - {@link org.apache.juneau.rest.annotation.RestMethod#summary() @RestMethod.summary()} / {@link org.apache.juneau.rest.RestInfoProvider#getMethodSummary(String,RestRequest)}
    - {@link org.apache.juneau.rest.annotation.RestMethod#description() @RestMethod.description()} / {@link org.apache.juneau.rest.RestInfoProvider#getMethodDescription(String,RestRequest)}
    - `@RestMethod.externalDocs()`
    - `@RestMethod.tags()`
    - `@RestMethod.deprecated()`
    - `@RestMethod.parameters()`
    - `@RestMethod.responses()`
- New `RestServletContext.paramFormat` context property.
- New/updated methods on {@link org.apache.juneau.rest.RestServlet}:
  - `RestServlet.createProperties()`
  - `RestServlet.createBeanContext(ObjectMap,Class[],Class[])`
  - `RestServlet.createBeanFilters()`
  - `RestServlet.createPojoSwaps()`
  - `RestServlet.createParsers(ObjectMap,Class[],Class[])`
  - `RestServlet.createUrlEncodingSerializer(ObjectMap,Class[],Class[])`
  - `RestServlet.createUrlEncodingParser(ObjectMap,Class[],Class[])`
  - `RestServlet.createConverters(ObjectMap)`
  - `RestServlet.createDefaultRequestHeaders(ObjectMap)`
  - `RestServlet.createDefaultResponseHeaders(ObjectMap)`
  - `RestServlet.createEncoders(ObjectMap)`
  - `RestServlet.createGuards(ObjectMap)`
  - `RestServlet.createMimetypesFileTypeMap(ObjectMap)`
  - `RestServlet.createResponseHandlers(ObjectMap)`
- New client-version annotations:
  - {@link org.apache.juneau.rest.annotation.RestResource#clientVersionHeader} - The name of the header used to identify the client version.
  - {@link org.apache.juneau.rest.annotation.RestMethod#clientVersion} - The client version range applied to a Java method.

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

- Removed the `JazzRestClient` class.
- New method `RestClient.setClientVersion(String)`.

### 5.2.0.1 (Mar 23, 2016)

Juno 5.2.0.1 is a moderate update.

###### com.ibm.team.juno

- Improved support for multi-line values in config files. Any line that begins with whitespace is interpreted as a continuation of the previous line.
- Support for '\uXXXX' character sequences in config files.
- Fixed issue in {@link org.apache.juneau.xml.XmlSerializer} where '\r' and '\n' characters were not being handled per XML specs.
- New methods on {@link org.apache.juneau.ObjectList}:
  - `ObjectList.getAt(Class,String)`
  - {@link org.apache.juneau.ObjectList#putAt(String,Object)}
  - {@link org.apache.juneau.ObjectList#postAt(String,Object)}
  - {@link org.apache.juneau.ObjectList#deleteAt(String)}
- New methods on {@link org.apache.juneau.ObjectMap}:
  - `ObjectMap.getAt(Class,String)`
  - {@link org.apache.juneau.ObjectMap#putAt(String,Object)}
  - {@link org.apache.juneau.ObjectMap#postAt(String,Object)}
  - {@link org.apache.juneau.ObjectMap#deleteAt(String)}
- New {@link org.apache.juneau.annotation.ThreadSafe @ThreadSafe} annotation.
- New `ClassFilter` class.
- `ConfigFile.getResolving(StringVarResolver,boolean)` method.
- `ConfigFile.getStringVar()` method.
- New `ParserContext.PARSER_trimStrings` property.
- New `SerializerContext.SERIALIZER_trimStrings` property.
- `Args.getStringVar()}` method.
- New {@link org.apache.juneau.utils.ManifestFile} class
- New {@link org.apache.juneau.utils.MessageBundle} class. Replaces SafeResourceBundle/SafeResourceMultiBundle/RestNls.
- New `StringMapVar` class.
- New `StringVars` class with reusable common `StringVar` instances.
- New {@link org.apache.juneau.internal.JuneauLogger} class.
- Default value for `XmlParserContext.XML_trimWhitespace` changed to true.

###### Server

- New methods on {@link org.apache.juneau.rest.RestContext}:
  - {@link org.apache.juneau.rest.RestContext#getMessages()}

###### Client

- Fixed potential issue in {@link org.apache.juneau.rest.client.RestClient} where the HTTP connection pool could end up exhausted if an error occurred.
- Improved thread safety on {@link org.apache.juneau.rest.client.RestClient}.
- New warning message is logged if a {@link org.apache.juneau.rest.client.RestClient} is garbage collected without being closed: "WARNING: RestClient garbage collected before it was finalized."

### 5.2.0.0 (Dec 30, 2015)

Juno 5.2.0.0 is a major update. Major changes have been made to the microservice architecture and config INI file APIs.

###### Core

- Significant changes and enhancements to the org.apache.juneau.ini API.
  - More consistent handling of comma-delimited lists of objects.
  - New methods in {@link org.apache.juneau.ini.ConfigFile}:
    - {@link org.apache.juneau.ini.ConfigFile#getStringArray(String)},{@link org.apache.juneau.ini.ConfigFile#getStringArray(String,String[])}
    - {@link org.apache.juneau.ini.ConfigFile#getSectionAsBean(String,Class)} - Instantiate a new bean with property values in the specfied section..
    - {@link org.apache.juneau.ini.ConfigFile#writeProperties(String,Object,boolean,Class[])} - Copy the properties in a config file section into properties on an existing bean or POJO.
    - {@link org.apache.juneau.ini.ConfigFile#getSectionMap(String)} - Get all the resolved values in a section.
    - {@link org.apache.juneau.ini.ConfigFile#containsNonEmptyValue(String)}
    - {@link org.apache.juneau.ini.ConfigFile#isEncoded(String)}
    - {@link org.apache.juneau.ini.ConfigFile#addListener(ConfigFileListener)} - Listen for modification events on the config file.
    - {@link org.apache.juneau.ini.ConfigFile#merge(ConfigFile)} - Merge the contents of another config file into this config file.
    - {@link org.apache.juneau.ini.ConfigFile#getResolving()}, `ConfigFile.getResolving(StringVarResolver)` - Return an instance of the config file that resolves string variables. Much more efficient than the previous design since the same underlying config file object is shared.
    - {@link org.apache.juneau.ini.ConfigFile#toWritable()} - Wraps the config file in a {@link org.apache.juneau.Writable} interface so that it can be serialized by the REST interface as a plain-text INI file instead of as a serialized POJO.
    - {@link org.apache.juneau.ini.ConfigFile#getInt(String)} - Now supports "M" and "K" to identify millions and thousands.
  - New methods in `ConfigMgr`:
    - `ConfigMgr.create()`, `ConfigMgr.create(Reader)`, `ConfigMgr.create(File)`
    - `ConfigMgr.deleteAll()`
  - New methods in {@link org.apache.juneau.ini.Section}:
    - {@link org.apache.juneau.ini.Section#setParent(ConfigFileImpl)} - Used by parsers to set the config file for this section.
    - {@link org.apache.juneau.ini.Section#setName(String)} - Used by parsers to set the name for this section.
  - New interfaces:
    - {@link org.apache.juneau.ini.ConfigFileListener}
    - {@link org.apache.juneau.ini.SectionListener}
    - {@link org.apache.juneau.ini.EntryListener}
  - {@link org.apache.juneau.ini.Encoder} methods have access to field names to use them as salt values.
  - The name of the default section is now "default". Before it was just null.
  - {@link org.apache.juneau.ini.XorEncoder} XOR key can be overridden through the "org.apache.juneau.ini.XorEncoder.key" system property.
- Support for converting Strings to POJOs if the POJO class has any of the following static methods:
  - `fromString(String)`
  - `valueOf(String)` (e.g. enums)
  - `parse(String)` (e.g. logging `Level` class)
  - `parseString(String)`
  - `forName(String)` (e.g. `Class` and `Charset` classes)
- Support for parsing into objects with unbound type variables. For example, if you have a class `Pair<S,T>` and you try to parse into this class (e.g. `parser.parse(in, Pair.class)`), the unbound type variables is interpreted as `Object` instead of throwing an exception.
- Support for serializing/parsing the following new types:
  - `AtomicInteger`
  - `AtomicLong`
  - `BigInteger`
  - `BigDecimal`
- Parsers have been enhanced to allow parent POJOs and field names to be passed into child POJOs. New {@link org.apache.juneau.annotation.NameProperty @NameProperty} and {@link org.apache.juneau.annotation.ParentProperty @ParentProperty} annotations are provided for identifying methods for setting names and parent POJOs on child POJOs. For example, the config file {@link org.apache.juneau.ini.Section} class represents a section in a config file. It needs to know it's own name and have a link to the {@link org.apache.juneau.ini.ConfigFile} that it belongs to. With these new annotations, config files can be reconstructed using any of the parsers.
- New classes and interfaces:
  - {@link org.apache.juneau.Streamable} interface for identifying objects that can be serialized directly to an output stream.
  - {@link org.apache.juneau.Writable} interface for identifying objects that can be serialized directly to a writer.
  - `StringObject` class that can be used for delayed object serialization.
  - {@link org.apache.juneau.internal.ByteArrayCache}
  - {@link org.apache.juneau.internal.ByteArrayInOutStream}
  - {@link org.apache.juneau.internal.FileUtils}
  - {@link org.apache.juneau.internal.ThrowableUtils}
  - `StringVarMultipart`
  - `StringVarWithDefault`
- New fields on {@link org.apache.juneau.ObjectList}:
  - {@link org.apache.juneau.ObjectList#EMPTY_LIST}
- New fields and methods on {@link org.apache.juneau.ObjectMap}:
  - {@link org.apache.juneau.ObjectMap#EMPTY_MAP}
  - {@link org.apache.juneau.ObjectMap#getStringArray(String)}
  - {@link org.apache.juneau.ObjectMap#getStringArray(String,String[])}
  - {@link org.apache.juneau.ObjectMap#putIfNull(String,Object)}
  - {@link org.apache.juneau.ObjectMap#putIfEmpty(String,Object)}
- New methods in {@link org.apache.juneau.internal.ArrayUtils}:
  - {@link org.apache.juneau.internal.ArrayUtils#contains(Object,Object[])}
  - {@link org.apache.juneau.internal.ArrayUtils#indexOf(Object,Object[])}
  - {@link org.apache.juneau.internal.ArrayUtils#toPrimitiveArray(Object)}
- New methods in {@link org.apache.juneau.internal.IOUtils}:
  - {@link org.apache.juneau.internal.IOUtils#pipe(Reader,Writer)}
  - {@link org.apache.juneau.internal.IOUtils#read(File)}
  - {@link org.apache.juneau.internal.IOUtils#readFile(String)}
  - {@link org.apache.juneau.internal.IOUtils#write(File,Reader)}
- New methods on {@link org.apache.juneau.utils.PojoRest}:
  - `PojoRest.get(Class,String,Object)`
  - {@link org.apache.juneau.utils.PojoRest#getString(String)}
  - {@link org.apache.juneau.utils.PojoRest#getString(String,String)}
  - {@link org.apache.juneau.utils.PojoRest#getInt(String)}
  - {@link org.apache.juneau.utils.PojoRest#getInt(String,Integer)}
  - {@link org.apache.juneau.utils.PojoRest#getLong(String)}
  - {@link org.apache.juneau.utils.PojoRest#getLong(String,Long)}
  - {@link org.apache.juneau.utils.PojoRest#getBoolean(String)}
  - {@link org.apache.juneau.utils.PojoRest#getBoolean(String,Boolean)}
  - {@link org.apache.juneau.utils.PojoRest#getMap(String)}
  - {@link org.apache.juneau.utils.PojoRest#getMap(String,Map)}
  - {@link org.apache.juneau.utils.PojoRest#getList(String)}
  - {@link org.apache.juneau.utils.PojoRest#getList(String,List)}
  - {@link org.apache.juneau.utils.PojoRest#getObjectMap(String)}
  - {@link org.apache.juneau.utils.PojoRest#getObjectMap(String,ObjectMap)}
  - {@link org.apache.juneau.utils.PojoRest#getObjectList(String)}
  - {@link org.apache.juneau.utils.PojoRest#getObjectList(String,ObjectList)}
- New methods on {@link org.apache.juneau.utils.ProcBuilder}:
  - {@link org.apache.juneau.utils.ProcBuilder#pipeTo(Writer,boolean)}
  - {@link org.apache.juneau.utils.ProcBuilder#pipeTo(Writer)}
  - {@link org.apache.juneau.utils.ProcBuilder#logTo(Writer,boolean)}
  - {@link org.apache.juneau.utils.ProcBuilder#logTo(Writer)}
  - {@link org.apache.juneau.utils.ProcBuilder#logTo(Level,Logger)}
  - {@link org.apache.juneau.utils.ProcBuilder#maxExitStatus(int)}
- New methods on {@link org.apache.juneau.internal.StringUtils}:
  - {@link org.apache.juneau.internal.StringUtils#isEmpty(Object)}
  - {@link org.apache.juneau.internal.StringUtils#nullIfEmpty(String)}
  - {@link org.apache.juneau.internal.StringUtils#base64EncodeToString(String)}
  - {@link org.apache.juneau.internal.StringUtils#base64Encode(byte[])}
  - {@link org.apache.juneau.internal.StringUtils#base64DecodeToString(String)}
  - {@link org.apache.juneau.internal.StringUtils#base64Decode(String)}
  - {@link org.apache.juneau.internal.StringUtils#generateUUID(int)}
  - {@link org.apache.juneau.internal.StringUtils#trim(String)}
  - {@link org.apache.juneau.internal.StringUtils#parseISO8601Date(String)}
  - {@link org.apache.juneau.internal.StringUtils#replaceVars(String,Map)}
  - {@link org.apache.juneau.internal.StringUtils#pathStartsWith(String,String)}
  - {@link org.apache.juneau.internal.StringUtils#pathStartsWith(String,String[])}
- New `StringVar.doResolve(String)` method.
- New `StringVarResolver.DEFAULT` field.
- Eliminated dependency on `javax.mail.internet.MimeUtility` by implementing our own {@link org.apache.juneau.internal.StringUtils#base64Encode(byte[])} method.
- {@link org.apache.juneau.transforms.CalendarSwap} and {@link org.apache.juneau.transforms.DateSwap} classes now handle blank input better. Returns null instead of throwing an exception.
- {@link org.apache.juneau.html.HtmlDocSerializer} specifies the default CSS location as `/servletPath/style.css` instead of `/servletPath/htdocs/juneau.css`. This coincides with enhancements made in the server code for specifying styles.
- {@link org.apache.juneau.html.HtmlDocSerializer} wraps output in two div tags instead of one (e.g. `<div class='outerdata'><div class='data' id='data'>...</div></div>`). Needed for supporting the new devops look-and-feel.
- Fixed indentation inconsistencies in {@link org.apache.juneau.html.HtmlDocSerializer}.
- Renamed HtmlSchemaSerializer to {@link org.apache.juneau.html.HtmlSchemaDocSerializer}.
- RDF serializers and parsers now support `RdfProperties.RDF_looseCollection` loose collections.
- RDF parser handles case where resources point to themselves (an unfortunate behavior in JFS RDF documents).
- JSON parser with throw an exception in strict mode if it encounters numbers that are valid in Java but invalid in JSON (e.g. octal, hexadecimal numbers).
- {@link org.apache.juneau.parser.Parser} methods now check for null input.
- {@link org.apache.juneau.serializer.SerializerGroup} and {@link org.apache.juneau.parser.ParserGroup} ignores serializers and parsers if they throw `NoClassDefFoundErrors`.
- {@link org.apache.juneau.urlencoding.UrlEncodingParser} creates lists if the same attribute name is encountered more than once. Before it would just replace the previous value with the new value.
- New `UrlEncodingSerializer.DEFAULT_SIMPLE_EXPANDED` serializer.
- Changes to {@link org.apache.juneau.utils.Args}:
  - `getMainArg(int)` changed to {@link org.apache.juneau.utils.Args#getArg(int)}. Non-existent arguments are returned as null instead of blank strings. This is more inline with the behavior of the rest of the library.
  - New {@link org.apache.juneau.utils.Args#hasArg(int)} method.
- Removed `org.apache.juneau.utils.CharsetUtils` class.
- Removed `org.apache.juneau.utils.ConcurrentIdentityList` class.
- Fixed bug in {@link org.apache.juneau.internal.MultiIterable} class.
- {@link org.apache.juneau.utils.PojoIntrospector} must now be instantiated with a `ReaderParser`. Simplifies the API on the class.
- {@link org.apache.juneau.utils.PojoRest} must now be instantiated with a `ReaderParser`. Simplifies the API on the class.
- {@link org.apache.juneau.utils.MessageBundle} and `SafeResourceMultiBundle` moved from server component.
- Several bug fixes and performance improvements in `StringVarResolver`.
- Various enhancements to {@link org.apache.juneau.internal.TeeWriter} and {@link org.apache.juneau.internal.TeeOutputStream}.
- Renamed CharSet to {@link org.apache.juneau.internal.AsciiSet}.
- {@link org.apache.juneau.serializer.SerializerGroup} and {@link org.apache.juneau.parser.ParserGroup} now ignores `NoClassDefFoundErrors` so that resources that include Jena support can continue to operate even if the Jena libraries are not present.
- New {@link org.apache.juneau.internal.FileUtils#createTempFile(String)} method.
- New {@link org.apache.juneau.utils.PojoQuery} modified to handle bean getters that throw exceptions.

###### Client

- Upgraded to use Apache HttpClient 4.5.
- New classes:
  - {@link org.apache.juneau.rest.client.AllowAllRedirects}
  - {@link org.apache.juneau.rest.client.HttpMethod}
  - {@link org.apache.juneau.rest.client.ResponsePattern}
  - {@link org.apache.juneau.rest.client.SimpleX509TrustManager}
  - {@link org.apache.juneau.rest.client.SSLOpts}
- Removed `org.apache.juneau.rest.client.LaxRedirectStrategy`. Use HTTP Client equivalent.
- New methods on {@link org.apache.juneau.rest.client.RestCall}:
  - `RestCall#addInterceptor(RestCallInterceptor)`
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(Writer)}
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(Writer,boolean)}
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(String,Writer,boolean)}
  - {@link org.apache.juneau.rest.client.RestCall#getWriter(String)}
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(OutputStream)}
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(OutputStream,boolean)}
  - {@link org.apache.juneau.rest.client.RestCall#pipeTo(String,OutputStream,boolean)}
  - {@link org.apache.juneau.rest.client.RestCall#getOutputStream(String)}
  - {@link org.apache.juneau.rest.client.RestCall#byLines()}
  - {@link org.apache.juneau.rest.client.RestCall#captureResponse()}
  - {@link org.apache.juneau.rest.client.RestCall#successPattern(String)}
  - {@link org.apache.juneau.rest.client.RestCall#failurePattern(String)}
  - `RestCall#addResponsePattern(ResponsePattern)`
  - {@link org.apache.juneau.rest.client.RestCall#run()} - Renamed from `execute()`.
  - {@link org.apache.juneau.rest.client.RestCall#getCapturedResponse()}
  - {@link org.apache.juneau.rest.client.RestCall#getResponsePojoRest(Class)}
  - {@link org.apache.juneau.rest.client.RestCall#getResponsePojoRest()}
  - {@link org.apache.juneau.rest.client.RestCall#logTo(Level,Logger)}
  - {@link org.apache.juneau.rest.client.RestCall#setConfig(RequestConfig)}
- New lifecycle listener methods on {@link org.apache.juneau.rest.client.RestCallInterceptor}:
  - {@link org.apache.juneau.rest.client.RestCallInterceptor#onInit(RestCall)}
  - {@link org.apache.juneau.rest.client.RestCallInterceptor#onClose(RestCall)}
- New methods on {@link org.apache.juneau.rest.client.RestClient}:
  - `RestClient.setBasicAuth(String,int,String,String)`
  - `RestClient.logTo(Level,Logger)`
  - `RestClient.setRootUrl(String)`
  - `RestClient.enableSSL(SSLOpts)`
  - `RestClient.enableLaxSSL()`
  - {@link org.apache.juneau.rest.client.RestClient#doCall(HttpMethod,Object,Object)}
  - `RestClient.createHttpClientBuilder()`
- New passthrough methods on {@link org.apache.juneau.rest.client.RestClient} defined on `HttpClientBuilder`:
  - `RestClient.setRedirectStrategy(RedirectStrategy)`
  - `RestClient.setDefaultCookieSpecRegistry(Lookup)`
  - `RestClient.setRequestExecutor(HttpRequestExecutor)`
  - `RestClient.setSSLHostnameVerifier(HostnameVerifier)`
  - `RestClient.setPublicSuffixMatcher(PublicSuffixMatcher)`
  - `RestClient.setSSLContext(SSLContext)`
  - `RestClient.setSSLSocketFactory(LayeredConnectionSocketFactory)`
  - `RestClient.setMaxConnTotal(int)`
  - `RestClient.setMaxConnPerRoute(int)`
  - `RestClient.setDefaultSocketConfig(SocketConfig)`
  - `RestClient.setDefaultConnectionConfig(ConnectionConfig)`
  - `RestClient.setConnectionTimeToLive(long,TimeUnit)`
  - `RestClient.setConnectionManager(HttpClientConnectionManager)`
  - `RestClient.setConnectionManagerShared(boolean)`
  - `RestClient.setConnectionReuseStrategy(ConnectionReuseStrategy)`
  - `RestClient.setKeepAliveStrategy(ConnectionKeepAliveStrategy)`
  - `RestClient.setTargetAuthenticationStrategy(AuthenticationStrategy)`
  - `RestClient.setProxyAuthenticationStrategy(AuthenticationStrategy)`
  - `RestClient.setUserTokenHandler(UserTokenHandler)`
  - `RestClient.disableConnectionState()`
  - `RestClient.setSchemePortResolver(SchemePortResolver)`
  - `RestClient.setUserAgent(String userAgent)`
  - `RestClient.setDefaultHeaders(Collection)`
  - `RestClient.addInterceptorFirst(HttpResponseInterceptor)`
  - `RestClient.addInterceptorLast(HttpResponseInterceptor)`
  - `RestClient.addInterceptorFirst(HttpRequestInterceptor)`
  - `RestClient.addInterceptorLast(HttpRequestInterceptor)`
  - `RestClient.disableCookieManagement()`
  - `RestClient.disableContentCompression()`
  - `RestClient.disableAuthCaching()`
  - `RestClient.setHttpProcessor(HttpProcessor)`
  - `RestClient.setRetryHandler(HttpRequestRetryHandler)`
  - `RestClient.disableAutomaticRetries()`
  - `RestClient.setProxy(HttpHost)`
  - `RestClient.setRoutePlanner(HttpRoutePlanner)`
  - `RestClient.disableRedirectHandling()`
  - `RestClient.setConnectionBackoffStrategy(ConnectionBackoffStrategy)`
  - `RestClient.setBackoffManager(BackoffManager)`
  - `RestClient.setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy)`
  - `RestClient.setDefaultCookieStore(CookieStore)`
  - `RestClient.setDefaultCredentialsProvider(CredentialsProvider)`
  - `RestClient.setDefaultAuthSchemeRegistry(Lookup)`
  - `RestClient.setContentDecoderRegistry(Map)`
  - `RestClient.setDefaultRequestConfig(RequestConfig)`
  - `RestClient.useSystemProperties()`
  - `RestClient.evictExpiredConnections()`
  - `RestClient.evictIdleConnections(long,TimeUnit)`
- `JazzRestClient` now supports OIDC authentication.
- These classes are now deprecated and will be removed in a future release:
  - `org.apache.juneau.rest.client.jazz.CertificateStore`
  - `org.apache.juneau.rest.client.jazz.ICertificateValidator`
  - `org.apache.juneau.rest.client.jazz.ITrustStoreProvider`
  - `org.apache.juneau.rest.client.jazz.LenientCertificateValidator`
  - `org.apache.juneau.rest.client.jazz.SharedTrustStoreProvider`
  - `org.apache.juneau.rest.client.jazz.ValidatingX509TrustManager`

###### Server

- New {@link org.apache.juneau.rest.ReaderResource} class. Represents the contents of a text file with convenience methods for resolving `StringVar` variables and adding HTTP response headers. REST Java methods can return instances of these to serialize `Readers` containing text with `StringVarResolver` variables in them.
- New {@link org.apache.juneau.rest.StreamResource} class. REST Java methods can return instances of these to serialize `OutputStreams`.
- Fixed a bug in the stack trace hash algorithm in {@link org.apache.juneau.rest.RestException}.
- New methods in {@link org.apache.juneau.rest.RestRequest}:
  - {@link org.apache.juneau.rest.RestRequest#getReaderResource(String)} - Replaces `getVarResource(String)`.
  - {@link org.apache.juneau.rest.RestRequest#getReaderResource(String,boolean)}
  - `RestRequest.getReaderResource(String,boolean,String)`
- Changes in {@link org.apache.juneau.rest.RestResponse}:
  - Don't set `Content-Encoding: identity` when no encoding is used. Some clients don't interpret it correctly.
- New methods in {@link org.apache.juneau.rest.RestServlet}:
  - `RestServlet.getChildClasses()` - Programmatic equivalent to {@link org.apache.juneau.rest.annotation.RestResource#children()} annotation.
  - `RestServlet.shouldLog(HttpServletRequest,HttpServletResponse,RestException)`
  - `RestServlet.shouldLogStackTrace(HttpServletRequest,HttpServletResponse,RestException)`
  - `RestServlet.logObjects(Level,String,Object[])`
  - `RestServlet.resolveStaticFile(String)`
  - `RestServlet.createStyleSheet()`
  - `RestServlet.createFavIcon()`
  - `RestServlet.createStaticFilesMap()`
  - `RestServlet.getConfigMgr()`
- Removed {@link org.apache.juneau.jso.JsoParser} from {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault`. These may represent a security risk if not handled correctly, so removed them as a precaution.
- Removed `RestServletProperties.REST_htDocsFolder`. Replaced with {@link org.apache.juneau.rest.annotation.RestResource#staticFiles()}.
- New annotations on {@link org.apache.juneau.rest.annotation.RestResource}.
  - `RestResource.stylesheet()`
  - `RestResource.favicon()`
  - {@link org.apache.juneau.rest.annotation.RestResource#staticFiles()}
- Eliminated `org.apache.juneau.rest.jaxrs.JsonProvider` class. Some JAX-RS implementations use code scanning to find providers, so if you were using `DefaultJenaProvider`, it would pick up `JsonProvider` as well. It's easy enough to create your own implementation if needed.
- OPTIONS pages now specify `consumes` and `produces` fields instead of `accept` and `contentType` which was confusing.
- Eliminated `properties` from OPTIONS pages.
- New `ResourceLink.ResourceLink(String,RestRequest,String,Object[])` constructor.
- New response handlers:
  - {@link org.apache.juneau.rest.response.StreamableHandler} - Allows REST Java methods to return instances of {@link org.apache.juneau.Streamable}.
  - {@link org.apache.juneau.rest.response.WritableHandler} - Allows REST Java methods to return instances of {@link org.apache.juneau.Writable}.
- New DevOps stylesheet.
- Servlet initialization and HTTP requests are now logged at FINE level.
- Added abstract modifier on various RestServlet subclasses to indicate that they're meant to be subclassed.
- New {@link org.apache.juneau.rest.RestUtils#trimPathInfo(StringBuffer,String,String)} method.

###### Microservice

- Completely revamped API.
- New {@link org.apache.juneau.microservice.Microservice} class that serves as a generic interface for microservices and their lifecycles.
- New {@link org.apache.juneau.microservice.RestMicroservice} class that implements a microservice consisting of a REST interface.
  - REST resources and configuration settings can be defined through either manifest files or config files.
  - Enhanced logging support.
  - Easy-to-configure SSL support.
  - BASIC auth support.
  - Automatic restartability if the config file changes.
- Eliminated `org.apache.juneau.microservice.Main` class. This is replaced by the microservice classes defined above.
- {@link org.apache.juneau.microservice.Resource} and {@link org.apache.juneau.microservice.ResourceGroup} classes now support the following new string variables:
  - "$ARG{key,default}"" - Command line arguments.
  - "$MF{key,default}"" - Manifest file entries.
- CSS stylesheet now configurable through config file entry "REST/stylesheet".
- New {@link org.apache.juneau.microservice.ResourceJena} class if you want your REST interface to support RDF.
- Eliminated the following classes:
  - `org.apache.juneau.microservice.RootResource`
  - `org.apache.juneau.microservice.SampleResource`
- New predefined reusable resources:
  - {@link org.apache.juneau.microservice.resources.ConfigResource} - REST resource for viewing and editing microservice config file.
  - {@link org.apache.juneau.microservice.resources.LogsResource} - REST resource for viewing log files.
  - {@link org.apache.juneau.microservice.resources.SampleRootResource} - Sample REST resource that contains the config and logs resource as children.
  - {@link org.apache.juneau.microservice.resources.ShutdownResource} - REST resource for stopping the microservice JVM. Useful for testing purposes.

###### Samples

- Converted to a REST microservice.
- Look-and-feel changed to IBM DevOps.

###### Documentation Updates

- org.apache.juneau.microservice - New package-level javadoc.
- org.apache.juneau.ini - New package-level javadoc.
- `StringVarResolver` - New documentation.
- org.apache.juneau.rest.client - New package-level javadoc.
- Overview / Samples - New section.
- org.apache.juneau.transform / Stop Classes - New section.
- org.apache.juneau.rest - Extensive updates.

### 5.1.0.20 (Sept 5, 2015)

Juno 5.1.0.20 is a moderate update. The biggest improvement is the ability to associate external INI config files with REST servlets using the {@link org.apache.juneau.ini.ConfigFile} functionality.

###### Core

- Significant API changes to org.apache.juneau.ini API.
  - {@link org.apache.juneau.ini.ConfigFile} is now thread safe and can be shared across multiple threads.
  - New `ConfigMgr` class for managing configuration files.
  - Serializers and parsers can be associated with config files for storing and retrieving POJOs. Default support provided for JSON.
- New {@link org.apache.juneau.html.SimpleHtmlWriter} class. Can be used for simple HTML DOM construction.
- New {@link org.apache.juneau.utils.ProcBuilder} class for calling external processes.
- New `ObjectMap.remove(Class,String,Object)` method.
- "class='link'" added to links generated by {@link org.apache.juneau.html.HtmlDocSerializer}.
- New `EncoderGroup#append(EncoderGroup)` method.
- New `HtmlDocSerializerContext.HTMLDOC_addLinks` configuration property.
- Modified the `Parser.createContext(ObjectMap,Method,Object)` method. Outer context objects can be passed in to create instances of non-static inner classes.
- Fixed bug in {@link org.apache.juneau.html.HtmlStrippedDocSerializer} where exception was thrown when trying to serialize primitive arrays.
- {@link org.apache.juneau.json.JsonParser} now handles parsing JSON boolean/numeric values as strings to bean properties of type boolean or number.
- {@link org.apache.juneau.urlencoding.UrlEncodingSerializer} and {@link org.apache.juneau.urlencoding.UrlEncodingParser} now represent arrays and collections as key-value pairs where the keys are numbers (e.g. "?0=foo&1=bar").
- Various internal improvements to {@link org.apache.juneau.utils.IOPipe}.
- New {@link org.apache.juneau.internal.ReflectionUtils#getResource(Class,String)} method.
- {@link org.apache.juneau.internal.StringUtils#parseNumber(String,Class)} now returns zero for empty strings. This affects the way most parsers handle blank values.

###### Server

- You can now parse into non-static inner classes of a servlet for parameters/attributes/content. Useful if you like to define your marshaller beans inside your servlet.
- Changes to {@link org.apache.juneau.rest.RestServlet}:
  - New methods for accessing external INI config files:
    `RestServlet.getConfig()`
    `RestServlet.createConfigFile()`
  - New "$C{...}" variable that resolve to INI config file values.
  - New "$UE{...}" variable that URL-encodes the value inside the variable.
  - New convenience methods for retrieving classpath resource files:
    `RestServlet.getResource(String)`
    `RestServlet.getResourceAsString(String)`
    `RestServlet.getResource(Class,String,String)`. Useful if you want to load predefined POJOs from JSON files in your classpath.
  - New `RestServlet.handleNotFound(int,RestRequest,RestResponse)` method for customized handling of when a resource or method was not found.
- {@link org.apache.juneau.rest.RestServletDefault} now automatically processes "/favicon.ico" requests by overriding the new `RestServlet.handleNotFound(int,RestRequest,RestResponse)` method.
- New {@link org.apache.juneau.rest.RestRequest} methods:
  - {@link org.apache.juneau.rest.RestRequest#resolveVars(String)}
  - `RestRequest.getVarResource(String)`
  - `RestRequest.getConfig()`
- New {@link org.apache.juneau.rest.RestResponse} methods:
  - {@link org.apache.juneau.rest.RestResponse#getDirectWriter(String)}.
  - {@link org.apache.juneau.rest.RestResponse#getNegotiatedWriter()}. `getWriter()` now returns an unnegotiated writer. `getUnbufferedWriter()` has been removed.
- New {@link org.apache.juneau.rest.annotation.RestMethod#encoders() @RestMethod.encoders()} and {@link org.apache.juneau.rest.annotation.RestMethod#inheritEncoders() @RestMethod.inheritEncoders} annotations. Allows encoders to be fine-tuned at the method level.
- New {@link org.apache.juneau.rest.annotation.RestResource#config() @RestResource.config()} annotation for associating external {@link org.apache.juneau.ini.ConfigFile} config files with servlets.
- `ResourceLink`.
- New org.apache.juneau.rest.matchers package for commonly-used {@link org.apache.juneau.rest.RestMatcher RestMatchers}:
  - {@link org.apache.juneau.rest.matchers#MultipartFormDataMatcher}
  - {@link org.apache.juneau.rest.matchers#UrlEncodedFormMatcher}

###### Microservice

- New juneau-microservice.jar file that encapsulates all 3 juneau jars with code necessary for creating fast and efficent jetty-powered REST microservices.
  Contains the following:
  - Jetty 8.0
  - Apache HttpClient 4.3.5
  - Apache Commons FileUpload 1.3.1
- Microservice now supports Java 6 (previously required Java 7)

### 5.1.0.19 (Aug 15, 2015)

Juno 5.1.0.19 is a minor update in terms of core functionality. But it introduces a Microservices project for building REST microservices and docker containers.

###### Core

- Beans can now be serialized to and parsed from {@link org.apache.juneau.ObjectMap ObjectMaps}. See Serializing to ObjectMaps for details.
- New {@link org.apache.juneau.ObjectMap#include(String[])} and {@link org.apache.juneau.ObjectMap#exclude(String[])} methods.
- {@link org.apache.juneau.html.annotation.Html @Html} annotations can now be applied to bean properties.
- New {@link org.apache.juneau.utils.IOPipe} utility class.
- Behavior change on `StringVarResolver`. null input now results in blank strings instead of null.

###### Client

- New {@link org.apache.juneau.rest.client.RestClient#doCallback(String)} method.

###### Server

- New {@link org.apache.juneau.rest.RestRequest#getHeaders()} method.
- New `RestResponse.getUnbufferedWriter()` method.
- Fixed bug that was preventing `x-response-headers` parameter from working correctly.
- Added {@link org.apache.juneau.annotation.Bean#properties() @Bean.properties} annotations to the various classes in org.apache.juneau.rest.labels so that the order of the bean properties are consistent on all JVMs. On IBM JVMs this is unnecessary because the order of the properties as defined in the class are stored in the bytecode. Other JVMs such as OpenJRE do not implement this feature causing the bean properties to be in random order.
- New `ResourceDescription.ResourceDescription(RestRequest,String,String)` constructor.

### 5.1.0.18 (Aug 5, 2015)

Juno 5.1.0.18 is a minor update affecting the server component only.

###### Server

- Fixed bug where localized strings weren't resolving when using chained resource bundles.
- Servlet and method labels and descriptions can now contain embedded string variables.
- New `RestMethod.input()` and `RestMethod.responses()` annotations. These replace the various `description` annotations added 2 days ago with a simpler design.
- New methods on {@link org.apache.juneau.rest.RestServlet}:
  - `RestServlet.getMethodDescription(String,RestRequest)` so that subclasses can override the method description in the OPTIONS page.
  - `RestServlet.createRequestVarResolver(RestRequest)` so that subclasses can override and augment the variable resolver.
  - `RestServlet.resolveChild(Class)` and `RestServlet.replaceChild(RestServlet)` classes that allows customized resolution of servlet instances (e.g. if services are defined in OSGi).
- Reverted the `MethodDescription` back to 5.1.0.16 since it was being used by someone.

### 5.1.0.17 (Aug 3, 2015)

Juno 5.1.0.17 is a major update.

###### Core

- {@link org.apache.juneau.BeanMap#get(Object)} and {@link org.apache.juneau.BeanMap#put(String,Object)} now automatically performs filtering if filters are defined on the bean property or bean property class.
  - Deleted the following methods which are now unnecessary:
    - `BeanMap.getFiltered(String)`
    - `BeanMap.putFiltered(String,Object)`
    - `BeanMapEntry.getFiltered(String)`
    - `BeanMapEntry.putFiltered(String,Object)`
    - `BeanMapEntry.putFiltered(String,Object)`
    - `BeanPropertyMeta.getFiltered()`
    - `BeanPropertyMeta.setFiltered(Object)`
    - `BeanPropertyMeta.getTransformedClassMeta()`
  - {@link org.apache.juneau.BeanPropertyMeta#getClassMeta()} now returns the filtered type of the property.
- `StringVarResolver` now has support for chained resolvers.
- `StringVarResolver` now resolves variables inside resolved values. i.e. if a resolved variable value itself contains a variable, it now resolves that variable too.
- Fixed bug where inner interface classes being used in `RestResource.filters()` were being interpreted as surrogate classes because they have hidden 1-arg constructors due to being inner classes.
- Fixed bug in {@link org.apache.juneau.internal.MultiSet} where exception was being thrown if last set was empty.
- New {@link org.apache.juneau.utils.ZipFileList} class for providing efficiently zipped directories through the REST interface.
- New `RdfProperties.RDF_useXmlNamespaces` property.
- New `XmlParserContext.XML_preserveRootElement` property.
- Worked around bug in Sun VM on OS/X where XML parser was throwing an exception when trying to set a reporter.

###### Server

- New {@link org.apache.juneau.rest.response.ZipFileListResponseHandler} class.
- Simplified labels in servlet resource bundles:
  - `"[ClassName].ResourceDescription"` is now `"[ClassName].label"`.
  - `"[ClassName].MethodDescription.[methodName]"` is now `"[ClassName].[methodName]"`.
- Several changes to {@link org.apache.juneau.rest.RestRequest}:
  - Added new methods:
    - `RestRequest.getQueryParameterMap()`
    - `RestRequest.getQueryParameterNames()`
    - `RestRequest.getPathInfoUndecoded()`
    - `RestRequest.getPathRemainderUndecoded()`
    - `RestRequest.getTrimmedRequestURI()`
    - `RestRequest.getTrimmedRequestURL()`
    - {@link org.apache.juneau.rest.RestRequest#getServletTitle()}
    - {@link org.apache.juneau.rest.RestRequest#getServletDescription()}
    - {@link org.apache.juneau.rest.RestRequest#getMethodDescription()}
  - Behavior changes to {@link org.apache.juneau.rest.RestRequest#getPathInfo()} to follow Servlet specs. Returns null instead of blank for no path info.
  - `RestRequest.getPathRemainder()` now automatically decodes the path remainder. Use `RestRequest.getPathRemainderUndecoded()` to get the unencoded path remainder.
  - Bug fixes in `RestRequest.getRequestParentURI()` when servlet is mapped to "/*".
  - Bug fixes in `RestRequest.getServletURI()` when servlet is mapped to "/*".
- New string replacement variables:
  - `$R{contextPath}` - Returns value from {@link org.apache.juneau.rest.RestRequest#getContextPath()}
  - `$R{methodDescription}` - Returns value from {@link org.apache.juneau.rest.RestRequest#getMethodDescription()}
  - `$R{servletTitle}` - Returns value from {@link org.apache.juneau.rest.RestRequest#getServletTitle()}
  - `$R{servletDescription}` - Returns value from {@link org.apache.juneau.rest.RestRequest#getServletDescription()}
  - `$R{trimmedRequestURI}` - Returns value from `RestRequest.getTrimmedRequestURI()`
  - `$E{var}` - Environment variables.
- Added methods `RestServlet.getDescription(RestRequest)` and `RestServlet.getLabel(RestRequest)`.
- {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault` now provide default HTML titles and descriptions:

  @Property(name=HTMLDOC_title, value="$R{servletTitle}"), @Property(name=HTMLDOC_description, value="$R{servletDescription}")

- Options pages on {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault` now provide default descriptions and back links: and descriptions:

  @Property(name=HTMLDOC_navlinks, value="{back:'$R{servletURI}"), @Property(name=HTMLDOC_description, value="Resource options")

- New {@link org.apache.juneau.rest.RestServletGroupDefault} class.
- Removed `RestServletProperties.REST_trimTrailingUriSlashes` and `RestServletProperties.REST_pathInfoBlankForNull`.
- New annotations for providing labels and descriptions. Useful if you don't plan on having to support other languages, so you don't want to provide labels in resource bundles.
  - `RestResource.label()`
  - {@link org.apache.juneau.rest.annotation.RestResource#description()}
  - {@link org.apache.juneau.rest.annotation.RestMethod#description()}
  - `RestMethod#responses()`
  - `Attr.description()`
  - `Content.description()`
  - `HasParam.description()`
  - `HasQParam.description()`
  - `Header.description()`
  - `Param.description()`
  - `QParam.description()`
- Support for sorting resources by name in {@link org.apache.juneau.rest.labels.ChildResourceDescriptions}.

###### Samples

- Added `/tempDir/upload` showing how to use `ServletFileUpload` with multipart form posts.

### 5.1.0.16 (June 28, 2015)

Juno 5.1.0.16 is a moderate update.

###### Core

- New methods on {@link org.apache.juneau.ClassMeta} that eliminates language-specific code in the general class metadata.
  - `ClassMeta.getXmlMeta()`
  - `ClassMeta.getJsonMeta()`
  - `ClassMeta.getHtmlMeta()`
  - `ClassMeta.getUrlEncodingMeta()`
  - `ClassMeta.getRdfMeta()`
- New {@link org.apache.juneau.dto.jsonschema.JsonType#ANY} enum.
- New {@link org.apache.juneau.html.annotation.Html#asPlainText @Html.asPlainText()} annotation.
- New `HtmlDocSerializerContext.HTMLDOC_cssImports` property.
- Significant changes to RDF support.
  - New {@link org.apache.juneau.jena.annotation.Rdf @Rdf} and {@link org.apache.juneau.jena.annotation.RdfSchema @RdfSchema} annotations. These replace the use of defining namespaced through the XML annotations, and allows XML and RDF to be serialized using different namespaces.
  - Support for serializing arrays/collections as RDF bags, RDF lists, and multi-valued properties.
  - Fixed warning message about "tab" setting when using the N3/Turtle serializers.
- New `SerializerContext.SERIALIZER_sortCollections` and `SerializerContext.SERIALIZER_sortMaps` properties.
- FindBug fixes.

###### Server

- New `RestRequest.getServletParentURI()` method.
- New `$R{servletParentURI}` variable.
- Removed final modifier from {@link org.apache.juneau.rest.labels.ChildResourceDescriptions}.

###### Samples

- Added source code links to examples.

### 5.1.0.15 (May 24, 2015)

Juno 5.1.0.15 is a minor update.

###### Core

- New properties in {@link org.apache.juneau.serializer.SerializerContext}:
  1. `SerializerContext.SERIALIZER_relativeUriBase`
  2. `SerializerContext.SERIALIZER_absolutePathUriBase`
  These replace the `SERIALIZER_uriAuthority` and `SERIALIZER_uriContext` properties.
- Improvements in {@link org.apache.juneau.csv.CsvSerializer}.

###### Server

- New properties in `RestServletProperties`:
  1. `REST_defaultCharset`
  2. `REST_servletURI`
  3. `REST_relativeServletURI`
- Improvements involving path calculations when servlets deployed outside of a war file with a context root.

###### Client

- New methods in {@link org.apache.juneau.rest.client.RestCall}:
  1. `RestRequest.getHeader(String,Class)`
  2. `RestRequest.getHeader(String,Object,Class)`
  3. `RestRequest.getHeader(String,Type,Type...)`
  4. `RestRequest.getQueryParameter(String,Class)`
  5. `RestRequest.getQueryParameter(String,Object,Class)`
  6. `RestRequest.getQueryParameter(String,Type,Type...)`
  7. `RestRequest.getQueryParameter(String,Object,Type,Type...)`
  8. `RestRequest.getQueryParameters(String,Class)`
  9. `RestRequest.getQueryParameters(String,Type,Type...)`
  10. `RestRequest.getFormDataParameter(String,Class)`
  11. `RestRequest.getFormDataParameter(String,Object,Class)`
  12. `RestRequest.getFormDataParameters(String,Class)`
  13. `RestRequest.getFormDataParameter(String,Type,Type...)`
  14. `RestRequest.getFormDataParameters(String,Type,Type...)`
  15. `RestRequest.getPathParameter(String,Class)`
  16. `RestRequest.getPathParameter(String,Type,Type...)`
  17. `RestRequest.getBody(Class)`
  18. `RestRequest.getBody(Type,Type...)`

### 5.1.0.14 (May 10, 2015)

Juno 5.1.0.14 is a moderate update.

The major addition is support for {@link org.apache.juneau.rest.remoteable Remoteable Services}, the ability to invoke server-side POJO methods through client-side proxy interfaces.

###### Core

- Simplified {@link org.apache.juneau.utils.PojoIntrospector} class.
- New {@link org.apache.juneau.internal.ClassUtils#getMethodSignature(Method)} method.

###### Client

- New methods in {@link org.apache.juneau.rest.client.RestClient} for working with remoteable services:
  - `RestClient.setRemoteableServletUri(String)`
  - {@link org.apache.juneau.rest.client.RestClient#getRemoteableProxy(Class)}

###### Server

- Added a default OPTIONS page to {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault`.
- `RestServletProperties.REST_allowMethodParam` has been enhanced to allow you to explicitely specify which HTTP methods can be used in the `&method` parameter.
- New methods added to {@link org.apache.juneau.rest.RestRequest}:
  - `RestRequest.getParser()`
  - `RestRequest.getReaderParser()`

### 5.1.0.13 (Apr 24, 2015)

Juno 5.1.0.13 is a minor update.

###### Core

- {@link org.apache.juneau.ClassMeta#newInstance()} method can now create new instances of arrays.
- Arguments passed to `Link` are now serialized using {@link org.apache.juneau.urlencoding.UrlEncodingSerializer}, so arbitrary POJOs can now be passed as arguments.
- New date filters: `org.apache.juneau.transforms.Datefilter.ISO8601DTZP` and `org.apache.juneau.transforms.Datefilter.SimpleP`.
- New `HtmlDocSerializerContext.HTMLDOC_nowrap` setting for {@link org.apache.juneau.html.HtmlDocSerializer} class. Adds "* {white-space:nowrap}" to the style header to prevent word wrapping.
- Fixed bug in {@link org.apache.juneau.uon.UonParser} where passing in a blank value on an array or collection type in a form post would cause a `ClassCastException`. New behavior creates an empty array or `Collection`.
- Improved implementation of `UrlEncodingSerializer.serializeUrlPart(Object)` method.

###### Server

- {@link org.apache.juneau.rest.RestConverter} API fixed to handle the existence of POJO filters. {@link org.apache.juneau.rest.converters.Introspectable}/{@link org.apache.juneau.rest.converters.Queryable}/{@link org.apache.juneau.rest.converters.Traversable} classes can now work with filtered POJOs.
- {@link org.apache.juneau.rest.annotation.RestResource#messages()} annotation can now be defined on super and subclasses so that NLS messages can be defined in multiple resource bundles.
- Performance improvements in `RestServletNls` class.
- Fixed bug where two REST java methods mapped to the same path pattern wasn't triggering an exception when it was supposed to.

###### Client

- New `RestCall.setRedirectMaxAttempts(int)` method to prevent endless redirection loops.
- New `RestCall#setRetryable(int,long,RetryOn)` method to automatically retry on failed connection attempts.
- New `RestCallInterceptor.onRetry(RestCall,int,HttpRequest,HttpResponse)` method for listening in on retry attempts.

### 5.1.0.12 (Mar 28, 2015)

Juno 5.1.0.12 is a minor update.

###### Core

- Fixed {@link org.apache.juneau.ini.ConfigFile#isEmpty()} method.
- Changed behavior on {@link org.apache.juneau.uon.UonParser} to not treat '~' characters as escapes unless followed by one of the following characters: `( ) , $ = ~`.

###### Client

- New class {@link org.apache.juneau.rest.client.RestCallInterceptor}. Allows responses to be inspected and modified before being processed. Replaces `RestClientListener` class.
- Minor connection cleanup fixes.

### 5.1.0.11 (Feb 14, 2015)

Juno 5.1.0.11 is a moderate update.

###### Core

- Additions to {@link org.apache.juneau.html.annotation.Html @Html} bean annotation.
  - New {@link org.apache.juneau.html.annotation.Html#noTables() @Html.noTables()} annotation that prevents arrays/Collections from being serialized as tables.
  - New {@link org.apache.juneau.html.annotation.Html#noTableHeaders() @Html.noTableHeaders()} annotation that prevents HTML tables from having header rows.
- Several improvements to URL-Encoding support.
  - Improved whitespace handling in {@link org.apache.juneau.uon.UonParser}.
  - New `UonParserContext.UON_whitespaceAware` property for controlling whether whitespace is ignored.
  - New `UrlEncodingContext.URLENC_expandedParams` property for controlling whether arrays/Collections should be serialized/parsed as multi-part parameters.
  - New {@link org.apache.juneau.urlencoding.annotation.UrlEncoding#expandedParams() @UrlEncoding.expandedParams()} annotation that specifies that bean properties of type array/Collection be serialized as multi-part parameters (e.g. `&key=val1&key=val2`).
- New `JsonSerializerContext.JSON_escapeSolidus` property for controlling whether slash characters should be escaped.
- New {@link org.apache.juneau.internal.TeeOutputStream} and {@link org.apache.juneau.internal.TeeWriter} classes.
- New {@link org.apache.juneau.ClassMeta#isInstance(Object)} method.
- Performance improvements when using the {@link org.apache.juneau.BeanMap#add(String,Object)} method. Array properties are stored in a temporary list cache until {@link org.apache.juneau.BeanMap#getBean()} is called.
- New `BeanPropertyMeta.add(BeanMap,Object)` method for adding values to Collection and array properties.
- Config INI files now support keys with name "*".

###### Server

- REST method parameters can now be generic types (e.g. @Param("foo") Map<String,Integer> foo). This applies to headers, attributes, and parameters.
- New `@Param.multipart()` and `@Query.multipart()` annotations for handling multi-part GET and POST parameters.
- GET parameters are now CASE-SENSITIVE per W3C standards.
  - `&Content` must now be specified as `&content`.
  - `&Method` must now be specified as `&method`.
  - `&debug` must now be specified as `&debug=true`.
  - `&plainText` must now be specified as `&plainText=true`.
  - `&notrace` must now be specified as `&noTrace=true`.
- Performance improvements around query parameters.
- New methods on {@link org.apache.juneau.rest.RestRequest} for handling multi-part parameters:
  - `RestRequest.getParameters(String,Class)`
  - `RestRequest#getQueryParameters(String,Class)`
- Fixed Jetty issue in {@link org.apache.juneau.rest.RestResponse#setHeader(String,String)} where setting the `Content-Type` through this method was inconsistent with the behavior in WAS/Tomcat.
- `&noTrace=true` now prevents any errors from being logged in log file.
- Workaround for Jetty issue where `ServletContext.getContextPath()` always ends with "null".
- `RestServletProperties.REST_allowMethodParam` is now true by default on all subclasses of {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault`.

###### Client

- New method {@link org.apache.juneau.rest.client.RestCall#allowRedirectsOnPosts(boolean)}.
- New method `RestCall.peekInputStream()` allows you to read response bodies without interrupting execution flow.
- New method {@link org.apache.juneau.rest.client.RestCall#toString()} now useful for debugging purposes. Shows all request/response headers and bodies.
- {@link org.apache.juneau.rest.client.RestCallException} now includes `HttpResponse` object for easier debugging.
- New method `RestClient.addListener(RestClientListener)` for registering request/response listeners.
- New `RestClient.setClassLoader(ClassLoader)` method.
- TLS support in `JazzRestClient`.

###### Other changes

- `samples.ear` and `samples.war` projects have been replaced with an OSGi bundle with activated servlets in `juno.samples`.

### 5.1.0.10 (Dec 23, 2014)

Juno 5.1.0.10 is a moderate update.

###### Core

- Major changes to URL-Encoded serializer and parser.
  - Logic for serializing and parsing URL-Encoded key-value pairs moved to {@link org.apache.juneau.urlencoding.UrlEncodingSerializer} and {@link org.apache.juneau.urlencoding.UrlEncodingParser} classes.
  - Logic for serializing and parsing URL-Encoded values moved to new {@link org.apache.juneau.uon.UonSerializer} and {@link org.apache.juneau.uon.UonParser} classes.
- Fix bug where `BeanRuntimeExceptions` weren't being thrown on subsequent calls to {@link org.apache.juneau.BeanContext#getClassMeta(Class)}.
- Moved logic for `BeanContext.getPrimitiveDefault(Class)` to new {@link org.apache.juneau.ClassMeta#getPrimitiveDefault()} method for performance reasons.
- Fixed bug in `BeanContext.addTransforms(Class[])` that would cause filter order to get messed up.
- {@link org.apache.juneau.ClassMeta#newInstance()} can now create array instances.
- Fixed indentation bugs in {@link org.apache.juneau.html.HtmlSerializer}.
- Fixed issue in {@link org.apache.juneau.html.HtmlSerializer} where newlines were not being converted into line breaks.
- New {@link org.apache.juneau.serializer.WriterSerializer#toString(Object)} method that's identical to the serialize method but throws `RuntimeExceptions` to make the serializer easier to use for debugging.

###### Server

- Fixed major issue that prevented parsing URL-Encoded form posts into POJOs. Calling `HttpServlet.getParameter(String)` was forcing the underlying servlet code to process the HTTP body itself, preventing the `UrlEncodingSerializer` class from being able to parse the content. Updated code no longer inadvertantly calls this method.
- New `RestRequest.getQueryParameter(String)`, `RestRequest.hasQueryParameter(String)`, and `RestRequest.hasAnyQueryParameters(String[])` methods that only look for parameters in the URL query string to prevent loading and parsing of URL-Encoded form posts.
- New `@QParam` and `@HasQParam` annotations for accessing query parameters from the URL query string.
- `&plainText` parameter can now specify a false value.
- Removed properties parameters from `RestServlet.onPreCall(RestRequest)` and `RestServlet#onPostCall(RestRequest,RestResponse)` methods since the properties are already accessible through `RestRequest.getProperties()`.
- Added {@link org.apache.juneau.uon.UonSerializer} and {@link org.apache.juneau.uon.UonParser} to serializer and parser lists on {@link org.apache.juneau.rest.RestServletDefault} and `RestServletJenaDefault`.

###### Client

- Moved to Apache HttpClient 4.3 to match Jazz 6.0.
- Renamed `RestResponseEntity` to {@link org.apache.juneau.rest.client.RestRequestEntity}.
- Improved performance on URL-Encoded form posts by serializing directly to output stream instead of serialized to string first.
- New methods on {@link org.apache.juneau.rest.client.RestClient} class that makes it easier to associate serializer and parser attributes with registered serializer and parser:
  - `RestClient#setProperty(String,Object)`
  - `RestClient#setProperties(ObjectMap)`
  - `RestClient#addNotBeanClasses(Class[])`
  - `RestClient.addTransforms(Class[])`
  - `RestClient#addImplClass(Class,Class)`
- Renamed `RestClient.shutdown()` to {@link org.apache.juneau.rest.client.RestClient#close()} to mirror change in Apache API.

###### Samples

- New `CodeFormatterResource` for quickly formatting Java and XML code samples in Javadocs.
- New `UrlEncodedFormResource` for showing how to work with URL-Encoded form posts.

### 5.1.0.9 (Dec 1, 2014)

Juno 5.1.0.9 is a major update. There weren't very many code changes, but the source has been made a part of Jazz Foundation. This required some restructuring of the project. The project on Jazz Hub will eventually be discontinued. However, the libraries on IBM Community Source will continue to be updated regularly.

- Project split up into 3 separate bundles:
  - `org.apache.juneau` - Core serializers and parsers.
  - `org.apache.juneau.rest` - REST server component.
  - `org.apache.juneau.rest.client` - REST client component.
- Code changes to facilitate breaking up bundles:
  - `org.apache.juneau.rest.labels.Link` class moved to `Link`.
  - References to `org.apache.juneau.rest.RestException` in {@link org.apache.juneau.encoders.Encoder} class changed to `IOException`.
- Changed configuration names for consistency with Jazz Framework.
- New {@link org.apache.juneau.rest.client.RestClient#execute(HttpUriRequest)} method that allows subclasses to handle their own HTTP request execution.
- Changes in `JazzRestClient` to handle introduction of SSO support in v6.
- `&plainText` debug feature was broken.
- Removed double-buffering in `RestRequest`.
- Metadata cleanup, Find Bug fixes.

### 5.1.0.8 (Oct 25, 2014)

Juno 5.1.0.8 is a moderate update, focused primarily on performance improvements.

- Improved performance on JSON and URL-Encoding parsers by approximately 50% on large data sets.
  - Rewrote {@link org.apache.juneau.parser.ParserReader} class to handle it's own buffering. The change allowed several optimizations to be made when dealing with JSON and URL-Encoding text by avoiding char array copies.
  - Added a `estimatedSize` parameter to the {@link org.apache.juneau.parser.Parser} parse methods to optimize buffering when the input size is known beforehand.
- Revamped the {@link org.apache.juneau.BeanContext} API to perform better in multi-threaded environments.
  - Introduced a new `BeanPropertyStore` class that handles creation of {@link org.apache.juneau.BeanContext} objects. This allows `BeanContext` objects to be considered immutable, and therefore cacheable/reusable by the framework. While this was technically possible to cache these objects beforehand, it relied on a locking mechanism to prevent bean contexts from being modified after being created. The new mechanism is much more straightforward.
- Modifications to the org.apache.juneau.rest.client APIs to make it easier to work with custom Apache HTTP clients.
  - Added overridable `RestClient#createHttpClient()` to allow customized subclasses to construct customized HTTP clients.
  - Removed the `DefaultRestClient` class since it's now fully redundant with `RestClient`.
  - Added `RestClient.shutdown()` method for cleaning up the internal HTTP client when you're done using a REST client.

### 5.1.0.7 (Oct 5, 2014)

Juno 5.1.0.7 is a moderate update.

- Improved error handling.
- New `ParserContext.PARSER_debug` and `SerializerContext.SERIALIZER_debug`. settings for logging additional information for debugging problems.
- New {@link org.apache.juneau.serializer.Serializer#SERIALIZER_ignoreRecursions} setting for explicitely ignoring recursions when serializing models. Previously, the SERIALIZER_detectRecursions setting did this, but now it simply looks for recursions and throws exceptions when they occur.
- Improved handling of `StackOverflowErrors`. When SERIALIZER_detectRecursions is enabled, a useful error message is displayed showing the exact chain of objects that resulted in the stack overflow.
- Bug fixes in {@link org.apache.juneau.dto.ResultSetList} for Oracle and SQL Server.
- Serializers and parsers can now access HTTP request attributes, parameters, and headers through `SerializerContext.getProperties()` and `ParserContext.getProperties()`.
- Removed media-type and encoding attributes from {@link org.apache.juneau.serializer.SerializerContext} and {@link org.apache.juneau.parser.ParserContext} since these are now available through context properties, and are typically not used.
- {@link org.apache.juneau.xml.XmlParser} now accepts `application/xml`.
- Improved handling of bean property serialization when multiple matching pojo filters for the bean property class exist.
- Improved concurrency on BeanContext class.
- Fixed bug in {@link org.apache.juneau.rest.converters.Traversable} that was causing it to be executed even if the servlet extra path info was empty.
- Fixed bug in {@link org.apache.juneau.rest.converters.Traversable} where it was not picking up filters and properties defined on REST Java methods.

### 5.1.0.6 (Sept 21, 2014)

Juno 5.1.0.6 is a moderate update.

- Simplified API for {@link org.apache.juneau.transform.PojoSwap}. Since it's rarely used, the `beanContext` parameter was replaced with a `PojoSwap#getBeanContext()` method on the class.
- New simplified way of defining POJO filters without needing to extend {@link org.apache.juneau.transform.PojoSwap}. See {@link org.apache.juneau.transform.SurrogateSwap} for details.
- New {@link org.apache.juneau.html.annotation.Html @Html} annotation. Will allow the definition of standard XHTML DTOs in future releases. For now, `Img` is an example of defining an XHTML element using Juno DTOs.
- {@link org.apache.juneau.json.JsonParser} now ignores trailing `';'` characters in input so that it can parse strings of the form "var x = {'foo':'bar'};".
- New `TumblrParserResource` in the samples war file showing how to combine the REST client and server APIs into a single resource in order to download Tumblr blogs and convert the response into any supported response content type.

### 5.1.0.5 (Sept 1, 2014)

Juno 5.1.0.5 is a moderate update.

- New {@link org.apache.juneau.rest.Redirect} class that simplifies performing redirections in REST methods.
- New pluggable {@link org.apache.juneau.rest.ResponseHandler} class and {@link org.apache.juneau.rest.annotation.RestResource#responseHandlers()} annotation for defining customer response handlers for special kinds of POJOs.
- New method `UrlEncodingSerializer.serializeUrlPart(Object)` method.
- New method `RestRequest.getServletURIBuilder()` for construcing servlet-based URLs more efficiently.
- New method {@link org.apache.juneau.rest.RestResponse#getNegotiatedOutputStream()} that uses encoders if a match is found, and {@link org.apache.juneau.rest.RestResponse#getOutputStream()} that just return the underlying output stream without any modifications.
- Fixed bug where some properties were not being propagated correctly when using `CoreObject.setProperties(ObjectMap)` on serializer and parser subclasses.
- Fixed bug in {@link org.apache.juneau.html.HtmlSerializer} where URL keys in Maps were not being serialized as hyperlinks.
- Fixed bug in {@link org.apache.juneau.json.JsonSerializer} where "_class" and "items" attributes were not quoted in strict mode when using SERIALIZER_addClassAttrs feature.
- Fixed bug where `Content-Encoding` and`Character-Encoding` headers were being set when calling {@link org.apache.juneau.rest.RestResponse#getOutputStream()}. These should not be set if interacting with the output streams at a low level.
- Eliminated various convenience `RestResponse.sendRedirect(...)` methods due to the introduction of the {@link org.apache.juneau.rest.Redirect} class.

### 5.1.0.4 (Aug 25, 2014)

Juno 5.1.0.4 is a minor update.

- New `RestServlet.getPath()` method.
- New `SerializerContext.getJavaMethod()` and `ParserContext.getJavaMethod()` to allow access to REST methods that invoked the serializers or parsers. For example, can be used to access additional annotations on REST methods to perform special handing during serialization or parsing.
- Better behavior on overriding of filters in `BeanContext.addTransforms(Class[])`. Previously, adding multiple conflicting filters resulted in random behavior. Now filters are overridden when multiple matching filters are applied.
- Allow {@link org.apache.juneau.html.HtmlDocSerializerContext} properties to be set via `Serializer.setProperty(String,Object)`. Previously, these could only be defined through override properties (e.g. through REST class and method annotations).
- Fixed memory leak in XML parser.

### 5.1.0.3 (Jun 28, 2014)

Juno 5.1.0.3 is a moderate update.

###### Core API updates

- Ability to detect and use non-public bean classes, getters/setters, and fields using the following new properties:
  - {@link org.apache.juneau.BeanContext#BEAN_beanConstructorVisibility} - Control which bean constructors are visible to Juno.
  - {@link org.apache.juneau.BeanContext#BEAN_beanClassVisibility} - Control which bean classes are interpreted as beans to Juno.
  - {@link org.apache.juneau.BeanContext#BEAN_beanFieldVisibility} - Control which fields are visible to Juno as bean properties.
  - {@link org.apache.juneau.BeanContext#BEAN_methodVisibility} - Control which getters/setters are visible to Juno as bean properties.
  Removed `BeanContext.INCLUDE_BEAN_FIELD_PROPERTIES` and `BeanContext.INCLUDE_BEAN_METHOD_PROPERTIES` properties, since ignoring fields and methods can be accomplished by setting the appropriate properties above to {@link org.apache.juneau.Visibility#NONE NONE}. Also, the {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotation can now be used on non-public fields/getters/setters to override the default behavior defined by the `VISIBILITY` properties identified above. This is a convenient way of identifying protected or private fields or methods as bean properties. Previously, you could only identify public fields/getters/setters using this annotation.
- New {@link org.apache.juneau.BeanContext#BEAN_useJavaBeanIntrospector} property that lets Juno use the Java bean `Introspector` class to determine bean properties. In the previous release, the method for determining bean properties was a mixture of Juno-based and Introspector-based. Now it's either pure Juno-based or pure Introspector-based. The result is considerably cleaner code and consistent behavior.
- New {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore} annotation. Replaces the previous `@BeanProperty(hidden=true)` annotation for ignoring bean properties. Can also be used on classes that look like beans so that they're not treated as beans.
- Support for parsing into non-static member classes. This applies to all parsers.
- New {@link org.apache.juneau.json.annotation.Json#wrapperAttr() @Json.wrapperAttr()} annotation that automatically wraps beans and objects in a wrapper attribute when serializing to or parsing from JSON.
- Changed the default ordering of bean properties to be in parent-to-child class order.
- New {@link org.apache.juneau.transform.BeanFilter#readProperty(Object,String,Object) readProperty()} and {@link org.apache.juneau.transform.BeanFilter#writeProperty(Object,String,Object) writeProperty()} methods added to {@link org.apache.juneau.transform.BeanFilter} class to allow individualized serialization and parsing behavior on a class-by-class basis.
- Eliminated previous restriction where bean subtype attributes had to be listed first in JSON objects when using the `Bean.subTypeProperty()` annotation. The previous behavior was not strictly JSON-compliant since JSON objects are supposed to consist of unordered lists of key/value pairs. While targeted for JSON, the restriction is also lifted for all other parsers.
- New fluent-style {@link org.apache.juneau.BeanMap#load(String) BeanMap.load()} methods for initializing bean maps.
- {@link org.apache.juneau.html.HtmlDocSerializer} will now embed the data portion of the output in a `<div id='data'>` element to make it easier to extract the data portion of the page in Javascript in browsers.

###### REST Server API updates

- New {@link org.apache.juneau.rest.RestRequest#getJavaMethod()} method for getting access to the method used to handle a request. Useful for accessing the method name or annotations during requests, such as in calls to {@link org.apache.juneau.rest.RestGuard#guard(RestRequest,RestResponse)}.
- Fixed bug when using Jetty where you tried to read text input after a header was written.
- Added new string variables `$A{...}` (request attributes) and `$P{...}` (request parameters) to `RestServlet.createRequestVarResolver(RestRequest)`.

### 5.1.0.2 (Apr 27, 2014)

Juno 5.1.0.2 is a minor update.

- Fixed issue preventing `&Accept-Language` from being used as a GET parameter.
- Minor XSS vulnerability fix.
- Empty results on HTML pages now shows "no results" instead of a blank page.
- Fixed issues preventing REST pages from rendering HTML in newer versions of Internet Explorer.
- Changed `RestServletProperties.REST_allowMethodParam` to be disabled by default.

### 5.1.0.1 (Jan 25, 2014)

Juno 5.1.0.1 is a minor update.

- Addressed some behavioral differences between Tomcat and WAS.
  - Query parameter lookup is now always case-insensitive (per WAS behavior).
  - Consistent handling of redirect requests (Tomcat and WAS handle relative redirect paths differently).
- Fixed bug involving incorrect resolution of overlapping URL match patterns.
- Overall improvements in HTTP request parameter and header value resolution.
- Made workspace changes so as not to be dependent on the WAS test environment being loaded.
- Renamed @Remainder annotation to {@link org.apache.juneau.rest.annotation.PathRemainder @PathRemainder}.
- Fixed bug involving incorrect calculation of `pathInfo` on child resources.

### 5.1.0.0 (Jan 18, 2014)

Juno 5.1.0.0 is a major update.

###### Major changes

- Brand new REST client API that uses Apache HttpClient for HTTP communication.
  The new client API is simply a thin layer on top of `HttpClient` that performs serialization and parsing using Juno parsers, but leaves all the details of the HTTP connection to the Apache code.
  See the org.apache.juneau.rest.client package for details.
- New `org.apache.juneau.rest.client.jazz` package and `org.apache.juneau.rest.client.jazz.JazzRestClient` class for performing REST operations against Jazz servers.
  Includes improved support for FORM authentication, and better SSL certificate validation.
- Completely redesigned URL-Encoding support.
  See org.apache.juneau.urlencoding package for details.
- Changes to Parser API.
  - Removal of `ExtendedReaderParser` abstract class and moved methods into {@link org.apache.juneau.parser.ReaderParser} class.
  - Removal of `DataFormat` class from API since it was no longer necessary due to API change above.
  - Removal of `ParserStringReader` class.
    This was a reader optimized to work with `String` input.
    However, it could interfere with garbage collection of the original string object.
    Instead, the existing {@link org.apache.juneau.parser.ParserReader} was enhanced to work well with `String` input, and tests show no significant performance differences.
  - New `org.apache.juneau.parser.Parser.parse(Object,int,ClassMeta)` convenience method added.

###### Other changes

- Various new methods added to {@link org.apache.juneau.internal.StringUtils} and {@link org.apache.juneau.internal.ClassUtils}.
- Improved support on `BeanContext.getClassMetaFromString(String)`.
  Now supports resolving `"long[]"`, and so forth.
- {@link org.apache.juneau.rest.labels.ResourceDescription} name parameter is now automatically URL-encoded in links.
- {@link org.apache.juneau.rest.RestRequest} now correctly handles cases involving URL-encoded characters in the path info portion of URLs (e.g. `http://host/contextRoot/foo%2Fbar`).
- Removed lazy-initialization that required locking in {@link org.apache.juneau.ClassMeta}.
- New `BeanContext.setDefaultParser(ReaderParser)` method added for specifying a default parser to use in a bean context (used when converting beans to `Strings` using `BeanContext.convertToType(Object,Class)`. Old behavior simply used the default JSON serializer in these cases.
- More consistent handling of exceptions across all parsers.
- Minor changes to {@link org.apache.juneau.rest.RestRequest} class.
  - Changed the order of parameters on `RestRequest#getParameter(String,Class)`.
  - Added `RestRequest.getMapParameter(String,Class,Class,Class)` and `RestRequest.getCollectionParameter(String,Class,Class)}` methods.

### 5.0.0.36 (Dec 18, 2013)

Juno 5.0.0.36 is a minor update.

- Implemented `org.apache.juneau.urlencoding.UrlEncodingParser.parseArgs(Reader,int,ClassMeta[])`.
- `name` parameter of `ResourceDescription#ResourceDescription(String,String,String)`. is now automatically URL-encoded so that the name can contain special characters (e.g. "foo/bar(baz)").
- Support for URL-matching and path info containing encoded characters (e.g. '/') now supported.
- Removed some lazy-initialization of bean information in {@link org.apache.juneau.ClassMeta} that allowed the removal of some synchronized blocks.
- Improved support of `BeanContext.getClassMetaFromString(String)`. Now supports primitive arrays such as "long[]" in addition to the previous support for the equivalent "[J".
- Various new convenience methods added to {@link org.apache.juneau.internal.StringUtils} and {@link org.apache.juneau.internal.ClassUtils}.

### 5.0.0.35 (Nov 26, 2013)

Juno 5.0.0.35 is a minor update.

- {@link org.apache.juneau.rest.RestGuard#guard(RestRequest,RestResponse)} now returns a boolean to allow redirects to login pages.
- Fixed bug in RestServlet where occasional false positive "duplicate method with same name and path" errors were occurring.

### 5.0.0.34 (Nov 10, 2013)

Juno 5.0.0.34 is a moderate update.

- New support for runtime-replaced variables in REST resource properties:

  @RestResource( messages="nls/Messages", properties={ @Property(name="label",value="$L{servletTitle}"), // Localized variable in Messages.properties @Property(name="javaVendor",value="$S{java.vendor}"), // System property @Property(name="foo",value="bar"), @Property(name="bar",value="baz"), @Property(name="v1",value="$R{foo}"), // Request variable. value="bar" @Property(name="v2",value="$R{$R{foo}}") // Nested request variable. value="baz" } )

  See `RestServlet.createRequestVarResolver(RestRequest)` for more information.
- Eliminated @Property.type annotation which was the old way of specifying NLS variables that got resolved at runtime.
- New methods on {@link org.apache.juneau.rest.RestRequest}:
  - `RestRequest.getVarResolver()`
  - `RestRequest.getServletURI()`
  - `RestRequest.getRequestParentURI()`
- New methods on {@link org.apache.juneau.rest.RestResponse}:
  - `RestResponse.sendRedirect(CharSequence)`
- New methods on {@link org.apache.juneau.rest.RestServlet} that allow easier customization by subclasses:
  - `RestServlet.createConfigFactory()`
  - `RestServlet.createConverters()`
  - `RestServlet.createDefaultRequestHeaders()`
  - `RestServlet.createDefaultResponseHeaders()`
  - `RestServlet.createEncoders()`
  - `RestServlet.createFilters()`
  - `RestServlet.createGuards()`
  - `RestServlet.createMimetypesFileTypeMap()`
  - `RestServlet.createParsers()`
  - `RestServlet.createProperties()`
  - `RestServlet.createRequestProperties(ObjectMap,RestRequest)`
  - `RestServlet.createRequestVarResolver(RestRequest)`
  - `RestServlet.createSerializers()`
  - `RestServlet.createUrlEncodingParser()`
- Changed `RestServletNls` to use `ResourceDescription/MethodDescription` instead of `RestResource/RestMethod`
- New property `RestServletProperties.REST_htDocsFolder`.
  New support for serving up static documents from classpath through REST interface.
- Exception APIs now use {@link java.text.MessageFormat} (e.g. "{0}") for message variables instead of "%s".
- New {@link org.apache.juneau.annotation.Bean#stopClass @Bean.stopClass} annotation for specifying stop classes for bean properties.
- New `BeanFilter.setStopClass(Class)` which is the program equivalent to the annotation above.
- New methods on {@link org.apache.juneau.dto.ResultSetList}:
  - `ResultSetList.handleBlob(Blob)`
  - `ResultSetList.handleClob(Clob)`

### 5.0.0.33 (Oct 20, 2013)

Juno 5.0.0.33 is a moderate update.

- Removed generic parameter from {@link org.apache.juneau.serializer.WriterSerializer} class.
  - Many of the examples in the documentation were written as follows, which resulted in "unchecked" compile warnings:
    `WriterSerializer s = new JsonSerializer();`
    These compile warnings will now go away.
- New settings in BeanContext. These can be applied to all serializers/parsers.
  - {@link org.apache.juneau.BeanContext#BEAN_ignoreInvocationExceptionsOnGetters}
  - {@link org.apache.juneau.BeanContext#BEAN_ignoreInvocationExceptionsOnSetters}
  - {@link org.apache.juneau.BeanContext#BEAN_notBeanPackages_add}
  - {@link org.apache.juneau.BeanContext#BEAN_notBeanPackages_remove}
- Eliminated `addNotBeanClassPatterns(String...)` methods throughout API since these are now controlled by {@link org.apache.juneau.BeanContext#BEAN_notBeanPackages_add} / {@link org.apache.juneau.BeanContext#BEAN_notBeanPackages_remove} properties.
- New settings in `RestServletProperties`.
  - `RestServletProperties.REST_trimTrailingUriSlashes`
    Also removed `RestRequest.getRequestURI(boolean trimTrailingSlashes)` method which is now redundant with this property.
  - `RestServletProperties.REST_pathInfoBlankForNull`
    Also removed `RestRequest.getPathInfo(boolean returnBlankForNull)` method which is now redundant with this property.
- New JSON-Schema {@link org.apache.juneau.dto.jsonschema.SchemaMap} class for supporting linked schemas.
- Serializers will no longer throw an exception when `maxDepth` setting is reached, and will instead simply ignore content below the specified depth.
  While the old behavior was as-designed, the new behavior is more in-line with expected behavior.
- Added support for HTTP header "X-Response-Headers" to {@link org.apache.juneau.rest.RestServlet}.
  Allows you to specify one or more headers that should be returned on the response from the servlet.
  For example, to get a page to automatically refresh every 1 second, you can append the following to a URL: `?x-response-headers={Refresh=1}`
- Removed `HtmlDocSerializerContext.HTML_REFRESH` setting that added a Refresh meta tag to HTML documents, since this can now be controlled through `X-Response-Headers`.
- Small improvements to samples.
  - `PhotosResource` now includes a default entry.

### 5.0.0.32 (Oct 5, 2013)

Juno 5.0.0.32 is a moderate update.

- New support for generating and consuming fully-compliant JSON-Schema documents.
  See org.apache.juneau.dto.jsonschema for information.
- New methods added to {@link org.apache.juneau.parser.Parser}:
  - `org.apache.juneau.parser.Parser.parseMap(Object,int,Class,Class,Class)`
  - `org.apache.juneau.parser.Parser.parseCollection(Object,int,Class,Class)`
- {@link org.apache.juneau.annotation.Bean @Bean} annotation can now be defined on interfaces and inherited by subclasses.
- Support for customizing serialized values for `Enums` through overriding `toString()` and `fromString()` on the enum class.
  Previously used `Enum.valueOf()` to convert strings back into `Enums`.
  Used for JSON-Schema support to allow {@link org.apache.juneau.dto.jsonschema.JsonType} enum to be serialized to lowercase per the specification (e.g. "string" instead of "STRING").
- {@link org.apache.juneau.dto.cognos Cognos} DTOs now have fluent-style bean setters.
- Support for generic bean objects whose type was erased at compile time.
  Previous behavior gave you an error message that the type could not be determined.
  New behavior assumes a type of `Object` when the type is erased.
- Bug fixes:
  - When duplicate fluent-style setters were defined with different parameter types (e.g. `setFoo(Foo f)`, `setFoo(Bar b)`), the {@link org.apache.juneau.BeanMap} API would sometime choose the wrong setter as the bean property setter.
    Now validates that the setter being chosen is the one whose return type matches the property getter.
  - Passing in `Accept` GET parameters with '+' (e.g. `&Accept=text/json+simple`) wasn't working anymore.
    The `Accept` parameter is supposed to interpret spaces as '+' to allow you to not have to write `&Accept=text/json%2Bsimple`.
  - Parsers would not set bean properties of abstract type {@link java.lang.Number}.
    Now it detects the numeric type based on input and sets the value accordingly.

### 5.0.0.31 (Aug 9, 2013)

Juno 5.0.0.31 is a moderate update.

- Simplified the {@link org.apache.juneau.serializer.Serializer} and {@link org.apache.juneau.parser.Parser} class hierarchies.
  This reverses a previous change that added a bunch of interfaces in these APIs (and subsequently required compiling with Java 7 to get around a compiler bug).
  The new class hierarchy is much simpler to understand.
- Added {@link org.apache.juneau.transforms.XMLGregorianCalendarSwap} to convert these to ISO8601 strings during serialization, and vice versa during parsing.
- Added a strict mode to {@link org.apache.juneau.json.JsonParser}.
- Added default {@link org.apache.juneau.json.JsonParser#DEFAULT_STRICT} parser.

### 5.0.0.30 (Aug 8, 2013)

Juno 5.0.0.30 is a minor update.

- Fixed bug involving beans using `Bean.subTypes()` annotation in addition to `subTypes` property.
- Modified the JSON parser to handle non-existent JSON values to get around an issue where Cognos was generating invalid JSON.

### 5.0.0.29 (Aug 2, 2013)

Juno 5.0.0.29 is a moderate update.

- Revamped the API for filter support:
  - Updated {@link org.apache.juneau.transform.BeanFilter} class to mirror the {@link org.apache.juneau.annotation.Bean @Bean} annotation.
  - Introduced support for bean `Bean.subTypeProperty() subtypes`.
  - Replaced `@Bean(filter=xxx)` with new `@Transform` annotation.
- Revamped URL-Encoding support.
  The old URL-Encoding serializer and parser simply used the JSON serializer/parser with a thin URL-encoding top layer.
  The new URL-Encoding serialize and parser was written from scratch and is considerably more consistent in design and output.
- Improved number parsing.
  The new number parser should handle any valid numeric syntax for decimals and floats that Java itself supports.
- {@link org.apache.juneau.json.JsonSerializer} LAX mode now quotes reserved word attributes.
- New predefined DateFilters with millisecond precision:
  - `org.apache.juneau.transforms.DateSwap.ISO8601DTP`
  - `org.apache.juneau.transforms.DateSwap.ISO8601DTZP`

### 5.0.0.28 (July 9, 2013)

Juno 5.0.0.28 is a moderate update.

- Fixes an `OutOfMemoryError` and performance issue caused by incorrect caching of class metadata.
- Added `WriterSerializer.serialize(Object,Writer)` convenience method for serializing directly to a writer.
  Applies to all serializers.

### 5.0.0.27 (July 7, 2013)

Juno 5.0.0.27 is a moderate update.

- Fixed some HTML formatting issues in {@link org.apache.juneau.html.HtmlSerializer}.
- {@link org.apache.juneau.rest.RestServletDefault} now includes {@link org.apache.juneau.plaintext.PlainTextSerializer} and {@link org.apache.juneau.plaintext.PlainTextParser} for plain-text support.
- Child resources now render on default `OPTIONS` pages through new method `ResourceOptions.getChildren()`.
- Changes to {@link org.apache.juneau.urlencoding.UrlEncodingSerializer}/{@link org.apache.juneau.urlencoding.UrlEncodingParser} to reduce the need for quoted string values.
  More changes are likely in this area of the code to support multipart form posts.
- FindBugs fixes.

### 5.0.0.26 (Jun 5, 2013)

Juno 5.0.0.26 is a minor update.

- FindBug fixes.
- Changed the way child REST resources are defined.
  Eliminated the @RestChild annotation on getter methods and replaced it with {@link org.apache.juneau.rest.annotation.RestResource#children() @RestResource.children()} defined on the resource class itself.
  Child resource paths are specified through {@link org.apache.juneau.rest.annotation.RestResource#path() @RestResource.path()}.
- New {@link org.apache.juneau.rest.labels.ChildResourceDescriptions} bean for automatically generating the contents of router resource pages.
- Changed `@RestMethod.pattern()` to {@link org.apache.juneau.rest.annotation.RestMethod#path() @RestMethod.path()} for naming consistency.

### 5.0.0.25 (May 11, 2013)

Juno 5.0.0.25 is a minor update.

###### Core API updates

- New {@link org.apache.juneau.dto.ResultSetList} DTO for serializing SQL result sets to JSON/XML/HTML and so forth.
- New `SqlQueryResource` class in the sample war for demonstrating the `ResultSetList` DTO.

###### Server API updates

- Fixed issue with media type for CSS files being reported as "text/plain" instead of "text/css".
- Moved initialization of class properties to before the call to `Servlet.init()` so that `getProperties()` can be called during servlet initialization.
- New `@Property.type` annotation with support for using system properties as resource properties.

### 5.0.0.24 (May 9, 2013)

Juno 5.0.0.24 is a major update.

###### Core API updates

- New support for {@link org.apache.juneau.dto.atom ATOM}.
  - New `AtomFeedResource` class added to sample war.
- New `XmlFormat.CONTENT` enum value.
  Allows bean properties to be persisted as XML element text.
- New `XmlContentHandler` class and `@Xml.contentHandler` annotation.
  Allows customized serialization and parsing of beans to XML element text.
  Added for support of ATOM text content that must support both plain text and embedded XHTML.
- New {@link org.apache.juneau.xml.annotation.XmlSchema @XmlSchema} and updated {@link org.apache.juneau.xml.annotation.XmlNs @XmlNs} annotations to better mimic JAXB.
- Removed `@Xml.valAttr` annotation since it's now redundant with `@Xml(format=CONTENT)`.
- Fixed timezone bug in {@link org.apache.juneau.transforms.CalendarSwap}.
- Simplified `Serializer.serialize(Object,Object,SerializerContext)` method.
- Fixed bug where lists returned by {@link org.apache.juneau.ObjectMap#getObjectList(String)} were not updatable.
- Eliminated old RDF/XML serializer.

###### Documentation updates

- New {@link org.apache.juneau.json JSON Support Overview} document.
- New {@link org.apache.juneau.xml XML Support Overview} document.
- New {@link org.apache.juneau.jena RDF Languages Support Overview} document.
- New {@link org.apache.juneau.dto.atom ATOM Support Overview} document.

### 5.0.0.23 (Apr 14, 2013)

Juno 5.0.0.23 is a minor update.

- Simplified {@link org.apache.juneau.dto.cognos Cognos} support.
- Fixed bug where `@Xml` annotation was not being inherited by inner classes.
- Javadoc stylesheet improvements.

### 5.0.0.22 (Apr 12, 2013)

Juno 5.0.0.22 is a minor update.

###### Core API changes

- New `@Property.nls()` annotation for specifying localized property values.
  For example, allows you to set the HTMLDOC_title and HTMLDOC_description properties to localized values pulled from a resource bundle.
  See the `AddressBookResource` class for an example.

###### REST Servlet API changes

- Fix a bug where the `&Content` query parameter was not always parsed correctly.

### 5.0.0.21 (Apr 9, 2013)

Juno 5.0.0.21 is a minor update.

###### Core API changes

- New `HtmlDocSerializerContext.HTMLDOC_navlinks` annotation for addint links to HTML page views.
- Renamed the properties in {@link org.apache.juneau.html.HtmlDocSerializerContext} for clarity.

###### Servlet API changes

- Added new `RestServlet.addDefaultProperties(ObjectMap,RestRequest)` method for programatically adding properties to the property map per request.
- Added the following new properties in the properties map to make them easily available to serializers and parsers (since they don't have access to the HTTP request object).
  Note that the `SerializerContext.SERIALIZER_uriAuthority` and `SerializerContext.SERIALIZER_uriContext` properties were previously available.
  - `RestServletProperties.REST_servletPath`
  - `RestServletProperties.REST_pathInfo`
  - `RestServletProperties.REST_method`
- Path variables annotated with `@Attr` are now automatically URL-decoded.

### 5.0.0.20 (Apr 7, 2013)

Juno 5.0.0.20 is a major update.

###### Core API changes

- New Jena-based {@link org.apache.juneau.jena.RdfSerializer} for serializing POJOs to RDF/XML, RDF/XML-ABBREV, N-Triple, Turtle, and N3.
  Serializes ANY POJOs to RDF, even simple objects and primitives.
- New Jena-based {@link org.apache.juneau.jena.RdfParser} for parsing RDF/XML, RDF/XML-ABBREV, N3, Turtle, and N-Triple back into POJOs.
- `XmlSerializerContext.XML_autoDetectNamespaces` default changed to true.
  The old default value would cause XML with unmapped namespaces if you didn't manually specify them via the `XmlSerializerContext.XML_namespaces` annotation.
  While setting the default to true is somewhat slower (since the serializer must crawl the POJO tree to find namespaces), the benefits of having it work out-of-the-box outweighs the performance concerns.
  For developers concerned about performance, they can always change it back to false and specify the namespaces themselves.

###### REST server API changes

- Allow inheritance of {@link org.apache.juneau.rest.annotation.RestResource @RestResource} annotation.
  Serializers, parsers, filters, properties , guards, and converters definitions are automatically inherited from parent classes and interfaces.
- Enhancements to {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod} annotation:
  - New `RestMethod.filters()` annotation for defining POJO filters at the method level.
  - New {@link org.apache.juneau.rest.annotation.RestMethod#serializersInherit()} and {@link org.apache.juneau.rest.annotation.RestMethod#parsersInherit()} annotations for controlling how serializers and parsers (and associated filters and properties) are inherited from the class.
    This replaces the previous `addSerializers` and `addParsers` annotations.
- New `RestServletJenaDefault` servlet that includes serialization/parsing support for all Jena-based serializers and parsers.
- New `DefaultJenaProvider` JAX-RS provider that includes serialization/parsing support for all Jena-based serializers and parsers.
- Eliminated `RestServletChild` class.
  It's redundant with the introduction of inheritable annotations.
- New methods on {@link org.apache.juneau.rest.RestServlet}:
  - `RestServlet.createConfigFactory()`
  - `RestServlet.createSerializers()`
  - `RestServlet.createParsers()`
  These augment the existing `getBeanContext()` / `getSerializers()` / `getParsers()` methods.

###### REST client API changes

- New `RestCall.setDateHeader(String,Object)` method for setting ISO8601 datetime headers.

### 5.0.0.19 (Apr 1, 2013)

Juno 5.0.0.19 is a minor update.

- New methods on {@link org.apache.juneau.rest.RestServlet}:
  - `RestServlet.onPreCall(RestRequest)`
  - `RestServlet.onPostCall(RestRequest,RestResponse)`
- TRIM_NULLS setting changed to `SerializerContext.SERIALIZER_trimNullProperties`.
  New property default is true. Only applies to bean properties, not map or collection entries.

### 5.0.0.18 (Mar 27, 2013)

Juno 5.0.0.18 is a moderate update.

The biggest change is the introduction of the {@link org.apache.juneau.jena.RdfSerializer} class that uses Jena to generate RDF/XML, RDF/XML-ABBREV, N-Tuple, N3, and Turtle output.

This code should be considered prototype-quality, and subject to change in the future.
There are plans of adding an equivalent `RdfParser` class in the future, so the serializer logic may need to be tweaked to allow POJOs to be reconstituted correctly in the parser.

The `RdfXmlSerializer` class should be considered deprecated for now.
However, I'm keeping it around, since it's considerably faster and uses far less memory than the Jena-based serializer since it serializes directly from POJOs to RDF/XML.
It may or may not be removed in the future depending on demand.

###### Other changes

- New {@link org.apache.juneau.jso.JsoParser} class.

### 5.0.0.17 (Mar 25, 2013)

Juno 5.0.0.17 is a minor update.

- Charset now passed as a parameter to `IOutputStreamSerializer.serialize()` and `IInputStreamParser.parse()`.

### 5.0.0.16 (Mar 25, 2013)

Juno 5.0.0.16 is a minor update.

- New {@link org.apache.juneau.rest.annotation.Properties @Properties} REST method parameter annotation that can be used to get the runtime properties map through a parameter instead of through {@link org.apache.juneau.rest.RestResponse}.

### 5.0.0.15 (Mar 24, 2013)

Juno 5.0.0.15 is a moderate update.

- Juno-Wink integration components that have been requested by many for a long time!
  Refer to org.apache.juneau.rest.jaxrs for information.
- New `@Produces` annotation in place of `ISerializer.getMediaTypes()` for specifying what media types a serializer produces.
  Available when subclassing from {@link org.apache.juneau.serializer.Serializer}.
- New `@Consumes` annotation in place of `IParser.getMediaTypes()` for specifying what media types a parser consumes.
  Available when subclassing from {@link org.apache.juneau.parser.Parser}.

### 5.0.0.14 (Mar 23, 2013)

Juno 5.0.0.14 is a major update.

The biggest change is that the `RestSerializer`, `RestParser`, `RestSerializerGroup`, and `RestParserGroup` classes have been eliminated entirely.
Instead, the existing {@link org.apache.juneau.serializer.Serializer}, {@link org.apache.juneau.parser.Parser}, {@link org.apache.juneau.serializer.SerializerGroup}, and {@link org.apache.juneau.parser.ParserGroup} classes of the core API have been augmented to replace them.

Adoptions will be required if you have previously used these classes.

###### Core API changes

- New org.apache.juneau.serializer package.
  - Entirely reworked class hierarchy to make it easier to define new serializers.
  - New {@link org.apache.juneau.serializer.WriterSerializer} base class for defining character-based serializers.
  - New {@link org.apache.juneau.serializer.OutputStreamSerializer} base class for defining byte-based serializers.
  - Updated {@link org.apache.juneau.serializer.SerializerGroup} class with full support for RFC2616 `Accept-Content` headers.
  - Improved cloning support on serializers and serializer groups.
- New org.apache.juneau.parser package.
  - Entirely reworked class hierarchy to make it easier to define new parsers.
  - New {@link org.apache.juneau.parser.ReaderParser} base class for defining character-based parsers.
  - New {@link org.apache.juneau.parser.InputStreamParser} base class for defining byte-based parsers.
  - Improved cloning support on parsers and parser groups.
- New org.apache.juneau.transform package.
  - Cleaner class structure.
  - Improved {@link org.apache.juneau.transform.BeanFilter} class for defining property filters on beans.
  - Improved {@link org.apache.juneau.utils.PojoQuery} class for defining filters on objects (previously called `ObjectFilter`).
- New org.apache.juneau.encoders package.
  - Defines API for {@link org.apache.juneau.encoders.Encoder Encoders} for enabling compression in REST servlets and clients.
  - Previously, gzip compression was enabled by default. This new API allows you to plug in your own compression algorithms.
  - New {@link org.apache.juneau.encoders.GzipEncoder} class for enabling gzip compression.
  - New {@link org.apache.juneau.encoders.EncoderGroup} class for managing multiple encoders and finding them based on RFC2616 `Accept-Encoding` header values.
- New org.apache.juneau.plaintext package.
  - New {@link org.apache.juneau.plaintext.PlainTextSerializer} and {@link org.apache.juneau.plaintext.PlainTextParser} classes for serializing/parsing text/plain content.
- New org.apache.juneau.jso package.
  - New {@link org.apache.juneau.jso.JsoSerializer} class for serializing `application/x-java-serialized-object` content.
- New org.apache.juneau.soap package.
  - New {@link org.apache.juneau.soap.SoapXmlSerializer} class for serializing `text/xml+soap` content.
- Improved cloning support on the {@link org.apache.juneau.BeanContext} class.
  - Better caching. Improved caching performance.
- `JsonMap` and `JsonList` changed to {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} to better reflect that they're not limited to just JSON support.
- Renamed `PojoSwap` to {@link org.apache.juneau.utils.PojoQuery} to not confuse it with the new Filter API.

###### REST server API changes

- Eliminated `org.apache.juneau.rest.serializers` and `org.apache.juneau.rest.parsers` packages.
  - All existing REST serializers and parsers merged into the core API.

###### REST client API changes

- Simplified {@link org.apache.juneau.rest.client.RestClient} API.
  - You can now only specify a single serializer or parser per client. This significantly simplifies the code.
  - Support for {@link org.apache.juneau.encoders.Encoder Encoders}.
- Eliminated `RestCmdLine` (since it's essentially redundant with CURL).

### 5.0.0.13 (Mar 14, 2013)

Juno 5.0.0.13 is a minor update.

###### Core API changes

- New support for relative URIs.
  - URIs of the form "foo/bar" are interpreted as relative to the context root of the web application.
  - URIs of the form "/foo/bar" are interpreted as relative to the HTTP authority (e.g. "http://myhost:9080").
- New `SerializerContext.SERIALIZER_uriContext` and `SerializerContext.SERIALIZER_uriAuthority` serializer properties for specifying values for relative URIs.
- New {@link org.apache.juneau.annotation.URI @URI} annotation that allows you to specify classes and bean properties as URLs that aren't `java.net.URI` or `java.net.URL`.
- New {@link org.apache.juneau.html.HtmlSerializer#HTML_uriAnchorText} HTML serializer property for tailoring how anchor text is rendered.
- Renamed `BeanProperty#uri` annotation to `BeanProperty#beanUri` to make it clear that this property represents the URI of the bean itself instead of an arbitrary property containing a URI.
- Removed `BeanProperty#id` annotation.

###### REST server API changes

- Improvements to {@link org.apache.juneau.rest.RestServlet} to automatically handle relative URIs in POJOs.
  - `SerializerContext.SERIALIZER_uriContext` property set by default to web app context root.
  - `SerializerContext.SERIALIZER_uriAuthority` property set by default to the request scheme+hostname+port.
- Fixed bug involving `Accept-Charset` header in Chrome that prevented HTML output from rendering correctly in that browser.
  `Accept-Charset` handling should now be fully W3C compliant.

### 5.0.0.12 (Mar 10, 2013)

Juno 5.0.0.12 is a minor update.

###### Core API changes

- Relaxed method naming conventions when using {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotation.
  Methods with zero parameters are interpreted as getters, and methods with one parameter are interpreted as setters.
  Eliminated the `BeanProperty.method` annotation, since it's now unnecessary.

###### REST server API changes

- Significantly improved response error messages.
  Older messages were rather cryptic. Error conditions should be much easier to debug now.
- New `PlainTextRestSerializer` class for serializing "plain/text" requests.
  Useful for debugging purposes.
- `Readers` and `InputStreams` can now be passed in as `@Content` parameters if you need direct access to the HTTP body content without involving the parsers.
  Equivalent to previously calling {@link org.apache.juneau.rest.RestRequest#getInputStream()} and {@link org.apache.juneau.rest.RestRequest#getReader()}.
- Improved support for the `?debug` parameter.
  Dumps better information to the log file, such as all header parameters.

### 5.0.0.11 (Mar 8, 2013)

Juno 5.0.0.11 is a moderate update.

###### REST server API changes

- New `UrlEncodingRestSerializer` and `UrlEncodingRestParser` classes.
  Allows parsing form posts directly to POJOs.
- Support for `Accept` and `Content-Type` "application/x-www-form-urlencoded" added by default on {@link org.apache.juneau.rest.RestServletDefault}.
- New `RestServlet.renderError(HttpServletRequest,HttpServletResponse,RestException)` method to allow customized handling of response errors.

### 5.0.0.10 (Mar 7, 2013)

Juno 5.0.0.10 is a minor update.

###### Core API changes

- New {@link org.apache.juneau.ObjectMap#findKeyIgnoreCase(String)} method.
- HtmlSerializer will now create 2-dimensional tables for collections of mixed beans/maps if all object have the same set of property names/keys.

###### REST server API changes

- New `RestServletProperties` class that defines all the class-level properties that can be set on the servlet.
- Properties can be set through {@link org.apache.juneau.rest.annotation.RestResource#properties() @RestResource.properties} annotation, or new `RestServlet.setProperty(String,Object)` method.
- New "?noTrace" URL parameter to prevent stack traces from being logged (for JUnit testing of error conditions).
- New `RestServletProperties.REST_useStackTraceHashes` property to prevent the same stack trace from being logged multiple times.
- New `RestServletProperties.REST_renderResponseStackTraces` property for preventing stack traces in responses for security reasons.
- New overridable `RestServlet.onError(HttpServletRequest,HttpServletResponse,RestException,boolean)` and `RestServlet.onSuccess(RestRequest,RestResponse,long)` methods for plugging in your own logging and peformance monitoring.
- Eliminated `RestServlet.getInitParams()` method, since it's now redundant with {@link org.apache.juneau.rest.RestServlet#getProperties()}.
- Header parameters passed as URL parameters are now case-insensitive.

### 5.0.0.9 (Feb 26, 2013)

Juno 5.0.0.9 is a moderate update.

###### Core API changes

- {@link org.apache.juneau.ini INI config file support}:
  - A convenient API for reading, writing, and manipulating INI files.
  - Ability to convert INI files to batch and shell environment variables.
  - Command-line interface for updating INI files.
  - Support for encoded INI file values.
- Support for fluent-style bean setters (setters that return the bean itself).
- Ability to use {@link org.apache.juneau.annotation.Bean @Bean} annotation to override bean identification settings.
- New {@link org.apache.juneau.ObjectMap#cast(Class)} method to convert `ObjectMaps` directly to beans.

###### REST server API changes

- Build-in default `OPTIONS` pages.
- New {@link org.apache.juneau.rest.annotation.RestResource#defaultRequestHeaders() @RestResource.defaultRequestHeaders} and {@link org.apache.juneau.rest.annotation.RestResource#defaultResponseHeaders() @RestResource.defaultResponseHeaders} annotations.
- New {@link org.apache.juneau.rest.annotation.RestMethod#serializers() @RestMethod.serializers} and {@link org.apache.juneau.rest.annotation.RestMethod#parsers() @RestMethod.parsers} annotations.
- New {@link org.apache.juneau.rest.annotation.RestMethod#properties() @RestMethod.properties} annotation.
- New {@link org.apache.juneau.rest.annotation.RestMethod#defaultRequestHeaders() @RestMethod.defaultRequestHeaders} annotation.
- New {@link org.apache.juneau.rest.annotation.RestMethod#matchers() @RestMethod.matchers} annotation and {@link org.apache.juneau.rest.RestMatcher} class.
- `Readers` and `InputStreams` can be specified on `@Content` annotated parameters.
- New `@HasParam` annotation.
- Full RFC2616 support for matching `Accept` headers to serializers.

###### Other notes

- Smaller library size (460kB).

### 5.0.0.8 (Jan 30, 2013)

Juno 5.0.0.8 is a minor update.

- New {@link org.apache.juneau.ini INI file} support.
  - Makes reading, updating, and manipulating INI configuration files a snap.
  - Supports automatic conversion of data types in line with the functionality of the rest of the product.
  - Comments and layout of INI files are persisted during saves.

### 5.0.0.7 (Jan 20, 2013)

Juno 5.0.0.7 is a major update.

###### Core API updates

- Combined previous 3 libraries into a single library.
- New {@link org.apache.juneau.parser.ParserListener} class.
  Adds ability to find and process unknown bean properties during parsing.
- Enhancements to {@link org.apache.juneau.xml.XmlParser}:
  - Coalescing support
  - Validations support
  - Support for replacing entity references
  - Resolver support
  - Event allocator support
  - Trim-whitespace support
- Enhanced XML support:
  - New {@link org.apache.juneau.xml.annotation.Xml#format() @Xml.format} annotation.
    Controls how POJOs get serialized to XML.
    Also allows you to collapse collections and arrays.
  - New `@Xml.namespaces` annotation.
    Namespaces can be defined at package, class, method, or field levels.
  - New `@Xml.nsUri` annotation.
    Shortcut for specifying namespace URIs.
  - New `@Xml.valAttr` annotation.
    Serializes a bean property value as an attribute.
  - Ability to override XS and XSI namespaces on XML and RDF/XML serializers.
  - Ability to override RDF namespace on RDF/XML serializer.
  - New more-efficient namespace resolution.
- New configurable property classes for everything are now structured better and easier to locate and identify through the following new classes:
  - {@link org.apache.juneau.BeanContext}
  - {@link org.apache.juneau.serializer.SerializerContext}
  - {@link org.apache.juneau.parser.ParserContext}
- Enhancements to {@link org.apache.juneau.BeanContext}:
  - Ability to mark bean properties as hidden using `@BeanProperty.hidden()` so that they don't get serialized.
  - Simplified `ClassType` {@link org.apache.juneau.ClassMeta} API.
    Combined 4 classes into a single class.
  - New `@Bean.filter` and `@BeanProperty.filter` annotations.
    Used for defining filters on bean classes and bean properties instead of just globally through `BeanContext.addTransforms(Class[])`.
  - New {@link org.apache.juneau.PropertyNamer} API / {@link org.apache.juneau.annotation.Bean#propertyNamer() @Bean.propertyNamer} annotation.
    Used for customizing bean property names.
  - New `@BeanProperty.beanUri` and `@BeanProperty.id` annotations.
    Used for associating beans with URLs and IDs.
    Used by XML serializer to add a url attribute on a bean element.
    Used by RDF/XML serializer to construct `rdf:resource` attributes.
  - New {@link org.apache.juneau.annotation.BeanProperty#properties() @BeanProperty.properties} annotation. Used for limiting properties on child elements.
- Automatic support for {@link java.net.URL} and {@link java.net.URI} objects.
  - Converted to hrefs in HTML.
  - Converted to url attributes in XML.
  - Converted to resource:about attributes in RDF/XML.
- Improvements to Javadocs.
- Improved {@link org.apache.juneau.utils.PojoQuery} support.

###### REST client updates

- GZIP compression support.
- Bug fixes.

###### REST server updates

- Support for overriding bean context and serializer properties in a REST method call through new {@link org.apache.juneau.rest.RestResponse#setProperty(String,Object)} method.
  For example, allows you to control whitespace options on a per-request basis.
- Several new annotations on REST servlets:
  - `@RestResource.filters()` - Associate post-formatting filters on a resource level.
  - {@link org.apache.juneau.rest.annotation.RestResource#guards() @RestResource.guards} - Associate resource-level guards.
  - {@link org.apache.juneau.rest.annotation.RestResource#messages() @RestResource.messages} - Associate a resource bundle with a REST servlet. Comes with several convenience methods for looking up messages for the client locale.
  - {@link org.apache.juneau.rest.annotation.RestResource#properties() @RestResource.properties} - Override default bean context, serializer, and parser properties though an annotation.
- Several new annotations on REST methods:
  - `@RestMethod.filters()` - Associate post-formatting filters on a method level.
  - {@link org.apache.juneau.rest.annotation.RestMethod#guards() @RestMethod.guards} - Associate method-level guards.
- New annotations on REST method parameters with automatic conversion:
  - `@Attr` - A parameter or URL variable value as a parsed POJO.
  - `@Param` - A query parameter value as a parsed POJO.
  - {@link org.apache.juneau.rest.annotation.PathRemainder @PathRemainder} - The remainder after a URL pattern match as a String.
  - {@link org.apache.juneau.rest.annotation.Header @Header} - An HTTP header value as a parsed POJO.
  - `@Content` - The HTTP content as a parsed POJO.
  - {@link org.apache.juneau.rest.annotation.Method @Method} - The HTTP method name as a String.
- HTTP response content POJOs can now simply be returned from methods instead of calling {@link org.apache.juneau.rest.RestResponse#setOutput(Object)}.

### 5.0.0.6 (Oct 30, 2012)

Juno 5.0.0.6 is a minor update that fixes a small bug in 5.0.0.5.

### 5.0.0.5 (Oct 29, 2012)

Juno 5.0.0.5 is a major update.

- New `@RestChild` annotation for identifying child resources.
- New `traversable` and `filterable` attributes added to {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod} annotation.
  Eliminates the need for `PojoResource` and `FilteredRestResource` classes.
- Simplified client API. Easier to use when making multiple connections to the same server.
- Support for pluggable authentication in the client API.
- Support for authenticating against Jazz Team Servers.
- Support for rendering package-level Javadocs in REST resources.
- Support for parsing of header values into specific object types.
- Changed default XML representation to not include JSON-type attributes. Produces cleaner XML.
- New `resourceUri` attributed added to @Bean annotation to associate beans with resource URIs.
  - Used for automatically creating hyperlinks in {@link org.apache.juneau.html.HtmlSerializer}.
  - Used for automatically creating uri attributes in {@link org.apache.juneau.xml.XmlSerializer}.
  - Used for automatically creating rdf:about attributes in `RdfXmlSerializer`.

### 5.0.0.4 (Oct 7, 2012)

Juno 5.0.0.4 is a minor update.

- New {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod} annoation on {@link org.apache.juneau.rest.RestServlet} methods.
  Allows the usage of URL pattern matching and automatic conversion of URL variables to arguments passed to method handlers.
  See {@link org.apache.juneau.rest.RestServlet} for more information.
- Enhancements to `BeanContext.convertToType(Object,Class)` to be able to convert `Strings` to classes with `fromString(String)`/`valueOf(String)` static methods or `T(String)` constructors.

### 5.0.0.3 (Oct 3, 2012)

Juno 5.0.0.3 is a minor update.

- Support for parsing into read-only beans (i.e. beans with only getters, property values set through constructor args).
  To support this, the {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor} annotation has been added.
- Merged separate settings classes back into their base classes (simplifies the API).
- {@link org.apache.juneau.serializer.SerializerGroup SerializerGroups} and {@link org.apache.juneau.parser.ParserGroup ParserGroups} now share {@link org.apache.juneau.BeanContext BeanContexts} to reduce memory consumption of class type metadata.

### 5.0.0.2 (Sept 28, 2012)

Juno 5.0.0.2 is a minor update.

- Improvements to Javadocs. Most of the information in the Juno Starters Guide wiki has been moved into the overview and package-level javadocs.
  Since the information is now written in HTML, you can now copy and paste the code examples directly from the Javadocs.
  The code examples are also syntax-highlighted using CSS.
- Support for defining default XML namespaces on packages and classes for the XML and RDF serializers.
- Restructured the packages along content type support (e.g. all JSON support moved to `org.apache.juneau.json`).
- Automatic support for parsing maps with `Enum` keys, and parsing `Enum` strings.
  This was previously possible using filters, but now it's built-in for all the parsers.
- Replaced the `ObjectList.toXArray()` methods with a new `elements(Class<T> type)` method that's more efficient and avoids creating an unnecessary array.
- Support for parsing into beans with read-only properties.
  New {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor} annotation allows you to specify bean property values to be passed in through a constructor.
- Separated the rest library into separate independent client and server libraries.
  Use one, use both, it's up to you.

### 5.0.0.1 (Jun 14, 2012)

Juno 5.0.0.1 is a moderate update.

- New support for generating XML-Schema documents from POJO models.
- New support for serializing to RDF/XML.

### 5.0.0.0 (Jun 11, 2012)

Version 5.0 marks a major release milestone for the Juno/JJSON library. It is now available for download from iRAM under the name "Juno (previously JJSON)". The Juno Starters Guide has been updated to reflect new functionality in this release.

- New name.
  Unfortunately, "JJSON" was already trademarked by another similar library. Therefore, it's been renamed "Juno" (after the Roman goddess and wife of Jupiter) which does not appear to have any similar trademark issues (crosses fingers). The name is also a play on the word "Uno", indicating that this is a single simple unifying interface of several kinds of technology.
- Simplified APIs for working with beans.
  Significant improvements have been made to the parsers to make it easier to convert serialized POJOs back into their original forms.
- Serializer/Parser classes now directly subclass from {@link org.apache.juneau.BeanContext}.
  In previous releases, if you wanted to change the way beans were handled by the serializers and parsers, you had to construct a separate bean map factory and pass it to the serializer or parser. Now, you can call the bean map factory methods directly on the serializer or parser class.
- Simplified Filter API for handling non-standard POJOs.
  The API for handling non-standard POJOs has been simplified by introducing the concept of a `Transform` class, which is associated with the `BeanContext` class (and thus the Serializer and Parser classes too) through the `BeanContext.addTransforms(Class[])` method.
  Two new subclasses of `Transform`:
  - {@link org.apache.juneau.transform.BeanFilter} - Filter POJO beans.
  - {@link org.apache.juneau.transform.PojoSwap} - Filter POJOs that aren't beans.
  This new API replaces the previous separate `Cast` and `BeanFilter` APIs which were considerably more complicated and puts them under a common API.
- Elimination of `_class` attributes in parsable output.
  One of the complaints about the previous version of JJSON was that if you wanted to have the resulting JSON or XML be parsable back into beans, you had to enable the "addClassAttrs" property on the bean map factory class so that "_class" attributes could be added to the output.
  This requirement is virtually eliminated in v5. In many cases, the parsers are able to determine through reflection what the correct target type is based on the top-level class passed in on the parse method.
- Performance improvements.
  Several significant performance improvements have been made in this release.
  - New Reader-based JSON parser.
    Previously, the JSON parser required that the entire JSON text be loaded into memory as a String before being parsed. The new JSON parser is Reader-based which significantly reduces memory consumption.
  - New StAX-based XML parser.
    The old XML parser was based on DOM. The new XML parser uses a StAX parser which significantly reduces memory consumption.
  - Caching of reflection data in the `BeanMap` API.
    The number of reflection calls have been significantly reduced in the `BeanMap` API code. Reflection is used to determine the class types of property values on beans. This information is now cached and persisted so that the reflection API calls to determine class types are only performed the first time a bean type is encountered.
  - Automatic support for GZIP compression/decompression in `RestServlets`.
    This is completely transparent to the developer. The output writer is negotiated by the framework to automatically handle compression and charset requests without the developer needing to know anything about it.
- Cognos/XML support.
- JSON-schema support.
- New {@link org.apache.juneau.utils.PojoIntrospector} class.
- Significant REST servlet API improvements.
  - Defining child resources is considerably simpler now. In addition to the standard doX() methods for handling the requests for the current resource, you can also define getX() methods for returning child resources which automatically become available under the child URL specified by the getter name.
  - Initialization of the child resources occurs automatically when the parent resource initialization occurs.
  - Other improvments have been made in the area of automatic negotiation of input and output type streams. For example, automatic support is provided for GZIP (`Accept-Encoding: gzip`) and charsets (e.g `Accept-Charset: SJIS`) on both incoming and outgoing data. It's all transparent from a developers perspective. The developer simply working with POJOs, and all details about content types, encoding, charsets, and so forth are handled by the framework.
  - Support for generating complex `OPTIONS` pages for resources.
- Automatic support for SOAP XML output on "text/soap+xml" requests against `RestServlet`.
- Support for XML namespaces.
- Support for setting the XML root element name by either passing in a parameter on the serializer, or by specifying it via a @Bean annotation.
- Support for loading beans directly from Readers and Strings.
- Parsing support for POJOs of type `Enum`.
- Significant improved support for various flavors of parameterized types, such as subclasses of parameterized types (e.g. `MyBeanList extends LinkedList<MyBean>`).
- Improved ordering of bean properties (should now be ordered as they are defined in the class).
- Various default filters provided:
  - byte[]<-->Base64 encoded strings
  - Date/Calendar<-->ISO8601/RFC822/Long
- New {@link org.apache.juneau.html.HtmlParser} and {@link org.apache.juneau.urlencoding.UrlEncodingParser} classes.
- HtmlSerializer now produces XHTML.