Revision: 1030
http://stripes.svn.sourceforge.net/stripes/?rev=1030&view=rev
Author: fdaoud
Date: 2009-01-09 19:28:54 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
Implementation of STS-633 (SpringInjectionFactory)
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptor.java
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptorSupport.java
Added Paths:
-----------
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInjectionFactory.java
Added:
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInjectionFactory.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInjectionFactory.java
(rev 0)
+++
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInjectionFactory.java
2009-01-09 19:28:54 UTC (rev 1030)
@@ -0,0 +1,57 @@
+/* Copyright 2009 Frederic Daoud
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.stripes.integration.spring;
+
+import javax.servlet.ServletContext;
+import net.sourceforge.stripes.config.Configuration;
+import net.sourceforge.stripes.controller.DefaultObjectFactory;
+import net.sourceforge.stripes.util.Log;
+
+/**
+ * <p>
+ * An extension of {...@link DefaultObjectFactory} that calls
+ * {...@link SpringHelper#injectBeans((Object, ServletContext))} in the
{...@link #postProcess(Object)}
+ * method, to inject dependencies marked with {...@link SpringBean} in every
type of object created
+ * by Stripes (Action Beans, Interceptors, Type Converters, Formatters, etc.).
+ * </p>
+ *
+ * @author Freddy Daoud
+ * @since Stripes 1.6
+ */
+public class SpringInjectionFactory extends DefaultObjectFactory {
+ private static final Log log =
Log.getInstance(SpringInjectionFactory.class);
+ private ServletContext servletContext;
+
+ /**
+ * Gets the {...@link ServletContext} so that it can be used to inject
Spring beans.
+ */
+ @Override
+ public void init(Configuration configuration) throws Exception {
+ super.init(configuration);
+ servletContext = configuration.getServletContext();
+ }
+
+ /**
+ * Calls {...@link SpringHelper#injectBeans((Object, ServletContext))} to
inject dependencies
+ * marked with {...@link SpringBean} into the object before returning it.
+ */
+ @Override
+ protected <T> T postProcess(T object) {
+ log.debug("Running Spring dependency injection for instance of ",
+ object.getClass().getSimpleName());
+ SpringHelper.injectBeans(object, servletContext);
+ return object;
+ }
+}
Modified:
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptor.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptor.java
2009-01-06 04:48:54 UTC (rev 1029)
+++
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptor.java
2009-01-09 19:28:54 UTC (rev 1030)
@@ -14,6 +14,7 @@
*/
package net.sourceforge.stripes.integration.spring;
+import net.sourceforge.stripes.config.DontAutoLoad;
import net.sourceforge.stripes.controller.Interceptor;
import net.sourceforge.stripes.controller.ExecutionContext;
import net.sourceforge.stripes.controller.Intercepts;
@@ -47,8 +48,10 @@
* @see SpringBean
* @author Tim Fennell
* @since Stripes 1.3
+ * @deprecated As of Stripes 1.6, replaced by {...@link
SpringInjectionFactory}.
*/
@Intercepts(LifecycleStage.ActionBeanResolution)
+...@dontautoload
public class SpringInterceptor implements Interceptor {
private static final Log log = Log.getInstance(SpringInterceptor.class);
Modified:
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptorSupport.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptorSupport.java
2009-01-06 04:48:54 UTC (rev 1029)
+++
trunk/stripes/src/net/sourceforge/stripes/integration/spring/SpringInterceptorSupport.java
2009-01-09 19:28:54 UTC (rev 1030)
@@ -31,7 +31,9 @@
* only once when the interceptor is first created and initialized.</p>
*
* @author Tim Fennell
- * @since Stripes 1.4
+ * @since Stripes 1.4
+ * @deprecated As of Stripes 1.6, replaced by {...@link
SpringInjectionFactory} which already injects
+ * Spring dependencies into Interceptors.
*/
public abstract class SpringInterceptorSupport implements Interceptor,
ConfigurableComponent {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development