background preloader

Project Lombok

Project Lombok

Dynamic Proxies Dynamic proxies provide an alternate, dynamic mechanism for implementing many common design patterns, including the Facade, Bridge, Interceptor, Decorator, Proxy (including remote and virtual proxies), and Adapter patterns. While all of these patterns can be easily implemented using ordinary classes instead of dynamic proxies, in many cases the dynamic proxy approach is more convenient and compact and can eliminate a lot of handwritten or generated classes. The Proxy pattern The Proxy pattern involves the creation of a "stub" or "surrogate" object, whose purpose is to accept requests and forward them to another object that actually does the work. In JDKs prior to 5.0, RMI stubs (and their counterpart, skeletons) were classes generated at compile time by the RMI compiler (rmic), which is part of the JDK tool set. Back to top The dynamic proxy mechanism At the heart of the dynamic proxy mechanism is the InvocationHandler interface, shown in Listing 1. Listing 1. Listing 2. Listing 3.

JDBI : Convenient SQL for Java Op4j spullara/mustache.java jOOQ is a fluent API for typesafe SQL query ryantenney/metrics-spring Guava ronmamo/reflections configleon - A Spring runtime configuration that adapts to your environment. Spring out of the box provides little support for loading property attributes based on environments and/or server contexts. Many projects work around this by creating custom ant builds. With Configleon you can build one war file that can be deployed to every location. Configleon really shines is in it's ability to cascade the property attributes. If we consider the development of a web application, it typically starts in a local environment. For example, say we are deploying the JMesa example web application to the test environment. Trying to deal with all the property attributes related to the various environments can be a nightmare. This application has been road tested for a couple years and I am very happy that it is now open sourced! 1-7-2010 We just moved to Spring 3.0 today and have verified that Configleon works perfectly with the new @Value annotation. @Value("${imagePath}") String imagePath 3-10-2010 Configleon .8.4 has been released.

Futures in Akka with Scala Akka is actor based, event-driven framework for building highly concurrent, reliable applications. Shouldn’t come a surprise that concept of a future is ubiquitous in a system like that. You typically never block waiting for a response, instead you send a message and expect response to arrive some time in the future. Sounds like great fit for… futures. We will continue our web crawler example taking yet another approach, this time with Akka on top of Scala. That was quick! First approach uses built in execution context composed of as many threads as many CPU/cores you have. Having Future instance we would like to process the result. This feels pretty much like ListenableFuture but with cleaner syntax. Of course we can register onComplete callback but futures in Akka/Scala are monads, thus we can process the data as a sequence of chained, strongly typed transformations (explicit types preserved for clarity): I want to be clear here. But the biggest win comes from for-comprehensions.

BTrace: hidden gem in Java developer toolbox This post is about BTrace which I am considering as a hidden gem for Java developer. BTrace is a safe, dynamic tracing tool for the Java platform. BTrace can be used to dynamically trace a running Java program (similar to DTrace for OpenSolaris applications and OS). Shortly, the tool allows to inject tracing points without restarting or reconfiguring your Java application while it’s running. What is very cool, BTrace itself uses Java language to define injection trace points. So let’s get started with a problem: we have an application which uses one of the NoSQL databases (f.e., let it be MongoDB) and suddenly starts to experience significant performance slowdown. First thing first, let’s run JVisualVM and install BTrace plugin: JVisualVM should be restarted in order for plugin to appear. The following very intuitive BTrace editor (with simple toolbar) should appear: This is a place where tracing instrumentation could be defined and dynamically injected into the running application.

Conceptos básicos del lenguaje RAML » RAML (Restful API Modelling Language) es un lenguaje basado en YAML utilizado para describir API’s Restful. Un fichero RAML puede ser consumido para generar código cliente, código servidor y documentación para una API. Información básica de documento RAML En la imagen podemos observar la información básica para un documento RAML. “#RAML 0.8” indica la versión de RAML que se esta utilizando. title: Nombre de la API.versión: Versión de la API.baseUri: URL base de la API.mediaType: Media types soportados por la API (puede incluir varios tipos). Documentación del documento RAML La documentación es una parte opcional del documento RAML y, en ella, podemos incluir toda la documentación relacionada con nuestra API. La documentación debe constar de un array de documentos, incluyendo estos un título, un contenido y usando la sintaxis Markdown. Resources y Methods Resources: Se definen mediante su URL relativa y debe comenzar por “/”. Resources types, traits, seguridad Herramientas basadas en RAML

Related: