org.apache.myfaces.el.unified.resolver
Class GuiceResolver
java.lang.Object
javax.el.ELResolver
org.apache.myfaces.el.unified.resolver.ManagedBeanResolver
org.apache.myfaces.el.unified.resolver.GuiceResolver
public class GuiceResolver
- extends ManagedBeanResolver
Register this ELResolver in faces-config.xml.
<application> <el-resolver>org.apache.myfaces.el.unified.resolver.GuiceResolver</el-resolver> </application>
Implement and configure a ServletContextListener in web.xml .
<listener> com.your_company.GuiceServletContextListener</listener-class> </listener>
Configure Guice in your ServletContextListener implementation, and place the Injector in application scope.
public class GuiceServletContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) { ServletContext ctx = event.getServletContext(); //when on
Java6, use ServiceLoader.load(com.google.inject.Module.class); Injector injector = Guice.createInjector(new
YourModule()); ctx.setAttribute(GuiceResolver.KEY, injector); }
public void contextDestroyed(ServletContextEvent event) { ServletContext ctx = event.getServletContext();
ctx.removeAttribute(GuiceResolver.KEY); }
}
- Author:
- Dennis Byrne
Fields inherited from class javax.el.ELResolver |
RESOLVABLE_AT_DESIGN_TIME, TYPE |
Methods inherited from class javax.el.ELResolver |
invoke |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KEY
public static final String KEY
GuiceResolver
public GuiceResolver()
getValue
public Object getValue(javax.el.ELContext ctx,
Object base,
Object property)
throws NullPointerException,
javax.el.PropertyNotFoundException,
javax.el.ELException
- Overrides:
getValue
in class ManagedBeanResolver
- Throws:
NullPointerException
javax.el.PropertyNotFoundException
javax.el.ELException
Copyright © 2015 The Apache Software Foundation. All rights reserved.