001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Anahide Tchertchian 018 */ 019package org.nuxeo.ecm.platform.actions.seam; 020 021import javax.el.ArrayELResolver; 022import javax.el.BeanELResolver; 023import javax.el.CompositeELResolver; 024import javax.el.ELContext; 025import javax.el.ELResolver; 026import javax.el.ExpressionFactory; 027import javax.el.ListELResolver; 028import javax.el.MapELResolver; 029import javax.el.ResourceBundleELResolver; 030 031import org.jboss.el.lang.FunctionMapperImpl; 032import org.jboss.seam.el.EL; 033import org.jboss.seam.el.SeamELResolver; 034import org.nuxeo.ecm.platform.actions.ELActionContext; 035import org.nuxeo.ecm.platform.el.DocumentModelResolver; 036 037/** 038 * Sample Seam action context, resolving components in Seam context (but not relying on faces context to do so) 039 * <p> 040 * Adds the {@link DocumentModelResolver} at the top of the list of default Seam resolvers. 041 * 042 * @since 5.7.3 043 */ 044public class SeamActionContext extends ELActionContext { 045 046 private static final long serialVersionUID = 1L; 047 048 public static final ELResolver EL_RESOLVER = createELResolver(); 049 050 public static ELResolver createELResolver() { 051 CompositeELResolver resolver = new CompositeELResolver(); 052 resolver.add(new DocumentModelResolver()); 053 resolver.add(new SeamELResolver()); 054 resolver.add(new MapELResolver()); 055 resolver.add(new ListELResolver()); 056 resolver.add(new ArrayELResolver()); 057 resolver.add(new ResourceBundleELResolver()); 058 resolver.add(new BeanELResolver()); 059 return resolver; 060 } 061 062 public SeamActionContext() { 063 super(createELContext(), EXPRESSION_FACTORY); 064 } 065 066 public SeamActionContext(ELContext originalContext, ExpressionFactory expressionFactory) { 067 super(originalContext, expressionFactory); 068 } 069 070 public static ELContext createELContext() { 071 return EL.createELContext(EL_RESOLVER, new FunctionMapperImpl()); 072 } 073 074}