Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan()


      }
    });

    // Scan twice in order to find errors in the bean definition compatibility check.
    scanner.scan(getClass().getPackage().getName());
    scanner.scan(getClass().getPackage().getName());

    context.registerAlias("classPathBeanDefinitionScannerJsr330ScopeIntegrationTests.SessionScopedTestBean", "session");
    context.refresh();
    return context;
  }
View Full Code Here


    if (!this.basePackages.isEmpty()) {
      if (logger.isInfoEnabled()) {
        logger.info("Scanning base packages: [" +
            StringUtils.collectionToCommaDelimitedString(this.basePackages) + "]");
      }
      scanner.scan(this.basePackages.toArray(new String[this.basePackages.size()]));
    }

    String[] configLocations = getConfigLocations();
    if (configLocations != null) {
      for (String configLocation : configLocations) {
View Full Code Here

        catch (ClassNotFoundException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("Could not load class for config location [" + configLocation +
                "] - trying package scan. " + ex);
          }
          int count = scanner.scan(configLocation);
          if (logger.isInfoEnabled()) {
            if (count == 0) {
              logger.info("No annotated classes found for specified class/package [" + configLocation + "]");
            }
            else {
View Full Code Here

  public void classPathBeanDefinitionScanner_inheritsEnvironmentFromEnvironmentCapableBDR_scanProfileAnnotatedConfigClasses() {
    // it's actually ConfigurationClassPostProcessor's Environment that gets the job done here.
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan1");
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }
View Full Code Here

  @Test
  public void classPathBeanDefinitionScanner_inheritsEnvironmentFromEnvironmentCapableBDR_scanProfileAnnotatedComponents() {
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan2");
    ctx.refresh();
    assertThat(scanner.getEnvironment(), is((Environment)ctx.getEnvironment()));
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }
View Full Code Here

  public void genericWAC() {
    GenericWebApplicationContext ctx = new GenericWebApplicationContext();
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("bogus.pkg");

    cll.contextInitialized(new ServletContextEvent(new MockServletContext()));
  }

  /**
 
View Full Code Here

        catch (ClassNotFoundException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("Could not load class for config location [" + configLocation +
                "] - trying package scan. " + ex);
          }
          int count = scanner.scan(configLocation);
          if (logger.isInfoEnabled()) {
            if (count == 0) {
              logger.info("No annotated classes found for specified class/package [" + configLocation + "]");
            }
            else {
View Full Code Here

    ctx.registerShutdownHook();
    configureApplicationContext(ctx);
    // built-in commands and converters
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    if (commandLine.getDisableInternalCommands()) {
      scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support");
    }
    else {
      scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters",
          "org.springframework.shell.plugin.support");
    }
View Full Code Here

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    if (commandLine.getDisableInternalCommands()) {
      scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support");
    }
    else {
      scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters",
          "org.springframework.shell.plugin.support");
    }
    // user contributed commands
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
    reader.loadBeanDefinitions(contextPath);
View Full Code Here

        if (configurationPackages != null) {
            final Descriptor serverDescriptor = getService(DescriptorService.class).getServerDescriptor();
            final ClassPathBeanDefinitionScanner scanner = new AlfrescoPlatformBeanDefinitionScanner(beanFactory,
                    serverDescriptor);
            scanner.setResourceLoader(this);
            scanner.scan(configurationPackages);
        }
    }

    @Override
  protected void initBeanDefinitionReader(final XmlBeanDefinitionReader beanDefinitionReader) {
View Full Code Here

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.