Saturday, 21 February 2015

Spring framework is loosely coupled because the following reasons

Spring framework is loosely coupled because the following reasons:

1.       We can use one or another modules of spring without having dependency with other modules.
Ex: We can use spring core + jdbc modules to develop persistence logic without using other modules.
2.       The dependent values of spring resource can be configured through XML file without hardcoding them directly in resources (classes)
We can use only spring to develop complete project or we can use spring along with other frameworks or java technologies to develop project.


Note:

Loosely coupled?

If degrees of dependency is less then it is called Loosely coupled. Ex: TV, remote.

Tightly coupled?

If degrees of dependency is high then it is called tightly coupled.
Ex: (1) fan, switch (2) CPU, and monitor

What is spring?

spring is an open source light weight, Non invasive, loosely coupled, Aspect oriented (AOP) dependency injection based Java Application Framework to develop all kinds of Applications.


How can you say that Spring is open source?

Ans: Along with spring Software we get it source code, this makes spring open source.

Spring is light weight?

(1) spring framework size is less
(2) spring containers can be activated as In-memory containers with out any physical servers support
(3) spring resources can be developed with out spring API

Spring is Non-Invasive Framework because the classes of spring application can be developed with out extending or implementing spring API classes/interfaces.


Spring Framework is not replacement or alternative for JSE, infact it is complement to those technologies.

Loosely coupled?

If degrees of dependency is less then it is called Loosely coupled. Ex: TV, remote.

Tightly coupled?

If degrees of dependency is high then it is called tightly coupled.
Ex: (1) fan, switch (2) CPU, and monitor


·         Middleware  service  of main logic in J2EE Technology but not in Spring.
·         Aspect Oriented Program (AOP) is a methodology of developing middleware services logics separately from main stream business logic and linking them with business logic dynamically at run time.
Middleware services are like security, Transactions and etc since Spring gives support for this AOP, we say spring is Aspect oriented.

Spring 3.x overview diagram

Wednesday, 1 October 2014

What is Framework?

Framework is a collection of JAR Files. We can download the JAR files from the Internet. And we can place all the JAR files in the Class path location.

Installation of the Framework:

Placing the all the JAR files in the class path location is nothing but Installation of the Framework.

Example for Framework:

1. JUnit
2. Spring
3. Strut
4. Hibernate
5. JSF....

Total about 64 frameworks are available in Java.

There are two types of Frameworks are available as of now:

1. Invasive Framework.
    Ex: Struts
2. Non Invasive Framework
    Ex: Spring

Difference between Technology (Software ) and Frame work?

Technology means it contains some set-up files, just we can install those files in our system then automatically that technology is installed in our system.
Example if you take TomCat Server, it contains set-up file , Java. That means where ever we find set-up files it is called Software.

Where as Frame work means it contains collection of JAR files we can download those JAR files from the Internet and we can  place all the JAR files in the Class path location , placing the all the JAR files are nothing but a Installation of the Frame work.

Similarities:
By using Technology / Framework we can develop the application

Contrasts:
While we are using the Technology it will take the lot of time to implement the Application (project) where as takes less time to implement the project with Framework.
Framework is nothing but a ready made tailor made shirt.


What is Invasive Framework.?

For example I would like to create "form bean" , now client entered username and password at browser side that means opening one browser we can enter username and password.  Once is submitted this form, these values will be stored in Server side.
In Server side, One class , it will have one object so these data (username and password) is saved in side the object.  This object is called Form bean object in struts.
imports org.apache.structs.action.ActionFrom;
public class LoginForm extends ActionForm
{

1. properties
2. settersMethods and GettersMethods
3. reset()
4. validate()

}

This is the way to implement the FormBean class.  The main purpus of this LoginBean (AtionForm) class is client entered input value has to be stored.

This ActionForm is provided by the reset() and validate(). You can see above LoginForm. Even it is Framework, ActionForm has to be extended. So this component comes under heavy weight. So this kind of Framework is called Invasive Frameworks. So Struts is "Heavy Weight" Component.

Non - Invasive Frame Work?

 That frame work does not force the developers for extending predefined API's .
Ex:
Spring, Hibernate,




You may like the following articles:
What is class path?

Form bean


Tuesday, 7 February 2012

Spring Frame Work Overview

Spring Frame Work Overview (1.x)

Spring Frame Work Overview (2.x)



Spring DAO:
Provides abstraction layer on JDBC to develope persistence logic.

Spring ORM:

Provides abstraction layer on ORM Frameworks like Hibernate, toplink and etc.. to develop OR mapping persistence logic.

Spring Web:

(a) provides plugins for structs + spring, jsf+spring integration.
(b) provides spring web mvc as web f/w to develop web applications.

Spring JEE:

Provides abstraction layer on multiple java JEE Technologies like JNDI, JMS,RMI,JTA and etc.. to develop JEE applications.

Spring AOP:

Providing a different mechanism or methodology to develop and apply middleware services like logging, security, Transaction and etc..

Note:
Middleware configurations means  

Spring 3.x Overview Diagram


Servlet container and EJB Container are Heavy weight but where as Spring is Light weight (Ram level) 

Wednesday, 18 May 2011

How to setup Spring in Eclipse

Step 1: install the java in your system
How to download, and install Java Software
Step 2: Install Eclipse IDE
http://www.eclipse.org/downloads/

Step 3: Now open Eclipse and create a Dynamic Web Project





Wednesday, 11 May 2011

Spring example 2 program

Prerequisite:

    Java SDK 1.6 (Used during this tutorial)
    Eclipse Indigo (Can also be used Later versions)
    Spring Framework 3.1
 
  Spring Environment Set up

Application to be Developed :



Here in this tutorial we are developing an application where we will Insert(Create) User Details in System. Other CRUD operation look here.
Application Setup :
How to create a Project in Eclipse?

Create the Java Project
Give the project name: SpringExample
Finish

Step 2: Create the package:
under the src folder in the created project.
Go to src Folder
right click the mouse
click on package



re



Add required Spring libraries using Add External JARs option
Create Java classes HelloWorld and MainApp under the com.rajendra package.



Create Beans configuration file Beans.xml under the src folder.
The final step is to create the content of all the Java files and Bean Configuration file and run the application as explained below.



HelloWorld.java

package com.rajendra;

public class HelloWorld {
 private String message;
 public void setMessage(String message){
this.message=message;
 }
 public void getMessage(){
System.out.println("your message : "+message);
 }
}

MainApp.java

package com.rajendra;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
public static void main(String[] args){
@SuppressWarnings("resource")
ApplicationContext context=new ClassPathXmlApplicationContext("Beans.xml");
HelloWorld objA=(HelloWorld)context.getBean("helloWorld");
objA.setMessage("This is Object A");
objA.getMessage();
HelloWorld objB=(HelloWorld) context.getBean("helloWorld");
objB.getMessage();
}

}

Following is the configuration file Beans.xml required for singleton scope:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.rajendra.HelloWorld"
      scope="singleton">
   </bean>

</beans>


Once you are done with creating source and bean configuration files, let us run the application.

Output:

your message : This is Object A
your message : This is Object A