Home » Tag Archives: Google Guava (page 2)

Tag Archives: Google Guava

Proxies done right with Guava’s AbstractInvocationHandler

java-interview-questions-answers

Not too often but sometimes we are forced to write custom dynamic proxy class using java.lang.reflect.Proxy. There is really no magic in this mechanism and it’s worth knowing even you will never really use it – because Java proxies are ubiquitous in various frameworks and libraries. The idea is quite simple: dynamically create an object that implements one or more ...

Read More »

Object-based micro-locking for concurrent applications by using Guava

One of the presumably most annoying problems with writing concurrent Java applications is the handling of resources that are shared among threads as for example a web applications’ session and application data. As a result, many developers choose to not synchronize such resources at all, if an application’s concurrency level is low. It is for example unlikely that a session ...

Read More »

Fine-Grained Concurrency with the Guava Striped Class

This post is going to cover how to use the Striped class from Guava to achieve finer-grained concurrency. The ConcurrentHashMap uses a striped locked approach to increase concurrency and the Striped class extends this principal by giving us the ability to have striped Locks, ReadWriteLocks and Semaphores. When accessing an object or data-structure such as an Array or HashMap typically ...

Read More »

Configuring Hadoop with Guava MapSplitters

In this post we are going to provide a new twist on passing configuration parameters to a Hadoop Mapper via the Context object. Typically, we set configuration parameters as key/value pairs on the Context object when starting a map-reduce job. Then in the Mapper we use the key(s) to retrieve the value(s) to use for our configuration needs. The twist ...

Read More »

Blog Categorisation using Encog, ROME, JSoup and Google Guava

java-interview-questions-answers

Continuing with Programming Collection Intelligence  (PCI) the next exercise was using the distance scores to pigeonhole a list of blogs based on the words used within the relevant blog. I had already found Encog as the framework for the AI / Machine learning algorithms, for this exercise I needed an RSS reader and a HTML parser. The 2 libraries I ended ...

Read More »

Guava’s EventBus – Simple Publisher/Subscriber

Looking over recent additions to Google’s Guava Libraries Release 10 I noticed the addition of EventBus. This is a lightweight implementation of a publish-subscribe style messaging system. This is similar to the publish-subscribe model provided by JMS, however the messages remain within the application rather than being broadcast externally. EventBus allows you to create streams within your program to which ...

Read More »

5 Reasons to use Guava

java-interview-questions-answers

Guava is an open source library containing many classes for Java and written by Google. It’s a potentially useful source of miscellaneous utility functions and classes that I’m sure many developers have written themselves before, or maybe just wanted and never had time to write. Here’s 5 good reasons to use it! 1. Collection Initializers and Utilities Generic homogeneous collections ...

Read More »

Google Guava Cache with regular expression patterns

java-interview-questions-answers

Quite recently I’ve seen a nice presentation about Google Guava and we came to the conclusion in our project that it could be really interesting to use the its Cache functionallity. Let us take a look at the regexp Pattern class and its compile function. Quite often in the code we can see that each time a regular expression is ...

Read More »

Hamcrest Matchers, Guava Predicate and Builder design pattern

Often, while coding we have to deal with some POJO objects that have dozens of fields in them. Many times we initialize those classes through a constructor having dozens of arguments which is terrible in any possibly imaginable way. Apart from that the functions that use those constructors are hardly testable. Let’s take a closer look at using a Builder ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns