use of org.jboss.jandex.AnnotationValue in project wildfly by wildfly.
the class AccessTimeoutAnnotationInformationFactory method fromAnnotation.
@Override
protected AccessTimeoutDetails 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.MILLISECONDS;
return new AccessTimeoutDetails(timeout, unit);
}
use of org.jboss.jandex.AnnotationValue in project wildfly by wildfly.
the class ApplicationExceptionAnnotationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
return;
}
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;
}
ApplicationExceptionDescriptions descriptions = new ApplicationExceptionDescriptions();
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();
}
// default "inherited" is true
boolean inherited = true;
AnnotationValue inheritedAnnValue = annotationInstance.value("inherited");
if (inheritedAnnValue != null) {
inherited = inheritedAnnValue.asBoolean();
}
descriptions.addApplicationException(exceptionClassName, rollback, inherited);
}
}
use of org.jboss.jandex.AnnotationValue in project wildfly by wildfly.
the class JPAAnnotationProcessor method processMethod.
private void processMethod(final DeploymentUnit deploymentUnit, final AnnotationInstance annotation, final MethodInfo methodInfo, final EEModuleClassDescription eeModuleClassDescription) throws DeploymentUnitProcessingException {
final String methodName = methodInfo.name();
if (!methodName.startsWith("set") || methodInfo.args().length != 1) {
eeModuleClassDescription.setInvalid(JpaLogger.ROOT_LOGGER.setterMethodOnlyAnnotation(annotation.name().toString(), methodInfo));
return;
}
final String contextNameSuffix = methodName.substring(3, 4).toLowerCase(Locale.ENGLISH) + methodName.substring(4);
final AnnotationValue declaredNameValue = annotation.value("name");
final String declaredName = declaredNameValue != null ? declaredNameValue.asString() : null;
final String localContextName;
if (declaredName == null || declaredName.isEmpty()) {
localContextName = methodInfo.declaringClass().name().toString() + "/" + contextNameSuffix;
} else {
localContextName = declaredName;
}
final String injectionType = methodInfo.args()[0].name().toString();
final InjectionSource bindingSource = this.getBindingSource(deploymentUnit, annotation, injectionType, eeModuleClassDescription);
if (bindingSource != null) {
final BindingConfiguration bindingConfiguration = new BindingConfiguration(localContextName, bindingSource);
eeModuleClassDescription.getBindingConfigurations().add(bindingConfiguration);
// setup the injection configuration
final InjectionTarget injectionTarget = new MethodInjectionTarget(methodInfo.declaringClass().name().toString(), methodName, methodInfo.args()[0].name().toString());
// source is always local ENC jndi name
final InjectionSource injectionSource = new LookupInjectionSource(localContextName);
final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTarget, injectionSource);
eeModuleClassDescription.addResourceInjection(injectionConfiguration);
}
}
use of org.jboss.jandex.AnnotationValue in project wildfly by wildfly.
the class JPAAnnotationProcessor method processField.
private void processField(final DeploymentUnit deploymentUnit, final AnnotationInstance annotation, final FieldInfo fieldInfo, final EEModuleClassDescription eeModuleClassDescription) throws DeploymentUnitProcessingException {
final String fieldName = fieldInfo.name();
final AnnotationValue declaredNameValue = annotation.value("name");
final String declaredName = declaredNameValue != null ? declaredNameValue.asString() : null;
final String localContextName;
if (declaredName == null || declaredName.isEmpty()) {
localContextName = fieldInfo.declaringClass().name().toString() + "/" + fieldName;
} else {
localContextName = declaredName;
}
// final AnnotationValue declaredTypeValue = annotation.value("type");
final DotName declaredTypeDotName = fieldInfo.type().name();
final DotName injectionTypeDotName = declaredTypeDotName == null || declaredTypeDotName.toString().equals(Object.class.getName()) ? fieldInfo.type().name() : declaredTypeDotName;
final String injectionType = injectionTypeDotName.toString();
final InjectionSource bindingSource = this.getBindingSource(deploymentUnit, annotation, injectionType, eeModuleClassDescription);
if (bindingSource != null) {
final BindingConfiguration bindingConfiguration = new BindingConfiguration(localContextName, bindingSource);
eeModuleClassDescription.getBindingConfigurations().add(bindingConfiguration);
// setup the injection target
final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString());
// source is always local ENC jndi
final InjectionSource injectionSource = new LookupInjectionSource(localContextName);
final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTarget, injectionSource);
eeModuleClassDescription.addResourceInjection(injectionConfiguration);
}
}
use of org.jboss.jandex.AnnotationValue in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_JMS method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
// TODO: how about @WebServiceProvider JMS based endpoints?
// group @WebService annotations in the deployment by wsdl contract location
Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
// support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
if (wsdlLocation != null && port != null && service != null) {
String key = wsdlLocation.asString();
List<AnnotationInstance> annotations = map.get(key);
if (annotations == null) {
annotations = new LinkedList<AnnotationInstance>();
map.put(key, annotations);
}
annotations.add(webServiceAnnotation);
}
}
// extract SOAP-over-JMS 1.0 bindings
List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
if (!map.isEmpty()) {
for (String wsdlLocation : map.keySet()) {
try {
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null)
continue;
final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
final URL url = wsdlLocationFile.toURL();
SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
for (AnnotationInstance ai : map.get(wsdlLocation)) {
String port = ai.value(PORT_NAME).asString();
String service = ai.value(SERVICE_NAME).asString();
AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
String tns = targetNS != null ? targetNS.asString() : null;
QName serviceName = new QName(tns, service);
QName portName = new QName(tns, port);
String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
if (soapAddress != null) {
ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
String beanClassName = webServiceClassInfo.name().toString();
// service name ?
list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
}
}
} catch (Exception ignore) {
WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
}
}
}
unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
Aggregations