The Codename One backend compiles your server to a native executable that starts in 40 ms and idles in about 9 MB. The catch has always been porting: real Spring services lean on dozens of small conveniences, and every one that’s missing is an edit. This round we took real services across and fixed what they tripped on, so most of this post is code that now moves over with nothing but its imports changed.
A Spring controller, mostly unchanged
Here’s a typical order endpoint. Every line of the body works on the backend now:
@RestController
@CrossOrigin(origins = "https://shop.example.com", allowCredentials = true)
public class OrderController {
private static final Logger LOG = Logger.getLogger(OrderController.class);
@Autowired
private OrderRepository orders;
@PostMapping(value = "/orders", consumes = "application/json", produces = "application/json")
public Order place(@RequestBody Order order) {
if (order.lines.isEmpty()) {
throw new ResponseStatusException(400, "An order needs at least one line");
}
MDC.put("customer", order.customer);
try {
LOG.info("Placing order with {} lines", order.lines.size());
return orders.save(order);
} finally {
MDC.remove("customer");
}
}
}
What changed to make that work:
consumes
andproduces
are checked. A request with the wrongContent-Type