CompositeComponentAttributesELResolver extends ELResolver { @Override public Object getValue(ELContext context, Object base, Object property) { Util.notNull("context", context); if (base != null && (base instanceof UIComponent) && UIComponent.isCompositeComponent((UIComponent) base) && property != null) { String propertyName = property.toString(); if (COMPOSITE_COMPONENT_ATTRIBUTES_NAME.equals(propertyName)) { UIComponent c = (UIComponent) base; context.setPropertyResolved(true); FacesContext ctx = (FacesContext) context.getContext(FacesContext.class); return getEvalMapFor(c, ctx); } if (COMPOSITE_COMPONENT_PARENT_NAME.equals(propertyName)) { UIComponent c = (UIComponent) base; context.setPropertyResolved(true); FacesContext ctx = (FacesContext) context.getContext(FacesContext.class); CompositeComponentStackManager m = CompositeComponentStackManager.getManager(ctx); UIComponent ccp = m.getParentCompositeComponent(TreeCreation, ctx, c); if (ccp == null) { ccp = m.getParentCompositeComponent(Evaluation, ctx, c); } return ccp; } } return null; }  @Override Object getValue(ELContext context, Object base, Object property); @Override Class<?> getType(ELContext context, Object base, Object property); @Override void setValue(ELContext context,
                         Object base,
                         Object property,
                         Object value); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
                                                             Object base); @Override Class<?> getCommonPropertyType(ELContext context, Object base); Map<String,Object> getEvalMapFor(UIComponent c, FacesContext ctx);  }
@Test public void testGetValue() throws Exception { ELContext elContext1 = EasyMock.createNiceMock(ELContext.class); FacesContext facesContext1 = EasyMock.createNiceMock(FacesContext.class); ELContext elContext2 = EasyMock.createNiceMock(ELContext.class); FacesContext facesContext2 = EasyMock.createNiceMock(FacesContext.class); HashMap<Object, Object> ctxAttributes1 = new HashMap<Object, Object>(); UIPanel composite = new UIPanel(); CompositeComponentBeanInfo compositeBeanInfo = new CompositeComponentBeanInfo(); BeanDescriptor beanDescriptor = new BeanDescriptor(composite.getClass()); compositeBeanInfo.setBeanDescriptor(beanDescriptor); composite.getAttributes().put(Resource.COMPONENT_RESOURCE_KEY, "dummy"); composite.getAttributes().put(UIComponent.BEANINFO_KEY, compositeBeanInfo); String property = "attrs"; expect(elContext1.getContext(FacesContext.class)).andReturn(facesContext1); expect(facesContext1.getAttributes()).andReturn(ctxAttributes1); expect(elContext2.getContext(FacesContext.class)).andReturn(facesContext2); expect(facesContext2.getAttributes()).andReturn(ctxAttributes1); replay(elContext1, facesContext1, elContext2, facesContext2); CompositeComponentAttributesELResolver elResolver = new CompositeComponentAttributesELResolver(); Map<String, Object> evalMap1 = (Map<String, Object>) elResolver.getValue(elContext1, composite, property); assertNotNull(evalMap1); Map<String, Object> evalMap2 = (Map<String, Object>) elResolver.getValue(elContext2, composite, property); assertNotNull(evalMap2); Field ctxField1 = evalMap1.getClass().getDeclaredField("ctx"); ctxField1.setAccessible(true); Field ctxField2 = evalMap2.getClass().getDeclaredField("ctx"); ctxField2.setAccessible(true); assertTrue(evalMap1 == evalMap2); assertTrue(facesContext1 != ctxField1.get(evalMap1)); assertTrue(facesContext2 == ctxField1.get(evalMap1)); assertTrue(facesContext1 != ctxField2.get(evalMap2)); assertTrue(facesContext2 == ctxField2.get(evalMap2)); verify(elContext1, facesContext1, elContext2, facesContext2); }