Package server

Source Code of server.SpringAwareResource

package server;

import javax.servlet.ServletContext;
import javax.ws.rs.core.Context;

import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import server.config.SpringConfigInitializer;

public class SpringAwareResource {

    @Context
    public void setContext(ServletContext sc) {
  autowire(sc);
    }

    public void autowire(ServletContext sc) {
  autowire(sc, this);
    }

    public static void autowire(ServletContext sc, Object target) {
  AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) sc
          .getAttribute(SpringConfigInitializer.SPRING_CONTEXT);
  context.getBeanFactory().autowireBean(target);
    }
}
TOP

Related Classes of server.SpringAwareResource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.