Cettia Java Server 1.2 brings functional programming support and borrows useful features from Java 8

Share
  • November 7, 2018

We covered Cettia’s 1.0 release two months ago and now 1.2 is ready to see the light of day. As previously announced, the team has decided to drop Java 7 support and add features based on Java 8 features such as functional interfaces and lambda expressions instead.

The good news is that migration from 1.1 to 1.2 should be a breeze as you only have to update the version of the dependency. Furthermore, there are no backward incompatible changes other than the minimum Java version, as explained in the blog post announcing the new release.

Asity and Cettia share the same creator so when Asity 2 received Spring MVC and Spring WebFlux support, the team was inspired by the Spring WebFlux’s functional programming model.

SEE ALSO: Asity is here chirping *universally reusable web fragments on the JVM*

This release also features a ServerSocketPredicates class, a helper for ServerSocketPredicate which consists of static methods that return various useful ServerSocketPredicates, and the default methods, and(ServerSocketPredicate that)or(ServerSocketPredicate that), and negate(), to ServerSocketPredicateServerSocketPredicate and ServerSocketPredicates are analogous to RequestPredicate and RequestPredicates of Spring WebFlux.

These are the static methods to create socket predicates defined in the ServerSocketPredicates.

all()
A predicate that always matches.
attr(String key, Object value)
A predicate that tests the socket attributes against the given key-value pair.
id(ServerSocket socket)
A predicate that tests the socket id against the given socket’s id.
id(String id)
A predicate that tests the socket id against the given socket id.
tag(String... tags)
A predicate that tests the socket tags against the given tags.

 

But since this is a “either/or” type of situation, the existing finder methods such as Server#all() and Server#byTag(String tags...) are deprecated. You’ll have to replace them with all() and tag(String... tags) defined in the ServerSocketPredicates with Server#find(ServerSocketPredicate predicate). Keep in mind that the finders will be removed in the next major version.

There’s also Sentence#find(ServerSocketPredicate predicate), which creates and returns a sentence with a given predicate like Server#find(ServerSocketPredicate predicate) but has a composed predicate that represents a short-circuiting logical AND of the original sentence’s predicate and the given predicate. This should have a positive impact on the reusability of a sentence.

Last but not least, Cettia starter kit based on Servlet 3 and Java API for WebSocket 1 and ralscha/cettia-demo based on Spring framework 5 have been updated.

Looking to try out this full-featured web app framework for Java?

Cettia makes it possible for developers to avoid repetitive, boilerplate code while still scaling their app horizontally. This framework was designed specifically to support environments where WebSocket is not available. Plus, it can handle both text and binary data together, recover missed events, and provides a multi-device user experience.

Cettia works seamlessly with any web framework on the JVM, making it easy to adopt.

The post Cettia Java Server 1.2 brings functional programming support and borrows useful features from Java 8 appeared first on JAXenter.

Source : JAXenter