Microbule provides a framework for developingMicroservicesquickly and easily! Services are written using the standardJava API for RESTful Services (JAX-RS).
Microbule supports many of the popular deployment containers/frameworks available. Simply choose from:
Okay, so maybe Microbule doesn’t really come in a box, but it does include some very helpful features “out-of-the-box”:
One of the beautiful features of Apache CXF is its ability to generate dynamic client proxies that implement the JAX-RSservice interface. Microbule uses this feature to provide type-safe client proxies:
JaxrsProxyFactory proxyFactory = ...;Map<String,Object> props = new HashMap<>();props.put("microbule.circuitbreaker.enabled", "false");HelloService helloService = proxyFactory.createProxy(HelloService.class, "http://localhost:8383/HelloService", props);
Microbule exposes a JaxrsProxyFactory OSGi service for you to use. Simply inject it wherever you need to create clientproxies.
Extending Microbule couldn’t be simpler. JAX-RS relies upon the notion of “providers” in order to customize the“containers” and “clients.” Microbule provides two extension points JaxrsServerDecorator and JaxrsProxyDecorator whichallow you to add container and client providers, respectively:
public class MyServerDecorator implements JaxrsServerDecorator { @Override public void decorate(JaxrsServerConfig server) { MyServerProvider provider = new MyServerProvider(); server.addProvider(provider); } } }
The JaxrsServerConfig object will provide access to the service interface, the base address, and the service propertiesassociated with the OSGi service used for the server. To register your provider, you must expose it as an OSGi servicewith the “name” service property indicating its name. Similarly, for customizing client proxies, you simply implementJaxrsProxyDecorator:
public class MyProxyDecorator implements JaxrsProxyDecorator { @Override public void decorate(JaxrsProxyConfig proxy) { MyProxyProvider provider = new MyProxyProvider(); proxy.addProvider(provider); } }
Again, the JaxrsProxyDecorator must be expopsed as an OSGi service with the “name” property.
By default, Microbule will apply all registered decorators to your services/proxies. However, you can opt out of themindividually using a service property. For example, if you want to provide your own JSON processing provider, you candisable the GSON-based provider by setting the following service property:
microbule.gson.enabled=false