gpt4 book ai didi

tomcat - 将 tomcat 设置为与 eclipse jsf2 中的 dcevm 一起工作

转载 作者:行者123 更新时间:2023-11-28 22:03:18 25 4
gpt4 key购买 nike

如何在 tomcat 和 eclipse 中使用 dcevm我下载了 jdk6u25 并将 tomcat7 设置为在 eclipse juno 中使用它然后当我更改托管 bean 中的任何内容时它可以工作,但没有考虑 xhtml 中的更改

我觉得是tomcat的问题

最佳答案

您至少必须清理 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;
}

关于tomcat - 将 tomcat 设置为与 eclipse jsf2 中的 dcevm 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15717748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com