Search in sources :

Example 1 with ClassReflectionIndex

use of org.jboss.as.server.deployment.reflect.ClassReflectionIndex in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addServices.

private void addServices(final ServiceTarget target, final JBossServiceConfig mBeanConfig, final ClassLoader classLoader, final DeploymentReflectionIndex index, ServiceComponentInstantiator componentInstantiator, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final String mBeanClassName = mBeanConfig.getCode();
    final List<ClassReflectionIndex> mBeanClassHierarchy = ReflectionUtils.getClassHierarchy(mBeanClassName, index, classLoader);
    final Object mBeanInstance = newInstance(mBeanConfig, mBeanClassHierarchy, classLoader);
    final String mBeanName = mBeanConfig.getName();
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final MBeanServices mBeanServices = new MBeanServices(mBeanName, mBeanInstance, mBeanClassHierarchy, target, componentInstantiator, deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS), classLoader, mbeanServerServiceName);
    final JBossServiceDependencyConfig[] dependencyConfigs = mBeanConfig.getDependencyConfigs();
    addDependencies(dependencyConfigs, mBeanClassHierarchy, mBeanServices);
    final JBossServiceDependencyListConfig[] dependencyListConfigs = mBeanConfig.getDependencyConfigLists();
    addDependencyLists(dependencyListConfigs, mBeanClassHierarchy, mBeanServices);
    final JBossServiceAttributeConfig[] attributeConfigs = mBeanConfig.getAttributeConfigs();
    addAttributes(attributeConfigs, mBeanClassHierarchy, mBeanServices, classLoader);
    // register all mBean related services
    mBeanServices.install();
}
Also used : JBossServiceDependencyListConfig(org.jboss.as.service.descriptor.JBossServiceDependencyListConfig) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) JBossServiceAttributeConfig(org.jboss.as.service.descriptor.JBossServiceAttributeConfig) JBossServiceDependencyConfig(org.jboss.as.service.descriptor.JBossServiceDependencyConfig) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 2 with ClassReflectionIndex

use of org.jboss.as.server.deployment.reflect.ClassReflectionIndex in project wildfly by wildfly.

the class ReflectionUtils method getSetter.

static Method getSetter(final List<ClassReflectionIndex> classHierarchy, final String propertyName) {
    final String setterName = "set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
    for (final ClassReflectionIndex classIndex : classHierarchy) {
        final Iterator<Method> methods = classIndex.getMethods().iterator();
        Method method = null;
        String methodName = null;
        while (methods.hasNext()) {
            method = methods.next();
            methodName = method.getName();
            if (setterName.equals(methodName) && method.getParameterTypes().length == 1) {
                return method;
            }
        }
    }
    final String className = classHierarchy.get(0).getIndexedClass().getName();
    throw SarLogger.ROOT_LOGGER.propertyMethodNotFound("Set", propertyName, className);
}
Also used : ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) Method(java.lang.reflect.Method)

Example 3 with ClassReflectionIndex

use of org.jboss.as.server.deployment.reflect.ClassReflectionIndex in project wildfly by wildfly.

the class Configurator method findMethod.

/**
     * Find method info
     *
     * @param index      the deployment reflection index
     * @param classInfo  the class info
     * @param name       the method name
     * @param paramTypes the parameter types
     * @param isStatic   must the method be static
     * @param isPublic   must the method be public
     * @param strict     is strict about method modifiers
     * @return the method info
     * @throws IllegalArgumentException when no such method
     */
@SuppressWarnings("unchecked")
public static Method findMethod(DeploymentReflectionIndex index, Class classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws IllegalArgumentException {
    if (name == null)
        throw PojoLogger.ROOT_LOGGER.nullName();
    if (classInfo == null)
        throw PojoLogger.ROOT_LOGGER.nullClassInfo();
    if (paramTypes == null)
        paramTypes = NO_PARAMS_TYPES;
    Class current = classInfo;
    while (current != null) {
        ClassReflectionIndex cri = index.getClassIndex(classInfo);
        Method result = locateMethod(cri, name, paramTypes, isStatic, isPublic, strict);
        if (result != null)
            return result;
        current = current.getSuperclass();
    }
    throw PojoLogger.ROOT_LOGGER.methodNotFound(name, Arrays.toString(paramTypes), classInfo.getName());
}
Also used : ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) Method(java.lang.reflect.Method)

Example 4 with ClassReflectionIndex

use of org.jboss.as.server.deployment.reflect.ClassReflectionIndex in project wildfly by wildfly.

the class JwsWebServiceEndpointVerifier method verifyFinalizeMethod.

void verifyFinalizeMethod() {
    ClassReflectionIndex classReflectionIndex = deploymentReflectionIndex.getClassIndex(endpointClass);
    Method finalizeMethod = classReflectionIndex.getMethod(void.class, "finalize");
    if (finalizeMethod != null) {
        verificationFailures.add(new ImplementationHasFinalize());
    }
}
Also used : ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method)

Example 5 with ClassReflectionIndex

use of org.jboss.as.server.deployment.reflect.ClassReflectionIndex in project wildfly by wildfly.

the class SessionSynchronizationMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription description) throws DeploymentUnitProcessingException {
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(Attachments.REFLECTION_INDEX);
    //if we implement SessionSynchronization we can ignore any DD information
    if (SessionSynchronization.class.isAssignableFrom(componentClass)) {
        final ClassReflectionIndex classIndex = reflectionIndex.getClassIndex(SessionSynchronization.class);
        description.setAfterBegin(classIndex.getMethod(void.class, "afterBegin"));
        description.setAfterCompletion(classIndex.getMethod(void.class, "afterCompletion", boolean.class));
        description.setBeforeCompletion(classIndex.getMethod(void.class, "beforeCompletion"));
        return;
    }
    SessionBeanMetaData data = description.getDescriptorData();
    if (data instanceof SessionBean31MetaData) {
        SessionBean31MetaData metaData = (SessionBean31MetaData) data;
        if (metaData.getAfterBeginMethod() != null)
            description.setAfterBegin(MethodResolutionUtils.resolveMethod(metaData.getAfterBeginMethod(), componentClass, reflectionIndex));
        if (metaData.getAfterCompletionMethod() != null)
            description.setAfterCompletion(MethodResolutionUtils.resolveMethod(metaData.getAfterCompletionMethod(), componentClass, reflectionIndex));
        if (metaData.getBeforeCompletionMethod() != null)
            description.setBeforeCompletion(MethodResolutionUtils.resolveMethod(metaData.getBeforeCompletionMethod(), componentClass, reflectionIndex));
    }
}
Also used : SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData)

Aggregations

ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)29 Method (java.lang.reflect.Method)24 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)8 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)6 HashMap (java.util.HashMap)5 List (java.util.List)5 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)5 ViewDescription (org.jboss.as.ee.component.ViewDescription)5 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)5 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)5 Module (org.jboss.modules.Module)5 ArrayList (java.util.ArrayList)4 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)4 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)4 WriteReplaceInterface (org.jboss.as.ee.component.serialization.WriteReplaceInterface)4 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)4 Map (java.util.Map)3 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)3