You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2008/04/02 11:04:41 UTC

svn commit: r643803 - in /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic: ./ SpringBasicFrameworkAdapter.java SpringBasicFrameworkAdapterFilter.java

Author: imario
Date: Wed Apr  2 02:04:37 2008
New Revision: 643803

URL: http://svn.apache.org/viewvc?rev=643803&view=rev
Log:
initial draft for a SpringBasicFrameworkAdapter

Added:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java   (with props)
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapterFilter.java
      - copied, changed from r643371, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java?rev=643803&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java Wed Apr  2 02:04:37 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.myfaces.orchestra.frameworkAdapter.springBasic;
+
+import org.apache.myfaces.orchestra.frameworkAdapter.basic.BasicFrameworkAdapter;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Same as {@link BasicFrameworkAdapter} but lookup the bean using the Spring framework.
+ *
+ * @see BasicFrameworkAdapter
+ */
+public class SpringBasicFrameworkAdapter extends BasicFrameworkAdapter {
+
+    private final ServletContext context;
+
+    public SpringBasicFrameworkAdapter(ServletContext context, String conversationMessagerClass) {
+        super(context, conversationMessagerClass);
+
+        this.context = context;
+    }
+
+    public Object getBean(String name) {
+        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(context);
+        return appContext.getBean(name);
+    }
+}

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapterFilter.java (from r643371, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapterFilter.java?p2=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapterFilter.java&p1=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java&r1=643371&r2=643803&rev=643803&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/springBasic/SpringBasicFrameworkAdapterFilter.java Wed Apr  2 02:04:37 2008
@@ -17,10 +17,12 @@
  * under the License.
  */
 
-package org.apache.myfaces.orchestra.frameworkAdapter.basic;
+package org.apache.myfaces.orchestra.frameworkAdapter.springBasic;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.frameworkAdapter.basic.BasicFrameworkAdapter;
+import org.apache.myfaces.orchestra.frameworkAdapter.basic.BasicFrameworkAdapterFilter;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -31,19 +33,21 @@
 import java.io.IOException;
 
 /**
- * Configures the BasicFrameworkAdapter.
+ * Configures the SpringBasicFrameworkAdapter.
  * <p>
  * Orchestra accesses information about the request, response, session, etc via a
  * FrameworkAdapter so that it can be used with multiple web tier frameworks. This
  * class selects and configures the simplest version of this adapter, which only
  * depends on the <i>basic</i> Servlet APIs.
  * <p>
- * If filter config parameter "conversationMessagerClass" is set, then this is 
- * passed to the BasicFrameworkAdapter, meaning that this can be either a 
+ * If filter config parameter "conversationMessagerClass" is set, then this is
+ * passed to the BasicFrameworkAdapter, meaning that this can be either a
  * beanname defined in the dependency-injection framework, or an absolute
  * classname of a type implementing ConversationMessager.
+ * <p>
+ * This filter access the Spring framework to lookup the bean in its {@link org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter#getBean} method
  */
-public class BasicFrameworkAdapterFilter implements Filter
+public class SpringBasicFrameworkAdapterFilter implements Filter
 {
     private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
 
@@ -54,7 +58,7 @@
     {
         String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
 
-         adapter = new BasicFrameworkAdapter(filterConfig.getServletContext(), conversationMessager);
+         adapter = new SpringBasicFrameworkAdapter(filterConfig.getServletContext(), conversationMessager);
     }
 
     public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
@@ -74,4 +78,4 @@
     public void destroy()
     {
     }
-}
+}
\ No newline at end of file