geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1173727 - in /geronimo/bundles/trunk/myfaces-bundle: ./ LICENSE MYFACES-3309.patch NOTICE pom.xml src/ src/main/ src/main/java/ src/main/java/javax/ src/main/java/javax/faces/ src/main/java/javax/faces/FactoryFinder.java
Date Wed, 21 Sep 2011 15:42:54 GMT
Author: xuhaihong
Date: Wed Sep 21 15:42:53 2011
New Revision: 1173727

URL: http://svn.apache.org/viewvc?rev=1173727&view=rev
Log:
Add MyFaces 2.0.9_1 bundle

Added:
    geronimo/bundles/trunk/myfaces-bundle/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/LICENSE
    geronimo/bundles/trunk/myfaces-bundle/MYFACES-3309.patch
    geronimo/bundles/trunk/myfaces-bundle/NOTICE
    geronimo/bundles/trunk/myfaces-bundle/pom.xml   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/main/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/main/java/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/   (with props)
    geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java   (with props)

Propchange: geronimo/bundles/trunk/myfaces-bundle/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: geronimo/bundles/trunk/myfaces-bundle/LICENSE
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle/LICENSE?rev=1173727&view=auto
==============================================================================
--- geronimo/bundles/trunk/myfaces-bundle/LICENSE (added)
+++ geronimo/bundles/trunk/myfaces-bundle/LICENSE Wed Sep 21 15:42:53 2011
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: geronimo/bundles/trunk/myfaces-bundle/MYFACES-3309.patch
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle/MYFACES-3309.patch?rev=1173727&view=auto
==============================================================================
--- geronimo/bundles/trunk/myfaces-bundle/MYFACES-3309.patch (added)
+++ geronimo/bundles/trunk/myfaces-bundle/MYFACES-3309.patch Wed Sep 21 15:42:53 2011
@@ -0,0 +1,74 @@
+Index: api/src/main/java/javax/faces/FactoryFinder.java
+===================================================================
+--- api/src/main/java/javax/faces/FactoryFinder.java	(revision 1172636)
++++ api/src/main/java/javax/faces/FactoryFinder.java	(working copy)
+@@ -200,9 +200,22 @@
+                 
+                 //Call getFactory method and pass the params
+                 return _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_GET_FACTORY_METHOD.invoke(ffp, factoryName);
+-            }
+-            catch (Exception e)
+-            {
++            } catch (InvocationTargetException e) {
++                Throwable targetException = e.getCause();
++                if (targetException instanceof NullPointerException) {
++                    throw (NullPointerException) targetException;
++                } else if (targetException instanceof FacesException) {
++                    throw (FacesException) targetException;
++                } else if (targetException instanceof IllegalArgumentException) {
++                    throw (IllegalArgumentException) targetException;
++                } else if (targetException instanceof IllegalStateException) {
++                    throw (IllegalStateException) targetException;
++                } else if (targetException == null) {
++                    throw new FacesException(e);
++                } else {
++                    throw new FacesException(targetException);
++                }
++            } catch (Exception e) {
+                 //No Op
+                 throw new FacesException(e);
+             }
+@@ -380,9 +393,20 @@
+                 
+                 //Call getFactory method and pass the params
+                 _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_SET_FACTORY_METHOD.invoke(ffp, factoryName, implName);
+-            }
+-            catch (Exception e)
+-            {
++            } catch (InvocationTargetException e) {
++                Throwable targetException = e.getCause();
++                if (targetException instanceof NullPointerException) {
++                    throw (NullPointerException) targetException;
++                } else if (targetException instanceof FacesException) {
++                    throw (FacesException) targetException;
++                } else if (targetException instanceof IllegalArgumentException) {
++                    throw (IllegalArgumentException) targetException;
++                } else if (targetException == null) {
++                    throw new FacesException(e);
++                } else {
++                    throw new FacesException(targetException);
++                }
++            } catch (Exception e) {
+                 //No Op
+                 throw new FacesException(e);
+             }
+@@ -449,9 +473,16 @@
+                 
+                 //Call getFactory method and pass the params
+                 _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_RELEASE_FACTORIES_METHOD.invoke(ffp, null);
+-            }
+-            catch (Exception e)
+-            {
++            } catch (InvocationTargetException e) {
++                Throwable targetException = e.getCause();
++                if (targetException instanceof FacesException) {
++                    throw (FacesException) targetException;
++                } else if (targetException == null) {
++                    throw new FacesException(e);
++                } else {
++                    throw new FacesException(targetException);
++                }
++            } catch (Exception e) {
+                 //No Op
+                 throw new FacesException(e);
+             }

Added: geronimo/bundles/trunk/myfaces-bundle/NOTICE
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle/NOTICE?rev=1173727&view=auto
==============================================================================
--- geronimo/bundles/trunk/myfaces-bundle/NOTICE (added)
+++ geronimo/bundles/trunk/myfaces-bundle/NOTICE Wed Sep 21 15:42:53 2011
@@ -0,0 +1,6 @@
+Apache Geronimo 
+Copyright 2003-2011 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: geronimo/bundles/trunk/myfaces-bundle/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle/pom.xml?rev=1173727&view=auto
==============================================================================
--- geronimo/bundles/trunk/myfaces-bundle/pom.xml (added)
+++ geronimo/bundles/trunk/myfaces-bundle/pom.xml Wed Sep 21 15:42:53 2011
@@ -0,0 +1,124 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>bundles-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+
+    <groupId>org.apache.geronimo.bundles</groupId>
+    <artifactId>${pkgArtifactId}</artifactId>
+    <version>2.0.9_1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Apache Geronimo Bundles: ${pkgArtifactId}-${pkgVersion}</name>
+    <description>
+        This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/bundles/trunk/myfaces-bundle</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/geronimo/bundles/trunk/myfaces-bundle</developerConnection>
+        <url>http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle</url>
+    </scm>
+
+    <properties>
+        <pkgGroupId>org.apache.myfaces.core</pkgGroupId>
+        <pkgArtifactId>myfaces-bundle</pkgArtifactId>
+        <pkgVersion>2.0.9</pkgVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>${pkgGroupId}</groupId>
+            <artifactId>${pkgArtifactId}</artifactId>
+            <version>${pkgVersion}</version>
+            <scope>provided</scope>            
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            javax.faces.*;version="${project.version}",
+                            org.apache.myfaces.config.annotation;version="${project.version}",
+                            org.apache.myfaces.shared_impl.webapp.webxml;version="${project.version}",
+                            org.apache.myfaces.shared.taglib;version="${project.version}",
+                            org.apache.myfaces.shared.taglib.core;version="${project.version}",
+                            org.apache.myfaces.spi;version="${project.version}",
+                            org.apache.myfaces.webapp;version="${project.version}",
+                            org.apache.myfaces.taglib.*;version="${project.version}",
+                            org.apache.myfaces.ee6;version="${project.version}",
+                            org.apache.myfaces.config.element;version="${project.version}",
+                            org.apache.myfaces.config.impl.digester.elements;version="${project.version}"
+                        </Export-Package>
+                        <Import-Package>
+                            !org.apache.myfaces.*,
+                            com.google.inject;version="[1.0.0, 2.0.0)";resolution:=optional,
+                            javax.annotation,
+                            javax.crypto,
+                            javax.crypto.spec,
+                            javax.ejb;resolution:=optional,
+                            javax.el;version="[1.0.0, 3.0.0)",
+                            javax.naming,
+                            javax.persistence;version="[1.0.0, 2.1)";resolution:=optional,
+                            javax.portlet;version="[1.0.0, 2.1)";resolution:=optional,
+                            javax.servlet;version="[2.5.0, 3.1)",
+                            javax.servlet.http;version="[2.5.0, 3.1)",
+                            javax.servlet.jsp;version="[2.1.0, 3.1)",
+                            javax.servlet.jsp.jstl.core;version="[1.1.2, 2.0.0)",
+                            javax.servlet.jsp.tagext;version="[2.1.0, 3.1)",
+                            javax.servlet.annotation;resolution:=optional,
+                            javax.xml.parsers,
+                            org.apache;resolution:=optional,
+                            org.apache.commons.beanutils;version="[1.8.3, 2.0.0)",
+                            org.apache.commons.codec.binary;version="[1.3.0, 2.0.0)",
+                            org.apache.commons.collections.map;version="[3.2.0, 4.0.0)",
+                            org.apache.commons.digester;version="[1.8.0, 2.0.0)",
+                            org.apache.commons.logging;version="[1.1.1, 2.0.0)",
+                            org.w3c.dom,
+                            org.xml.sax,
+                            org.xml.sax.helpers,
+                            org.apache.jasper.compiler;resolution:=optional,
+                            org.apache.jasper.el;resolution:=optional,
+                            org.apache.el;resolution:=optional,
+                            org.apache.tomcat;resolution:=optional,
+                            *
+                        </Import-Package>
+                        <Embed-Dependency>*;type=!pom;inline=true</Embed-Dependency>
+                        <Include-Resource>
+                           {maven-resources},
+                           javax/faces/FactoryFinder.class=target/classes/javax/faces/FactoryFinder.class,
+                           javax/faces/FactoryFinder$1.class=target/classes/javax/faces/FactoryFinder$1.class,
+                           javax/faces/FactoryFinder$2.class=target/classes/javax/faces/FactoryFinder$2.class
+                        </Include-Resource>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: geronimo/bundles/trunk/myfaces-bundle/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/bundles/trunk/myfaces-bundle/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/bundles/trunk/myfaces-bundle/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java?rev=1173727&view=auto
==============================================================================
--- geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java (added)
+++ geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java Wed Sep 21 15:42:53 2011
@@ -0,0 +1,549 @@
+/*
+ * 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 javax.faces;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.visit.VisitContextFactory;
+import javax.faces.context.ExceptionHandlerFactory;
+import javax.faces.context.ExternalContextFactory;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.context.PartialViewContextFactory;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.view.ViewDeclarationLanguageFactory;
+import javax.faces.view.facelets.TagHandlerDelegateFactory;
+
+/**
+ * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ * 
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision$ $Date$
+ */
+public final class FactoryFinder
+{
+    public static final String APPLICATION_FACTORY = "javax.faces.application.ApplicationFactory";
+    public static final String EXCEPTION_HANDLER_FACTORY = "javax.faces.context.ExceptionHandlerFactory";
+    public static final String EXTERNAL_CONTEXT_FACTORY = "javax.faces.context.ExternalContextFactory";
+    public static final String FACES_CONTEXT_FACTORY = "javax.faces.context.FacesContextFactory";
+    public static final String LIFECYCLE_FACTORY = "javax.faces.lifecycle.LifecycleFactory";
+    public static final String PARTIAL_VIEW_CONTEXT_FACTORY = "javax.faces.context.PartialViewContextFactory";
+    public static final String RENDER_KIT_FACTORY = "javax.faces.render.RenderKitFactory";
+    public static final String TAG_HANDLER_DELEGATE_FACTORY = "javax.faces.view.facelets.TagHandlerDelegateFactory";
+    public static final String VIEW_DECLARATION_LANGUAGE_FACTORY = "javax.faces.view.ViewDeclarationLanguageFactory";
+    public static final String VISIT_CONTEXT_FACTORY = "javax.faces.component.visit.VisitContextFactory";
+
+    /**
+     * used as a monitor for itself and _factories. Maps in this map are used as monitors for themselves and the
+     * corresponding maps in _factories.
+     */
+    private static Map<ClassLoader, Map<String, List<String>>> _registeredFactoryNames = new HashMap<ClassLoader, Map<String, List<String>>>();
+
+    /**
+     * Maps from classLoader to another map, the container (i.e. Tomcat) will create a class loader for each web app
+     * that it controls (typically anyway) and that class loader is used as the key.
+     * 
+     * The secondary map maps the factory name (i.e. FactoryFinder.APPLICATION_FACTORY) to actual instances that are
+     * created via getFactory. The instances will be of the class specified in the setFactory method for the factory
+     * name, i.e. FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MyFactory.class).
+     */
+    private static Map<ClassLoader, Map<String, Object>> _factories = new HashMap<ClassLoader, Map<String, Object>>();
+
+    private static final Set<String> VALID_FACTORY_NAMES = new HashSet<String>();
+    private static final Map<String, Class<?>> ABSTRACT_FACTORY_CLASSES = new HashMap<String, Class<?>>();
+    private static final ClassLoader myFacesClassLoader;
+
+    static
+    {
+        VALID_FACTORY_NAMES.add(APPLICATION_FACTORY);
+        VALID_FACTORY_NAMES.add(EXCEPTION_HANDLER_FACTORY);
+        VALID_FACTORY_NAMES.add(EXTERNAL_CONTEXT_FACTORY);
+        VALID_FACTORY_NAMES.add(FACES_CONTEXT_FACTORY);
+        VALID_FACTORY_NAMES.add(LIFECYCLE_FACTORY);
+        VALID_FACTORY_NAMES.add(PARTIAL_VIEW_CONTEXT_FACTORY);
+        VALID_FACTORY_NAMES.add(RENDER_KIT_FACTORY);
+        VALID_FACTORY_NAMES.add(TAG_HANDLER_DELEGATE_FACTORY);
+        VALID_FACTORY_NAMES.add(VIEW_DECLARATION_LANGUAGE_FACTORY);
+        VALID_FACTORY_NAMES.add(VISIT_CONTEXT_FACTORY);
+        
+        ABSTRACT_FACTORY_CLASSES.put(APPLICATION_FACTORY, ApplicationFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(EXCEPTION_HANDLER_FACTORY, ExceptionHandlerFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(EXTERNAL_CONTEXT_FACTORY, ExternalContextFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(FACES_CONTEXT_FACTORY, FacesContextFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(LIFECYCLE_FACTORY, LifecycleFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(PARTIAL_VIEW_CONTEXT_FACTORY, PartialViewContextFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(RENDER_KIT_FACTORY, RenderKitFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(TAG_HANDLER_DELEGATE_FACTORY, TagHandlerDelegateFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(VIEW_DECLARATION_LANGUAGE_FACTORY, ViewDeclarationLanguageFactory.class);
+        ABSTRACT_FACTORY_CLASSES.put(VISIT_CONTEXT_FACTORY, VisitContextFactory.class);
+        try
+        {
+            ClassLoader classLoader;
+            if (System.getSecurityManager() != null) {
+                classLoader = (ClassLoader) AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
+                    public Object run() {
+                        return FactoryFinder.class.getClassLoader();
+                    }
+                });
+            }
+            else {
+                classLoader = FactoryFinder.class.getClassLoader();
+            }
+
+            if (classLoader == null)
+            {
+                throw new FacesException("jsf api class loader cannot be identified", null);
+            }
+            myFacesClassLoader = classLoader;
+        }
+        catch (Exception e)
+        {
+            throw new FacesException("jsf api class loader cannot be identified", e);
+        }
+    }
+
+    // ~ Start FactoryFinderProvider Support ------------------------------------------------------------------------------------
+    
+    private static Object _factoryFinderProviderFactoryInstance;
+    
+    private static volatile boolean _initialized = false;
+    
+    private static void initializeFactoryFinderProviderFactory()
+    {
+        if (!_initialized)
+        {
+            _factoryFinderProviderFactoryInstance = _FactoryFinderProviderFactory.getInstance();
+            _initialized = true;
+        }
+    }
+
+    // ~ End FactoryFinderProvider Support ------------------------------------------------------------------------------------
+
+    // avoid instantiation
+    FactoryFinder()
+    {
+    }
+
+    /**
+     * <p>
+     * Create (if necessary) and return a per-web-application instance of the appropriate implementation class for the
+     * specified JavaServer Faces factory class, based on the discovery algorithm described in the class description.
+     * </p>
+     * 
+     * <p>
+     * The standard factories and wrappers in JSF all implement the interface {@link FacesWrapper}. If the returned
+     * <code>Object</code> is an implementation of one of the standard factories, it must be legal to cast it to an
+     * instance of <code>FacesWrapper</code> and call {@link FacesWrapper#getWrapped()} on the instance.
+     * </p>
+     * 
+     * @param factoryName
+     *            Fully qualified name of the JavaServer Faces factory for which an implementation instance is requested
+     * 
+     * @return A per-web-application instance of the appropriate implementation class for the specified JavaServer Faces
+     *         factory class
+     * 
+     * @throws FacesException
+     *             if the web application class loader cannot be identified
+     * @throws FacesException
+     *             if an instance of the configured factory implementation class cannot be loaded
+     * @throws FacesException
+     *             if an instance of the configured factory implementation class cannot be instantiated
+     * @throws IllegalArgumentException
+     *             if <code>factoryname</code> does not identify a standard JavaServer Faces factory name
+     * @throws IllegalStateException
+     *             if there is no configured factory implementation class for the specified factory name
+     * @throws NullPointerException
+     *             if <code>factoryname</code> is null
+     */
+    public static Object getFactory(String factoryName) throws FacesException
+    {
+        initializeFactoryFinderProviderFactory();
+        
+        if (_factoryFinderProviderFactoryInstance == null)
+        {
+            // Do the typical stuff
+            return _getFactory(factoryName);
+        }
+        else
+        {
+            try
+            {
+                //Obtain the FactoryFinderProvider instance for this context.
+                Object ffp = _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_FACTORY_GET_FACTORY_FINDER_METHOD.invoke(
+                            _factoryFinderProviderFactoryInstance, null);
+                
+                //Call getFactory method and pass the params
+                return _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_GET_FACTORY_METHOD.invoke(ffp, factoryName);
+            } catch (InvocationTargetException e) {
+                Throwable targetException = e.getCause();
+                if (targetException instanceof NullPointerException) {
+                    throw (NullPointerException) targetException;
+                } else if (targetException instanceof FacesException) {
+                    throw (FacesException) targetException;
+                } else if (targetException instanceof IllegalArgumentException) {
+                    throw (IllegalArgumentException) targetException;
+                } else if (targetException instanceof IllegalStateException) {
+                    throw (IllegalStateException) targetException;
+                } else if (targetException == null) {
+                    throw new FacesException(e);
+                } else {
+                    throw new FacesException(targetException);
+                }
+            } catch (Exception e) {
+                //No Op
+                throw new FacesException(e);
+            }
+        }
+    }
+
+    private static Object _getFactory(String factoryName) throws FacesException
+    {
+        if (factoryName == null)
+        {
+            throw new NullPointerException("factoryName may not be null");
+        }
+
+        ClassLoader classLoader = getClassLoader();
+
+        // This code must be synchronized because this could cause a problem when
+        // using update feature each time of myfaces (org.apache.myfaces.CONFIG_REFRESH_PERIOD)
+        // In this moment, a concurrency problem could happen
+        Map<String, List<String>> factoryClassNames = null;
+        Map<String, Object> factoryMap = null;
+
+        synchronized (_registeredFactoryNames)
+        {
+            factoryClassNames = _registeredFactoryNames.get(classLoader);
+
+            if (factoryClassNames == null)
+            {
+                String message = "No Factories configured for this Application. This happens if the faces-initialization "
+                        + "does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application "
+                        + "and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!"
+                        + "\nIf you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which "
+                        + "do not support registering context-listeners via TLD files and "
+                        + "a context listener is not setup in your web.xml.\n"
+                        + "A typical config looks like this;\n<listener>\n"
+                        + "  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>\n"
+                        + "</listener>\n";
+                throw new IllegalStateException(message);
+            }
+
+            if (!factoryClassNames.containsKey(factoryName))
+            {
+                throw new IllegalArgumentException("no factory " + factoryName + " configured for this application.");
+            }
+
+            factoryMap = _factories.get(classLoader);
+
+            if (factoryMap == null)
+            {
+                factoryMap = new HashMap<String, Object>();
+                _factories.put(classLoader, factoryMap);
+            }
+        }
+
+        List<String> classNames;
+        Object factory;
+        synchronized (factoryClassNames)
+        {
+            factory = factoryMap.get(factoryName);
+            if (factory != null)
+            {
+                return factory;
+            }
+
+            classNames = factoryClassNames.get(factoryName);
+        }
+
+        // release lock while calling out
+        factory = newFactoryInstance(ABSTRACT_FACTORY_CLASSES.get(factoryName), classNames.iterator(), classLoader);
+
+        synchronized (factoryClassNames)
+        {
+            // check if someone else already installed the factory
+            if (factoryMap.get(factoryName) == null)
+            {
+                factoryMap.put(factoryName, factory);
+            }
+        }
+
+        return factory;
+    }
+
+    private static Object newFactoryInstance(Class<?> interfaceClass, Iterator<String> classNamesIterator,
+                                             ClassLoader classLoader)
+    {
+        try
+        {
+            Object current = null;
+
+            while (classNamesIterator.hasNext())
+            {
+                String implClassName = classNamesIterator.next();
+                Class<?> implClass = null;
+                try {
+                    implClass = classLoader.loadClass(implClassName);
+                } catch (ClassNotFoundException e) {
+                    implClass = myFacesClassLoader.loadClass(implClassName);
+                }
+
+                // check, if class is of expected interface type
+                if (!interfaceClass.isAssignableFrom(implClass))
+                {
+                    throw new IllegalArgumentException("Class " + implClassName + " is no " + interfaceClass.getName());
+                }
+
+                if (current == null)
+                {
+                    // nothing to decorate
+                    current = implClass.newInstance();
+                }
+                else
+                {
+                    // let's check if class supports the decorator pattern
+                    try
+                    {
+                        Constructor<?> delegationConstructor = implClass.getConstructor(new Class[] { interfaceClass });
+                        // impl class supports decorator pattern,
+                        try
+                        {
+                            // create new decorator wrapping current
+                            current = delegationConstructor.newInstance(new Object[] { current });
+                        }
+                        catch (InstantiationException e)
+                        {
+                            throw new FacesException(e);
+                        }
+                        catch (IllegalAccessException e)
+                        {
+                            throw new FacesException(e);
+                        }
+                        catch (InvocationTargetException e)
+                        {
+                            throw new FacesException(e);
+                        }
+                    }
+                    catch (NoSuchMethodException e)
+                    {
+                        // no decorator pattern support
+                        current = implClass.newInstance();
+                    }
+                }
+            }
+
+            return current;
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new FacesException(e);
+        }
+        catch (InstantiationException e)
+        {
+            throw new FacesException(e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new FacesException(e);
+        }
+    }
+
+    public static void setFactory(String factoryName, String implName)
+    {
+        initializeFactoryFinderProviderFactory();
+        
+        if (_factoryFinderProviderFactoryInstance == null)
+        {
+            // Do the typical stuff
+            _setFactory(factoryName, implName);
+        }
+        else
+        {
+            try
+            {
+                //Obtain the FactoryFinderProvider instance for this context.
+                Object ffp = _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_FACTORY_GET_FACTORY_FINDER_METHOD.invoke(
+                        _factoryFinderProviderFactoryInstance,null);
+                
+                //Call getFactory method and pass the params
+                _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_SET_FACTORY_METHOD.invoke(ffp, factoryName, implName);
+            } catch (InvocationTargetException e) {
+                Throwable targetException = e.getCause();
+                if (targetException instanceof NullPointerException) {
+                    throw (NullPointerException) targetException;
+                } else if (targetException instanceof FacesException) {
+                    throw (FacesException) targetException;
+                } else if (targetException instanceof IllegalArgumentException) {
+                    throw (IllegalArgumentException) targetException;
+                } else if (targetException == null) {
+                    throw new FacesException(e);
+                } else {
+                    throw new FacesException(targetException);
+                }
+            } catch (Exception e) {
+                //No Op
+                throw new FacesException(e);
+            }
+            
+        }
+    }
+
+    private static void _setFactory(String factoryName, String implName)
+    {
+        checkFactoryName(factoryName);
+
+        ClassLoader classLoader = getClassLoader();
+        Map<String, List<String>> factoryClassNames = null;
+        synchronized (_registeredFactoryNames)
+        {
+            Map<String, Object> factories = _factories.get(classLoader);
+
+            if (factories != null && factories.containsKey(factoryName))
+            {
+                // Javadoc says ... This method has no effect if getFactory() has already been
+                // called looking for a factory for this factoryName.
+                return;
+            }
+
+            factoryClassNames = _registeredFactoryNames.get(classLoader);
+
+            if (factoryClassNames == null)
+            {
+                factoryClassNames = new HashMap<String, List<String>>();
+                _registeredFactoryNames.put(classLoader, factoryClassNames);
+            }
+        }
+
+        synchronized (factoryClassNames)
+        {
+            List<String> classNameList = factoryClassNames.get(factoryName);
+
+            if (classNameList == null)
+            {
+                classNameList = new ArrayList<String>();
+                factoryClassNames.put(factoryName, classNameList);
+            }
+
+            classNameList.add(implName);
+        }
+    }
+
+    public static void releaseFactories() throws FacesException
+    {
+        initializeFactoryFinderProviderFactory();
+        
+        if (_factoryFinderProviderFactoryInstance == null)
+        {
+            // Do the typical stuff
+            _releaseFactories();
+        }
+        else
+        {
+            try
+            {
+                //Obtain the FactoryFinderProvider instance for this context.
+                Object ffp = _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_FACTORY_GET_FACTORY_FINDER_METHOD.invoke(
+                        _factoryFinderProviderFactoryInstance, null);
+                
+                //Call getFactory method and pass the params
+                _FactoryFinderProviderFactory.FACTORY_FINDER_PROVIDER_RELEASE_FACTORIES_METHOD.invoke(ffp, null);
+            } catch (InvocationTargetException e) {
+                Throwable targetException = e.getCause();
+                if (targetException instanceof FacesException) {
+                    throw (FacesException) targetException;
+                } else if (targetException == null) {
+                    throw new FacesException(e);
+                } else {
+                    throw new FacesException(targetException);
+                }
+            } catch (Exception e) {
+                //No Op
+                throw new FacesException(e);
+            }
+            
+        }
+    }
+
+    private static void _releaseFactories() throws FacesException
+    {
+        ClassLoader classLoader = getClassLoader();
+
+        // This code must be synchronized
+        synchronized (_registeredFactoryNames)
+        {
+            _factories.remove(classLoader);
+
+            // _registeredFactoryNames has as value type Map<String,List> and this must
+            // be cleaned before release (for gc).
+            Map<String, List<String>> factoryClassNames = _registeredFactoryNames.get(classLoader);
+            if (factoryClassNames != null)
+            {
+                factoryClassNames.clear();
+            }
+
+            _registeredFactoryNames.remove(classLoader);
+        }
+    }
+
+    private static void checkFactoryName(String factoryName)
+    {
+        if (!VALID_FACTORY_NAMES.contains(factoryName))
+        {
+            throw new IllegalArgumentException("factoryName '" + factoryName + "'");
+        }
+    }
+
+    private static ClassLoader getClassLoader()
+    {
+        try
+        {
+            ClassLoader classLoader = null;
+            if (System.getSecurityManager() != null) {                
+                classLoader = (ClassLoader) AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
+                    public Object run() {
+                        return Thread.currentThread().getContextClassLoader();
+                    }
+                });
+            }
+            else {
+                classLoader = Thread.currentThread().getContextClassLoader();
+            }
+            
+            if (classLoader == null)
+            {
+                throw new FacesException("web application class loader cannot be identified", null);
+            }
+            return classLoader;
+        }
+        catch (Exception e)
+        {
+            throw new FacesException("web application class loader cannot be identified", e);
+        }
+    }
+}

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/bundles/trunk/myfaces-bundle/src/main/java/javax/faces/FactoryFinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message