Tuesday, December 22, 2009

Dependency Injection - Design Paradigm and Available Solutions

Ever since Dependency Injection (or DI) coined by Martin Fowler, it has been praised & accepted by many people and frameworks like Spring has used it as their USP as well.

With EJB3 interceptor model & JSR 330, DI has established further ground with Sun Microsystems likeness towards it.
DI can be defined as:
"DI is a special form of IOC (Inversion of Control) and design paradigm flexible enough to allow external dependencies to be configured/applied dynamically to software architecture."

Martin Fowler has identified 3 types of DI:
  • Type 1 or interface injection, in which the exported module provides an interface that its users must implement in order to get the dependencies at runtime
  •  Type 2 or setter injection, in which the dependent module exposes a setter method that the framework uses to inject the dependency
  •  Type 3 or constructor injection, in which the dependencies are provided through the class constructor
DI is language-agnostic and there are solutions available in PHP, .NET, Python, Ruby, Perl, etc. This article goes further in listing solutions available from Java's perspective.

Available Popular Solutions in Java for DI
  • EJB3 Interceptors (Standardized Model by Sun) 
  • JSR 330: Dependency Injection for Java (recently finalized for future Java releases, led by Google, SpringSource, Sun)
  • Spring framework (one of the earliest framework to promote DI)
  • Google Guice (pronounced as "juice")
  • Apache HiveMind (Services & Configuration Microkernel)
  • Apache Tapestry IOC
  • JBoss Microcontainer
  • Plexus
 Benefits of DI
  • Reduction of dependent code
  • Configuration Flexibility
Drawbacks of DI
  • Excessive usage can lead to complicated/hard-to-debug code
  • Difficult to understand complex DI usage because of dynamic injection

Saturday, November 14, 2009

EJB3 – The much improved easy-to-use server-side component model

Earlier EJB versions have been criticized for their heavy-weight components model, but with EJB3 drastic improvements have been made to offer best possible server-side component available in the industry.


The primary goal of EJB3 is to reduce complexity EJB development model and provide ease-of-use and faster development approach to server-side components.

EJB3 has edge over other competing technologies with respect to server-side component model and I have highlighted some of the points below:
1. Annotations – The powerful feature of J2SE 1.5 contributes to the ease of development of EJB components. Using annotations, its “piece-of-cake” to convert a POJO to an Enterprise Bean.

2. Interceptors & Dependency Injection (DI) – DI provides optimization by resource injection during compile-time and frameworks like Spring have been using it for a long time. Utilizing the latest features of Core Java (J2SE 1.5 onwards), DI contributes in optimizing EJB3 development using Interceptors.
Developers can concentrate on business logic only and even log messages, security, etc. can be handled by Interceptors, which can be applied at method level or component level.

3. Elimination of Extra Classes – With EJB3, there is no need to provide Home Interface for Session Beans. Also, required interfaces for persistence entities have been eliminated as well.

4. Replacement of Entity Beans – Heavyweight Entity beans have been replaced by lightweight JPA Entities (POJO based) and it is a major shift in the way persistence has been handled so far. JPA takes the best of all worlds by providing best features of ORM tools (Hibernate, TopLink, IBATIS) , EJB2.1 CMP persistence model and JDOs.

5. Optional Callback Methods – Container Callback methods are optional and developers are no longer need to provide empty methods (general practice earlier) for these methods.

6. POJO Model – EJB3 has finally accepted plain Java objects for local/remote & enterprise bean classes and there is no need to implement any interface or extend any class. Annotations simplifies this process and bean type/client type are indicated by using annotations.

Though industry has already started using other persistence models (specially heavily relying on ORM tools) & POJO based frameworks for server-side component models, EJB3 has come up with new improved and standardized approach and it might be the revival of it.

Best of Luck to EJB3 model!!

Monday, October 5, 2009

Cloud Computing - The Next BIG Thing in IT


Cloud Computing is a new buzzword in IT industry and if you do some analysis, then you will find out, it is more than just a “buzzword”. It is the next revolutionary thing for IT in forthcoming decade.

So, why the “hype” – its because it offers to solve a complex problem of procuring IT capabilities using on-demand easy-to-use approach, which is scalable, flexible and based on pay-as-you-use basis.
For example, if you are building a web-oriented project, traditionally you need to think of initial capital investment for procuring resources (e.g.hardware box, application server license etc).But using Cloud Computing, you can deploy your Web Application to Amazon EC2 without initial capital investment and you can pay as per usage basis.

Cloud Computing Definition:
A pay-as-you-use computing solution (scalable & flexible) to deliver IT-enabled capabilities (software, infrastructure, platform) as a Service (xaaS) using Internet technologies.
Key benefits: Rapid implementation time (infrastructure is readily available using public cloud), usage based payment services & flexible scalability.

Cloud Services (xaaS)

  • SaaS (Software as a Service, ex- Google/Yahoo Mail, Google Docs)
  • PaaS (Platform as a Service, ex- Amazon EC2)
  • IaaS (Infrastructure as a Service, computer infrastructure as a Service, like storage, network equipment, data center, etc. ex-Amazon S3)


Cloud Computing Solution Types
Cloud solution can be of three types: Public Cloud (where you avail it from third-party) , Private Cloud (you create your own cloud using your infrastructure, ownership lies with you, more secure) and Hybrid Cloud (most viable, combination of both worlds)

Public Cloud Solution: Amazon EC2/S3, Google AppEngine, SalesForce, vmware’s vCloud, Sun Cloud
Private Cloud Solution: vmware vSphere (Cloud OS)
Hybrid Cloud Solution: vmware vSphere with vCloud

I will prefer Private Cloud as it is not only Secure but also allows you to use your existing infrastructure resource (using virtualization) for creating your own virtual world. Private Cloud OS like vmware vSphere can give you a great experience in managing the entire infrastructure seamlessly.

Cloud Computing Benefits

  • Hardware Cost reduction (vmware offers 15:1 virtualization ratio)
  • Pay on Usage basis
  • Maximum Resource Utilization
  • Scalability & Flexibility (easy scale-up, scale-down)
  • Reduced Environmental Impact (Green data centre)
  • Reduced Operational Cost
  • Reduced Other Cost (70-80% reduction in datacenter space, power, cooling infrastructure)

Cloud Computing Concerns
Security (on Public Cloud), New technology, Legal Issues/Privacy (in Public Cloud), Dependence on constant connectivity (Internet Availability in Public Cloud),  Tranparency with Service Provider (in Public Cloud), Actual Cost (pay as you use may not be cheap at times in Public Cloud)

Conclusion
Use Cloud Computing by developing a clear cloud computing strategy (long-term) and use incremental approach by targeting short/medium term goals aligned with your long-term strategy. Also, analyze your applications and build portfolio of them as per their suitability for private/public cloud alongside.

Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.

Thursday, September 10, 2009

Why will Java survive?

A friend of mine, who has started working on .NET based project, raised concerned over survivability of Java, which prompted me to highlights key pillars for Java, which will keep it ahead from others:
1. Being an open-source language, there is no vendor lockin like Microsoft. There are 100+ companies surviving on open nature of Java namely JBOSS, APACHE, etc. Also, big companies like IBM, ORACLE, BEA have 1000+ products based on Java technologies.
2. Frameworks - Struts/Spring/Wicket and there are so many frameworks offered by Java technologies as compared to Microsoft single .NET framework. It gives flexibility and choice in choosing competing “state-of-the-art” products.
3. New Languages - As new languages like Ruby, Python, PHP are coming up, JAVA's open-source approach enabled competing JAVA based version of these like JRuby, SCALA, JPython.
4.Faster Development with IDEs- Eclipse, RAD, JBuilder, NetBeans, TogetherJ and there are so many IDEs now offering Wizard-based Web Services, EJB, etc. development and makes life easier.
5. Clustering/High Availability & other non-functional requirements support- Java based enterprise servers not only offer range of products but also there are specialized companies like "TERACOTTA" especially for faster & optimized clustering.
6. Open Specification based Technologies - All Java technologies (Servlet, JSP, JMX, EJB, JTA, JTS, JMS, JAXB, JDBC, JAAS, JMX, JSTL, JCA, JavaSpaces, JavaFX, JSF, etc.) are based on open-specifications (JSRs) developed in accordance with major industry players like Sun, Oracle, IBM, BEA and hence the “collaborative approach” of “mutual knowledge sharing” has higher chances of success in future.
7. Hardware devices for Java - Java based hardware devices (like Azul Vega 3300,7300 Series, inSilicon JVX Accelerator)  are also present in market strengthening its present & future.
8. Java “everywhere” – Java is not limited to server or desktop technology; it has made a bigger presence in mobile devices & others.
9. Last but not least, Java is portable & supported on multiple operating systems like Unix, Linux, Solaris, Windows, etc.
Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.

Monday, August 24, 2009

Virtualization Explained (for x86 based system) - Server Virtualization

Virtualization can be applied to any specific hardware (CPU, storage, memory, network, etc) through the use of software/hardware and it has been part of our lives for a very long time (think of using Virtual Page File in Windows or JVM of Java). But in today’s world and in coming future, it will be “most talked/hyped term” in IT field, specially in relation to Cloud Computing.
Virtualization is one of the key enablers for “Cloud Computing” and because of Virtualization of CPU for x86 based architecture in this decade, it has gained popularity.
(Please note that historically IBM has coined “Virtualization” term in early 70’s for their p-series and i-series based systems)
Though there are no such standards in classifying Virtualization for CPU, the most popular techniques/categories are as follows implemented using Hypervisor or VMM:
Þ       OS assisted virtualization or para-virtualization
Þ       Full virtualization
Þ       Hardware assisted virtualization
Note:
Virtual Machine Monitor (VMM) or Hypervisor – A software layer which lies between hardware (or metal as called by hardware techies) and one or more operating systems. In simple terms, Hypervisor is the software enabler for virtualization.
OS assisted virtualization or para-virtualization
 
As it suggests, this technique depends on support from Operating System for virtualization and hence OS kernel needs to be modified for this purpose. Clearly, Windows OS (XP, Vista) will not be supported because they can not be modified because of closed-source development model.
Modified OS kernel replaces non-virtualized instructions from user applications to hypercalls understandable by hypervisor, which communicates with hardware-layer.
Mostly, all para-virtualization based virtualization solutions are using Xen (an open source para-virtualizer). 
 
Advantages:
Better Performance & Efficiency
Disadvantages:
Security Concerns (because of OS kernel modification), Less support from closed-source OS like Windows, High maintenance cost (upgrades)


Full virtualization
Full virtualization does not modify guest Operating System rather it uses Binary Translation for non-virtualized instructions and direct execution for virtualized instructions. Guest OS is not even aware that it is being virtualized.
Full virtualization is the only solution if situation warrants no hardware assist or operating system assistance.
Advantages:
Best Isolation & Security. Simplifies migration & portability as no OS modification is needed.
Disadvantages:
Slower in comparison to para-virtualization
 
Hardware assisted virtualization (or accelerated virtualization)
Hardware-assisted virtualization was not possible for x86-architecture till 2006 and that was the main reason for emergence full-virtualization and para-virtualization techniques for x-86 architecture, which rely on software for virtualization.
Hardware vendors (e.g. Intel VT, AMD-V) are key enablers in hardware virtualization for. It gives best performance among all virtualization techniques.
Virtualization can broadly classified into two segments – Desktop Virtualization (or Virtual Desktop Infrastructure, VDI) & Server Virtualization
This article discussed only Server Virtualization using Hypervisor.
Server Virtualization can also be achieved using following other techniques:
1. Guest OS Virtualization - Installing Virtualization Software on Operating System and then creating one or many Virtual Machines
2. Kernel Virtualization - Generally applicable to Linux/Unix modified Kernel

Also, Hypervisors are generally classified as follows:
  • Type 1 (or bare metal) - VMM in Ring 0, Guest OS in Ring 1 e.g. VMware ESX
  • Type 2 (or hosted) - Host OS in Ring 0, VMM in Ring 1 e.g. VMware Server (earlier called as GSX)
  • Hybrid - Host OS (Kernel mode) & VMM co-exists in Ring 0
Leading Vendors for Server Virtualization
VMware (Leader & most promising in Server Virtualization with market share > 80%) – ESX, GSX (free to use license)
Virtualiron (acquired by Oracle, Xen based)
Citrix (Desktop Virtualization is Core Business; emerging leader in Server Virtualization specially after acquiring XenSource in 2007)
ORACLE (strengthening their virtualization stack with free to use license, Xen-based)   
SUN (innovative & renowned in Server Virtualization with Solaris Zones, LDOM)
IBM (early providers of virtualization with their proprietary architecture, p-series, i-series)
Microsoft (emerging leader with their Hyper-V technology in Windows Server 2008)
RedHat (Xen-based, claims to provide first product to deliver commercial quality open source virtualization)

In terms of core technology point of view, in essence, there are only 2 major ways world is leading towards providing server virtualization:
  • Xen-based (open source)
  • VMware based (closed source)
Feel free to discuss it further in more detail.
Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.

Tuesday, July 14, 2009

Scalability – The simple explanation

Scalability is not a newly coined term; hence this article does not try to explain “scalability” in general rather it focuses on terms generally attached to it by technocrats.

To start with, let me give a simple definition of scalability:
“Scalability is the ability of the software system to graciously accommodate increasing demand without making any modifications to the system itself; also without compromising system’s performance, reliability and availability”

Scalability has two distinct flavors:
• Vertical Scalability – where you increase resources (cpu, memory, disk, etc) on the same box. For example, by expanding storage by adding RAID/SAN
• Horizontal Scalability – where you increase “units of resources (server box)”. For example, in clustering environment, adding hardware Load Balancers, Firewalls, Web Servers, App Servers.
The other term technocrats coined these days is Linear Scalability.

Linear Scalability
To understand Linear Scalability, you need to first understand “Scalability Factor”. For example, if scalability factor is “0.8” then you add “2 new CPU units”, you will be able to take advantage of “2 units x 0.8” of total processing capacity. In other words, you loose 20% of processing power on addition of each unit.

A True Linear Scalable system will have scalability factor of “1” (meaning scalability factor is always constant); hence you will be able to take 100% advantage or capacity of increased resources.
For example, SBA (Space Based Architecture) systems, like GigaSpaces, offers true Linear Scalability.

Levels of Scalability
Scalability also needs consideration at many levels:
• Firewalls (single firewall may cause delays)
• Web (or HTTP) Server
• Hardware-level Scalability (Load Balancers, IP Sprayers)
• Application Servers (special COTS like Teraacotta for special handling of scalability or GigaSpaces XP Server)
• Component Level Scalability (ex EJB)
• Database Level Scalability

The most important point while considering the level of scalablity required in your software system is to identify the number and growth rate of prospective users (concurrent or others) of your system in the future.

Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.