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();
}
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);
}
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());
}
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());
}
}
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));
}
}
Aggregations