Cache, Certificates, Stream Uploads, and a Simulator That Can Write
A short look at the cache, token management, certificate API, and stream support added to the Codename One backend, along with the simulator's virtual keyboard and recording features.
Every template prepared this month (banking, streaming, messaging, delivery, and games) has a server, and each server ran into some of the gaps that modern web applications take for granted. In this post I've gathered the pieces added to the Codename One backend and the new features that came to the simulator. Some of them also affect the client side. Anyone who has worked with Spring Boot will recognize many of the APIs; unless there is a deliberate reason to differ, the backend follows Spring's behavior.
Size-bounded cache
If a service that queries prices calls the external price source for every offer, it both slows down and consumes its quota. Keeping the cache forever, on the other hand, leads to stale prices being shown. The new cache structure offers a size limit, expiration after write, a listener triggered when an entry is removed, and metrics. The short example below shows how to track an entry when it is evicted.
Cache<String, Price> prices = Cache.<String, Price>builder("prices")
.maximumSize(5000)
.expireAfterWriteMillis(30000)
.removalListener((key, value, cause) -> {
System.out.println(key + " çıkarıldı: " + cause);
})
.build();
Token management for accessing other services
The server sometimes connects to a Google API with a service account, and sometimes to a billing service with client credentials. Fetching the token, caching it, and renewing it before it expires is work that gets rewritten in every project. AccessTokenProvider takes over this cycle. In the same change, importing users from an existing identity store was also added. When moving an application's accounts to the new system, you don't need to ask everyone to reset their passwords.
Certificate work without OpenSSL on the command line
Mutual TLS and private certificate authorities are commonly used between banks and business partners. The PKI API can read and parse PEM files, validate a certificate chain against your own root certificates, generate a certificate signing request (CSR), and read and write PKCS#12 files. The core idea is to stop depending on an external OpenSSL script for certificate checks and instead move them directly into the application code.
Collecting errors in one place
Instead of writing a separate try-catch inside every handler with @RestControllerAdvice and @ExceptionHandler, you can convert exceptions into HTTP responses from a single place. Request interceptors and validation mechanisms came with the same change. Below is a simple handler that returns 404 for records that cannot be found.
@RestControllerAdvice
public class NotFoundHandler {
@ExceptionHandler(NoSuchElementException.class)
public HttpServer.Response notFound(NoSuchElementException e) {
return HttpServer.Response.text(404, "Kayıt bulunamadı");
}
}
Reading the body as a stream and using proxies
For video uploads, loading the file into memory is not an option. request.getBodyStream() lets you read the body as it arrives. Large uploads, including multipart ones, are written to disk rather than memory. HttpProxy forwards requests to an internal service, but only to the hosts you specify and explicitly allow. This way, a carelessly configured route cannot turn your server into an open proxy.
JSON conversions and java.time in the ORM
These two topics apply to both the client and the server. JSON mapping now supports custom converters through JsonTypeAdapter, constructor-based object creation, generics, arrays, and explicit handling of null values. For example, you can store a monetary amount as a decimal string, so the value is never converted to a double at any stage. On the ORM side, java.time types are mapped without any extra annotation. Instant and LocalDateTime are stored as epoch milliseconds, and LocalDate as epoch days. This means a date column becomes a number that can be indexed and compared.
Tests that start only what they need
@WebMvcTest starts only a controller and the beans you list, not the whole application. Calls made with MockMvc work without opening a real socket. The same change also defined a metrics schema for observability and health check (probe) mechanisms. This means a metric shown on a dashboard has the same meaning for every service written with Codename One. Keep in mind that the backend is still in technical preview.
A simulator that types
There is probably a bug you have run into at least once: the login form looks flawless in the simulator, but on a real phone the keyboard covers the password field when it opens. Because the simulator has no keyboard, nobody notices this problem. You can now open a virtual keyboard with the appearance matching the app's platform through the Simulate > Virtual Keyboard menu.
The behavior differs by platform. On iOS the screen size is kept, Display.getInvisibleAreaUnderVKB() returns the height of the keyboard, and the focused field is scrolled into the visible area. On Android's resize mode, the form receives the sizeChanged event and lays itself out again. In pan mode, the whole screen slides upward. By default, Android uses the mode the platform selects for each field. You can force and test either mode with the Android: Resize and Android: Pan options in the menu, or with the androidSoftInput setting.

Image: DEV Community
The simulator can now also record. It can produce MP4, MOV, WebM, or animated GIF output, and it can record just the screen or the image together with the device frame. Touches are shown with a visual marker, and subtitles can be added. Through the simulator's MCP server, a coding agent can drive an entire flow and deliver the video to you. This removes the need for a separate screen recording program for store previews, bug reports, or sharing.
Still, it is worth remembering that this is not an exact replica of a real device. Keyboard behavior is an emulation of the platforms, so do the final check on a physical device. However, seeing a password field being covered at your development desk is much better than learning about it from a negative review.
Highlights
- The cache now offers a size limit, expiration, an eviction listener, and metrics support.
- AccessTokenProvider handles fetching, caching, and renewing tokens for external services.
- The PKI API lets you perform PEM, chain validation, CSR, and PKCS#12 operations inside your application code.
- Large bodies are read as streams, and HttpProxy forwards requests only to allowed hosts.
- The simulator comes with a virtual keyboard, platform-specific behavior, and video recording.
- The simulator's MCP tools allow a coding agent to drive a whole flow and produce a video.
When to use it
Most of these pieces are things you will need on the first day of taking a service to production: external API calls, enterprise certificates, large file uploads, and consistent error responses. If you are building a prototype or a small application that serves only a single client, you may not need to use all of them at once. On the simulator side, if you test every form as it is, it helps to open the virtual keyboard and record a short clip, especially to see the keyboard's effect on login and payment screens. This helps surface problems that would otherwise be caught only in real device tests.
Comments (0)
No comments yet; be the first.
Leave a comment