Codota Logo
ApplicationContextHolder
Code IndexAdd Codota to your IDE (free)

How to use
ApplicationContextHolder
in
org.finra.herd.core

Best Java code snippets using org.finra.herd.core.ApplicationContextHolder (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: org.finra.herd/herd-dao

/**
 * Gets the data source bean from the application context statically. This is needed for static @Bean creation methods that won't have access to an
 * auto-wired data source.
 *
 * @return the data source.
 */
public static DataSource getHerdDataSource()
{
  return (DataSource) ApplicationContextHolder.getApplicationContext().getBean(HERD_DATA_SOURCE_BEAN_NAME);
}
origin: org.finra.herd/herd-tools-common

  /**
   * Creates and returns the Spring application context.
   *
   * @return the application context
   */
  protected ApplicationContext createApplicationContext()
  {
    // Create the Spring application context and register the JavaConfig classes we need.
    // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in
    // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies
    // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the uploader).
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    ApplicationContextHolder.setApplicationContext(applicationContext);
    applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class,
      DataBridgeEnvSpringModuleConfig.class);
    applicationContext.refresh();
    return applicationContext;
  }
}
origin: FINRAOS/herd

  /**
   * Creates and returns the Spring application context.
   *
   * @return the application context
   */
  private ApplicationContext createApplicationContext()
  {
    // Create the Spring application context and register the JavaConfig classes we need.
    // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in
    // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies
    // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the application).
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    ApplicationContextHolder.setApplicationContext(applicationContext);
    applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class,
      DataBridgeEnvSpringModuleConfig.class);
    applicationContext.refresh();
    return applicationContext;
  }
}
origin: org.finra.herd/herd-service

/**
 * Determines whether Quartz tables need to be created which should return true for JUnits only.
 *
 * @return whether Quartz tables need to be created.
 */
private Boolean shouldCreateQuartzTables()
{
  return (Boolean) ApplicationContextHolder.getApplicationContext().getBean(CREATE_QUARTZ_TABLES_BEAN_NAME);
}
origin: FINRAOS/herd

  /**
   * Creates and returns the Spring application context.
   *
   * @return the application context
   */
  private ApplicationContext createApplicationContext()
  {
    // Create the Spring application context and register the JavaConfig classes we need.
    // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in
    // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies
    // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the application).
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    ApplicationContextHolder.setApplicationContext(applicationContext);
    applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class,
      DataBridgeEnvSpringModuleConfig.class);
    applicationContext.refresh();
    return applicationContext;
  }
}
origin: FINRAOS/herd

/**
 * Gets the data source bean from the application context statically. This is needed for static @Bean creation methods that won't have access to an
 * auto-wired data source.
 *
 * @return the data source.
 */
public static DataSource getHerdDataSource()
{
  return (DataSource) ApplicationContextHolder.getApplicationContext().getBean(HERD_DATA_SOURCE_BEAN_NAME);
}
origin: FINRAOS/herd

  /**
   * Creates and returns the Spring application context.
   *
   * @return the application context
   */
  protected ApplicationContext createApplicationContext()
  {
    // Create the Spring application context and register the JavaConfig classes we need.
    // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in
    // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies
    // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the uploader).
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    ApplicationContextHolder.setApplicationContext(applicationContext);
    applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class,
      DataBridgeEnvSpringModuleConfig.class);
    applicationContext.refresh();
    return applicationContext;
  }
}
origin: org.finra.herd/herd-service

/**
 * Gets the Activiti database schema update param from the application context statically.
 *
 * @return the Activiti database schema update param.
 */
private String getActivitiDbSchemaUpdateParamBeanName()
{
  return (String) ApplicationContextHolder.getApplicationContext().getBean(ACTIVITI_DB_SCHEMA_UPDATE_PARAM_BEAN_NAME);
}
origin: FINRAOS/herd

  @Override
  protected void prepareContext(GenericApplicationContext context)
  {
    // Set the application context in the context holder for access by static @Bean methods.
    ApplicationContextHolder.setApplicationContext(context);

    // Perform standard functionality.
    super.prepareContext(context);
  }
}
origin: FINRAOS/herd

/**
 * Gets the Hibernate HBM2DDL bean from the application context statically.
 *
 * @return the Hibernate HBM2DDL auto param.
 */
public String getHibernateHbm2DdlAutoParam()
{
  return (String) ApplicationContextHolder.getApplicationContext().getBean(HIBERNATE_HBM2DDL_AUTO_PARAM_BEAN_NAME);
}
origin: FINRAOS/herd

  @Override
  protected void prepareContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig)
  {
    // Set the application context in the context holder for access by static @Bean methods.
    ApplicationContextHolder.setApplicationContext(context);

    // Perform standard functionality.
    super.prepareContext(context, mergedConfig);
  }
}
origin: FINRAOS/herd

/**
 * Gets the Activiti database schema update param from the application context statically.
 *
 * @return the Activiti database schema update param.
 */
private String getActivitiDbSchemaUpdateParamBeanName()
{
  return (String) ApplicationContextHolder.getApplicationContext().getBean(ACTIVITI_DB_SCHEMA_UPDATE_PARAM_BEAN_NAME);
}
origin: org.finra.herd/herd-app

/**
 * Initializes the context loader listener which bootstraps Spring and provides access to the application context.
 *
 * @param servletContext the servlet context.
 */
protected void initContextLoaderListener(ServletContext servletContext)
{
  // Add the context loader listener for the base (i.e. root) Spring configuration.
  // We register all our @Configuration annotated classes with the context so Spring will load all the @Bean's via these classes.
  // We also set the application context in an application context holder before "registering" so static @Bean's
  // (e.g. PropertySourcesPlaceholderConfigurer) will have access to it since they can't take advantage of autowiring or having a class be
  // ApplicationContextAware to get it.
  AnnotationConfigWebApplicationContext contextLoaderListenerContext = new AnnotationConfigWebApplicationContext();
  ApplicationContextHolder.setApplicationContext(contextLoaderListenerContext);
  contextLoaderListenerContext
    .register(CoreSpringModuleConfig.class, DaoSpringModuleConfig.class, DaoEnvSpringModuleConfig.class, ServiceSpringModuleConfig.class,
      ServiceEnvSpringModuleConfig.class, UiSpringModuleConfig.class, UiEnvSpringModuleConfig.class, RestSpringModuleConfig.class,
      AppSpringModuleConfig.class);
  servletContext.addListener(new ContextLoaderListener(contextLoaderListenerContext));
}
origin: org.finra.herd/herd-dao

/**
 * Gets the Hibernate HBM2DDL bean from the application context statically.
 *
 * @return the Hibernate HBM2DDL auto param.
 */
public String getHibernateHbm2DdlAutoParam()
{
  return (String) ApplicationContextHolder.getApplicationContext().getBean(HIBERNATE_HBM2DDL_AUTO_PARAM_BEAN_NAME);
}
origin: FINRAOS/herd

/**
 * Determines whether Quartz tables need to be created which should return true for JUnits only.
 *
 * @return whether Quartz tables need to be created.
 */
private Boolean shouldCreateQuartzTables()
{
  return (Boolean) ApplicationContextHolder.getApplicationContext().getBean(CREATE_QUARTZ_TABLES_BEAN_NAME);
}
origin: org.finra.herd/herd-app

/**
 * Retrieves functional points that have no roles mapped to them.
 *
 * @return set of {@link GrantedAuthority} representing functional points
 */
public Set<GrantedAuthority> getUnrestrictedFunctions()
{
  // TODO Getting HerdDao from applicationContext statically because if we try to wire HerdDao here it does not get constructed with proxy class that is
  // needed for @Cacheable methods to work.
  SecurityFunctionDao securityFunctionDao = ApplicationContextHolder.getApplicationContext().getBean(SecurityFunctionDao.class);
  Set<GrantedAuthority> authorities = new HashSet<>();
  // Add all unrestricted functional points.
  for (String function : securityFunctionDao.getUnrestrictedSecurityFunctions())
  {
    authorities.add(new SimpleGrantedAuthority(function));
  }
  return authorities;
}
origin: org.finra.herd/herd-app

SecurityFunctionDao securityFunctionDao = ApplicationContextHolder.getApplicationContext().getBean(SecurityFunctionDao.class);
origin: org.finra.herd/herd-dao

/**
 * The data source for the application.
 *
 * @return the data source.
 */
@Bean
public static DataSource herdDataSource()
{
  // Access the environment using the application context holder since we're in a static method that doesn't have access to the environment in any
  // other way.
  Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment();
  // Get the configuration property for the data source JNDI name.
  String dataSourceJndiName = ConfigurationHelper.getProperty(ConfigurationValue.HERD_DATA_SOURCE_JNDI_NAME, environment);
  // Return a new JNDI data source.
  return new JndiDataSourceLookup().getDataSource(dataSourceJndiName);
}
origin: FINRAOS/herd

/**
 * The data source for the application.
 *
 * @return the data source.
 */
@Bean
public static DataSource herdDataSource()
{
  // Access the environment using the application context holder since we're in a static method that doesn't have access to the environment in any
  // other way.
  Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment();
  // Get the configuration property for the data source JNDI name.
  String dataSourceJndiName = ConfigurationHelper.getProperty(ConfigurationValue.HERD_DATA_SOURCE_JNDI_NAME, environment);
  // Return a new JNDI data source.
  return new JndiDataSourceLookup().getDataSource(dataSourceJndiName);
}
origin: org.finra.herd/herd-service

JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
  .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
org.finra.herd.coreApplicationContextHolder

Javadoc

A class that can statically hold a Spring application context for later easy retrieval. It is recommended that you store the context in this holder once the context is created in a WebApplicationInitializer. It can then be easily retrieved from a JavaConfig @Bean annotated static method that returns a Bean Factory Post Processor (BFPP) such as a property source place holder configurer.

Note that this class should only be used when there is no easy way to get a hold of the context using normal means such as autowiring and making a class ApplicationContextAware.

Most used methods

  • setApplicationContext
  • getApplicationContext

Popular in Java

  • Reactive rest calls using spring rest template
  • addToBackStack (FragmentTransaction)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • setContentView (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now