Package grails.spring

Examples of grails.spring.BeanBuilder


            }
        }
    }

    public static BeanBuilder reloadSpringResourcesConfig(RuntimeSpringConfiguration config, GrailsApplication application, Class<?> groovySpringResourcesClass) throws InstantiationException, IllegalAccessException {
        springGroovyResourcesBeanBuilder = new BeanBuilder(null, config,Thread.currentThread().getContextClassLoader());
        springGroovyResourcesBeanBuilder.setBinding(new Binding(CollectionUtils.newMap(
            "application", application,
            "grailsApplication", application))); // GRAILS-7550
        Script script = (Script) groovySpringResourcesClass.newInstance();
        script.run();
View Full Code Here


    public ApplicationContext getParentCtx() {
        return application.getParentContext();
    }

    public BeanBuilder beans(Closure closure) {
        BeanBuilder bb = new BeanBuilder(getParentCtx(), new GroovyClassLoader(application.getClassLoader()));
        bb.invokeMethod("beans", new Object[]{closure});
        return bb;
    }
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Plugin " + this + " is participating in Spring configuration...");
        }

        Closure c = (Closure)plugin.getProperty(DO_WITH_SPRING);
        BeanBuilder bb = new BeanBuilder(getParentCtx(),springConfig, application.getClassLoader());
        Binding b = new Binding();
        b.setVariable("application", application);
        b.setVariable(GrailsApplication.APPLICATION_ID, application);
        b.setVariable("manager", getManager());
        b.setVariable("plugin", this);
        b.setVariable("parentCtx", getParentCtx());
        b.setVariable("resolver", getResolver());
        bb.setBinding(b);
        c.setDelegate(bb);
        bb.invokeMethod("beans", new Object[]{c});
    }
View Full Code Here

    @Override
    protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        if (configLocations.length > 0) {
            for (String configLocation : configLocations) {
                BeanBuilder beanBuilder = new BeanBuilder(getParent(),getClassLoader());
                final ServletContextResource resource = new ServletContextResource(getServletContext(), configLocation);
                beanBuilder.loadBeans(resource);
                beanBuilder.registerBeans(this);
            }
        }
        super.prepareBeanFactory(beanFactory);
    }
View Full Code Here

   * filename for the script must end with "MudBeans.groovy"
   *
   * e.g. /mudspace/my/weapons/WeaponMudBeans.groovy
   */
  public void initialize() {
    BeanBuilder builder = new BeanBuilder(getApplicationContext(), getGroovyScriptEngine().getGroovyClassLoader());
    try {
      logger.info("initializing..");
      builder.loadBeans("classpath*:**/*MudBeans.groovy");

    } catch (Exception e) {
      logger.error(e, e);
    } finally {
      setApplicationContext(builder.createApplicationContext());
    }
  }
View Full Code Here

  }

  public void loadDomain(String domain) {
    Binding binding = createScriptBinding();

    BeanBuilder builder = new BeanBuilder(getApplicationContext(), getEngine().getGroovyClassLoader());
    builder.setBinding(binding);
    try {
      builder.loadBeans(domain);
    } catch (IOException e) {
      logger.error(e, e);
    } finally {
      System.out.println(builder.getBeanDefinitions().keySet());
      ApplicationContext beanContext = builder.createApplicationContext();
      if (logger.isDebugEnabled()) {
        logger.debug("loaded beans from beanbuilder:" + Arrays.asList(beanContext.getBeanDefinitionNames()));
      }
      setApplicationContext(beanContext);
    }
View Full Code Here

   * filename for the script must end with "MudBeans.groovy"
   *
   * e.g. /mudspace/my/weapons/WeaponMudBeans.groovy
   */
  public void initialize() {
    BeanBuilder builder = new BeanBuilder(getApplicationContext(), getGroovyScriptEngine().getGroovyClassLoader());
    try {
      builder.loadBeans("classpath*:**/*MudBeans.groovy");
    } catch (IOException e) {
      logger.error(e, e);
    }
    setApplicationContext(builder.createApplicationContext());
  }
View Full Code Here

TOP

Related Classes of grails.spring.BeanBuilder

Copyright © 2018 www.massapicom. 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.