use of org.jboss.as.ee.component.EEModuleConfiguration in project wildfly by wildfly.
the class EjbManagementDeploymentUnitProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleConfiguration moduleDescription = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (moduleDescription == null) {
// Nothing to do
return;
}
if (deploymentUnit.getParent() != null && deploymentUnit.getParent().getParent() != null) {
// We only expose management resources 2 levels deep
return;
}
// Iterate through each component, installing it into the container
for (final ComponentConfiguration configuration : moduleDescription.getComponentConfigurations()) {
try {
final ComponentDescription componentDescription = configuration.getComponentDescription();
if (componentDescription instanceof EJBComponentDescription) {
installManagementResource(configuration, deploymentUnit);
}
} catch (RuntimeException e) {
throw EjbLogger.ROOT_LOGGER.failedToInstallManagementResource(e, configuration.getComponentName());
}
}
}
use of org.jboss.as.ee.component.EEModuleConfiguration 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 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 (Throwable 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);
}
}
use of org.jboss.as.ee.component.EEModuleConfiguration 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) {
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);
}
// now we need to process resource bindings that are not part of a component
// we don't process app client modules, as it just causes problems by installing bindings that
// were only intended to be installed when running as an app client
boolean appClient = DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit) || this.appclient;
if (!ignoreUnusedResourceBinding && !MetadataCompleteMarker.isMetadataComplete(phaseContext.getDeploymentUnit()) && !appClient) {
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
for (EEModuleClassDescription config : eeModuleDescription.getClassDescriptions()) {
if (handledClasses.contains(config.getClassName())) {
continue;
}
if (config.isInvalid()) {
continue;
}
final Set<BindingConfiguration> classLevelBindings = new HashSet<>(config.getBindingConfigurations());
// between classes and not miss out on any.)
if (!classLevelBindings.isEmpty()) {
ClassInfo classInfo = index.getClassByName(DotName.createSimple(config.getClassName()));
if (!isConcreteClass(classInfo) && !hasConcreteSubclass(index, classInfo)) {
continue;
}
}
for (BindingConfiguration binding : classLevelBindings) {
final String bindingName = binding.getName();
final boolean compBinding = bindingName.startsWith("java:comp") || !bindingName.startsWith("java:");
if (compBinding && !DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// we don't have a comp namespace
continue;
}
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
if (deploymentDescriptorBindings.containsKey(bindInfo.getBinderServiceName())) {
// this has been overridden by a DD binding
continue;
}
ROOT_LOGGER.tracef("Binding %s using service %s", binding.getName(), bindInfo.getBinderServiceName());
addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
}
}
}
}
use of org.jboss.as.ee.component.EEModuleConfiguration in project wildfly by wildfly.
the class ComponentInstallProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(MODULE);
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (module == null || moduleConfiguration == null) {
return;
}
ComponentRegistry componentRegistry = deploymentUnit.getAttachment(COMPONENT_REGISTRY);
final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES);
final ServiceName bindingDependencyService = JndiNamingDependencyProcessor.serviceName(deploymentUnit.getServiceName());
// Iterate through each component, installing it into the container
for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
try {
ROOT_LOGGER.tracef("Installing component %s", configuration.getComponentClass().getName());
deployComponent(phaseContext, configuration, dependencies, bindingDependencyService);
componentRegistry.addComponent(configuration);
// we need to make sure that the web deployment has a dependency on all components it the app, so web components are started
// when the web subsystem is starting
// we only add a dependency on components in the same sub deployment, otherwise we get circular dependencies when initialize-in-order is used
deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.WEB_DEPENDENCIES, configuration.getComponentDescription().getStartServiceName());
} catch (Exception e) {
throw EeLogger.ROOT_LOGGER.failedToInstallComponent(e, configuration.getComponentName());
}
}
}
use of org.jboss.as.ee.component.EEModuleConfiguration in project wildfly by wildfly.
the class MdbDeliveryDependenciesProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (moduleConfiguration == null) {
return;
}
// support for using capabilities to resolve service names
CapabilityServiceSupport capabilityServiceSupport = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
boolean clusteredSingletonFound = false;
for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
ComponentDescription description = configuration.getComponentDescription();
if (description instanceof MessageDrivenComponentDescription) {
final MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
if (mdbDescription.isDeliveryControlled()) {
final MdbDeliveryControllerService mdbDeliveryControllerService = new MdbDeliveryControllerService();
final ServiceBuilder<MdbDeliveryControllerService> builder = serviceTarget.addService(mdbDescription.getDeliveryControllerName(), mdbDeliveryControllerService).addDependency(description.getCreateServiceName(), MessageDrivenComponent.class, mdbDeliveryControllerService.getMdbComponent()).setInitialMode(Mode.PASSIVE);
if (mdbDescription.isClusteredSingleton()) {
clusteredSingletonFound = true;
builder.requires(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName());
builder.addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName());
}
if (mdbDescription.getDeliveryGroups() != null) {
for (String deliveryGroup : mdbDescription.getDeliveryGroups()) {
final ServiceName deliveryGroupServiceName = capabilityServiceSupport.getCapabilityServiceName(MDB_DELIVERY_GROUP_CAPABILITY_NAME, deliveryGroup);
if (phaseContext.getServiceRegistry().getService(deliveryGroupServiceName) == null) {
throw EjbLogger.DEPLOYMENT_LOGGER.missingMdbDeliveryGroup(deliveryGroup);
}
builder.addDependency(deliveryGroupServiceName);
}
}
builder.install();
}
}
}
if (clusteredSingletonFound) {
// Add dependency on the singleton barrier, which starts on-demand
// (the MDB delivery controller won't demand the singleton barrier service to start)
serviceTarget.addDependency(SingletonBarrierService.SERVICE_NAME);
}
}
Aggregations