Example usage for org.springframework.beans.factory BeanFactory getClass

List of usage examples for org.springframework.beans.factory BeanFactory getClass

Introduction

In this page you can find the example usage for org.springframework.beans.factory BeanFactory getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

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

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    checkState(AutowireCapableBeanFactory.class.isInstance(beanFactory),
            "BeanFactory must be of type AutowireCapableBeanFactory but found %s", beanFactory.getClass());
    this.beanFactory = AutowireCapableBeanFactory.class.cast(beanFactory);
}

From source file:org.jclouds.demo.tweetstore.config.LoggingConfig.java

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    checkArgument(beanFactory instanceof AutowireCapableBeanFactory,
            "expected an instance of '%s' but was '%s'", AutowireCapableBeanFactory.class,
            beanFactory.getClass());
    this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
}

From source file:de.hybris.platform.addonsupport.config.SpelBeanFactory.java

@Override
public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
    if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
        throw new IllegalStateException(
                "SpelBeanFactory doesn't work with a BeanFactory which does not implement ConfigurableListableBeanFactory: "
                        + beanFactory.getClass());
    }/*from   ww w  .  j a  v  a  2 s.c om*/
    this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}

From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java

@Override
public void setBeanFactory(BeanFactory beanFactory) {
    if (!(beanFactory instanceof ConfigurableBeanFactory)) {
        throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with a BeanFactory "
                + "which does not implement ConfigurableBeanFactory: " + beanFactory.getClass());
    }/*from  www.  j  av  a 2  s . c  o m*/
    this.beanFactory = (ConfigurableBeanFactory) beanFactory;

    // Required so that references (up container hierarchies) are correctly resolved.
    this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

    // Required so that all BeanPostProcessors, Scopes, etc become available.
    this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

    // Filter out BeanPostProcessors that are part of the AOP infrastructure,
    // since those are only meant to apply to beans defined in the original factory.
    for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it
            .hasNext();) {
        if (it.next() instanceof AopInfrastructureBean) {
            it.remove();
        }
    }
}

From source file:net.mojodna.sprout.Sprout.java

public final void setBeanFactory(final BeanFactory factory) throws BeansException {
    if (!factory.isSingleton(beanName)) {
        log.warn(getClass().getName() + " must be defined with singleton=\"true\" in order to self-register.");
        return;/*  ww  w. j a v a 2 s  .  c  o  m*/
    }

    final String pkgName = getClass().getPackage().getName();
    final String path = pkgName.substring(pkgName.indexOf(PACKAGE_DELIMITER) + PACKAGE_DELIMITER.length())
            .replace('.', '/') + "/";

    if (factory instanceof AbstractBeanFactory) {
        final AbstractBeanFactory dlbf = (AbstractBeanFactory) factory;

        final Collection<Method> methods = SproutUtils.getDeclaredMethods(getClass(), Sprout.class);

        // register beans for each url
        log.debug("Registering paths...");
        for (final Iterator<Method> i = methods.iterator(); i.hasNext();) {
            final Method method = i.next();
            String name = method.getName();
            if (Modifier.isPublic(method.getModifiers())
                    && method.getReturnType().equals(ActionForward.class)) {
                if (name.equals("publick"))
                    name = "public";
                final String url = path + name.replaceAll("([A-Z])", "_$1").toLowerCase();
                log.debug(url);
                if (!ArrayUtils.contains(dlbf.getAliases(beanName), url))
                    dlbf.registerAlias(beanName, url);
            }
        }
    } else {
        log.warn("Unable to self-register; factory bean was of an unsupported type.");
        throw new BeanNotOfRequiredTypeException(beanName, AbstractBeanFactory.class, factory.getClass());
    }
}

From source file:org.impalaframework.spring.service.SpringServiceBeanUtils.java

static BeanDefinition getBeanDefinition(BeanFactory beanFactory, String beanName) {
    if (beanFactory instanceof BeanDefinitionRegistry) {
        return ((BeanDefinitionRegistry) beanFactory).getBeanDefinition(beanName);
    }/*from   w  w  w .  ja  v a  2 s.  co  m*/
    if (beanFactory instanceof BeanDefinitionExposing) {
        BeanDefinition beanDefinition = ((BeanDefinitionExposing) beanFactory).getBeanDefinition(beanName);
        return beanDefinition;
    }

    throw new InvalidStateException("Cannot get bean definition as bean factory ["
            + beanFactory.getClass().getName() + "] does not implement [" + BeanDefinitionRegistry.class
            + "] or " + BeanDefinitionExposing.class.getName() + "]");
}

From source file:org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator.java

@Override
public final void setBeanFactory(BeanFactory beanFactory) {
    if (!(beanFactory instanceof ConfigurableBeanFactory)) {
        throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory "
                + "that doesn't implement ConfigurableBeanFactory: " + beanFactory.getClass());
    }//  ww w  . java 2 s.c  o m
    this.beanFactory = (ConfigurableBeanFactory) beanFactory;
}

From source file:org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.java

public void setBeanFactory(BeanFactory beanFactory) {
    Assert.isAssignable(ConfigurableListableBeanFactory.class, beanFactory.getClass(),
            "a ConfigurableListableBeanFactory is required");
    this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}

From source file:org.springframework.scripting.support.ScriptFactoryPostProcessor.java

@Override
public void setBeanFactory(BeanFactory beanFactory) {
    if (!(beanFactory instanceof ConfigurableBeanFactory)) {
        throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with "
                + "non-ConfigurableBeanFactory: " + beanFactory.getClass());
    }/*w w w . jav a 2 s  .  c  o  m*/
    this.beanFactory = (ConfigurableBeanFactory) beanFactory;

    // Required so that references (up container hierarchies) are correctly resolved.
    this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

    // Required so that all BeanPostProcessors, Scopes, etc become available.
    this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

    // Filter out BeanPostProcessors that are part of the AOP infrastructure,
    // since those are only meant to apply to beans defined in the original factory.
    for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it
            .hasNext();) {
        if (it.next() instanceof AopInfrastructureBean) {
            it.remove();
        }
    }
}

From source file:org.springframework.statemachine.processor.StateMachineAnnotationPostProcessor.java

@Override
public void setBeanFactory(BeanFactory beanFactory) {
    Assert.isAssignable(ConfigurableListableBeanFactory.class, beanFactory.getClass(),
            "a ConfigurableListableBeanFactory is required");
    this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}