MoxyContextResolver返回JAXBContext的时间太长

MoxyContextResolver返回JAXBContext的时间太长,jaxb,jersey,moxy,Jaxb,Jersey,Moxy,环境:java 7,jersey 2.17+jersey media moxy 2.17 GET请求总是需要一个FindResponse实例。在我的测试中,我总是返回相同的结果。但是对于每个GET请求,实体提供者(无论是json还是xml)都会为jaxbcontext调用MoxyContextResolver,并且返回jaxbcontext需要1分钟以上的时间 在下面初始化应用程序的代码中,我有2000多个JAXB类。 我可以理解第一次返回jaxbcontext是否需要一些时间;但是,随着越来越

环境:java 7,jersey 2.17+jersey media moxy 2.17

GET请求总是需要一个FindResponse实例。在我的测试中,我总是返回相同的结果。但是对于每个GET请求,实体提供者(无论是json还是xml)都会为jaxbcontext调用MoxyContextResolver,并且返回jaxbcontext需要1分钟以上的时间

在下面初始化应用程序的代码中,我有2000多个JAXB类。 我可以理解第一次返回jaxbcontext是否需要一些时间;但是,随着越来越多的GET请求的发出,所需的时间越来越长

我尝试从应用程序扩展,而不是ResourceConfig,并将我自己的jaxb ContextResolver作为单例返回,但“解析器”解析为两个jaxb上下文解析器,第一个始终是默认的MoxyContextResolver,第二个是我的自定义解析器。我的自定义解析器无法用于创建jaxb上下文

SamoMoxyApplication.java

public class SamoMoxyApplication extends ResourceConfig {

    public SamoMoxyApplication() {
        super();
        Set<Class> jaxbClasses = new HashSet<Class>(SamoTypeResolver.getSamoJaxbTypes());
        jaxbClasses.add(FindResponse.class);
        jaxbClasses.add(ListWrapper.class);

        Map<String, Object> properties = new HashMap<String, Object>();
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL url = classLoader.getResource("META-INF/config/mdm-oxm.xml");
        properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, url.toString());

        MoxyXmlFeature xmlFeature = new MoxyXmlFeature(properties, classLoader, false,
                jaxbClasses.toArray(new Class[0]));
        register(xmlFeature);

        MdmMoxyContextResolver moxyContextResolver = new MdmMoxyContextResolver(properties, classLoader, jaxbClasses.toArray(new Class[0]));
        register(moxyContextResolver);

        register(SamoMoxyResource.class);
    }

}
公共类SamoMoxyApplication扩展了ResourceConfig{
公共SamoMoxyApplication(){
超级();
Set jaxbClasses=newhashset(samotypesolver.getSamoJaxbTypes());
add(FindResponse.class);
add(ListWrapper.class);
映射属性=新的HashMap();
ClassLoader ClassLoader=Thread.currentThread().getContextClassLoader();
URL=classLoader.getResource(“META-INF/config/mdm-oxm.xml”);
put(JAXBContextProperties.OXM_METADATA_SOURCE,url.toString());
MoxyXmlFeature=new MoxyXmlFeature(属性、类加载器、false、,
toArray(新类[0]);
寄存器(xmlFeature);
MdmMoxyContextResolver moxyContextResolver=新的MdmMoxyContextResolver(属性、类加载器、jaxbClasses.toArray(新类[0]);
寄存器(moxyContextResolver);
寄存器(SamoMoxyResource.class);
}
}
mdm-oxm.xml(这是xml绑定标记中的全部内容,在我的测试中,FindResponse实例中只包装了一个LagInterface实例)


<java-types>
    <java-type name="LagInterface">
        <xml-root-element name="lag.Interface" />
    </java-type>
</java-types>