Feeds:
Posts
Comments

Archive for October, 2014

Recently I stumbled upon a particular Spring project  called Spring Loaded .The ReadMe section did catch my attention because it boosts developer productivity by reloading class files as and when they change.

There have been quite a few projects which provide such benefits and I believe the most popular commercial choice is JRebel. Those guys have done a great job in turning  one of the greatest JAVA Web developers pain into a line of business.  However there have been alternatives but none so simple as JRebel

Fortunately Spring Loaded was quite simple to use and configure. Its just a single jar. However, I am quite sure it is not a sophisticated as  other commercial options. But its getting there and is currently being used in Grails 2.

ReLoading in Action

The most reliable  way to show automatic reloading in action is by capturing a video. Unfortunately you guys will just have to trust me.

Start off by downloading the jar and including in your normal java project.

Create a POJO “Person”


public class Person {
	
	
	
	public  void printBody()
	{

		System.out.println("*********");
		this.hands();
//		this.gloves();
		System.out.println("Body");
		this.legs();
//		this.shoes();
		System.out.println("*********");
	}
	
	private  void hands()
	{
		System.out.println("Hands");
	}
	
	private  void gloves()
	{
		System.out.println("Gloves");
	}		
	
	private  void legs()
	{
		System.out.println("Legs");
	}	
	
	private  void shoes()
	{
		System.out.println("Shoes");
	}	

}

Now create a class to run the POJO

public class LiveEcho {

	
	public static void main(String[] args) throws Exception {
		
		while(true)
		{
			Thread.sleep(5000);
			new Person().printBody();

		}
		
	}
}

When you run the LiveEcho class you will see statements in the console like below.

*********
Hands
Body
Legs
*********
*********
Hands
Body
Legs
*********
*********
Hands
Body
Legs
*********

Nothing amazing. While the application is running, try uncommenting out “this.gloves()” or “this.shoes()”. Still nothing amazing.

In order to let Spring Loaded to be aware of the changes, we need to pass “-javaagent:springloaded-1.1.5.RELEASE.jar” as a java argument. I have done it here from my eclipse option

SprngLoadedConfig

SprngLoadedConfig

Run the LiveEcho class again. This time while the class is running, try uncommenting out “this.gloves()” or “this.shoes()”. You will see the output on the console changing

*********
Hands
Body
Legs
*********
*********
Hands
Body
Legs
*********
*********
Hands
Body
Legs
*********
*********
Hands
Gloves
Body
Legs
*********
*********
Hands
Gloves
Body
Legs
*********
*********
Hands
Gloves
Body
Legs
Shoes
*********
*********
Hands
Gloves
Body
Legs
Shoes
*********

As you can see, Spring Loaded has noticed the changes in the Person class files and reloaded the changes without re-starting the JVM.

Further reading

There are different ways of checking whether the classes have re-loaded or what are the changes that have taken place.

Q. How do I know when a reload has occurred so I can clear my state? A. You can write a plugin that is called when reloads occur and you can then take the appropriate action. Create an implementation of ReloadEventProcessorPlugin and then register it via SpringLoadedPreProcessor.registerGlobalPlugin(plugin). (There are other ways to register plugins, which will hopefully get some documentation!)

I have not tried it out on complex web project and their likes, but I am sure they are getting there.

Advertisements

Read Full Post »

Mobile development has been evolving drastically in the past few years. It started with native development , where you needed to code for every platform such as iOS, Android, Windows, etc. With the increased number of devices and operating systems and the need for speed to market, technology vendors started to provide:

Mobile Application Development Platform (MADP) which can be used to build and package (used before production). These platforms reduce the maintenance overhead of developing natively for every operating system. It enables developer to write the code once and package it for different operating systems.

But soon mobile development required more features such as analytics to know the usage of the application, push notification, offline synchronization for cases when internet is not available on the device due to the person entering elevator for example.  Mobile devices have limited resources in term of  processing, storage, bandwidth, thus it requires lightweight mechanisms to connect to backend services.

Technology vendors, yet again, brought in a new concept to cope up with the continuous demands and features. Mobile Backend as a Service (Mbaas) which is used to connect to backend as well as mobile specific features such as offline sync, analytics, push notification. All reused services can be defined and published through MBaas (used after production)

Some vendor providers have combined both MADP and Mbaas into their offerings while others provide these two separately.

 

Mbaas is to a great extend overlapping with another technology which is the Enterprise Service Bus (ESB). ESB is used to integrate with multiple backend services.

 

So how can we decide on what to use?

What does our organization need? MADP, Mbaas, or ESB?

 

Recommended approach

 

Mobile Platforms

Mobile Platforms

I would recommend the below approach starting from bottom up:

  • Backend service: Existing services provided internally or externally which could be published through web services, databases, etc.
  • Integration Layer: This layer will connect backend services together thus it needs to support multiple adaptors to connect to these services. Moreover, it may transform some of the protocols and payload if required for the service integration. It will also orchestrate between these service to provide simpler services i.e. using information accessible by different services rather than requesting the information from the end user. This layer can be used if you already have an ESB or a need for the ESB within your organization.
  • Mobile Integration Layer: This layer is a highly optimized layer for the mobile or any future device. It publishes the service provided through the Integration Layer in a very lightweight manner as mobile devices have limited capabilities in term of processing power, bandwidth, etc.. Moreover, it provides mobile specific features such as offline sync, analytics, push notification. This layer needs to integrate with different development approach i.e. native, hybrid, etc.
  • Development Layer: This layer is used to develop and package mobile development. It can be provided as an add value for any organization who would like to start or shift their mobile development. It can integrate with the Mobile Integration Layer and use any of its facilities.

The advantages of using such an approach are:

  • Segregation of responsibilities between integration platform, mobile backend and development platform which enables you to use the power of every platform
  • Decoupling of the layers which will enable you to be less vendor lock and ease the replacement technology of any of these layers
  • Be able to support multiple development platforms and languages such as JavaScript, .Net, native, etc. This will resolve any the technical skill constraint.
  • MBaas technology can integrate with any other technology i.e. development and integration

Conclusion:

Don’t fall for vendor jargon and technology hype. Carefully measure and evaluate which piece of technology fits into your bigger picture puzzle.

 

Read Full Post »