2013-03-30 68 views
2

如何在tomcat和eclipse中使用dcevm 我下載了jdk6u25,並設置了tomcat7在eclipse juno中使用它,然後當我更改託管bean中的任何內容時,在XHTML變化不會考慮設置tomcat在eclipse中使用dcevm jsf2

我認爲這個問題是在Tomcat中

回答

0

你必須清理BeanElResolver和ElMethodCache至少。下面的例子是對於JBoss-EL實現:

private void clearJbossElMethodCache() { 
    try { 
     Field cacheField = getField(org.jboss.el.util.ReflectionUtil.class, "methodCache"); 
     cacheField.setAccessible(true); 
     Object cache = cacheField.get(null); 
     Method m = cache.getClass().getMethod("clear"); 
     m.invoke(cache); 
    } 
    catch (Exception e) { 
    } 
} 

public void clearBeanElResolver() { 
    BeanELResolver beanELResolver = getSeamBeanELResover(); 
    doCleanBeanElResolver(beanELResolver); 
    doCleanBeanElResolver(ELUtils.BEAN_RESOLVER); 
    java.beans.Introspector.flushCaches(); 
} 

private void doCleanBeanElResolver(BeanELResolver beanELResolver) { 
     try { 
      try { 
       Field cacheField = getField(beanELResolver.getClass(), "cache"); 
       cacheField.setAccessible(true); 
       Object cache = cacheField.get(beanELResolver); 
       try { 
        Method m = cache.getClass().getMethod("clear"); 
        m.invoke(cache); 
       } catch (NoSuchMethodException e) 
       { 
        Class<?> cacheClass = getClass().getClassLoader().loadClass("javax.el.BeanELResolver$ConcurrentCache"); 
        Constructor<?> con = cacheClass.getConstructor(int.class); 
        con.setAccessible(true); 
        Object cacheInstance = con.newInstance(100); 
        cacheField.set(beanELResolver, cacheInstance); 
       } 

      } 
      catch (NoSuchFieldException ee) { 
       Field props = getField(beanELResolver.getClass(), "properties"); 
       props.setAccessible(true); 
       Object cache = props.get(beanELResolver); 
       Method m = cache.getClass().getMethod("clear"); 
       m.invoke(cache); 
      } 
     } 
     catch (Exception e) { 
     } 
} 

private BeanELResolver getSeamBeanELResover() { 
    if (EL.EL_RESOLVER instanceof CompositeELResolver) { 
     CompositeELResolver compositeElResolver = (CompositeELResolver) EL.EL_RESOLVER; 
     try { 
      Field elResolvesField = getField(CompositeELResolver.class, "resolvers"); 
      elResolvesField.setAccessible(true); 
      ELResolver elResolvers[] = (ELResolver[]) elResolvesField.get(compositeElResolver); 
      for (ELResolver elResolver: elResolvers) { 
       if (elResolver instanceof BeanELResolver) { 
        return (BeanELResolver) elResolver; 
       } 
      } 
     } 
     catch (Exception e) { 
     } 
    } 
    return null; 
} 
相關問題