Try out the Java 8 updates in JPA 2.2 and Java EE 8 updates in JSF 2.3, plus a minor update to OpenAPI 3.0, in the October 2017 beta of WebSphere Liberty.

Thanks to your support for our regular beta programme, we are able to release new Liberty features every few months. Most recently, last week. Look out for more betas over the coming months.

What’s new in this beta?

Get it now! Ask a question about the beta

Some limitations in this beta

/me blushes So, we were hoping to have fixed these but, well, we got caught up in the excitement of Open Liberty, JavaOne, the Liberty 17.0.0.3 release, too much sugar… The upshot is that we didn’t actually get them fixed in time for this beta. So I still have to explain…

*deep breath*

The beta enables the microProfile-1.2 feature by default (this includes JAX-RS2.0, CDI 1.2, JSON-P 1.0, mpConfig-1.1, mpFaultTolerance-1.0, mpHealth-1.0, mpJwt-1.0, and mpMetrics-1.0). The new Java EE 8 features available in this beta (see the September beta) are currently not compatible with the microProfile-1.2 feature.

This means that to try any of the Java EE 8 features in this beta, you must add the relevant definition to the server.xml (see below for details) and you must remove the microProfile-1.2 definition from the server.xml to disable it.

Also note that the jaxrs-2.1 feature doesn’t currently work with servlet-4.0 (see the September beta). What can I say? It’s a beta and there are limitations. It will get better. 🙂 Promise.

Java Persistence API 2.2 (JPA 2.2)

Updated to support new features introduced in Java 8, including the new Java Date and Time API, Query Result Collection streaming, repeatable JPA annotations.

Java 8 introduced a new Date and Time API, which is more powerful than the old APIs part of java.util for years. Collection streaming, introduced in Java 8, is now formally supported by the JPA 2.2 specification, enabling new ways to process query result sets. Many JPA annotations are now repeatable, eliminating the need to use grouping annotations.

Simply add <feature>jpa-2.2</feature> to the server.xml‘s <featureManager> list to enable the JPA 2.2 spec level and the Eclipselink 2.7 JPA persistence provider bundled with the feature. If you wish to use your own Eclipselink 2.7 binaries, you can instead enable the <feature>jpaContainer-2.2</feature> feature which provides JPA 2.2 container integration but does not enable the provided Eclipselink JPA provider implementation.

Examples of JPA 2.2 Enhancements:

@Repeatable Annotations (before JPA 2.2):

@PersistenceContexts(
  @PersistenceContext(name=“foo”, unitName=“bar”),
  @PersistenceContext(name=“cloud”, unitName=“sky”))
@Stateless
public class SomeEJB {
…

@Repeatable Annotations (with JPA 2.2):

@PersistenceContext(name=“foo”, unitName=“bar”),
@PersistenceContext(name=“cloud”, unitName=“sky”)
@Stateless
public class SomeEJB {
…

JPA 2.2 supports java.time types:

@Entity
public class MyEntity {
…
  // The following map to database time column types natively now
  @Basic private java.time.LocalDate localDate;
  @Basic private java.time.LocalDateTime localDateTime;
  @Basic private java.time.LocalTime localTime;
  @Basic private java.time.OffsetTime offsetTime;
  @Basic private java.time.OffsetDateTime offsetDateTime;
…
}

Attribute Converter classes now support CDI bean injection:

@Converter
public class B2IConverter implements AttributeConverter<Boolean, Integer> {
    final static Integer FALSE = new Integer(0);
    final static Integer TRUE = new Integer(1);

    @Inject
    private MyLogger logger;

    @Override
    public Integer convertToDatabaseColumn(Boolean b) {
        Integer i = b ? TRUE : FALSE;
        logger.log("Convert: " + b + " -> " + i);
        return i;
    }

    @Override
    public Boolean convertToEntityAttribute(Integer i) {
        Boolean b = TRUE.equals(s) ? Boolean.TRUE : Boolean.FALSE;
        logger.log("Convert: " + i + " -> " + b);
        return b;
    }
}

Method Stream getResultStream() added to Query and TypedQuery interfaces:

@Stateless public class SBean {
   @PersistenceContext(unitName=“Personnel”) EntityManager em;

   public int getEmployeeSalaryBudget(int deptId) {
      final AtomicInteger salBudget = 0;

      TypedQuery<Employee> q = em.createQuery(”SELECT e FROM Employee e WHERE e.deptId = :deptId”, Employee.class);
      q.setParameter(“deptId”, deptId);

      Stream<Employee> empStream = q.getResultStream();
      empStream.forEach( t -> salBudget.set(salBudget.get() + t.getSalary()));

      return salBudget.get();
   }
}

For more information, see:

JavaServer Faces 2.3 (JSF 2.3)

JavaServer Faces 2.3 (JSF 2.3) is the latest version of the JSF specification. JSF 2.3 contains many new features and enhancements.

Take advantage of the latest JSF features and enhancements. The jsf-2.3 feature pulls in the Apache MyFaces implementation and integrates it into the Liberty runtime. The following features of JSF 2.3 have been tested and are available for use:

  • <f:importConstants/>
  • Enhanced component search facility
  • DataModel implementions can be registered
  • CDI replacement for @ManagedProperty
  • UIData and <ui:repeat>support for Map and Iterable
  • <ui:repeat> condition check
  • Java Time Support
  • WebSocket Integration via <f:websocket>
  • Multi-field Validation via <f:validateWholeBean>
  • Use CDI for evaluation of JSF specific EL implicit Objects
  • Support @Inject on JSF specific artifacts

To enable the JSF 2.3 feature just add the following feature definition to your server.xml:

    <featureManager>
        <feature>jsf-2.3</feature>
    </featureManager>

If you wish to use CDI you currently must enable the cdi-1.2 feature along with the jsf-2.3 feature in your server.xml. When a Java EE 8 CDI feature is available you will have to use the Java EE 8 version instead of the Java EE 7 version.

For more information, see:
* Apache MyFaces
* JavaServerFaces 2.3 Specification

OpenAPI 3.0

You can now customize the URLs for public endpoints in the openapi-3.0 feature.

By default, two endpoints are available for a server:

`GET http://host:http_port/api/docs`
`GET http://host:http_port/api/explorer`

You can change the URL of the public endpoints with the publicURL attribute in the server.xml. For example, setting the following configuration in the server.xml makes the public REST API documentation available with GET http://host:http_port/myAPI/docs and http://host:http_port/myAPI/explorer:

<openapi publicURL="myAPI" />

What’s already in there?

The September Liberty beta included previews of some of our Java EE 8 features, including Servlet 4.0, JAX-RS 2.1, and JSF 2.3, plus HTTP/2.0 and distributed tracing.

This is our first beta release since the 17.0.0.3 release in October 2017.

Get it now! Ask a question on Stack Overflow

Join The Discussion

Your email address will not be published. Required fields are marked *