Example usage for org.springframework.beans.factory.config AutowireCapableBeanFactory createBean

List of usage examples for org.springframework.beans.factory.config AutowireCapableBeanFactory createBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config AutowireCapableBeanFactory createBean.

Prototype

<T> T createBean(Class<T> beanClass) throws BeansException;

Source Link

Document

Fully create a new bean instance of the given class.

Usage

From source file:guru.qas.martini.runtime.event.EventManagerConfiguration.java

@Bean
EventManager getEventManger(AutowireCapableBeanFactory beanFactory,
        @Value("${martini.event.manager.impl:#{null}}") Class<? extends EventManager> implementation) {
    return null == implementation ? beanFactory.createBean(DefaultEventManager.class)
            : beanFactory.createBean(implementation);
}

From source file:de.fhg.igd.vaadin.util.servlets.AutowiringApplicationServlet.java

/**
 * Create and configure a new instance of the configured application class.
 *
 * <p>/*  w  w  w.  j av a2 s.c  o  m*/
 * The implementation in {@link AutowiringApplicationServlet} delegates to
 * {@link #getAutowireCapableBeanFactory getAutowireCapableBeanFactory()}, then invokes
 * {@link AutowireCapableBeanFactory#createBean AutowireCapableBeanFactory.createBean()}
 * using the configured {@link Application} class.
 * </p>
 *
 * @param request the triggering {@link HttpServletRequest}
 * @throws ServletException if creation or autowiring fails
 */
@Override
protected Application getNewApplication(HttpServletRequest request) throws ServletException {
    final Class<? extends Application> cl;
    try {
        cl = getApplicationClass();
    } catch (final ClassNotFoundException e) {
        throw new ServletException("failed to determine ApplicationClass", e);
    }
    try {
        final AutowireCapableBeanFactory beanFactory = getAutowireCapableBeanFactory();
        return beanFactory.createBean(cl);
    } catch (final BeansException e) {
        throw new ServletException("failed to create new instance of " + cl, e);
    }
}

From source file:com.expressui.core.util.SpringApplicationServlet.java

@Override
protected Application getNewApplication(HttpServletRequest request) throws ServletException {
    Class<? extends Application> applicationClass;
    try {/*from   w ww  . ja va 2 s. c o  m*/
        applicationClass = getApplicationClass();
    } catch (ClassNotFoundException e) {
        throw new ServletException(e);
    }
    AutowireCapableBeanFactory beanFactory = getAutowireCapableBeanFactory();
    try {
        Application application = beanFactory.createBean(applicationClass);
        log.debug("Created new Application of type: " + applicationClass);
        return application;
    } catch (BeansException e) {
        throw new ServletException(e);
    }
}

From source file:nijhof2axon.ui.AutowiringApplicationServlet.java

/**
 * Create and configure a new instance of the configured application class.
 * <p/>/*  w w  w .  j  a  v a  2 s . c  o m*/
 * <p>
 * The implementation in {@link AutowiringApplicationServlet} delegates to
 * {@link #getAutowireCapableBeanFactory getAutowireCapableBeanFactory()}, then invokes
 * {@link AutowireCapableBeanFactory#createBean AutowireCapableBeanFactory.createBean()}
 * using the configured {@link Application} class.
 * </p>
 *
 * @param request the triggering {@link HttpServletRequest}
 * @throws ServletException if creation or autowiring fails
 */
@Override
protected Application getNewApplication(HttpServletRequest request) throws ServletException {
    Class<? extends Application> cl = null;
    try {
        cl = getApplicationClass();
    } catch (ClassNotFoundException e) {
        throw new ServletException("failed to find the application class ", e);
    }
    log.debug("creating new instance of " + cl);
    AutowireCapableBeanFactory beanFactory = getAutowireCapableBeanFactory();
    try {
        return beanFactory.createBean(cl);
    } catch (BeansException e) {
        throw new ServletException("failed to create new instance of " + cl, e);
    }
}

From source file:com.qpark.eip.core.spring.lockedoperation.AbstractAsyncLockableOperation.java

/**
 * Invoke the real logic of the {@link LockableOperation}.
 *
 * @param context/*  w  w w . ja v a 2 s.c om*/
 *            the {@link LockableOperationContext} (could be
 *            <code>null</code>) to pass to the {@link LockableOperation}.
 */
@Override
protected final void invokeOperation(final LockableOperationContext context) {
    this.getLogger().debug("Create AsyncRunner for the operation {} ({})",
            new Object[] { this.getName(), this.getUUID() });
    AutowireCapableBeanFactory beanFactory = this.applicationContext.getAutowireCapableBeanFactory();
    AsyncLockableOperationRunner operationRunner = beanFactory.createBean(AsyncLockableOperationRunner.class);
    beanFactory.initializeBean(operationRunner,
            new StringBuffer(this.getName()).append(System.currentTimeMillis()).toString());

    operationRunner.setOperation(this);
    operationRunner.setContext(context);

    SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(
            new StringBuffer("exec").append(this.getName()).toString());
    executor.submit(operationRunner);
    this.getLogger().debug("AsyncRunner of operation {} ({}) started with SimpleAsyncTaskExecutor",
            new Object[] { this.getName(), this.getUUID() });
}