Try out our latest beta capabilities: Security API 1.0, Liberty Gradle plugin integration in Eclipse, endpoint control with MBeans, and JPA 2.2! It’s all in this December 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. Check out the 17.0.0.4 release of WebSphere Liberty which is built on the 17.0.0.4 release of Open Liberty. Look out for more betas over the coming months. If you just can’t wait, take a look at the daily builds of Open Liberty.

Follow Open Liberty happenings on @OpenLibertyIO.

What’s new in this beta?

Get it now! Ask a question about the beta

Security API 1.0

The appSecurity-3.0 feature provides support for the Java EE Security API 1.0 specification. The Java Specification Request (JSR) 375 specifies the requirement.

The specification promotes self-contained application security portability across all Java EE servers, and makes use of modern programming concepts such as expression language and context dependency injection (CDI). It defines annotations specific to various authentication mechanisms, identity stores to handle user authentication, and common programming API to do programmatic Java EE security. It reduces the dependency on the deployment descriptors and application server based configuration for securing Java EE web resources.

Once you configure the appSecurity-3.0 feature, your application can annotate the authentication mechanisms and the identity stores that will use the application server provided implementations. You can also provide your own implementations to replace the application server provided ones. The applications can also use the SecurityContext API to perform programmatic security checks. You can find an example server.xml configuration in the Knowledge Center docs.

Gradle integration with WebSphere Developer Tools (WDT)

Import web application Gradle projects into WDT for developing in Eclipse. You can now take advantage of WDT features from your Gradle projects, including running applications directly from the workspace, incremental publishing, and using the server configuration editor while maintaining the Gradle structure of your project.

For fully integrated Gradle development of web applications within WDT:

Set up your Gradle project to use the Liberty Gradle plugin (see the Liberty Gradle plugin docs, or have a look at one of the samples: Servlet sample, JPA sample, JTA sample). Import your project as an existing Gradle project into WDT: File > Import > Gradle > Existing Gradle Project When prompted to create a server, click Yes:

Start working on your application.

When you make changes to your application or server configuration WDT automatically runs the Gradle tasks needed to publish your changes.

Find out more in the Knowledge Center documentation.

The open source Liberty Gradle plugin is used with the Gradle WAR plugin to install project WAR files and loose applications to a Liberty Server. For more details, see the Liberty Gradle plugin documentation in GitHub.

Endpoint control with MBeans

Prior to this feature, the only option for administrators wanting to stop inbound http traffic to the server was to use the server pause/resume commands (added in version 17.0.0.1) from the command line; for more info, see the Knowledge Center docs.

The endpoint control feature provides Liberty administrators with a new MBean that provides the same function as the command line counterparts, but may be more useful in a operations context because it can be invoked via JMX. Like the command line functions, the MBean is currently limited to controlling HTTP endpoints but, because it is a generic mechanism for controlling server endpoints (like messaging and IIOP), it gives us the flexibility to add other endpoint types. Keep watching the Liberty betas for new endpoint types being added.

The beta MBean has the Object name: WebSphere:feature=kernel,name=ServerEndpointControl and, like most mbeans, is self-describing. If you don’t know what any of that means, take a look at this blog post on controlling server endpoint traffic with MBeans.

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:

What’s already in there?

The November Liberty beta included previews of some of our Java EE 8 features, including Servlet 4.0, CDI 2.0, Application Security, JPA 2.2, and JSF 2.3.

For supported features, take a look at 17.0.0.4 also released today.

Get it now! Ask a question on Stack Overflow