spring

Adding a Pre-constructed Bean to a Spring Application Context

I am writing a class that implements the following method: public void run(javax.sql.DataSource dataSource); Within this method, I wish to construct a Spring application context using a configuration file similar to the following: <bean id="dataSource" abstract="true" /> <bean id="dao" class="my.Dao"> <property name="dataSource" r...

Understanding the need for a DI framework

This might be a naive question. I'm currently learning the Spring framework and dependency injection. While the basic principle of DI is rather easy to grasp, it's not immediately obvious why you need an elaborate framework to implement it. Consider the following: public abstract class Saw { public abstract void cut(String wood); }...

Eclipse Webflow IDE

I tried using the Spring IDE plugin (webflow) for Eclipse. It hangs on me. Anytime I Spring-enable a project, and open a flow definition file, Eclipse crawls to a halt. Each operation (read click) takes ages. My eclipse projects is a Maven project and I've Maven-enabled it using a Maven plugin for eclipse. I'm not sure if the Maven plug...

Spring IoC and Generic Interface Type

Hi all, I'm trying to use Spring IoC with an interface like this: public interface ISimpleService<T> { void someOp(T t); T otherOp(); } Can Spring provide IoC based on the generic type argument T? I mean, something like this: public class SpringIocTest { @Autowired ISimpleService<Long> longSvc; @Autowired I...

Load Balancing, Spring Security, ConcurrentSessionFilter

I have a Spring 2.5.6/Flex application setup and running with Spring Security 2.0.4. Recently a load balancer (A Foundry ServerIron 4g http://www.foundrynet.com/products/a...ems/si-4g.html) was put into place and now I am getting cross domain errors. Basically the load balancer is firing off a request to myloadbalancer.abc.com and myreal...

Is Spring too complex for JDBC operations?

Just been looking at the Spring framework for JDBC - it looks like there is a bit of a learning curve - and I'm still not able to find a nice up to date quick start Spring/JDBC tutorial of any quality! Is there something lighter than Spring for basic JDBC operations - or has anyone got any good links for tutorials Many thanks ...

Custom Spring sterotype annotation with scope of prototype?

Hi I created a custom sterotype @Action, and Spring has managed to detect it in the package scan I configured in the configurations. The next step I would like to do is to tell Spring that all classes with @Action should be created with prototype, instead of Singleton. My @Action interface is as follows: @Target({ElementType.TYPE}) @R...

Is it possible to use Spring within Eclipse plugins?

Is it possible to use a Spring container for DI from inside Eclipse plugins? I'm wondering because I know that Eclipse causes a lot of issues with class loading, looking up things within the plugin, etc. The plugin is intended to be distributed as a JAR. ...

Insert rows (parent and children) programmatically

I am using Spring and JDBCTemplate. The scenario is a CUSTOMER table and ORDERS table - parent-child relationship. I want to do an insert (for example 1 customer and 5 orders) - but I am unsure how you programmatically insert a row in the CUSTOMER table (some how get hold of the Oracle generated unique id), and then insert the correspo...

Spring - binding to an object rather than a String or primitive

Hello, Let's say I have the following command object: class BreakfastSelectCommand{ List<Breakfast> possibleBreakfasts; Breakfast selectedBreakfast; } How can I have spring populate "selectedBreakfast" with a breakfast from the list? I was figuring I'd do something like this in my jsp: <form:radiobuttons items="${possibleBreakfas...

How assign bean's property an Enum value in Spring config file?

I have a standalone enum type defined, something like this: package my.pkg.types; public enum MyEnumType { TYPE1, TYPE2 } No I want to inject a value of that type into a bean property: <bean name="someName" class="my.pkg.classes"> <property name="type" value="my.pkg.types.MyEnumType.TYPE1" /> </bean> ...and that didn't ...

How do I set an cache time for objects in OSCache using spring-modules?

I have an application in need of some caching, and for some of the semi-static data, I want them to stay in the cache a maximum amount of time (for instance 10 minutes) before being refreshed. My system merely retrieves data, never updates it, so I have no idea of when to flush the cache using the property. In the OSCache docs, such an ...

How to design DAOs when the datasource varies dynamically

Usually when defining a DAO, you would have a setter for the datasource on the DAO object. My problem is that our datasource varies dynamically based on the request to the server. i.e. every request can access different database instance. The request holds logical properties, that later can be used to retrieve the connection to the DB o...

spring not enforcing method security annotations

I'm some what lost as to why spring isn't enforcing the @Secured("ROLE_USER") on my service interface. My controllers are established using annotations. An example of my service Interface public interface MyServiceManager { @Secured("ROLE_USER") public void delete(int cid); @RolesAllowed({"ROLE_USER"}) public Contact...

Oracle connections in Spring

I am using Oracle 9 JDBC Thin Driver - the connection string I have used for standard JDBC was: jdbcConn.connect("jdbc:oracle:thin:myDevDb/myDevDb@fooServer:1521:MYSIDNAME"); ...just trying to get my head around using this kind of connection in Spring 2.5. How do you wire up Spring to an Oracle connection - think it has something t...

How can I serialise a javabean to be loaded by Spring's DataBinder?

I need to serialise a javabean (with arbitrary nested beans) to plain text, and then later restore as an Object graph. For the purposes of this question I am not interested in XML, JSON, etc. but rather name/value pairs. The Spring DataBinder is great for turning a list of name/value pairs into a real Object. For example we can supply:...

Basic Spring help

I'm trying out my first Spring project and must be doing something really stupid because I can't figure out how to get the following simple snippet of code to work: Here is my definition file: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSche...

Problem migrating Spring Web App from tomcat 5.5 to tomcat 6.0

I have a spring web application which has been working fine on tomcat 5.5. I've attempted to deploy the same web app to a tomcat 6 container and come up against some issues. The main two problems I've had are relating to configuring the container for jstl and getting the spring security login to work properly. I believe I've solved the...

Spring vs Hibernate

Just trying to get my head round Spring and figuring out how I wire up an Oracle connection in xml config file, and now find out I need yet another framework! - Hibernate, this is soooo frustrating as it feels like I'm getting deeper and deeper into more and more frameworks without actually getting what I need done! I looked at Hibernat...

Is there ever a case for 'new' when using dependency injection?

Does dependency injection mean that you don't ever need the 'new' keyword? Or is it reasonable to directly create simple leaf classes such as collections? In the example below I inject the comparator, query and dao, but the SortedSet is directly instantiated: public Iterable<Employee> getRecentHires() { SortedSet<Employee> entries ...