use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class WeldComponentIntegrationProcessor method addWeldIntegration.
/**
* As the weld based instantiator needs access to the bean manager it is installed as a service.
*/
private void addWeldIntegration(final Iterable<ComponentIntegrator> componentIntegrators, final ComponentInterceptorSupport componentInterceptorSupport, final ServiceTarget target, final ComponentConfiguration configuration, final ComponentDescription description, final Class<?> componentClass, final String beanName, final ServiceName weldServiceName, final ServiceName weldStartService, final ServiceName beanManagerService, final Set<Class<?>> interceptorClasses, final ClassLoader classLoader, final String beanDeploymentArchiveId) {
final ServiceName serviceName = configuration.getComponentDescription().getServiceName().append("WeldInstantiator");
final WeldComponentService weldComponentService = new WeldComponentService(componentClass, beanName, interceptorClasses, classLoader, beanDeploymentArchiveId, description.isCDIInterceptorEnabled(), description, isComponentWithView(description, componentIntegrators));
final ServiceBuilder<WeldComponentService> builder = target.addService(serviceName, weldComponentService).addDependency(weldServiceName, WeldBootstrapService.class, weldComponentService.getWeldContainer()).addDependency(weldStartService);
configuration.setInstanceFactory(WeldManagedReferenceFactory.INSTANCE);
configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, ComponentStartService service) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(serviceName);
}
});
boolean isComponentIntegrationPerformed = false;
for (ComponentIntegrator componentIntegrator : componentIntegrators) {
Supplier<ServiceName> bindingServiceNameSupplier = () -> {
if (componentInterceptorSupport == null) {
WeldLogger.DEPLOYMENT_LOGGER.componentInterceptorSupportNotAvailable(componentClass);
}
return addWeldInterceptorBindingService(target, configuration, componentClass, beanName, weldServiceName, weldStartService, beanDeploymentArchiveId, componentInterceptorSupport);
};
DefaultInterceptorIntegrationAction integrationAction = (bindingServiceName) -> {
if (componentInterceptorSupport == null) {
WeldLogger.DEPLOYMENT_LOGGER.componentInterceptorSupportNotAvailable(componentClass);
}
addJsr299BindingsCreateInterceptor(configuration, description, beanName, weldServiceName, builder, bindingServiceName, componentInterceptorSupport);
addCommonLifecycleInterceptionSupport(configuration, builder, bindingServiceName, beanManagerService, componentInterceptorSupport);
configuration.addComponentInterceptor(new UserInterceptorFactory(factory(InterceptionType.AROUND_INVOKE, builder, bindingServiceName, componentInterceptorSupport), factory(InterceptionType.AROUND_TIMEOUT, builder, bindingServiceName, componentInterceptorSupport)), InterceptorOrder.Component.CDI_INTERCEPTORS, false);
};
if (componentIntegrator.integrate(beanManagerService, configuration, description, builder, bindingServiceNameSupplier, integrationAction, componentInterceptorSupport)) {
isComponentIntegrationPerformed = true;
break;
}
}
if (!isComponentIntegrationPerformed) {
//otherwise they will be called twice
description.setIgnoreLifecycleInterceptors(true);
// for components with no view register interceptors that delegate to InjectionTarget lifecycle methods to trigger lifecycle interception
configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new AbstractInjectionTargetDelegatingInterceptor() {
@Override
protected void run(Object instance) {
weldComponentService.getInjectionTarget().postConstruct(instance);
}
}), InterceptorOrder.ComponentPostConstruct.CDI_INTERCEPTORS);
configuration.addPreDestroyInterceptor(new ImmediateInterceptorFactory(new AbstractInjectionTargetDelegatingInterceptor() {
@Override
protected void run(Object instance) {
weldComponentService.getInjectionTarget().preDestroy(instance);
}
}), InterceptorOrder.ComponentPreDestroy.CDI_INTERCEPTORS);
}
builder.install();
configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new WeldInjectionContextInterceptor(weldComponentService)), InterceptorOrder.ComponentPostConstruct.WELD_INJECTION_CONTEXT_INTERCEPTOR);
configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new WeldInterceptorInjectionInterceptor(interceptorClasses)), InterceptorOrder.ComponentPostConstruct.INTERCEPTOR_WELD_INJECTION);
configuration.addPostConstructInterceptor(WeldInjectionInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.COMPONENT_WELD_INJECTION);
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class WeldJaxwsInjectionServices method registerWebServiceRefInjectionPoint.
@Override
public <T> ResourceReferenceFactory<T> registerWebServiceRefInjectionPoint(final InjectionPoint injectionPoint) {
WebServiceRef annotation = getResourceAnnotated(injectionPoint).getAnnotation(WebServiceRef.class);
if (annotation == null) {
throw WeldLogger.ROOT_LOGGER.annotationNotFound(WebServiceRef.class, injectionPoint.getMember());
}
validateWebServiceRefInjectionPoint(injectionPoint, annotation);
try {
ManagedReferenceFactory factory = WebServiceReferences.createWebServiceFactory(deploymentUnit, classNameFromType(injectionPoint.getType()), new WSRefAnnotationWrapper(annotation), (AnnotatedElement) injectionPoint.getMember(), getBindingName(injectionPoint, annotation));
return new ManagedReferenceFactoryToResourceReferenceFactoryAdapter<>(factory);
} catch (DeploymentUnitProcessingException e) {
throw new RuntimeException(e);
}
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class WildFlyJobXmlResolver method forDeployment.
/**
* Creates the {@linkplain JobXmlResolver resolver} for the deployment inheriting any visible resolvers and job XML
* files from dependencies.
*
* @param deploymentUnit the deployment to process
*
* @return the resolve
*
* @throws DeploymentUnitProcessingException if an error occurs processing the deployment
*/
public static WildFlyJobXmlResolver forDeployment(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
// If this deployment unit already has a resolver, just use it
if (deploymentUnit.hasAttachment(BatchAttachments.JOB_XML_RESOLVER)) {
return deploymentUnit.getAttachment(BatchAttachments.JOB_XML_RESOLVER);
}
// Get the module for it's class loader
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final ClassLoader classLoader = module.getClassLoader();
WildFlyJobXmlResolver resolver;
// access to the EAR/lib directory so those resources need to be processed
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
// Create a new WildFlyJobXmlResolver without jobs from sub-deployments as they'll be processed later
final List<ResourceRoot> resources = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS).stream().filter(r -> !SubDeploymentMarker.isSubDeployment(r)).collect(Collectors.toList());
resolver = create(classLoader, resources);
deploymentUnit.putAttachment(BatchAttachments.JOB_XML_RESOLVER, resolver);
} else {
// Create a new resolver for this deployment
if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
resolver = create(classLoader, deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS));
} else {
resolver = create(classLoader, Collections.singletonList(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT)));
}
deploymentUnit.putAttachment(BatchAttachments.JOB_XML_RESOLVER, resolver);
// Process all accessible sub-deployments
final List<DeploymentUnit> accessibleDeployments = deploymentUnit.getAttachmentList(Attachments.ACCESSIBLE_SUB_DEPLOYMENTS);
for (DeploymentUnit subDeployment : accessibleDeployments) {
// Skip our self
if (deploymentUnit.equals(subDeployment)) {
continue;
}
if (subDeployment.hasAttachment(BatchAttachments.JOB_XML_RESOLVER)) {
final WildFlyJobXmlResolver toCopy = subDeployment.getAttachment(BatchAttachments.JOB_XML_RESOLVER);
WildFlyJobXmlResolver.merge(resolver, toCopy);
} else {
// We need to create a resolver for the sub-deployment and merge the two
final WildFlyJobXmlResolver toCopy = forDeployment(subDeployment);
subDeployment.putAttachment(BatchAttachments.JOB_XML_RESOLVER, toCopy);
WildFlyJobXmlResolver.merge(resolver, toCopy);
}
}
}
return resolver;
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class ApplicationClientParsingDeploymentProcessor method parseAppClient.
private ApplicationClientMetaData parseAppClient(DeploymentUnit deploymentUnit, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CLIENT_DEPLOYMENT_DESCRIPTOR);
// Locate the descriptor
final VirtualFile descriptor;
if (alternateDescriptor != null) {
descriptor = alternateDescriptor;
} else {
descriptor = deploymentRoot.getRoot().getChild(APP_XML);
}
if (descriptor.exists()) {
InputStream is = null;
try {
is = descriptor.openStream();
ApplicationClientMetaData data = new ApplicationClientMetaDataParser().parse(getXMLStreamReader(is), propertyReplacer);
return data;
} catch (XMLStreamException e) {
throw AppClientLogger.ROOT_LOGGER.failedToParseXml(e, descriptor, e.getLocation().getLineNumber(), e.getLocation().getColumnNumber());
} catch (IOException e) {
throw new DeploymentUnitProcessingException("Failed to parse " + descriptor, e);
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
// Ignore
}
}
} else {
return null;
}
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class RaXmlDeploymentProcessor method deploy.
/**
* Process a deployment for a Connector. Will install a {@Code
* JBossService} for this ResourceAdapter.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ManagementResourceRegistration baseRegistration = deploymentUnit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
final ManagementResourceRegistration registration;
final Resource deploymentResource = phaseContext.getDeploymentUnit().getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
final ConnectorXmlDescriptor connectorXmlDescriptor = deploymentUnit.getAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY);
if (connectorXmlDescriptor == null) {
// Skip non ra deployments
return;
}
if (deploymentUnit.getParent() != null) {
registration = baseRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement("subdeployment")));
} else {
registration = baseRegistration;
}
ResourceAdaptersService.ModifiableResourceAdaptors raxmls = null;
final ServiceController<?> raService = phaseContext.getServiceRegistry().getService(ConnectorServices.RESOURCEADAPTERS_SERVICE);
if (raService != null)
raxmls = ((ResourceAdaptersService.ModifiableResourceAdaptors) raService.getValue());
ROOT_LOGGER.tracef("processing Raxml");
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (module == null)
throw ConnectorLogger.ROOT_LOGGER.failedToGetModuleAttachment(deploymentUnit);
try {
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
String deploymentUnitPrefix = "";
if (deploymentUnit.getParent() != null) {
deploymentUnitPrefix = deploymentUnit.getParent().getName() + "#";
}
final String deploymentUnitName = deploymentUnitPrefix + deploymentUnit.getName();
if (raxmls != null) {
for (Activation raxml : raxmls.getActivations()) {
String rarName = raxml.getArchive();
if (deploymentUnitName.equals(rarName)) {
RaServicesFactory.createDeploymentService(registration, connectorXmlDescriptor, module, serviceTarget, deploymentUnitName, deploymentUnit.getServiceName(), deploymentUnitName, raxml, deploymentResource, phaseContext.getServiceRegistry());
}
}
}
//create service pointing to rar for other future activations
ServiceName serviceName = ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(deploymentUnitName);
InactiveResourceAdapterDeploymentService service = new InactiveResourceAdapterDeploymentService(connectorXmlDescriptor, module, deploymentUnitName, deploymentUnitName, deploymentUnit.getServiceName(), registration, serviceTarget, deploymentResource);
ServiceBuilder builder = serviceTarget.addService(serviceName, service);
builder.setInitialMode(Mode.ACTIVE).install();
} catch (Throwable t) {
throw new DeploymentUnitProcessingException(t);
}
}
Aggregations