@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 List<AnnotationInstance> aroundInvokes = index.getAnnotations(AROUND_INVOKE_ANNOTATION_NAME); for (AnnotationInstance annotation : aroundInvokes) { processAroundInvoke(eeModuleDescription, annotation.target()); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final Set<Class<? extends ServerApplicationConfig>> config = new HashSet<>(); final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); final List<AnnotationInstance> serverEndpoints = index.getAnnotations(SERVER_ENDPOINT); if (serverEndpoints != null) { for (AnnotationInstance endpoint : serverEndpoints) { if (endpoint.target() instanceof ClassInfo) { ClassInfo clazz = (ClassInfo) endpoint.target(); try { Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module); if (!Modifier.isAbstract(moduleClass.getModifiers())) { annotatedEndpoints.add(moduleClass); UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketEndpoint(clazz.name().toString(), e); final List<AnnotationInstance> clientEndpoints = index.getAnnotations(CLIENT_ENDPOINT); if (clientEndpoints != null) { for (AnnotationInstance endpoint : clientEndpoints) { if (endpoint.target() instanceof ClassInfo) { final Set<ClassInfo> subclasses = index.getAllKnownImplementors(SERVER_APPLICATION_CONFIG); final Set<ClassInfo> epClasses = index.getAllKnownSubclasses(ENDPOINT);
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); 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) { return; //not an EE deployment if (compositeIndex.getClassByName(DotName.createSimple(clazz)) == null) { boolean found = false; for (String pack : BUILTIN_TAGLIBS) {
private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index, CompositeIndex parent) throws DeploymentUnitProcessingException { Set<ClassInfo> classes = new HashSet<ClassInfo>(); if (type.isAnnotation()) { List<AnnotationInstance> instances = index.getAnnotations(typeName); for (AnnotationInstance instance : instances) { AnnotationTarget annotationTarget = instance.target(); if (annotationTarget instanceof ClassInfo) { classes.add((ClassInfo) annotationTarget); classes.addAll(index.getAllKnownSubclasses(typeName)); classes.addAll(index.getAllKnownImplementors(typeName)); if(parent != null) { Set<ClassInfo> parentImplementors = new HashSet<>(); parentImplementors.addAll(parent.getAllKnownImplementors(typeName)); parentImplementors.addAll(parent.getAllKnownSubclasses(typeName)); for(ClassInfo pc: parentImplementors) { classes.addAll(index.getAllKnownSubclasses(pc.name())); classes.addAll(index.getAllKnownImplementors(pc.name()));
roots.add(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT)); roots.addAll(deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS)); for (ResourceRoot root : roots) { VirtualFile c = root.getRoot().getChild(META_INF_FACES); CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); for (DotName annotation : JSF_ANNOTATIONS) { List<AnnotationInstance> annotations = index.getAnnotations(annotation); if (!annotations.isEmpty()) { return true; Set<ClassInfo> implementors = index.getAllKnownImplementors(annotation); if (!implementors.isEmpty()) { return true;
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);
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ProcessApplication.class.getName())); postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PostDeploy.class.getName())); preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PreUndeploy.class.getName())); servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(ServletProcessApplication.class.getName())); } else { return null; ClassInfo paClassInfo = (ClassInfo) annotationInstance.target(); String paClassName = paClassInfo.name().toString(); if(listenerMetaData.getListenerClass().equals(paClassInfo.name().toString())) { isListener = true;
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); if (compositeIndex == null) { return; List<AnnotationInstance> applicationExceptionAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ApplicationException.class.getName())); if (applicationExceptionAnnotations == null || applicationExceptionAnnotations.isEmpty()) { return; deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.APPLICATION_EXCEPTION_DESCRIPTIONS, descriptions); for (AnnotationInstance annotationInstance : applicationExceptionAnnotations) { AnnotationTarget target = annotationInstance.target(); if (!(target instanceof ClassInfo)) { throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(ApplicationException.class.getName(), target); String exceptionClassName = ((ClassInfo) target).name().toString(); boolean rollback = false; AnnotationValue rollBackAnnValue = annotationInstance.value("rollback"); if (rollBackAnnValue != null) { rollback = rollBackAnnValue.asBoolean(); AnnotationValue inheritedAnnValue = annotationInstance.value("inherited"); if (inheritedAnnValue != null) { inherited = inheritedAnnValue.asBoolean();
static void handleParseAnnotations(final DeploymentUnit deploymentUnit) { final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); if(compositeIndex == null) { log.warnf("Cannot find composite annotation index in: %s", deploymentUnit); final DotName runWithName = DotName.createSimple(CLASS_NAME_JUNIT_RUNNER); final List<AnnotationInstance> runWithList = compositeIndex.getAnnotations(runWithName); final DotName testNGClassName = DotName.createSimple(CLASS_NAME_TESTNG_RUNNER); final Set<ClassInfo> testNgTests = compositeIndex.getAllKnownSubclasses(testNGClassName); final AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { final ClassInfo classInfo = (ClassInfo) target; final String testClassName = classInfo.name().toString(); testClasses.add(testClassName); testClasses.add(classInfo.name().toString()); deploymentUnit.putAttachment(CLASSES, testClasses);
private void verifyApacheCXFModuleDependencyRequirement(DeploymentUnit unit) { if (!hasCxfModuleDependency(unit)) { //notify user if he clearly forgot the CXF module dependency final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); final DotName[] dotNames = {WEB_SERVICE_ANNOTATION, WEB_SERVICE_PROVIDER_ANNOTATION}; for (final DotName dotName : dotNames) { for (AnnotationInstance ai : index.getAnnotations(dotName)) { AnnotationTarget at = ai.target(); if (at instanceof ClassInfo) { final ClassInfo clazz = (ClassInfo)ai.target(); for (DotName dn : clazz.annotations().keySet()) { if (dn.toString().startsWith("org.apache.cxf")) { WSLogger.ROOT_LOGGER.missingModuleDependency(dn.toString(), clazz.name().toString(), "org.apache.cxf"); } } } } } } }
protected void scan(final DeploymentUnit du, final ClassLoader classLoader, final ResteasyDeploymentData resteasyDeploymentData) throws DeploymentUnitProcessingException, ModuleLoadException { final CompositeIndex index = du.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); final Set<ClassInfo> applicationClasses = index.getAllKnownSubclasses(APPLICATION); try { for (ClassInfo c : applicationClasses) { if (Modifier.isAbstract(c.flags())) continue; @SuppressWarnings("unchecked") Class<? extends Application> scanned = (Class<? extends Application>) classLoader.loadClass(c.name().toString()); resteasyDeploymentData.getScannedApplicationClasses().add(scanned); List<AnnotationInstance> providers = null; if (resteasyDeploymentData.isScanResources()) { resources = index.getAnnotations(JaxrsAnnotations.PATH.getDotName()); providers = index.getAnnotations(JaxrsAnnotations.PROVIDER.getDotName()); continue; if(info.name().toString().startsWith(ORG_APACHE_CXF)) { final Set<ClassInfo> implementors = index.getAllKnownImplementors(iface.name()); for (final ClassInfo implementor : implementors) { if(implementor.name().toString().startsWith(ORG_APACHE_CXF)) {
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(JsfVersionMarker.isJsfDisabled(deploymentUnit)) { return; final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); if (compositeIndex == null) { return; // Can not continue without index final Module module = deploymentUnit.getAttachment(Attachments.MODULE); if (module == null) { return; // Can not continue without module final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(annotation.indexName); if (annotationInstances == null || annotationInstances.isEmpty()) { continue; instances.put(annotation.annotationClass, discoveredClasses); for (AnnotationInstance annotationInstance : annotationInstances) { final AnnotationTarget target = annotationInstance.target(); if (target instanceof ClassInfo) { final DotName className = ClassInfo.class.cast(target).name(); final Class<?> annotatedClass; try { annotatedClass = classLoader.loadClass(className.toString()); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.classLoadingFailed(className)); deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(FACES_ANNOTATIONS_SC_ATTR, instances));
@Override public final void installService(DeploymentPhaseContext ctx, String serviceName, T instance) { CompositeIndex index = ctx.getDeploymentUnit().getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); List<AnnotationInstance> annotations = index.getAnnotations(NAMED_FACTORY); if (annotations.isEmpty()) ROOT_LOGGER.noFactoryName(getServiceClass().getName()); else { for (AnnotationInstance annotation : annotations) { AnnotationTarget annotationTarget = annotation.target(); if (annotationTarget instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) annotationTarget; DotName target = DotName.createSimple(serviceName); if (classInfo.name().equals(target)) { String nameValue = annotation.value("name").asString(); AbstractExtensionManagerService<T> service = createService(nameValue, instance); ServiceName extensionServiceName = Constants.DATAGRID.append(service.getServiceTypeName(), nameValue.replaceAll("\\.", "_")); ServiceBuilder<T> serviceBuilder = ctx.getServiceTarget() .addService(extensionServiceName, service) .setInitialMode(ServiceController.Mode.ACTIVE) .addDependency(extensionManagerServiceName, ExtensionManagerService.class, service.getExtensionManager()); serviceBuilder.install(); } } } } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit unit = phaseContext.getDeploymentUnit(); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION); moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, TRANSACTION_API, false, false, true, false)); moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.wildfly.transaction.client"), false, false, true, false)); final CompositeIndex compositeIndex = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); if (compositeIndex == null) { return; } final List<AnnotationInstance> transactionalAnnotations = compositeIndex.getAnnotations(DotName.createSimple(Transactional.class.getName())); final List<AnnotationInstance> transactionScopedAnnotations = compositeIndex.getAnnotations(DotName.createSimple(TransactionScoped.class.getName())); if (transactionalAnnotations.size() > 0 || transactionScopedAnnotations.size() > 0) { addJTSModuleDependencyToDeployment(unit); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() == null) { //register resource, provider and application as CDI annotation defining types deploymentUnit.addToAttachmentList(INJECTION_TARGET_DEFINING_ANNOTATIONS, JaxrsAnnotations.PROVIDER.getDotName()); deploymentUnit.addToAttachmentList(INJECTION_TARGET_DEFINING_ANNOTATIONS, JaxrsAnnotations.PATH.getDotName()); } final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); for (final JaxrsAnnotations annotation : JaxrsAnnotations.values()) { if (!index.getAnnotations(annotation.getDotName()).isEmpty()) { JaxrsDeploymentMarker.mark(deploymentUnit); return; } } }
private List<AnnotationInstance> getAnnotations(DeploymentUnit depUnit, String className) { CompositeIndex index = depUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); List<AnnotationInstance> annotations = index.getAnnotations(DotName.createSimple(className)); return annotations; }
private boolean hasInjectionPoint(DeploymentUnit depUnit, String anName) { boolean result = false; CompositeIndex compositeIndex = depUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); List<AnnotationInstance> annotationList = compositeIndex.getAnnotations(DotName.createSimple(anName)); for (AnnotationInstance instance : annotationList) { AnnotationTarget target = instance.target(); if (target instanceof FieldInfo) { FieldInfo fieldInfo = (FieldInfo) target; String typeName = fieldInfo.type().toString(); if (typeName.startsWith("org.osgi.framework") || typeName.startsWith("org.osgi.service")) { LOGGER.debugf("OSGi injection point of type '%s' detected: %s", typeName, fieldInfo.declaringClass()); result = true; break; } } } return result; } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); for (final CdiAnnotations annotation : CdiAnnotations.values()) { if (!index.getAnnotations(annotation.getDotName()).isEmpty()) { CdiAnnotationMarker.mark(deploymentUnit); return; } } }
public boolean addConditionally(DeploymentUnit depUnit, CamelDeploymentSettings.Builder depSettingsBuilder, URL fileURL) { boolean skipResource = false; CompositeIndex index = depUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); // [#1215] Add support for Spring based CamelContext injection for (AnnotationInstance aninst : index.getAnnotations(DotName.createSimple("org.apache.camel.cdi.ImportResource"))) { for (String resname : aninst.value().asStringArray()) { skipResource |= fileURL.getPath().endsWith(resname); } } if (skipResource == false) { depSettingsBuilder.camelContextUrl(fileURL); return true; } return false; }
private void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException { final List<AnnotationInstance> annotations = index.getAnnotations(MANAGED_BEAN_ANNOTATION); if (annotations != null) { for (final AnnotationInstance annotation : annotations) { final AnnotationTarget target = annotation.target(); if (target instanceof ClassInfo) { final String className = ((ClassInfo) target).name().toString(); managedBeanClasses.add(className); } else { throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidManagedBeanAnnotation(target)); } } } }