You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/03/17 19:28:20 UTC

svn commit: r924403 - in /myfaces/core/branches/1.2.x: api/ api/src/main/java/javax/faces/webapp/ impl/ impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/myfaces/config/annotation/ impl/src/main/java/org/apache/myfaces/ta...

Author: lu4242
Date: Wed Mar 17 18:28:20 2010
New Revision: 924403

URL: http://svn.apache.org/viewvc?rev=924403&view=rev
Log:
MYFACES-2290 Add OSGi bundle information and bundle classloader / activator (trying to be nice with OSGi)

Modified:
    myfaces/core/branches/1.2.x/api/pom.xml
    myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java
    myfaces/core/branches/1.2.x/impl/pom.xml
    myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
    myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java
    myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java

Modified: myfaces/core/branches/1.2.x/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/pom.xml?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/pom.xml (original)
+++ myfaces/core/branches/1.2.x/api/pom.xml Wed Mar 17 18:28:20 2010
@@ -130,6 +130,7 @@
                   org.apache.commons.logging;version="[1.1.1, 2.0.0)",
                   javax.faces.*;version="${project.version}"
                 </Import-Package>
+                <Require-Bundle>org.apache.myfaces.core.impl</Require-Bundle>
               </instructions>
             </configuration>
           </execution>

Modified: myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java Wed Mar 17 18:28:20 2010
@@ -115,6 +115,10 @@ final class _ErrorPageWriter {
 
     private static String[] splitTemplate(String rsc) throws IOException {
         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(rsc);
+        if (is == null)
+        {
+            is = _ErrorPageWriter.class.getClassLoader().getResourceAsStream(rsc);
+        }
         if (is == null) {
             throw new FileNotFoundException(rsc);
         }

Modified: myfaces/core/branches/1.2.x/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/impl/pom.xml?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/impl/pom.xml (original)
+++ myfaces/core/branches/1.2.x/impl/pom.xml Wed Mar 17 18:28:20 2010
@@ -242,6 +242,8 @@
                   org.xml.sax,
                   org.xml.sax.helpers,
                   org.apache.jasper.compiler;resolution:=optional,
+                  org.apache.jasper.el;resolution:=optional,
+                  org.apache.el;resolution:=optional,
                   javax.faces.*;version="${project.version}",
                   *
                 </Import-Package>

Modified: myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Wed Mar 17 18:28:20 2010
@@ -260,7 +260,14 @@ public class ApplicationImpl extends App
         }
         catch (MissingResourceException e)
         {
-            throw new FacesException("Could not load resource bundle for name '" + name + "': " + e.getMessage(), e);
+            try
+            {
+                return getResourceBundle(bundleName, locale, this.getClass().getClassLoader());
+            }
+            catch (MissingResourceException e1)
+            {            
+                throw new FacesException("Could not load resource bundle for name '" + name + "': " + e.getMessage(), e1);
+            }
         }
     }
 

Modified: myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java (original)
+++ myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java Wed Mar 17 18:28:20 2010
@@ -119,6 +119,7 @@ public class DefaultLifecycleProviderFac
         ClassLoader classLoader = ClassUtils.getContextClassLoader();
         ClassLoaders loaders = new ClassLoaders();
         loaders.put(classLoader);
+        loaders.put(this.getClass().getClassLoader());
         DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
         ResourceNameIterator iter = dsn.findResourceNames(LIFECYCLE_PROVIDER);
         while (iter.hasNext()) {

Modified: myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java (original)
+++ myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java Wed Mar 17 18:28:20 2010
@@ -128,7 +128,7 @@ public class LoadBundleTag
             throw new NullPointerException("LoadBundle: 'basename' must not be null");
         }
 
-        final ResourceBundle bundle;
+        ResourceBundle bundle;
         try
         {
             bundle = ResourceBundle.getBundle(basename,
@@ -137,7 +137,16 @@ public class LoadBundleTag
         }
         catch (MissingResourceException e)
         {
-            throw new JspException("Resource bundle '" + basename + "' could not be found.", e);
+            try
+            {
+                bundle = ResourceBundle.getBundle(basename,
+                        locale,
+                        this.getClass().getClassLoader());
+            }
+            catch (MissingResourceException e1)
+            {
+                throw new JspException("Resource bundle '" + basename + "' could not be found.", e1);
+            }
         }
 
         facesContext.getExternalContext().getRequestMap().put(_var,

Modified: myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java?rev=924403&r1=924402&r2=924403&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java (original)
+++ myfaces/core/branches/1.2.x/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java Wed Mar 17 18:28:20 2010
@@ -93,6 +93,10 @@ public class StartupServletContextListen
                 //so that we do not have to enforce that the initializer
                 //must be serializable
                 Class pluginClass = ClassUtils.getContextClassLoader().loadClass(plugin);
+                if (pluginClass == null)
+                {
+                    pluginClass = this.getClass().getClassLoader().loadClass(plugin);
+                }
                 StartupListener initializer = (StartupListener) pluginClass.newInstance();
                 
                 switch(operation) {