Posts

Showing posts from November, 2011

Service Provider Framework Pattern Example

Image
This example is created based on the explanation found in the “Effective Java, Second Edition, Chapter 2: Creating and destroying objects”. This pattern about the framework which provide multiple implementations with the compact API. Complete decoupling of implementations made this pattern interesting to me always .  There are three main components: Service , provider, registration and Service Access API . In this example, there can be number of traveling implementations, for example, using bus, train, aircraft, car and so on. They are service providers. All these service implementations need be hide behind the registration. User doesn’t worry about the service implementation an only stick to the Service API. Let’s see the important TravelService interface which is the client completely rely on. I would like to keep this very simple with one service. package com.ojitha.travel.service; public interface TravelService { String getVehical(); } The particular service must ...