Search in sources :

Example 1 with BeanInfo

use of org.jboss.as.pojo.service.BeanInfo in project wildfly by wildfly.

the class BaseBeanFactory method create.

@SuppressWarnings("unchecked")
public Object create() throws Throwable {
    Module module = bmd.getModule().getInjectedModule().getValue();
    Class<?> beanClass = module.getClassLoader().loadClass(bmd.getBeanClass());
    DeploymentReflectionIndex index = DeploymentReflectionIndex.create();
    BeanInfo beanInfo = new DefaultBeanInfo(index, beanClass);
    Object result = BeanUtils.instantiateBean(bmd, beanInfo, index, module);
    BeanUtils.configure(bmd, beanInfo, module, result, false);
    BeanUtils.dispatchLifecycleJoinpoint(beanInfo, result, bmd.getCreate(), "create");
    BeanUtils.dispatchLifecycleJoinpoint(beanInfo, result, bmd.getStart(), "start");
    return result;
}
Also used : DefaultBeanInfo(org.jboss.as.pojo.service.DefaultBeanInfo) BeanInfo(org.jboss.as.pojo.service.BeanInfo) DefaultBeanInfo(org.jboss.as.pojo.service.DefaultBeanInfo) Module(org.jboss.modules.Module) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 2 with BeanInfo

use of org.jboss.as.pojo.service.BeanInfo in project wildfly by wildfly.

the class LifecycleConfig method getType.

@Override
public Class<?> getType(ConfigVisitor visitor, ConfigVisitorNode previous) {
    if (previous instanceof ValueConfig == false)
        throw PojoLogger.ROOT_LOGGER.notValueConfig(previous);
    ValueConfig vc = (ValueConfig) previous;
    BeanInfo beanInfo = visitor.getBeanInfo();
    Method m = beanInfo.findMethod(methodName, Configurator.getTypes(parameters));
    return m.getParameterTypes()[vc.getIndex()];
}
Also used : BeanInfo(org.jboss.as.pojo.service.BeanInfo) Method(java.lang.reflect.Method)

Example 3 with BeanInfo

use of org.jboss.as.pojo.service.BeanInfo in project wildfly by wildfly.

the class ConstructorConfig method getType.

@Override
public Class<?> getType(ConfigVisitor visitor, ConfigVisitorNode previous) {
    if (factory != null)
        throw PojoLogger.ROOT_LOGGER.tooDynamicFromFactory();
    if (previous instanceof ValueConfig == false)
        throw PojoLogger.ROOT_LOGGER.notValueConfig(previous);
    ValueConfig vc = (ValueConfig) previous;
    if (factoryClass != null) {
        if (factoryMethod == null)
            throw PojoLogger.ROOT_LOGGER.nullFactoryMethod();
        BeanInfo beanInfo = getTempBeanInfo(visitor, factoryClass);
        Method m = beanInfo.findMethod(factoryMethod, Configurator.getTypes(parameters));
        return m.getParameterTypes()[vc.getIndex()];
    } else {
        BeanInfo beanInfo = visitor.getBeanInfo();
        if (beanInfo == null)
            throw PojoLogger.ROOT_LOGGER.nullBeanInfo();
        Constructor ctor = beanInfo.findConstructor(Configurator.getTypes(parameters));
        return ctor.getParameterTypes()[vc.getIndex()];
    }
}
Also used : Constructor(java.lang.reflect.Constructor) BeanInfo(org.jboss.as.pojo.service.BeanInfo) Method(java.lang.reflect.Method)

Aggregations

BeanInfo (org.jboss.as.pojo.service.BeanInfo)3 Method (java.lang.reflect.Method)2 Constructor (java.lang.reflect.Constructor)1 DefaultBeanInfo (org.jboss.as.pojo.service.DefaultBeanInfo)1 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)1 Module (org.jboss.modules.Module)1