myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Mon, 12 Aug 2019 13:46:33 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 88e4208  refactored
88e4208 is described below

commit 88e42086846b60cbeecf9c39c464d9f7acfe41be
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Mon Aug 12 15:46:23 2019 +0200

    refactored
---
 .../javax/faces/component/UIComponentBase.java     |  4 +-
 .../main/java/javax/faces/component/UIForm.java    | 70 ++++++++++------------
 .../main/java/javax/faces/component/UIInput.java   | 42 ++++++-------
 .../javax/faces/component/UINamingContainer.java   |  8 ++-
 .../main/java/javax/faces/component/UIOutput.java  |  8 +--
 .../javax/faces/component/UISelectBoolean.java     |  2 +
 .../java/javax/faces/component/UISelectMany.java   | 10 ++--
 .../java/javax/faces/component/UISelectOne.java    |  3 +-
 .../java/javax/faces/component/UIViewAction.java   |  7 ++-
 .../javax/faces/component/UIViewParameter.java     |  7 +--
 .../java/javax/faces/component/UIViewRoot.java     | 29 ++++-----
 .../java/javax/faces/component/_ClassUtils.java    | 10 ++--
 .../javax/faces/component/_ComponentUtils.java     | 50 ++++------------
 .../faces/component/behavior/BehaviorBase.java     |  6 +-
 .../myfaces/util/lang/ClassLoaderExtension.java    | 36 -----------
 .../org/apache/myfaces/util/lang/ClassUtils.java   | 48 +--------------
 16 files changed, 111 insertions(+), 229 deletions(-)

diff --git a/api/src/main/java/javax/faces/component/UIComponentBase.java b/api/src/main/java/javax/faces/component/UIComponentBase.java
index 2545aae..ee4a84f 100755
--- a/api/src/main/java/javax/faces/component/UIComponentBase.java
+++ b/api/src/main/java/javax/faces/component/UIComponentBase.java
@@ -79,8 +79,6 @@ public abstract class UIComponentBase extends UIComponent
 {
     private static Logger log = Logger.getLogger(UIComponentBase.class.getName());
 
-    private static final Iterator<UIComponent> _EMPTY_UICOMPONENT_ITERATOR = Collections.<UIComponent>emptyIterator();
-
     private static final String _STRING_BUILDER_KEY
             = "javax.faces.component.UIComponentBase.SHARED_STRING_BUILDER";
 
@@ -1032,7 +1030,7 @@ public abstract class UIComponentBase extends UIComponent
         {
             if (getChildCount() == 0)
             {
-                return _EMPTY_UICOMPONENT_ITERATOR;
+                return Collections.<UIComponent>emptyIterator();
             }
 
             return getChildren().iterator();
diff --git a/api/src/main/java/javax/faces/component/UIForm.java b/api/src/main/java/javax/faces/component/UIForm.java
index ce1f1d4..09ed456 100755
--- a/api/src/main/java/javax/faces/component/UIForm.java
+++ b/api/src/main/java/javax/faces/component/UIForm.java
@@ -54,7 +54,7 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
         // prefix to ensure the generated ids are unique, but that's only necessary
         // when no seed is provided. If a seed is provided, that one is already unique
         // for all the view, so the following logic is not necessary.
-        if (!isPrependId() && seed==null )
+        if (!isPrependId() && seed == null)
         {
             bld = new StringBuilder();
             UniqueIdVendor parentUniqueIdVendor = _ComponentUtils.closest(UniqueIdVendor.class,
this);
@@ -89,7 +89,7 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
 
         // Generate an identifier for a component. The identifier will be prefixed with
         // UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot.
-        if(seed==null)
+        if(seed == null)
         {
             Integer uniqueIdCounter = (Integer) getStateHelper().get(PropertyKeys.uniqueIdCounter);
             uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
@@ -106,14 +106,12 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
     
     public boolean isSubmitted()
     {
-        //return _submitted;
         return (Boolean) getTransientStateHelper().getTransient(PropertyKeys.submitted, false);
     }
 
     public void setSubmitted(boolean submitted)
     {
         getTransientStateHelper().putTransient(PropertyKeys.submitted, submitted);
-        //_submitted = submitted;
     }
 
     @Override
@@ -137,8 +135,7 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
                     return;
                 }
 
-                int facetCount = getFacetCount();
-                if (facetCount > 0)
+                if (getFacetCount() > 0)
                 {
                     for (UIComponent facet : getFacets().values())
                     {
@@ -151,7 +148,6 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
                     UIComponent child = getChildren().get(i);
                     child.processDecodes(context);
                 }
-                
             }
             finally
             {
@@ -192,9 +188,8 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
 
                 //Pre validation event dispatch for component
                 context.getApplication().publishEvent(context, PreValidateEvent.class, getClass(),
this);
-                
-                int facetCount = getFacetCount();
-                if (facetCount > 0)
+
+                if (getFacetCount() > 0)
                 {
                     for (UIComponent facet : getFacets().values())
                     {
@@ -246,9 +241,8 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
                 {
                     return;
                 }
-                
-                int facetCount = getFacetCount();
-                if (facetCount > 0)
+
+                if (getFacetCount() > 0)
                 {
                     for (UIComponent facet : getFacets().values())
                     {
@@ -324,41 +318,41 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
                 VisitResult res = context.invokeVisitCallback(this, callback);
                 switch (res)
                 {
-                //we are done nothing has to be processed anymore
-                case COMPLETE:
-                    return true;
+                    //we are done nothing has to be processed anymore
+                    case COMPLETE:
+                        return true;
 
-                case REJECT:
-                    return false;
+                    case REJECT:
+                        return false;
 
-                //accept
-                default:
-                    // Take advantage of the fact this is a NamingContainer
-                    // and we can know if there are ids to visit inside it
-                    Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
+                    //accept
+                    default:
+                        // Take advantage of the fact this is a NamingContainer
+                        // and we can know if there are ids to visit inside it
+                        Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
 
-                    if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
-                    {
-                        if (getFacetCount() > 0)
+                        if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
                         {
-                            for (UIComponent facet : getFacets().values())
+                            if (getFacetCount() > 0)
                             {
-                                if (facet.visitTree(context, callback))
+                                for (UIComponent facet : getFacets().values())
                                 {
-                                    return true;
+                                    if (facet.visitTree(context, callback))
+                                    {
+                                        return true;
+                                    }
                                 }
                             }
-                        }
-                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
-                        {
-                            UIComponent child = getChildren().get(i);
-                            if (child.visitTree(context, callback))
+                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
                             {
-                                return true;
+                                UIComponent child = getChildren().get(i);
+                                if (child.visitTree(context, callback))
+                                {
+                                    return true;
+                                }
                             }
                         }
-                    }
-                    return false;
+                        return false;
                 }
             }
             finally
@@ -409,11 +403,13 @@ public class UIForm extends UIComponentBase implements NamingContainer,
UniqueId
         {
             return super.getContainerClientId(ctx);
         }
+
         UIComponent parentNamingContainer = _ComponentUtils.findParentNamingContainer(this,
false);
         if (parentNamingContainer != null)
         {
             return parentNamingContainer.getContainerClientId(ctx);
         }
+
         return null;
     }
 
diff --git a/api/src/main/java/javax/faces/component/UIInput.java b/api/src/main/java/javax/faces/component/UIInput.java
index 538acf8..2e9768d 100644
--- a/api/src/main/java/javax/faces/component/UIInput.java
+++ b/api/src/main/java/javax/faces/component/UIInput.java
@@ -192,6 +192,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
         {
             throw new NullPointerException("context");
         }
+
         try
         {
             setCachedFacesContext(context);
@@ -206,7 +207,9 @@ public class UIInput extends UIOutput implements EditableValueHolder
             setCachedFacesContext(null);
             popComponentFromEL(context);
         }
+
         super.processDecodes(context);
+
         try
         {
             setCachedFacesContext(context);
@@ -228,6 +231,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
                 {
                     context.getApplication().publishEvent(context,  PostValidateEvent.class,
getClass(), this);
                 }
+
                 if (!isValid())
                 {
                     context.renderResponse();
@@ -248,6 +252,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
         {
             throw new NullPointerException("context");
         }
+        
         try
         {
             setCachedFacesContext(context);
@@ -262,13 +267,10 @@ public class UIInput extends UIOutput implements EditableValueHolder
             setCachedFacesContext(null);
             popComponentFromEL(context);
         }
-
-        //super.processValidators(context);
         
         // Call the processValidators() method of all facets and children of this UIComponent,
in the order
         // determined by a call to getFacetsAndChildren().
-        int facetCount = getFacetCount();
-        if (facetCount > 0)
+        if (getFacetCount() > 0)
         {
             for (UIComponent facet : getFacets().values())
             {
@@ -303,6 +305,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
                 {
                     context.getApplication().publishEvent(context,  PostValidateEvent.class,
getClass(), this);
                 }
+
                 if (!isValid())
                 {
                     context.validationFailed();
@@ -338,6 +341,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
             setCachedFacesContext(null);
             popComponentFromEL(context);
         }
+
         super.processUpdates(context);
 
         try
@@ -353,6 +357,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
                 context.renderResponse();
                 throw e;
             }
+
             if (!isValid())
             {
                 context.renderResponse();
@@ -386,14 +391,11 @@ public class UIInput extends UIOutput implements EditableValueHolder
         {
             throw new NullPointerException();
         }
-        if (!isValid())
-        {
-            return;
-        }
-        if (!isLocalValueSet())
+        if (!isValid() || !isLocalValueSet())
         {
             return;
         }
+
         ValueExpression expression = getValueExpression("value");
         if (expression == null)
         {
@@ -879,14 +881,10 @@ public class UIInput extends UIOutput implements EditableValueHolder
         
         if (_validatorList == null)
         {
-            //normally add user 0-3 validators: 
-            _validatorList = new _DeltaList<Validator>(3);
+            _validatorList = new _DeltaList<>(3);
         }
 
         _validatorList.add(validator);
-        
-        // The argument validator must be inspected for the presence of the ResourceDependency
annotation.
-        //_handleAnnotations(FacesContext.getCurrentInstance(), validator);
     }
 
     /** See getValidator. */
@@ -905,8 +903,8 @@ public class UIInput extends UIOutput implements EditableValueHolder
     @Override
     public Validator[] getValidators()
     {
-        if (_ExternalSpecifications.isBeanValidationAvailable() &&
-            Boolean.TRUE.equals(this.getAttributes().containsKey(BEAN_BEFORE_JSF_PROPERTY)))
+        if (_ExternalSpecifications.isBeanValidationAvailable()
+                && Boolean.TRUE.equals(this.getAttributes().containsKey(BEAN_BEFORE_JSF_PROPERTY)))
         {
             int bvIndex = -1;
             for (int i = 0; i < _validatorList.size(); i++)
@@ -937,13 +935,15 @@ public class UIInput extends UIOutput implements EditableValueHolder
             }
             else
             {
-                return _validatorList == null ? EMPTY_VALIDATOR_ARRAY
+                return _validatorList == null
+                        ? EMPTY_VALIDATOR_ARRAY
                         : _validatorList.toArray(new Validator[_validatorList.size()]);
             }
         }
         else
         {
-            return _validatorList == null ? EMPTY_VALIDATOR_ARRAY
+            return _validatorList == null
+                    ? EMPTY_VALIDATOR_ARRAY
                     : _validatorList.toArray(new Validator[_validatorList.size()]);
         }
     }
@@ -1188,9 +1188,9 @@ public class UIInput extends UIOutput implements EditableValueHolder
             Object attachedState = holder.saveState(facesContext);
             if (attachedState != null)
             {
-                return new _AttachedDeltaWrapper(_validatorList.getClass(),
-                        attachedState);
+                return new _AttachedDeltaWrapper(_validatorList.getClass(), attachedState);
             }
+
             //_validatorList instances once is created never changes, we can return null
             return null;
         }
@@ -1273,7 +1273,7 @@ public class UIInput extends UIOutput implements EditableValueHolder
         // use Throwable to get the current call stack
         Throwable throwableHelper = new Throwable();
         StackTraceElement[] stackTraceElements = throwableHelper.getStackTrace();
-        List<StackTraceElement> debugStackTraceElements = new LinkedList<StackTraceElement>();
+        List<StackTraceElement> debugStackTraceElements = new LinkedList<>();
         
         // + 1 because this method should also be skipped
         for (int i = skipStackTaceElements + 1; i < stackTraceElements.length; i++)
diff --git a/api/src/main/java/javax/faces/component/UINamingContainer.java b/api/src/main/java/javax/faces/component/UINamingContainer.java
index 18605c4..b7ff8dc 100644
--- a/api/src/main/java/javax/faces/component/UINamingContainer.java
+++ b/api/src/main/java/javax/faces/component/UINamingContainer.java
@@ -76,7 +76,7 @@ public class UINamingContainer extends UIComponentBase implements NamingContaine
 
         // Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX,
         // and will be unique within this UIViewRoot.
-        if(seed==null)
+        if(seed == null)
         {
             Integer uniqueIdCounter = (Integer) getStateHelper().get(PropertyKeys.uniqueIdCounter);
             uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
@@ -104,7 +104,8 @@ public class UINamingContainer extends UIComponentBase implements NamingContaine
         Map<Object, Object> attributes = context.getAttributes();
         Character separatorChar = (Character) attributes.get(SEPARATOR_CHAR_PARAM_NAME);
         if (separatorChar == null)
-        { // not cached yet for this request
+        { 
+            // not cached yet for this request
             ExternalContext eContext = context.getExternalContext();
             
             // The implementation must determine if there is a <context-param> with
the value given by the 
@@ -124,7 +125,8 @@ public class UINamingContainer extends UIComponentBase implements NamingContaine
             // Cache it under standard name
             attributes.put(SEPARATOR_CHAR_PARAM_NAME, separatorChar);
         }
-        return separatorChar.charValue();
+
+        return separatorChar;
     }
     
     @JSFProperty(deferredValueType="java.lang.Boolean")
diff --git a/api/src/main/java/javax/faces/component/UIOutput.java b/api/src/main/java/javax/faces/component/UIOutput.java
index a70cfdf..89ae0b3 100644
--- a/api/src/main/java/javax/faces/component/UIOutput.java
+++ b/api/src/main/java/javax/faces/component/UIOutput.java
@@ -119,8 +119,6 @@ public class UIOutput extends UIComponentBase implements ValueHolder
         {
             getStateHelper().put(PropertyKeys.converterSet,Boolean.TRUE);
         }
-        // The argument converter must be inspected for the presence of the ResourceDependency
annotation.
-        //_handleAnnotations(FacesContext.getCurrentInstance(), converter);
     }
     
     private boolean _isSetConverter()
@@ -168,9 +166,9 @@ public class UIOutput extends UIComponentBase implements ValueHolder
             Object parentSaved = super.saveState(facesContext);
             Object converterSaved = null;
             boolean nullDelta = true;
-            if (!_isSetConverter() &&
-                _converter != null && 
-                _converter instanceof PartialStateHolder)
+            if (!_isSetConverter()
+                    && _converter != null
+                    && _converter instanceof PartialStateHolder)
             {
                 //Delta
                 StateHolder holder = (StateHolder) _converter;
diff --git a/api/src/main/java/javax/faces/component/UISelectBoolean.java b/api/src/main/java/javax/faces/component/UISelectBoolean.java
index fa1ff75..b544bea 100644
--- a/api/src/main/java/javax/faces/component/UISelectBoolean.java
+++ b/api/src/main/java/javax/faces/component/UISelectBoolean.java
@@ -74,6 +74,7 @@ public class UISelectBoolean extends UIInput
         {
             throw new NullPointerException("name");
         }
+        
         if (name.equals("selected"))
         {
             return super.getValueExpression("value");
@@ -91,6 +92,7 @@ public class UISelectBoolean extends UIInput
         {
             throw new NullPointerException("name");
         }
+        
         if (name.equals("selected"))
         {
             super.setValueExpression("value", binding);
diff --git a/api/src/main/java/javax/faces/component/UISelectMany.java b/api/src/main/java/javax/faces/component/UISelectMany.java
index f513f67..ca5a2ef 100644
--- a/api/src/main/java/javax/faces/component/UISelectMany.java
+++ b/api/src/main/java/javax/faces/component/UISelectMany.java
@@ -93,6 +93,7 @@ public class UISelectMany extends UIInput
         {
             throw new NullPointerException("name");
         }
+        
         if (name.equals("selectedValues"))
         {
             return super.getValueExpression("value");
@@ -110,6 +111,7 @@ public class UISelectMany extends UIInput
         {
             throw new NullPointerException("name");
         }
+        
         if (name.equals("selectedValues"))
         {
             super.setValueExpression("value", binding);
@@ -303,7 +305,7 @@ public class UISelectMany extends UIInput
 
         // run the validators if there are item values to validate, or 
         // if we are required to validate empty fields
-        if (hasValues  || shouldValidateEmptyFields(context))
+        if (hasValues || shouldValidateEmptyFields(context))
         {
             _ComponentUtils.callValidators(context, this, convertedValue);
         }
@@ -312,7 +314,7 @@ public class UISelectMany extends UIInput
         {
             // all selected values must match to the values of the available options
 
-            Collection<SelectItem> items = new ArrayList<SelectItem>();
+            Collection<SelectItem> items = new ArrayList<>();
             for (Iterator<SelectItem> iter = new _SelectItemsIterator(this, context);
iter.hasNext();)
             {
                 items.add(iter.next());
@@ -327,8 +329,8 @@ public class UISelectMany extends UIInput
                 if (!_SelectItemsUtil.matchValue(context, this, itemValue, items.iterator(),
converter)
                         || (
                             this.isRequired()
-                            && _SelectItemsUtil.isNoSelectionOption(context, this,
itemValue,
-                                                                    items.iterator(), converter)
+                            && _SelectItemsUtil.isNoSelectionOption(context, this,
itemValue, items.iterator(),
+                                    converter)
                         ))
                 {    
                     _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
diff --git a/api/src/main/java/javax/faces/component/UISelectOne.java b/api/src/main/java/javax/faces/component/UISelectOne.java
index 172fb5f..3ebdb1f 100644
--- a/api/src/main/java/javax/faces/component/UISelectOne.java
+++ b/api/src/main/java/javax/faces/component/UISelectOne.java
@@ -176,8 +176,7 @@ public class UISelectOne extends UIInput
             {
                 return; // Matched & Required false, so return ok.
             }
-            if (! _SelectItemsUtil.isNoSelectionOption(context, this, value, 
-                    items.iterator(), converter))
+            if (! _SelectItemsUtil.isNoSelectionOption(context, this, value, items.iterator(),
converter))
             {
                 return; // Matched & Required true & No-selection did NOT match,
so return ok.
             }
diff --git a/api/src/main/java/javax/faces/component/UIViewAction.java b/api/src/main/java/javax/faces/component/UIViewAction.java
index c0f553b..6459fa5 100644
--- a/api/src/main/java/javax/faces/component/UIViewAction.java
+++ b/api/src/main/java/javax/faces/component/UIViewAction.java
@@ -107,7 +107,7 @@ public class UIViewAction extends UIComponentBase implements ActionSource2
             ActionListener defaultActionListener = context.getApplication().getActionListener();
             if (defaultActionListener != null)
             {
-                String  viewIdBeforeAction = context.getViewRoot().getViewId();
+                String viewIdBeforeAction = context.getViewRoot().getViewId();
                 Boolean oldBroadcastProcessing = (Boolean) context.getAttributes().
                     get(BROADCAST_PROCESSING_KEY);
                 try
@@ -182,8 +182,9 @@ public class UIViewAction extends UIComponentBase implements ActionSource2
         
         ActionEvent evt = new ViewActionEvent(this);
         String phase = getPhase();
-        PhaseId phaseId = (phase != null) ? PhaseId.phaseIdValueOf(phase) :
-            isImmediate() ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
+        PhaseId phaseId = phase != null
+                ? PhaseId.phaseIdValueOf(phase)
+                : isImmediate() ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
         evt.setPhaseId(phaseId);
         this.queueEvent(evt);
         
diff --git a/api/src/main/java/javax/faces/component/UIViewParameter.java b/api/src/main/java/javax/faces/component/UIViewParameter.java
index 29451ee..a3cc8da 100644
--- a/api/src/main/java/javax/faces/component/UIViewParameter.java
+++ b/api/src/main/java/javax/faces/component/UIViewParameter.java
@@ -113,7 +113,6 @@ public class UIViewParameter extends UIInput
         }
         
         // Otherwise, just return the local value.
-        
         return ((String) this.getLocalValue());
     }
 
@@ -235,7 +234,7 @@ public class UIViewParameter extends UIInput
         
         if ((getValueExpression ("value") == null) && isValid() && isLocalValueSet())

         {
-            context.getExternalContext().getRequestMap().put (getName(), getLocalValue());
+            context.getExternalContext().getRequestMap().put(getName(), getLocalValue());
         }
     }
 
@@ -271,8 +270,7 @@ public class UIViewParameter extends UIInput
         {
             log.finest("releaseRenderer rendererMap -> " + delegateRendererMap.toString());
         }
-        
-        
+
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         
         if (log.isLoggable(Level.FINEST))
@@ -281,7 +279,6 @@ public class UIViewParameter extends UIInput
             log.finest("releaseRenderer renderer -> " + delegateRendererMap.get(classLoader));
         }
         
-        
         delegateRendererMap.remove(classLoader);
         
         if (log.isLoggable(Level.FINEST))
diff --git a/api/src/main/java/javax/faces/component/UIViewRoot.java b/api/src/main/java/javax/faces/component/UIViewRoot.java
index 9158f40..04f7b5e 100644
--- a/api/src/main/java/javax/faces/component/UIViewRoot.java
+++ b/api/src/main/java/javax/faces/component/UIViewRoot.java
@@ -941,8 +941,6 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
         {
             // The try block must have a finally block that ensures that no FacesEvents remain
in the event queue
             broadcastEvents(context, PhaseId.RESTORE_VIEW);
-
-            //visitTree(VisitContext.createVisitContext(context), new RestoreStateCallback());
         }
     }
 
@@ -1644,11 +1642,10 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
         {
             return null;
         }
-        return _systemEventListeners.get (systemEvent);
+        return _systemEventListeners.get(systemEvent);
     }
     
-    public void subscribeToViewEvent(Class<? extends SystemEvent> systemEvent,
-            SystemEventListener listener)
+    public void subscribeToViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener
listener)
     {
         List<SystemEventListener> listeners;
         
@@ -1657,23 +1654,21 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
         
         if (_systemEventListeners == null)
         {
-            _systemEventListeners = new HashMap<Class<? extends SystemEvent>, List<SystemEventListener>>();
+            _systemEventListeners = new HashMap<>();
         }
         
-        listeners = _systemEventListeners.get (systemEvent);
-        
+        listeners = _systemEventListeners.get(systemEvent);
         if (listeners == null)
         {
             listeners = new ArrayList<SystemEventListener>();
             
-            _systemEventListeners.put (systemEvent, listeners);
+            _systemEventListeners.put(systemEvent, listeners);
         }
         
         listeners.add (listener);
     }
     
-    public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent,
-            SystemEventListener listener)
+    public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent,
SystemEventListener listener)
     {
         List<SystemEventListener> listeners;
         
@@ -1685,11 +1680,10 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
             return;
         }
         
-        listeners = _systemEventListeners.get (systemEvent);
-        
+        listeners = _systemEventListeners.get(systemEvent);
         if (listeners != null)
         {
-            listeners.remove (listener);
+            listeners.remove(listener);
         }
     }
 
@@ -1771,8 +1765,8 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
     {
         // Gather the events and purge the event list to prevent concurrent modification
during broadcasting
         int size = _events.size();
-        List<FacesEvent> anyPhase = new ArrayList<FacesEvent>(size);
-        List<FacesEvent> onPhase = new ArrayList<FacesEvent>(size);
+        List<FacesEvent> anyPhase = new ArrayList<>(size);
+        List<FacesEvent> onPhase = new ArrayList<>(size);
         
         for (int i = 0; i < size; i++)
         {
@@ -1807,10 +1801,9 @@ public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
 
     private Map<PhaseId, boolean[]> _getListenerSuccessMap()
     {
-        // lazy init: 
         if (listenerSuccessMap == null)
         {
-            listenerSuccessMap = new HashMap<PhaseId, boolean[]>();
+            listenerSuccessMap = new HashMap<>();
         }
         return listenerSuccessMap;
     }
diff --git a/api/src/main/java/javax/faces/component/_ClassUtils.java b/api/src/main/java/javax/faces/component/_ClassUtils.java
index 54e2599..9a1ba1e 100755
--- a/api/src/main/java/javax/faces/component/_ClassUtils.java
+++ b/api/src/main/java/javax/faces/component/_ClassUtils.java
@@ -135,14 +135,16 @@ final class _ClassUtils
         try
         {
             // Try WebApp ClassLoader first
-            return Class.forName(type, false, // do not initialize for faster startup
-                getContextClassLoader());
+            return Class.forName(type,
+                    false, // do not initialize for faster startup
+                    getContextClassLoader());
         }
         catch (ClassNotFoundException ignore)
         {
             // fallback: Try ClassLoader for ClassUtils (i.e. the myfaces.jar lib)
-            return Class.forName(type, false, // do not initialize for faster startup
-                _ClassUtils.class.getClassLoader());
+            return Class.forName(type,
+                    false, // do not initialize for faster startup
+                    _ClassUtils.class.getClassLoader());
         }
     }
 
diff --git a/api/src/main/java/javax/faces/component/_ComponentUtils.java b/api/src/main/java/javax/faces/component/_ComponentUtils.java
index 2955f2c..5b2e8c5 100755
--- a/api/src/main/java/javax/faces/component/_ComponentUtils.java
+++ b/api/src/main/java/javax/faces/component/_ComponentUtils.java
@@ -61,31 +61,17 @@ class _ComponentUtils
 
     static UIComponent findParentNamingContainer(UIComponent component, boolean returnRootIfNotFound)
     {
-        UIComponent parent = component.getParent();
-        if (returnRootIfNotFound && parent == null)
+        NamingContainer result = closest(NamingContainer.class, component);
+        if (result != null)
         {
-            return component;
+            return (UIComponent) result;
         }
-        while (parent != null)
+        
+        if (returnRootIfNotFound)
         {
-            if (parent instanceof NamingContainer)
-            {
-                return parent;
-            }
-            if (returnRootIfNotFound)
-            {
-                UIComponent nextParent = parent.getParent();
-                if (nextParent == null)
-                {
-                    return parent; // Root
-                }
-                parent = nextParent;
-            }
-            else
-            {
-                parent = parent.getParent();
-            }
+            return getRootComponent(component);
         }
+        
         return null;
     }
     
@@ -134,7 +120,7 @@ class _ComponentUtils
      */
     static UIComponent findComponent(UIComponent findBase, String id, final char separatorChar)
     {
-        if (!(findBase instanceof NamingContainer) && idsAreEqual(id, findBase))
+        if (!(findBase instanceof NamingContainer) && id.equals(findBase.getId()))
         {
             return findBase;
         }
@@ -152,7 +138,7 @@ class _ComponentUtils
                         return find;
                     }
                 }
-                else if (idsAreEqual(id, facet))
+                else if (id.equals(facet.getId()))
                 {
                     return facet;
                 }
@@ -170,13 +156,13 @@ class _ComponentUtils
                     return find;
                 }
             }
-            else if (idsAreEqual(id, child))
+            else if (id.equals(child.getId()))
             {
                 return child;
             }
         }
 
-        if (findBase instanceof NamingContainer && idsAreEqual(id, findBase))
+        if (findBase instanceof NamingContainer && id.equals(findBase.getId()))
         {
             return findBase;
         }
@@ -248,20 +234,6 @@ class _ComponentUtils
         return null;
     }
 
-    /*
-     * Return true if the specified component matches the provided id. This needs some quirks
to handle components whose
-     * id value gets dynamically "tweaked", eg a UIData component whose id gets the current
row index appended to it.
-     */
-    private static boolean idsAreEqual(String id, UIComponent cmp)
-    {
-        if (id.equals(cmp.getId()))
-        {
-            return true;
-        }
-
-        return false;
-    }
-
     static void callValidators(FacesContext context, UIInput input, Object convertedValue)
     {
         // first invoke the list of validator components
diff --git a/api/src/main/java/javax/faces/component/behavior/BehaviorBase.java b/api/src/main/java/javax/faces/component/behavior/BehaviorBase.java
index 9aba6f4..426c99b 100644
--- a/api/src/main/java/javax/faces/component/behavior/BehaviorBase.java
+++ b/api/src/main/java/javax/faces/component/behavior/BehaviorBase.java
@@ -174,7 +174,7 @@ public class BehaviorBase implements Behavior, PartialStateHolder
         }        
         else if (attachedObject instanceof List)
         {
-            List<Object> lst = new ArrayList<Object>(((List<?>) attachedObject).size());
+            List<Object> lst = new ArrayList<>(((List<?>) attachedObject).size());
             for (Object item : (List<?>) attachedObject)
             {
                 if (item != null)
@@ -208,7 +208,7 @@ public class BehaviorBase implements Behavior, PartialStateHolder
         if (stateObj instanceof _AttachedListStateWrapper)
         {
             List<Object> lst = ((_AttachedListStateWrapper) stateObj).getWrappedStateList();
-            List<Object> restoredList = new ArrayList<Object>(lst.size());
+            List<Object> restoredList = new ArrayList<>(lst.size());
             for (Object item : lst)
             {
                 restoredList.add(restoreAttachedState(context, item));
@@ -265,7 +265,7 @@ public class BehaviorBase implements Behavior, PartialStateHolder
         {
             // Lazy instanciation with size 1:
             // the only posibility how to add listener is <f:ajax listener="" /> -
there is no <f:ajaxListener/> tag 
-            _behaviorListeners = new _DeltaList<BehaviorListener>(1);
+            _behaviorListeners = new _DeltaList<>(1);
         }
         
         _behaviorListeners.add(listener);
diff --git a/impl/src/main/java/org/apache/myfaces/util/lang/ClassLoaderExtension.java b/impl/src/main/java/org/apache/myfaces/util/lang/ClassLoaderExtension.java
deleted file mode 100644
index 0387f17..0000000
--- a/impl/src/main/java/org/apache/myfaces/util/lang/ClassLoaderExtension.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.util.lang;
-
-/**
- * Extends the existing with a new loading mechanism
- */
-public class ClassLoaderExtension
-{
-    /**
-     * standard forName for the loader
-     *
-     * @param name
-     * @return
-     */
-    public Class forName(String name)
-    {
-        return null;
-    }
-}
diff --git a/impl/src/main/java/org/apache/myfaces/util/lang/ClassUtils.java b/impl/src/main/java/org/apache/myfaces/util/lang/ClassUtils.java
index 629e68e..a6f2781 100755
--- a/impl/src/main/java/org/apache/myfaces/util/lang/ClassUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/util/lang/ClassUtils.java
@@ -67,8 +67,6 @@ public final class ClassUtils
     public static final Class DOUBLE_OBJECT_ARRAY_CLASS = Double[].class;
     public static final Class STRING_OBJECT_ARRAY_CLASS = String[].class;
 
-    public static ClassLoaderExtension [] classLoadingExtensions = new ClassLoaderExtension[0];
-
     protected static final String[] EMPTY_STRING = new String[0];
 
     protected static final String[] PRIMITIVE_NAMES = new String[] { "boolean", "byte", "char",
"double", "float",
@@ -130,32 +128,6 @@ public final class ClassUtils
 
     //~ Methods ------------------------------------------------------------------------------------
 
-    public synchronized static void addClassLoadingExtension(ClassLoaderExtension extension,
boolean top)
-    {
-      /**
-       * now at the first look this looks somewhat strange
-       * but to get the best performance access we assign new native
-       * arrays to our static variable
-       * 
-       * we have to synchronized nevertheless because if two threads try to register
-       * loaders at the same time none of them should get lost
-       */
-        ClassLoaderExtension [] retVal = new ClassLoaderExtension[classLoadingExtensions.length+1];
-        ArrayList extensions = new ArrayList(classLoadingExtensions.length+1);
-
-        if(!top)
-        {
-            extensions.addAll(Arrays.asList(classLoadingExtensions));
-        }
-        extensions.add(extension);
-        if(top)
-        {
-            extensions.addAll(Arrays.asList(classLoadingExtensions));
-        }    
-
-        classLoadingExtensions = (ClassLoaderExtension []) extensions.toArray(retVal);
-    }
-
     /**
      * Tries a Class.loadClass with the context class loader of the current thread first
and
      * automatically falls back to the ClassUtils class loader (i.e. the loader of the
@@ -166,23 +138,8 @@ public final class ClassUtils
      * @throws NullPointerException if type is null
      * @throws ClassNotFoundException
      */
-    public static Class classForName(String type)
-        throws ClassNotFoundException
+    public static Class classForName(String type) throws ClassNotFoundException
     {
-        //we now assign the array to safekeep the reference on
-        // the local variable stack, that way
-        //we can avoid synchronisation calls
-        ClassLoaderExtension [] loaderPlugins = classLoadingExtensions;
-        for (int cnt = 0; cnt < loaderPlugins.length; cnt ++)
-        {
-            ClassLoaderExtension extension = loaderPlugins[cnt];
-            Class retVal = extension.forName(type);
-            if(retVal != null)
-            {
-                return retVal;
-            }
-        }
-
         Assert.notNull(type, "type");
         
         try
@@ -252,8 +209,7 @@ public final class ClassUtils
      * @throws NullPointerException if type is null
      * @throws ClassNotFoundException
      */
-    public static Class javaTypeToClass(String type)
-        throws ClassNotFoundException
+    public static Class javaTypeToClass(String type) throws ClassNotFoundException
     {
         Assert.notNull(type, "type");
 


Mime
View raw message