Daily Archives: July 5, 2013

SCJP – Quick Notes

Topics Covered

General

General Tips

Language Fundamantals

Interfaces

Constructors

Modifiers

Methods

main()

Identifiers

Keywords

Defaults

Arrays

Primitive Types

Numeric Literals

Character Literals

String Literals

Class Literals

Operators and Assignments

Conversions

Numeric Promotion

Unary Operators

Arithmetic Operators

Comparison Operators

Assignmant Operators

Casting

Ternary Operator

String Operators

Boolean equals()

Precedence

Bitwise Vs Logical Operators

Method Invocation

Flow Control and Exception handing

Statements

Exceptions

Declarations and Access Control

Access Modifiers

Special Modifiers

this and super

Shadowing

Hiding

Access Control

Garbage Collection

Overloading and Overriding

Inner Classes

Annonymous Classes

Threads

Basics

Page Visitors: 3077

Spring – Application Monitoring – Performance Monitor

Thanks to my colleague for sharing this info on application monitoring using out of the box spring interceptors.

To put in place performance monitoring of service methods (methods annotated with @Service), do the following.

The interceptor class which will be used for this is org.springframework.aop.interceptor.PerformanceMonitorInterceptor.

In your spring application context configure the interceptor as below:-

The logger has to be set at trace level for the logging to happen

Page Visitors: 1814

Spring – Multiple transaction manager in an application

In the application context declare the following:-

In the Java code do the following as shown below as code snippet:-

Page Visitors: 4559

Spring Book – Chapter 2 – Getting started with Spring

Developing enterprise application using Spring Framework is much simpler than using standard Java EE in many ways. Even though Java EE’s declarative programming model using EJB simplifies infrastructural aspects of development such as transactions and security, t still introduces unwanted complexity to the application as a whole. Developers need to still write more Framework code than the application code. Over the period Java EE has also redefined itself to introduce new programming techniques like Aspect Oriented Programming (AOP) and Dependency Injection (DI). So many new Frameworks got evolved using these techniques. Leading from this pack of Framework at the moment is by Spring Framework by a long way. In this chapter I will try to give you details on various aspects of Spring Framework, along with the sample application that will be used throughout this book to show the various concepts in this Framework.

In this chapter, I will give you details on how you can start building applications with Spring Framework. I will also give details on the sample application on which the entire book is based. It also talks about the some basic concepts which are very much essential for understanding Spring in a holistic way.

Developing with Spring Framework

Getting the Spring Framework

Before you get started, you need to get the Spring Framework. You have two options to do so: you can either download the package distribution from Spring website, or you can checkout the source from github.

Downloading standard package distribution

Visit http://www.springsource.org/download/community?project=Spring%2520Framework and download the latest Spring release (version 3.1.1.RELEASE at the time of writing). Previous releases can also be found in this same page.

Checking out source from github

Alternatively you can visit https://github.com/SpringSource/spring-Framework and can download as required or fork the Framework and create your own repository and play around with it.

Using Maven Build Framework

If you are using Maven Build Framework for building your application, you can download the necessary artifacts into your project by mere declaring the maven repository in your build xml called as pom.xml. You will have to make sure that your machine is appropriately configured so that your Maven can look into the repository URL and download the necessary artifacts which you require in your project. Declare the repository as follows in your pom.xml:

Listing 1-1. Repository declaration in pom.xml if you are using maven as your build tool

After that declare the spring modules that you require in your project as below (in the below example spring-context jar with version 3.1.1.RELEASE will be downloaded into the project and set dependency on):

Spring Packaging

The Spring Framework is a series of JAR files, which we can get by two ways as explained in the above section. To install it all you really have to do is extract the downloaded compressed file to some location on your computer, and then reference the appropriate JARs in a Java project.

Spring Dependencies Structure

Quite simply the dependency between various jars comprising the Spring Framework can be summarized as below:

Figure 1 Spring Framework Dependencies

Page Visitors: 7782