use of org.jboss.as.ee.component.EEApplicationClasses in project wildfly by wildfly.
the class JPAAnnotationProcessor method deploy.
@Override
public void deploy(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);
// @PersistenceContext
List<AnnotationInstance> persistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXT_ANNOTATION_NAME);
// create binding and injection configurations out of the @PersistenceContext annotations
this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceContexts, applicationClasses);
// @PersistenceContexts
List<AnnotationInstance> collectionPersistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXTS_ANNOTATION_NAME);
// create binding and injection configurations out of the @PersistenceContext annotations
processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceContexts, applicationClasses);
// @PersistenceUnits
List<AnnotationInstance> collectionPersistenceunits = index.getAnnotations(PERSISTENCE_UNITS_ANNOTATION_NAME);
processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceunits, applicationClasses);
// @PersistenceUnit
List<AnnotationInstance> persistenceUnits = index.getAnnotations(PERSISTENCE_UNIT_ANNOTATION_NAME);
// create binding and injection configurations out of the @PersistenceUnit annotations
this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceUnits, applicationClasses);
// if we found any @PersistenceContext or @PersistenceUnit annotations then mark this as a JPA deployment
if (!persistenceContexts.isEmpty() || !persistenceUnits.isEmpty() || !collectionPersistenceContexts.isEmpty() || !collectionPersistenceunits.isEmpty()) {
JPADeploymentMarker.mark(deploymentUnit);
}
}
use of org.jboss.as.ee.component.EEApplicationClasses in project wildfly by wildfly.
the class WebComponentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
return;
}
final Map<String, ComponentDescription> componentByClass = new HashMap<String, ComponentDescription>();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
if (moduleDescription == null) {
//not an EE deployment
return;
}
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
componentByClass.put(component.getComponentClassName(), component);
}
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
final Set<String> classes = getAllComponentClasses(deploymentUnit, compositeIndex, warMetaData, tldsMetaData);
for (String clazz : classes) {
if (clazz == null || clazz.trim().isEmpty()) {
continue;
}
ComponentDescription description = componentByClass.get(clazz);
if (description != null) {
//TODO: make sure the component is a managed bean
if (!(description.getViews().size() == 1)) {
throw UndertowLogger.ROOT_LOGGER.wrongComponentType(clazz);
}
} else {
//we do not make the standard tags into components, as there is no need
if (compositeIndex.getClassByName(DotName.createSimple(clazz)) == null) {
boolean found = false;
for (String pack : BUILTIN_TAGLIBS) {
if (clazz.startsWith(pack)) {
found = true;
break;
}
}
if (found) {
continue;
}
}
description = new WebComponentDescription(clazz, clazz, moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription);
moduleDescription.addComponent(description);
deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, description.getStartServiceName());
}
}
}
use of org.jboss.as.ee.component.EEApplicationClasses 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.EEApplicationClasses in project wildfly by wildfly.
the class ApplicationClientManifestProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
return;
}
final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Manifest manifest = root.getAttachment(Attachments.MANIFEST);
if (manifest != null) {
Attributes main = manifest.getMainAttributes();
if (main != null) {
String mainClass = main.getValue("Main-Class");
if (mainClass != null && !mainClass.isEmpty()) {
try {
final Class<?> clazz = module.getClassLoader().loadClass(mainClass);
deploymentUnit.putAttachment(AppClientAttachments.MAIN_CLASS, clazz);
final ApplicationClientComponentDescription description = new ApplicationClientComponentDescription(clazz.getName(), moduleDescription, deploymentUnit.getServiceName(), applicationClasses);
moduleDescription.addComponent(description);
deploymentUnit.putAttachment(AppClientAttachments.APPLICATION_CLIENT_COMPONENT, description);
final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
if (environment != null) {
DescriptorEnvironmentLifecycleMethodProcessor.handleMethods(environment, moduleDescription, mainClass);
}
} catch (ClassNotFoundException e) {
throw AppClientLogger.ROOT_LOGGER.cannotLoadAppClientMainClass(e);
}
}
}
}
}
use of org.jboss.as.ee.component.EEApplicationClasses in project wildfly by wildfly.
the class InterceptorAnnotationProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
return;
}
if (componentConfigurations == null || componentConfigurations.isEmpty()) {
return;
}
for (final ComponentDescription description : componentConfigurations) {
processComponentConfig(applicationClasses, deploymentReflectionIndex, description, deploymentUnit);
}
}
Aggregations