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); if (annotationTarget instanceof ClassInfo) { final ClassInfo classInfo = (ClassInfo) annotationTarget; final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray(); 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;
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();
public static String[] asOptionalStringArray(AnnotationInstance annotation, String property) { AnnotationValue value = annotation.value(property); return value == null ? new String[0] : value.asStringArray(); }
private Properties getActivationConfigProperties(final AnnotationInstance messageBeanAnnotation, PropertyReplacer propertyReplacer) { final Properties props = new Properties(); final AnnotationValue activationConfig = messageBeanAnnotation.value("activationConfig"); if (activationConfig == null) return props; for (final AnnotationInstance propAnnotation : activationConfig.asNestedArray()) { String propertyName = propAnnotation.value("propertyName").asString(); String propertyValue = propAnnotation.value("propertyValue").asString(); props.put(propertyReplacer.replaceProperties(propertyName), propertyReplacer.replaceProperties(propertyValue)); } return props; }
@Override protected Integer fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final long timeout = annotationInstance.value().asLong(); AnnotationValue unitAnnVal = annotationInstance.value("unit"); final TimeUnit unit = unitAnnVal != null ? TimeUnit.valueOf(unitAnnVal.asEnum()) : TimeUnit.SECONDS; return (int) unit.toSeconds(timeout); } }
public void set(final AutoTimer timer, final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final AnnotationValue value = annotationInstance.value(name); if (booleanValue) { if (value == null) { setBoolean(timer, defaultBooleanValue); } else { setBoolean(timer, value.asBoolean()); } } else { if (value == null) { setString(timer, defaultStringValue); } else { setString(timer, propertyReplacer.replaceProperties(value.asString())); } } }
final String runtimeName = depUnit.getName(); BundleInfo info = depUnit.getAttachment(OSGiConstants.BUNDLE_INFO_KEY); if (deployment == null && info != null) { deployment = DeploymentFactory.createDeployment(info); MethodInfo slTarget = (MethodInfo) slAware.target(); for (AnnotationInstance anDeployment : getAnnotations(depUnit, "org.jboss.arquillian.container.test.api.Deployment")) { AnnotationValue namevalue = anDeployment.value("name"); Object deploymentName = namevalue != null ? namevalue.value() : null; if (slTarget == anDeployment.target() && depUnit.getName().equals(deploymentName)) { int startLevel = slAware.value("startLevel").asInt(); deployment.setStartLevel(startLevel); deployment.setAutoStart(false); AnnotationValue value = marker.value("autoStart"); if (value != null && deployment.isAutoStart()) { deployment.setAutoStart(value.asBoolean()); value = marker.value("startLevel"); if (value != null && deployment.getStartLevel() == null) { deployment.setStartLevel(value.asInt());
final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY); final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit); if(compositeIndex == null) { AnnotationTarget target = instance.target(); if (!(target instanceof ClassInfo)) { throw EeLogger.ROOT_LOGGER.classOnlyAnnotation("@ManagedBean", target); continue; final String beanClassName = classInfo.name().toString(); final AnnotationValue nameValue = instance.value(); final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? beanClassName : replacer.replaceProperties(nameValue.asString()); final ManagedBeanComponentDescription componentDescription = new ManagedBeanComponentDescription(beanName, beanClassName, moduleDescription, deploymentUnit.getServiceName());
private void processSessionBeans(final DeploymentUnit deploymentUnit, final List<AnnotationInstance> sessionBeanAnnotations, final SessionBeanComponentDescription.SessionBeanType annotatedSessionBeanType) { final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName(); PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit); final AnnotationTarget target = sessionBeanAnnotation.target(); if (!(target instanceof ClassInfo)) { EjbLogger.DEPLOYMENT_LOGGER.warn(EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(sessionBeanAnnotation.name().toString(), target).getMessage()); continue; continue; final String ejbName = sessionBeanClassInfo.name().local(); final AnnotationValue nameValue = sessionBeanAnnotation.value("name"); final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString()); final SessionBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, SessionBeanMetaData.class); final SessionBeanComponentDescription.SessionBeanType sessionBeanType; final String beanClassName; if (beanMetaData != null) { beanClassName = override(sessionBeanClassInfo.name().toString(), beanMetaData.getEjbClass()); sessionBeanType = override(annotatedSessionBeanType, descriptionOf(((SessionBeanMetaData) beanMetaData).getSessionType())); } else { beanClassName = sessionBeanClassInfo.name().toString(); sessionBeanType = annotatedSessionBeanType; final boolean passivationCapableAnnotationValue = sessionBeanAnnotation.value("passivationCapable") == null ? true : sessionBeanAnnotation.value("passivationCapable").asBoolean(); final Boolean passivationCapableDeploymentDescriptorValue; if ((beanMetaData instanceof SessionBean32MetaData)) {
final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName(); DeploymentDescriptorEnvironment deploymentDescriptorEnvironment = null; final AnnotationTarget target = messageBeanAnnotation.target(); final ClassInfo beanClassInfo = (ClassInfo) target; if (! EjbValidationsUtil.assertEjbClassValidity(beanClassInfo).isEmpty() ) { continue; final String ejbName = beanClassInfo.name().local(); final AnnotationValue nameValue = messageBeanAnnotation.value("name"); final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString()); final MessageDrivenBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, MessageDrivenBeanMetaData.class); final String beanClassName; final String messagingType; if (beanMetaData != null) { beanClassName = override(beanClassInfo.name().toString(), beanMetaData.getEjbClass()); deploymentDescriptorEnvironment = new DeploymentDescriptorEnvironment("java:comp/env/", beanMetaData); beanClassName = beanClassInfo.name().toString(); messageListenerInterfaceName = getMessageListenerInterface(compositeIndex, messageBeanAnnotation); final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry()); final MessageDrivenComponentDescription beanDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, messageListenerInterfaceName, activationConfigProperties, defaultResourceAdapterName, beanMetaData, defaultMdbPoolAvailable); beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);
@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(); } } } } }
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 String getMessageListenerInterface(final CompositeIndex compositeIndex, final AnnotationInstance messageBeanAnnotation) throws DeploymentUnitProcessingException { final AnnotationValue value = messageBeanAnnotation.value("messageListenerInterface"); if (value != null) return value.asClass().name().toString(); final ClassInfo beanClass = (ClassInfo) messageBeanAnnotation.target(); final Set<DotName> interfaces = new HashSet<DotName>(getPotentialViewInterfaces(beanClass)); // check super class(es) of the bean DotName superClassDotName = beanClass.superName(); while (interfaces.isEmpty() && superClassDotName != null && !superClassDotName.toString().equals(Object.class.getName())) { final ClassInfo superClass = compositeIndex.getClassByName(superClassDotName); if (superClass == null) { break; } interfaces.addAll(getPotentialViewInterfaces(superClass)); // move to next super class superClassDotName = superClass.superName(); } if (interfaces.size() != 1) throw EjbLogger.ROOT_LOGGER.mdbDoesNotImplementNorSpecifyMessageListener(beanClass); return interfaces.iterator().next().toString(); }
protected AccessType getAccessFromIndex(DotName className) { Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className ); List<AnnotationInstance> accessAnnotationInstances = indexedAnnotations.get( ACCESS ); if ( MockHelper.isNotEmpty( accessAnnotationInstances ) ) { for ( AnnotationInstance annotationInstance : accessAnnotationInstances ) { if ( annotationInstance.target() != null && annotationInstance.target() instanceof ClassInfo ) { ClassInfo ci = (ClassInfo) ( annotationInstance.target() ); if ( className.equals( ci.name() ) ) { //todo does ci need to have @Entity or @MappedSuperClass ?? return AccessType.valueOf( annotationInstance.value().asEnum() ); } } } } return null; }
@Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { String resourceAdapterValue = annotationInstance.value().asString(); return propertyReplacer.replaceProperties(resourceAdapterValue); } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME); final AnnotationTarget annotationTarget = annotation.target(); final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation, propertyReplacer); if (annotationTarget instanceof FieldInfo) { final AnnotationTarget annotationTarget = annotation.target(); if (annotationTarget instanceof ClassInfo) { final AnnotationValue annotationValue = annotation.value(); final AnnotationInstance[] ejbAnnotations = annotationValue.asNestedArray(); for (AnnotationInstance ejbAnnotation : ejbAnnotations) { final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(ejbAnnotation, propertyReplacer);
servlet.setServletClass(classInfo.toString()); AnnotationValue nameValue = annotation.value("name"); if (nameValue == null || nameValue.asString().isEmpty()) { servlet.setName(classInfo.toString()); } else { servlet.setName(nameValue.asString()); AnnotationValue loadOnStartup = annotation.value("loadOnStartup"); if (loadOnStartup != null && loadOnStartup.asInt() >= 0) { servlet.setLoadOnStartupInt(loadOnStartup.asInt()); servlet.setAsyncSupported(asyncSupported.asBoolean()); AnnotationInstance[] initParamsAnnotations = initParamsValue.asNestedArray(); if (initParamsAnnotations != null && initParamsAnnotations.length > 0) { List<ParamValueMetaData> initParams = new ArrayList<ParamValueMetaData>(); initParam.setParamName(initParamName.asString()); initParam.setParamValue(initParamValue.asString()); if (initParamDescription != null) { Descriptions descriptions = getDescription(initParamDescription.asString()); if (descriptions != null) { initParam.setDescriptions(descriptions); getDescriptionGroup((descriptionValue == null) ? "" : descriptionValue.asString(), (displayNameValue == null) ? "" : displayNameValue.asString(), (smallIconValue == null) ? "" : smallIconValue.asString(), (largeIconValue == null) ? "" : largeIconValue.asString()); if (descriptionGroup != null) {
protected List<TargetAnnotation> fromMultiAnnotation(AnnotationInstance multiAnnotationInstance) { List<TargetAnnotation> instances = new ArrayList<TargetAnnotation>(); final AnnotationInstance[] values = multiAnnotationInstance.value().asNestedArray(); for(AnnotationInstance value : values) { instances.add(new TargetAnnotation(value, multiAnnotationInstance.target())); } return instances; }
public static String asRequiredString(AnnotationInstance annotationInstance, final String attributeName, PropertyReplacer propertyReplacer) { final AnnotationValue nameValue = annotationInstance.value(attributeName); if (nameValue == null) { throw ROOT_LOGGER.annotationAttributeMissing(annotationInstance.name().toString(), attributeName); } final String nameValueAsString = nameValue.asString(); if (nameValueAsString.isEmpty()) { throw ROOT_LOGGER.annotationAttributeMissing(annotationInstance.name().toString(), attributeName); } return propertyReplacer != null ? propertyReplacer.replaceProperties(nameValueAsString) : nameValueAsString; } }