use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class LifecycleAnnotationParsingProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
for (DotName annotationName : LIFE_CYCLE_ANNOTATIONS) {
final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName);
for (AnnotationInstance annotation : lifecycles) {
processLifeCycle(eeModuleDescription, annotation.target(), annotationName, applicationClasses);
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class ModuleJndiBindingProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(Attachments.EE_MODULE_CONFIGURATION);
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
if (moduleConfiguration == null || DeploymentUtils.skipRepeatedActivation(deploymentUnit, 0)) {
return;
}
final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES);
final Map<ServiceName, BindingConfiguration> deploymentDescriptorBindings = new HashMap<ServiceName, BindingConfiguration>();
final List<BindingConfiguration> bindingConfigurations = eeModuleDescription.getBindingConfigurations();
//we need to make sure that java:module/env and java:comp/env are always available
if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
bindingConfigurations.add(new BindingConfiguration("java:module/env", new ContextInjectionSource("env", "java:module/env")));
}
if (deploymentUnit.getParent() == null) {
bindingConfigurations.add(new BindingConfiguration("java:app/env", new ContextInjectionSource("env", "java:app/env")));
}
for (BindingConfiguration binding : bindingConfigurations) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
deploymentDescriptorBindings.put(bindInfo.getBinderServiceName(), binding);
addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
}
// these are bindings that have been added via a deployment descriptor
for (final ComponentConfiguration componentConfiguration : moduleConfiguration.getComponentConfigurations()) {
// handle these duplicates?
for (BindingConfiguration binding : componentConfiguration.getComponentDescription().getBindingConfigurations()) {
final String bindingName = binding.getName();
final boolean compBinding = bindingName.startsWith("java:comp") || !bindingName.startsWith("java:");
if (componentConfiguration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE && compBinding) {
//components with there own comp context do their own binding
continue;
}
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
deploymentDescriptorBindings.put(bindInfo.getBinderServiceName(), binding);
addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
}
}
//now add all class level bindings
final Set<String> handledClasses = new HashSet<String>();
for (final ComponentConfiguration componentConfiguration : moduleConfiguration.getComponentConfigurations()) {
final Set<Class<?>> classConfigurations = new HashSet<Class<?>>();
classConfigurations.add(componentConfiguration.getComponentClass());
for (final InterceptorDescription interceptor : componentConfiguration.getComponentDescription().getAllInterceptors()) {
try {
classConfigurations.add(ClassLoadingUtils.loadClass(interceptor.getInterceptorClassName(), module));
} catch (ClassNotFoundException e) {
throw EeLogger.ROOT_LOGGER.cannotLoadInterceptor(e, interceptor.getInterceptorClassName(), componentConfiguration.getComponentClass());
}
}
processClassConfigurations(phaseContext, applicationClasses, moduleConfiguration, deploymentDescriptorBindings, handledClasses, componentConfiguration.getComponentDescription().getNamingMode(), classConfigurations, componentConfiguration.getComponentName(), dependencies);
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class ResourceInjectionAnnotationParsingProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
if (module == null) {
return;
}
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(RESOURCE_ANNOTATION_NAME);
for (AnnotationInstance annotation : resourceAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final AnnotationValue nameValue = annotation.value("name");
final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
final AnnotationValue typeValue = annotation.value("type");
final String type = typeValue != null ? typeValue.asClass().name().toString() : null;
if (annotationTarget instanceof FieldInfo) {
final FieldInfo fieldInfo = (FieldInfo) annotationTarget;
final ClassInfo classInfo = fieldInfo.declaringClass();
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processFieldResource(phaseContext, fieldInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
} else if (annotationTarget instanceof MethodInfo) {
final MethodInfo methodInfo = (MethodInfo) annotationTarget;
ClassInfo classInfo = methodInfo.declaringClass();
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processMethodResource(phaseContext, methodInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
} else if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
}
}
final List<AnnotationInstance> resourcesAnnotations = index.getAnnotations(RESOURCES_ANNOTATION_NAME);
for (AnnotationInstance outerAnnotation : resourcesAnnotations) {
final AnnotationTarget annotationTarget = outerAnnotation.target();
if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
for (AnnotationInstance annotation : values) {
final AnnotationValue nameValue = annotation.value("name");
final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
final AnnotationValue typeValue = annotation.value("type");
final String type = (typeValue != null) ? typeValue.asClass().name().toString() : null;
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
}
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class DescriptorEnvironmentLifecycleMethodProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
if (environment != null) {
handleMethods(environment, eeModuleDescription, null);
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EEModuleConfigurationProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
if (module == null || moduleDescription == null) {
return;
}
final int startupBeansCount = moduleDescription.getStartupBeansCount();
if (deploymentUnit.getParent() == null) {
deploymentUnit.putAttachment(Attachments.STARTUP_COUNTDOWN, new StartupCountdown(startupBeansCount));
} else {
final StartupCountdown countdown = deploymentUnit.getParent().getAttachment(Attachments.STARTUP_COUNTDOWN);
// copy ref to child deployment
deploymentUnit.putAttachment(Attachments.STARTUP_COUNTDOWN, countdown);
countdown.countUp(startupBeansCount);
}
final Set<ServiceName> failed = new HashSet<ServiceName>();
final EEModuleConfiguration moduleConfiguration = new EEModuleConfiguration(moduleDescription);
deploymentUnit.putAttachment(Attachments.EE_MODULE_CONFIGURATION, moduleConfiguration);
final ClassLoader oldCl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
final Iterator<ComponentDescription> iterator = moduleDescription.getComponentDescriptions().iterator();
while (iterator.hasNext()) {
final ComponentDescription componentDescription = iterator.next();
ROOT_LOGGER.debugf("Configuring component class: %s named %s", componentDescription.getComponentClassName(), componentDescription.getComponentName());
final ComponentConfiguration componentConfiguration;
try {
componentConfiguration = componentDescription.createConfiguration(reflectionIndex.getClassIndex(ClassLoadingUtils.loadClass(componentDescription.getComponentClassName(), module)), module.getClassLoader(), module.getModuleLoader());
for (final ComponentConfigurator componentConfigurator : componentDescription.getConfigurators()) {
componentConfigurator.configure(phaseContext, componentDescription, componentConfiguration);
}
moduleConfiguration.addComponentConfiguration(componentConfiguration);
} catch (Exception e) {
if (componentDescription.isOptional()) {
// https://issues.jboss.org/browse/WFLY-924 Just log a WARN summary of which component failed and then log the cause at DEBUG level
ROOT_LOGGER.componentInstallationFailure(componentDescription.getComponentName());
ROOT_LOGGER.debugf(e, "Not installing optional component %s due to an exception", componentDescription.getComponentName());
// keep track of failed optional components
failed.add(componentDescription.getStartServiceName());
failed.add(componentDescription.getCreateServiceName());
failed.add(componentDescription.getServiceName());
iterator.remove();
} else {
throw EeLogger.ROOT_LOGGER.cannotConfigureComponent(e, componentDescription.getComponentName());
}
}
}
deploymentUnit.putAttachment(Attachments.FAILED_COMPONENTS, Collections.synchronizedSet(failed));
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCl);
}
}
Aggregations