1

我正在使用与 jersey 2.x 集成的遗留 spring 2.0.6 项目。

应用程序上下文包含一些 bean,例如:

<!-- - Application context definition -->
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="propertiesArray">
        <list>
            <bean factory-bean="propertiesHolder" factory-method="asProperties" />
        </list>
    </property>
</bean>
<bean name="propertiesHolder"
    class="com.my.TenantPropertiesHolder" scope="request">
    <aop:scoped-proxy/>
</bean>

<!-- LDAP Repository -->
<bean id="LDAP" class="com.my.LdapRepository">

    <property name="name" value="${LDAP.name}" />
    <property name="providerUrl" value="${LDAP.providerUrl}" />
    <property name="baseQuery" value="${LDAP.baseQuery}" />
    <property name="userCommonName" value="${LDAP.userCommonName}" />
    <property name="userPassword" value="${LDAP.userPassword}" />
</bean>

在 web.xml 中我有:

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> 
       classpath:klas-auth-Context.xml
    </param-value>
 </context-param>
 <listener>
     <listener-class>org.springframework.web.context.request.RequestContextListener          </listener-class>
 </listener>
 <servlet>
     <servlet-name>Secured REST Service</servlet-name>
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
     <init-param>
         <param-name>jersey.config.server.provider.packages</param-name>
         <param-value>com.my</param-value>
     </init-param>
     <init-param>
         <param-name>javax.ws.rs.Application</param-name>
         <param-value>com.my.core.auth.injection.JAXRSConfig</param-value>
     </init-param>     
     <load-on-startup>1</load-on-startup>
  </servlet>

我怎样才能让它工作?我如何在没有 Spring Web 上下文加载器侦听器的情况下恢复 ldap bean?

<listener-class>
      org.springframework.web.context.ContextLoaderListener  
</listener-class>

从我的休息服务?

使用上下文加载器侦听器,这是我在服务中的代码:

private static ApplicationContext appContext;

@PostConstruct
public void init() {
    appContext = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
}

现在怎么办?

4

0 回答 0