Home » Tag Archives: Spring (page 41)

Tag Archives: Spring

Spring Scoped Proxy

spring-interview-questions-answers

Consider two Spring beans defined this way: @Component class SingletonScopedBean{ @Autowired private PrototypeScopedBean prototypeScopedBean; public String getState(){ return this.prototypeScopedBean.getState(); } } @Component @Scope(value="prototype") class PrototypeScopedBean{ private final String state; public PrototypeScopedBean(){ this.state = UUID.randomUUID().toString(); } public String getState() { return state; } } Here a prototype scoped bean is injected into a Singleton scoped bean. Now, consider this test using ...

Read More »

Observer Pattern with Spring Events

spring-interview-questions-answers

INTRODUCTION The essence of the Observer Pattern is to ‘Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.’ GoF. Observer pattern is a subset of publish/subscribe pattern which allows a number of observer objects to see an event. This pattern can be used in different situations, but in ...

Read More »

Customizing Spring Data JPA Repository

spring-data-logo

Spring Data is a very convenient library. However, as the project as quite new, it is not well featured. By default, Spring Data JPA will provide implementation of the DAO based on SimpleJpaRepository. In recent project, I have developed a customize repository base class so that I could add more features on it. You could add vendor specific features to ...

Read More »

Maven Web Project Kickstarter Codebase with Spring, Hibernate, Akka, Twitter Bootstrap, Apache Tiles and jQuery

akka-logo

I am happy to upload my second project to GitHub to help people get started with Java Web App Development as quickly as possible. I am sharing this code with Apache License 2.0. Here is the URL for the same: https://github.com/ykameshrao/spring-hibernate-springdata-springmvc-maven-project-framework The project consists of following parts: 1) Commons-Deps: Dependencies declared as a single pom file to easily manage the ...

Read More »

Hibernate native SQL features into your Spring Data Repository

spring-data-logo

JPA provides @NamedNativeQuery for you to use native SQL. However, the usage is not so convenient, especially when you need to map multiple entities in your native SQL. You have to define a set of SqlResultSetMapping mapping which is quite error prone. For those who have used Hibernate native SQL features before, you will find that it is much more ...

Read More »

Measure execution time in Java – Spring StopWatch Example

spring-interview-questions-answers

There are two ways to measure elapsed execution time in Java either by using System.currentTimeinMillis() or by using System.nanoTime() . These two methods can be used to measure elapsed or execution time between two method calls or event in Java. Calculating elapsed time is one of the first thing Java programmer do to find out how many seconds or millisecond ...

Read More »

Spring @Configuration and FactoryBean

spring-interview-questions-answers

Consider a FactoryBean for defining a cache using a Spring configuration file: <cache:annotation-driven /> <context:component-scan base-package='org.bk.samples.cachexml'></context:component-scan> <bean id='cacheManager' class='org.springframework.cache.support.SimpleCacheManager'> <property name='caches'> <set> <ref bean='defaultCache'/> </set> </property> </bean> <bean name='defaultCache' class='org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean'> <property name='name' value='default'/> </bean> The factory bean ConcurrentMapCacheFactoryBean is a bean which is in turn responsible for creating a Cache bean. My first attempt at translating this setup to a ...

Read More »

Spring JDBC Database connection pool setup

spring-interview-questions-answers

Setting up JDBC Database Connection Pool in Spring framework is easy for any Java application, just matter of changing few configuration in spring configuration file.If you are writing core java application and not running on any web or application server like Tomcat or Weblogic, Managing Database connection pool using Apache Commons DBCP and Commons Pool along-with Spring framework is nice ...

Read More »

Spring Profiles in XML Config Files

spring-interview-questions-answers

My last blog was very simple as it covered my painless upgrade from Spring 3.0.x to Spring 3.1.x and I finished by mentioning that you can upgrade your Spring schemas to 3.1 to allow you to take advantage of Spring’s newest features. In today’s blog, I’m going to cover one of the coolest of these features: Spring profiles. But, before ...

Read More »

Spring Security Implementing Custom UserDetails with Hibernate

spring-security-logo

Most of the time, we will want to configure our own security access roles in web applications. This is easily achieved in Spring Security. In this article we will see the most simple way to do this. First of all we will need the following tables in the database: CREATE TABLE IF NOT EXISTS `mydb`.`security_role` ( `id` INT(11) NOT NULL ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close