spring

Internals of Spring Framework and other IoC containers

I've been using spring for some time, but I always wondered how does it work, more specifically, how do they load and weave beans/classes marked only with an interface or @annotation. For the xml declarations, it's easy to see how spring preprocesses my beans (they are declared in the xml context that spring reads), but for the classes...

Getting template text from FreeMarker in Spring app

Hi, In my Spring app, I'd like to use FreeMarker to generate the text of emails that will be sent by my application. The generated text will never be returned to the view so I don't need to configure a FreeMarker view resolver. The documentation seems to indicate that I should configure a FreeMarkerConfigurationFactoryBean like this <b...

cache FreeMarker templates

Hi, I'm using the Spring class FreeMarkerConfigurationFactoryBean to retrieve FreeMarker templates. I would like these templates to be cached, but there doesn't appear to be any way to indicate that this behaviour is required. In contrast, Spring modules provides a CachingTemplateResolver which does provide template caching, but is it ...

Spring + Tiles2 + Freemarker - integrate via Freemarker Servlet or via Spring's FreeMarkerViewResolver?

Hi all, i was strugling today trying to migrate from Freemarker to Tiles2 + Freemarker. My freemarker templates use macros that come from spring.ftl. If i provide a fremarker servlet in web.xml, my model is visible to freemarker, but specific spring variables (naturally) are not populated into the model as springs FreemarkerView is r...

With Spring Webflow 2, what request parameters, if any, are necessary to trigger "submit" transition from view-state?

My view-state to action-state transition does not appear to be happening. In the following example, I want the view-state to transition to the action-state when the user submits the form. Pretty basic stuff. But the setA() method does not get called. In the jsp, does the submit input element need to have a name of "_eventId", or "_e...

How do I get my dependenices inject using @Configurable in conjunction with readResolve()

The framework I am developing for my application relies very heavily on dynamically generated domain objects. I recently started using Spring WebFlow and now need to be able to serialize my domain objects that will be kept in flow scope. I have done a bit of research and figured out that I can use writeReplace() and readResolve(). The ...

How do I specify a TCP transport is server mode (listening) or client mode in activemq?

The example given for a spring injected endpoint is as follows: <endpoint id="hl7listener" uri="mina:tcp://localhost:8888?sync=true&amp;codec=hl7codec"/> How do I setup a client mode endpoint such that is will connect to a specific port on another server? How do I configure the endpoint to listen for inbound connections? (the example...

How to nest Spring JMS MessageConverters

I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter would call the child converter, which is assumed to generate a TextMessage. It would take the payload and GZIP compress it, creating a BytesMessage which is ultimately returned to the sender. The problem is in writing fromMessage(). ...

Is it possible to partially autowire a spring bean?

I want to autowire a bean partially - that is, I want some args to be autowired but other to be explicitly set. For example: public MyClient(Service svc, boolean b) In the case of this constructor, I would like to specify in my xml the value for b, but have svc autowired. Is that possible? Thanks, Lowell ...

New to Spring - BeanFactory vs ApplicationContext?

I'm pretty new to the Spring Framework, I've been playing around with it and putting a few samples apps together for the purposes of evaluating Spring MVC for use in an upcoming company project. So far I really like what I see in Spring MVC, seems very easy to use and encourages you to write classes that are very unit test-friendly. Jus...

What causes duplicate requests to occur using spring,tomcat and hibernate

I'm working on a project in Java using the spring framework, hibernate and tomcat. Background: I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model) manipulation prior to persisting using hibernate. Problem: For some reas...

Hibernate transaction problem

We are using Hibernate Spring MVC with OpenSessionInView filter. Here is a problem we are running into (pseudo code) transaction 1 load object foo transaction 1 end update foo's properties (not calling session.save or session.update but only foo's setters) validate foo (using hibernate validator) if validation fails ? go back to edi...

Duplicate spring configurations being loaded?

I'm looking at the output from spring being loaded up by tomcat and there's something very strange...Everything is duplicated. What would cause this? Whatever it is, it's causing my application to run in odd ways. Additional Info: The application is a web app. All the spring information is loaded using the context loader(?) defined i...

When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?

I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. The code snippet below is what I'm doing. My question is, is this the accepted way? I don't like having a call to a static method inside this controller - that defeats the whole purpose of Spring, IMHO. Is there a w...

PHP MVC (symfony/Zend) vs ASP MVC vs Spring MVC vs Ruby on Rails?

I'm paralyzed by choice. I know PHP, C# and Java fairly well as languages. Most of my web development in the past has been in PHP (with my own or other OSS frameworks). I've spent the last 2-3 years developing desktop GUI apps in C#. Before that I was doing desktop GUI apps in Java (with a little Servlets/JSP). I want to develop a...

Any disadvantages to using spring to separate tests and data?

I've been struggling coming up with a good solution to separate my testing data from unit tests (hard coded values). Until it dawned on me that I could create beans with spring and use those beans to hold my data. Are there any draw backs to coding my unit tests this way? Albeit they run a bit slower seeing as how spring has to c...

spring and interfaces

I read all over the place about how Spring encourages you to use interfaces in your code. I don't see it. There is no notion of interface in your spring xml configuration. What part of Spring actually encourages you to use interfaces (other than the docs)? ...

Spring & Hibernate EJB Events

Is it possible to define a spring-managed EJB3 hibernate listener? I have this definition in my persistence.xml: <properties> <property name="hibernate.ejb.interceptor" value="my.class.HibernateAuditInterceptor" /> <property name="hibernate.ejb.event.post-update" value="my.class.HibernateAuditTrailEventListene...

spring beans and sessionFactory in different xml files.

we have 3 applications using 3 different spring configuration files. But we have one database and one datasource,so one sessionFactory. how can we import the sessionFactory bean into the 3 different spring config files. ...

ORM solutions (JPA; Hibernate) vs. JDBC

I need to be able to insert/update objects at a consistent rate of at least 8000 objects every 5 seconds in an in-memory HSQL database. I have done some comparison performance testing between Spring/Hibernate/JPA and pure JDBC. I have found a significant difference in performance using HSQL.. With Spring/Hib/JPA, I can insert 3000-400...