Home » Author Archives: Biju Kunjummen

Author Archives: Biju Kunjummen

Netflix Archaius for property management – Basics

java-interview-questions-answers

Netflix Archaius provides a neat set of features to load dynamic properties into an application. This blog post is just a documentation of the extent of Archaius that I have understood, there is much more to it than I have documented here, but this should provide a good start:     Default Behavior Consider a simple properties file: stringprop=propvalue listprop=value1, ...

Read More »

Spring-session demonstration using docker-compose

spring-interview-questions-answers

I have earlier written about an exciting new project called Spring-session which provides a clean way to externalize user sessions for java based web applications. I managed to get a good demonstration set-up for spring-session using docker-compose which shows off the strengths of this project and I wanted to write about this here. In short, this is the set-up that ...

Read More »

Spring Enable annotation – writing a custom Enable annotation

spring-interview-questions-answers

Spring provides a range of annotations with names starting with Enable*, these annotations in essence enable certain Spring managed features to be activated. One good example of such an annotation is EnableWebMvc which brings in all the beans needed to support a MVC flow in Spring based applications. Another good example is the EnableAsync annotation to activate beans to support ...

Read More »

Hot and cold rx-java Observable

java-logo

My own understanding of Hot and Cold Observable is quite shaky, but here is what I have understood till now! Cold Observable Consider an API which returns an rx-java Observable: import obs.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import rx.Observable; import rx.schedulers.Schedulers; public class Service1 { private static final Logger logger = LoggerFactory.getLogger(Service1.class); public Observable<String> operation() { return Observable.<String>create(s -> { logger.info("Start: ...

Read More »

Using rx-java Observable in a Spring MVC flow

spring-interview-questions-answers

Spring MVC has supported asynchronous request processing flow for sometime now and this support internally utilizes the Servlet 3 async support of containers like Tomcat/Jetty. Spring Web Async support Consider a service call that takes a little while to process, simulated with a delay: public CompletableFuture<Message> getAMessageFuture() { return CompletableFuture.supplyAsync(() -> { logger.info("Start: Executing slow task in Service 1"); Util.delay(1000); ...

Read More »

Netflix Archaius properties in a Spring project

spring-interview-questions-answers

Archaius Basics Netflix Archaius is a library for managing configuration for an application. Consider a properties file “sample.properties” holding a property called “myprop”:               myprop=myprop_value_default This is how the file is loaded up using Archaius: ConfigurationManager .loadCascadedPropertiesFromResources("sample"); String myProp = DynamicPropertyFactory.getInstance().getStringProperty("myprop", "NOT FOUND").get(); assertThat(myProp, equalTo("myprop_value_default")); Archaius can load property appropriate to an environment, consider ...

Read More »

Async abstractions using rx-java

java-logo

One of the big benefits in using Rx-java for me has been the way the code looks exactly the same whether the underlying calls are synchronous or asynchronous and hence the title of this entry. Consider a very simple use case of a client code making three slow running calls and combines the results into a list:       ...

Read More »

Netflix Governator Tests – Introducing governator-junit-runner

java-interview-questions-answers

Consider a typical Netflix Governator junit test.                     public class SampleWithGovernatorJunitSupportTest { @Rule public LifecycleTester tester = new LifecycleTester(); @Test public void testExampleBeanInjection() throws Exception { tester.start(); Injector injector = tester .builder() .withBootstrapModule(new SampleBootstrapModule()) .withModuleClass(SampleModule.class) .usingBasePackages("sample.gov") .build() .createInjector(); BlogService blogService = injector.getInstance(BlogService.class); assertThat(blogService.get(1l), is(notNullValue())); assertThat(blogService.getBlogServiceName(), equalTo("Test Blog Service")); } } This ...

Read More »

Disambiguating between instances with Google Guice

java-interview-questions-answers

Google guice provides a neat way to select a target implementation if there are multiple implementations of an interface. My samples are based on an excellent article by Josh Long(@starbuxman) on a similar mechanism that Spring provides. So, consider an interface called MarketPlace having two implementations, an AndroidMarketPlace and AppleMarketPlace:           interface MarketPlace { } class ...

Read More »

Learning Netflix Governator – Part 2

java-logo

To continue from the previous entry on some basic learnings on Netflix Governator, here I will cover one more enhancement that Netflix Governator brings to Google Guice – Lifecycle Management Lifecycle Management essentially provides hooks into the different lifecycle phases that an object is taken through, to quote the wiki article on Governator:           Allocation (via ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close