All Downloads are FREE. Search and download functionalities are using the official Maven repository.

qa.justtestlah.utils.SpringContext Maven / Gradle / Ivy

Go to download

JustTestLah! is a JAVA test framework targeting projects that support multiple platforms, in particular Web, Android and iOS. It follows a BDD approach and allows testing against all platforms using the same feature files. JustTestLah's main aim is to make the configuration and the actual test code as easy as possible.

There is a newer version: 1.9-RC4
Show newest version
package qa.justtestlah.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/** Helper class to provide access to Spring beans in classes not managed by Spring. */
@Component
public class SpringContext implements ApplicationContextAware {

  private static ApplicationContext context;

  /**
   * Returns the Spring managed bean instance of the given class type if it exists. Returns null
   * otherwise.
   *
   * @param  type of the requested bean
   * @param clazz the {@link Class} of the requested bean
   * @return matching bean from the Spring context
   */
  public static  T getBean(Class clazz) {
    return context.getBean(clazz);
  }

  @Override
  public void setApplicationContext(ApplicationContext context) throws BeansException {
    SpringContext.context = context;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy