use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_POJO method processAnnotation.
// @Override
protected void processAnnotation(final DeploymentUnit unit, final EEModuleDescription moduleDescription) throws DeploymentUnitProcessingException {
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, unit)) {
return;
}
final Map<String, EEModuleClassDescription> classDescriptionMap = new HashMap<String, org.jboss.as.ee.component.EEModuleClassDescription>();
final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
for (EEModuleClassDescription classDescritpion : moduleDescription.getClassDescriptions()) {
if (isJaxwsEndpoint(classDescritpion, index) && !exclude(unit, classDescritpion)) {
classDescriptionMap.put(classDescritpion.getClassName(), classDescritpion);
}
}
final JBossWebMetaData jbossWebMD = getJBossWebMetaData(unit);
final JAXWSDeployment jaxwsDeployment = getJaxwsDeployment(unit);
if (jbossWebMD != null) {
final Set<String> matchedEps = new HashSet<String>();
for (final ServletMetaData servletMD : getServlets(jbossWebMD)) {
final String endpointClassName = getEndpointClassName(servletMD);
final String endpointName = getEndpointName(servletMD);
if (classDescriptionMap.containsKey(endpointClassName) || matchedEps.contains(endpointClassName)) {
// creating component description for POJO endpoint
final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
final String urlPattern = getUrlPattern(endpointName, unit);
jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
classDescriptionMap.remove(endpointClassName);
matchedEps.add(endpointClassName);
} else {
if (unit.getParent() != null && DeploymentTypeMarker.isType(DeploymentType.EAR, unit.getParent())) {
final EEModuleDescription eeModuleDescription = unit.getParent().getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex parentIndex = unit.getParent().getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
for (EEModuleClassDescription classDescription : eeModuleDescription.getClassDescriptions()) {
if (classDescription.getClassName().equals(endpointClassName) && isJaxwsEndpoint(classDescription, parentIndex)) {
final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
final String urlPattern = getUrlPattern(endpointName, unit);
jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
}
}
}
}
}
}
for (EEModuleClassDescription classDescription : classDescriptionMap.values()) {
ClassInfo classInfo = null;
String serviceName = null;
String urlPattern = null;
// #1 Override serviceName with the explicit urlPattern from port-component/port-component-uri in jboss-webservices.xml
EJBEndpoint ejbEndpoint = getWebserviceMetadataEJBEndpoint(jaxwsDeployment, classDescription.getClassName());
if (ejbEndpoint != null) {
urlPattern = UrlPatternUtils.getUrlPatternByPortComponentURI(getJBossWebserviceMetaDataPortComponent(unit, ejbEndpoint.getName()));
}
// #2 Override serviceName with @WebContext.urlPattern
if (urlPattern == null) {
final ClassAnnotationInformation<WebContext, WebContextAnnotationInfo> annotationWebContext = classDescription.getAnnotationInformation(WebContext.class);
if (annotationWebContext != null) {
WebContextAnnotationInfo wsInfo = annotationWebContext.getClassLevelAnnotations().get(0);
if (wsInfo != null && wsInfo.getUrlPattern().length() > 0) {
urlPattern = wsInfo.getUrlPattern();
}
}
}
// #3 use serviceName declared in a class annotation
if (urlPattern == null) {
final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription.getAnnotationInformation(WebService.class);
if (annotationInfo != null) {
WebServiceAnnotationInfo wsInfo = annotationInfo.getClassLevelAnnotations().get(0);
serviceName = wsInfo.getServiceName();
classInfo = (ClassInfo) wsInfo.getTarget();
urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
if (jaxwsDeployment.contains(urlPattern)) {
urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName, wsInfo.getName());
}
}
final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> annotationProviderInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
if (annotationProviderInfo != null) {
WebServiceProviderAnnotationInfo wsInfo = annotationProviderInfo.getClassLevelAnnotations().get(0);
serviceName = wsInfo.getServiceName();
classInfo = (ClassInfo) wsInfo.getTarget();
}
}
if (classInfo != null) {
final String endpointClassName = classDescription.getClassName();
final ComponentDescription pojoComponent = createComponentDescription(unit, endpointClassName, endpointClassName, endpointClassName);
final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
if (urlPattern == null) {
urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
}
// register POJO endpoint
jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointClassName, pojoViewName, UrlPatternUtils.getUrlPattern(urlPattern)));
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class AbstractIntegrationProcessorJAXWS method createComponentDescription.
static ComponentDescription createComponentDescription(final DeploymentUnit unit, final String componentName, final String componentClassName, final String dependsOnEndpointClassName) {
final EEModuleDescription moduleDescription = getRequiredAttachment(unit, EE_MODULE_DESCRIPTION);
// JBoss WEB processors may install fake components for WS endpoints - removing them forcibly
moduleDescription.removeComponent(componentName, componentClassName);
// register WS component
ComponentDescription componentDescription = new WSComponentDescription(componentName, componentClassName, moduleDescription, unit.getServiceName());
moduleDescription.addComponent(componentDescription);
// register WS dependency
final ServiceName endpointServiceName = EndpointService.getServiceName(unit, dependsOnEndpointClassName);
componentDescription.addDependency(endpointServiceName, ServiceBuilder.DependencyType.REQUIRED);
return componentDescription;
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class WSRefAnnotationProcessor method processRef.
private static void processRef(final DeploymentUnit unit, final String type, final WSRefAnnotationWrapper annotation, final ClassInfo classInfo, final InjectionTarget injectionTarget, final String bindingName) throws DeploymentUnitProcessingException {
final EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final AnnotatedElement target = createAnnotatedElement(unit, classInfo, injectionTarget);
final String componentClassName = classInfo.name().toString();
final Map<String, String> bindingMap = new HashMap<String, String>();
boolean isEJB = false;
for (final ComponentDescription componentDescription : moduleDescription.getComponentsByClassName(componentClassName)) {
if (componentDescription instanceof SessionBeanComponentDescription) {
isEJB = true;
bindingMap.put(componentDescription.getComponentName() + "/" + bindingName, bindingName);
}
}
if (!isEJB) {
bindingMap.put(bindingName, bindingName);
}
for (String refKey : bindingMap.keySet()) {
String refName = bindingMap.get(refKey);
ManagedReferenceFactory factory = WebServiceReferences.createWebServiceFactory(unit, type, annotation, target, refName, refKey);
final EEModuleClassDescription classDescription = moduleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
// Create the binding from whence our injection comes.
final InjectionSource serviceRefSource = new FixedInjectionSource(factory, factory);
final BindingConfiguration bindingConfiguration = new BindingConfiguration(refName, serviceRefSource);
classDescription.getBindingConfigurations().add(bindingConfiguration);
// our injection comes from the local lookup, no matter what.
final ResourceInjectionConfiguration injectionConfiguration = injectionTarget != null ? new ResourceInjectionConfiguration(injectionTarget, new LookupInjectionSource(refName)) : null;
if (injectionConfiguration != null) {
classDescription.addResourceInjection(injectionConfiguration);
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class WebIntegrationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription module = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// Skip non web deployments
return;
}
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no war metadata found");
return;
}
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
if (webMetaData == null) {
WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no merged web metadata found");
return;
}
if (!WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
createDependency(deploymentUnit, warMetaData);
}
return;
}
createDependency(deploymentUnit, warMetaData);
List<ListenerMetaData> listeners = webMetaData.getListeners();
if (listeners == null) {
listeners = new ArrayList<ListenerMetaData>();
webMetaData.setListeners(listeners);
} else {
//if the weld servlet listener is present remove it
//this should allow wars to be portable between AS7 and servlet containers
final ListIterator<ListenerMetaData> iterator = listeners.listIterator();
while (iterator.hasNext()) {
final ListenerMetaData listener = iterator.next();
if (listener.getListenerClass().trim().equals(WELD_SERVLET_LISTENER)) {
WeldLogger.DEPLOYMENT_LOGGER.debugf("Removing weld servlet listener %s from web config, as it is not needed in EE6 environments", WELD_SERVLET_LISTENER);
iterator.remove();
break;
}
}
}
listeners.add(0, INITIAL_LISTENER_METADATA);
listeners.add(TERMINAL_LISTENER_MEDATADA);
//These listeners use resource injection, so they need to be components
registerAsComponent(WELD_INITIAL_LISTENER, deploymentUnit);
registerAsComponent(WELD_TERMINAL_LISTENER, deploymentUnit);
deploymentUnit.addToAttachmentList(ExpressionFactoryWrapper.ATTACHMENT_KEY, WeldJspExpressionFactoryWrapper.INSTANCE);
if (webMetaData.getContextParams() == null) {
webMetaData.setContextParams(new ArrayList<ParamValueMetaData>());
}
final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_FORWARD);
setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_INCLUDE);
if (webMetaData.getFilterMappings() != null) {
// register ConversationFilter
boolean filterMappingFound = false;
for (FilterMappingMetaData mapping : webMetaData.getFilterMappings()) {
if (CONVERSATION_FILTER_NAME.equals(mapping.getFilterName())) {
filterMappingFound = true;
break;
}
}
if (filterMappingFound) {
// otherwise WeldListener will take care of conversation context activation
boolean filterFound = false;
// register ConversationFilter
if (webMetaData.getFilters() == null) {
webMetaData.setFilters(new FiltersMetaData());
}
for (FilterMetaData filter : webMetaData.getFilters()) {
if (CONVERSATION_FILTER_CLASS.equals(filter.getFilterClass())) {
filterFound = true;
break;
}
}
if (!filterFound) {
webMetaData.getFilters().add(conversationFilterMetadata);
registerAsComponent(CONVERSATION_FILTER_CLASS, deploymentUnit);
webMetaData.getContextParams().add(CONVERSATION_FILTER_INITIALIZED);
}
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class WeldImplicitDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
return;
}
if (Utils.getRootDeploymentUnit(deploymentUnit).getAttachment(WeldConfiguration.ATTACHMENT_KEY).isRequireBeanDescriptor()) {
// if running in the require-bean-descriptor mode then bean archives are found by BeansXmlProcessor
return;
}
/*
* look for classes with bean defining annotations
*/
final Set<AnnotationType> beanDefiningAnnotations = new HashSet<>(getRootDeploymentUnit(deploymentUnit).getAttachment(WeldAttachments.BEAN_DEFINING_ANNOTATIONS));
final Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
final ExplicitBeanArchiveMetadataContainer explicitBeanArchiveMetadata = deploymentUnit.getAttachment(ExplicitBeanArchiveMetadataContainer.ATTACHMENT_KEY);
final ResourceRoot classesRoot = deploymentUnit.getAttachment(WeldAttachments.CLASSES_RESOURCE_ROOT);
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
for (Entry<ResourceRoot, Index> entry : indexes.entrySet()) {
ResourceRoot resourceRoot = entry.getKey();
if (resourceRoot == classesRoot) {
// BDA for WEB-INF/classes is keyed under deploymentRoot in explicitBeanArchiveMetadata
resourceRoot = deploymentRoot;
}
/*
* Make sure bean defining annotations used in archives with bean-discovery-mode="none" are not considered here
* WFLY-4388
*/
if (explicitBeanArchiveMetadata != null && explicitBeanArchiveMetadata.getBeanArchiveMetadata().containsKey(resourceRoot)) {
continue;
}
for (final AnnotationType annotation : beanDefiningAnnotations) {
if (!entry.getValue().getAnnotations(annotation.getName()).isEmpty()) {
WeldDeploymentMarker.mark(deploymentUnit);
return;
}
}
}
/*
* look for session beans and managed beans
*/
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final Iterable<ImplicitBeanArchiveDetector> detectors = ServiceLoader.load(ImplicitBeanArchiveDetector.class, WildFlySecurityManager.getClassLoaderPrivileged(WeldImplicitDeploymentProcessor.class));
for (ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
for (ImplicitBeanArchiveDetector detector : detectors) {
if (detector.isImplicitBeanArchiveRequired(component)) {
WeldDeploymentMarker.mark(deploymentUnit);
return;
}
}
}
}
Aggregations