public static <A extends Annotation, T> Set<Method> runtimeAnnotationPresent(final Class<?> componentClass, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex index, final Class<A> annotationType) { RuntimeAnnotationInformation<Object> result = runtimeAnnotationInformation(componentClass, applicationClasses, index, annotationType); return result.getMethodAnnotations().keySet(); }
public ClusterNodeConfig newClusterNode(final String nodeName) { final ClusterNodeConfig node = new ClusterNodeConfig(nodeName); this.nodes.add(node); return node; }
public ClusterConfig newClusterConfig(final String clusterName) { final ClusterConfig clusterConfig = new ClusterConfig(clusterName); this.clusterConfigs.add(clusterConfig); return clusterConfig; }
@Override protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException { final RuntimeAnnotationInformation<Boolean> data = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Asynchronous.class); for (final Map.Entry<String, List<Boolean>> entry : data.getClassAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { description.addAsynchronousClass(entry.getKey()); } } for (final Map.Entry<Method, List<Boolean>> entry : data.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(entry.getKey())); } } }
@Override protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException { final RuntimeAnnotationInformation<AutoTimer> scheduleAnnotationData = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Schedule.class); final Set<Method> timerAnnotationData = MethodAnnotationAggregator.runtimeAnnotationPresent(componentClass, applicationClasses, deploymentReflectionIndex, Timeout.class); final Method timeoutMethod; if (timerAnnotationData.size() > 1) { throw EjbLogger.ROOT_LOGGER.componentClassHasMultipleTimeoutAnnotations(componentClass); } else if (timerAnnotationData.size() == 1) { timeoutMethod = timerAnnotationData.iterator().next(); } else { timeoutMethod = null; } description.setTimeoutMethod(timeoutMethod); //now for the schedule methods for (Map.Entry<Method, List<AutoTimer>> entry : scheduleAnnotationData.getMethodAnnotations().entrySet()) { for (AutoTimer timer : entry.getValue()) { description.addScheduleMethod(entry.getKey(), timer); } } }
public final void deploy(final 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); PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit); if (index == null || eeModuleDescription == null) { return; } final List<ClassAnnotationInformationFactory> factories = annotationInformationFactories(); for (final ClassAnnotationInformationFactory factory : factories) { final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, propertyReplacer); for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) { EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey()); clazz.addAnnotationInformation(entry.getValue()); } } afterAnnotationsProcessed(phaseContext, deploymentUnit); }
@Override protected void processAnnotations(DeploymentUnit deploymentUnit, CompositeIndex compositeIndex) throws DeploymentUnitProcessingException { if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } processMessageBeans(deploymentUnit, compositeIndex.getAnnotations(MESSAGE_DRIVEN_ANNOTATION_NAME), compositeIndex); }
private void checkDescriptorConfiguration(final EJBClientDescriptorMetaData ejbClientDescriptorMetaData) throws DeploymentUnitProcessingException { final boolean profileDefined = ejbClientDescriptorMetaData.getProfile() != null; final boolean receiversDefined = (!ejbClientDescriptorMetaData.getRemotingReceiverConfigurations().isEmpty()) || (ejbClientDescriptorMetaData.isLocalReceiverExcluded() != null) || (ejbClientDescriptorMetaData.isLocalReceiverPassByValue() != null); if (profileDefined && receiversDefined) { throw EjbLogger.ROOT_LOGGER.profileAndRemotingEjbReceiversUsedTogether(); } }
@Override protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException { final EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName()); //we only care about annotations on the bean class itself if (clazz == null) { return; } final ClassAnnotationInformation<DeclareRoles, String[]> declareRoles = clazz.getAnnotationInformation(DeclareRoles.class); if (declareRoles == null) { return; } if (!declareRoles.getClassLevelAnnotations().isEmpty()) { description.addDeclaredRoles(declareRoles.getClassLevelAnnotations().get(0)); } }
public void addAnnotationInformation(ClassAnnotationInformation annotationInformation) { this.annotationInformation.put(annotationInformation.getAnnotationType(), annotationInformation); }
/** * Adds an outbound connection reference used by a remoting receiver in the client context represented * by this {@link EJBClientDescriptorMetaData} * * @param outboundConnectionRef The name of the outbound connection. Cannot be null or empty string. */ public RemotingReceiverConfiguration addRemotingReceiverConnectionRef(final String outboundConnectionRef) { if (outboundConnectionRef == null || outboundConnectionRef.trim().isEmpty()) { throw new IllegalArgumentException("Cannot add a remoting receiver which references a null/empty outbound connection"); } final RemotingReceiverConfiguration remotingReceiverConfiguration = new RemotingReceiverConfiguration(outboundConnectionRef); this.remotingReceiverConfigurations.put(outboundConnectionRef, remotingReceiverConfiguration); return remotingReceiverConfiguration; }
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; }
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription componentConfiguration) { //handle lock annotations final RuntimeAnnotationInformation<LockType> lockData = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Lock.class); for (Map.Entry<String, List<LockType>> entry : lockData.getClassAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { componentConfiguration.setBeanLevelLockType(entry.getKey(), entry.getValue().get(0)); } } for (Map.Entry<Method, List<LockType>> entry : lockData.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { componentConfiguration.setLockType(entry.getValue().get(0), MethodIdentifier.getIdentifierForMethod(entry.getKey())); } } final RuntimeAnnotationInformation<AccessTimeoutDetails> accessTimeout = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, AccessTimeout.class); for (Map.Entry<String, List<AccessTimeoutDetails>> entry : accessTimeout.getClassAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { componentConfiguration.setBeanLevelAccessTimeout(entry.getKey(), entry.getValue().get(0)); } } for (Map.Entry<Method, List<AccessTimeoutDetails>> entry : accessTimeout.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { componentConfiguration.setAccessTimeout(entry.getValue().get(0), MethodIdentifier.getIdentifierForMethod(entry.getKey())); } } }
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription componentConfiguration) throws DeploymentUnitProcessingException { final RuntimeAnnotationInformation<Boolean> removeMethods = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Remove.class); for (Map.Entry<Method, List<Boolean>> entry : removeMethods.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { final Boolean retainIfException = entry.getValue().get(0); final MethodIdentifier removeMethodIdentifier = MethodIdentifier.getIdentifierForMethod(entry.getKey()); componentConfiguration.addRemoveMethod(removeMethodIdentifier, retainIfException); } } }
/** * Process annotations and merge any available metadata at the same time. */ @Override protected void processAnnotations(final DeploymentUnit deploymentUnit, final CompositeIndex compositeIndex) throws DeploymentUnitProcessingException { if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } // Find and process any @Stateless bean annotations final List<AnnotationInstance> slsbAnnotations = compositeIndex.getAnnotations(STATELESS_ANNOTATION); if (!slsbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, slsbAnnotations, SessionBeanComponentDescription.SessionBeanType.STATELESS); } // Find and process any @Stateful bean annotations final List<AnnotationInstance> sfsbAnnotations = compositeIndex.getAnnotations(STATEFUL_ANNOTATION); if (!sfsbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, sfsbAnnotations, SessionBeanComponentDescription.SessionBeanType.STATEFUL); } // Find and process any @Singleton bean annotations final List<AnnotationInstance> sbAnnotations = compositeIndex.getAnnotations(SINGLETON_ANNOTATION); if (!sbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, sbAnnotations, SessionBeanComponentDescription.SessionBeanType.SINGLETON); } }
private void processTransactionAttributeAnnotation(final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, MethodIntf methodIntf, final EJBComponentDescription componentConfiguration) { final RuntimeAnnotationInformation<TransactionAttributeType> data = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, TransactionAttribute.class); for (Map.Entry<String, List<TransactionAttributeType>> entry : data.getClassAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { //we can't specify both methodIntf and class name final String className = methodIntf == null ? entry.getKey() : null; componentConfiguration.getTransactionAttributes().setAttribute(methodIntf, className, entry.getValue().get(0)); } } for (Map.Entry<Method, List<TransactionAttributeType>> entry : data.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { String[] parameterTypes = MethodInfoHelper.getCanonicalParameterTypes(entry.getKey()); componentConfiguration.getTransactionAttributes().setAttribute(methodIntf, entry.getValue().get(0), entry.getKey().getDeclaringClass().getName(), entry.getKey().getName(), parameterTypes); } } }
@Override protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription description) throws DeploymentUnitProcessingException { RuntimeAnnotationInformation<String> init = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Init.class); for (Map.Entry<Method, List<String>> entry : init.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { final String value = entry.getValue().get(0); if (value != null && !value.isEmpty()) { description.addInitMethod(entry.getKey(), value); } else { description.addInitMethod(entry.getKey(), null); } } } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } 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_TIMEOUT_ANNOTATION_NAME); for (AnnotationInstance annotation : aroundInvokes) { processAroundInvoke(annotation.target(), eeModuleDescription); } }
private void processTransactionTimeoutAnnotation(final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, MethodIntf methodIntf, final EJBComponentDescription componentConfiguration) { final RuntimeAnnotationInformation<Integer> data = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, TransactionTimeout.class); for (Map.Entry<String, List<Integer>> entry : data.getClassAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { //we can't specify both methodIntf and class name final String className = methodIntf == null ? entry.getKey() : null; componentConfiguration.getTransactionTimeouts().setAttribute(methodIntf, className, entry.getValue().get(0)); } } for (Map.Entry<Method, List<Integer>> entry : data.getMethodAnnotations().entrySet()) { if (!entry.getValue().isEmpty()) { final String className = entry.getKey().getDeclaringClass().getName(); String[] parameterTypes = MethodInfoHelper.getCanonicalParameterTypes(entry.getKey()); componentConfiguration.getTransactionTimeouts().setAttribute(methodIntf, entry.getValue().get(0), className, entry.getKey().getName(), parameterTypes); } } }
private void processComponentConfig(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final Module module, final DeploymentReflectionIndex deploymentReflectionIndex, final T description) throws DeploymentUnitProcessingException { final Class<?> componentClass; try { componentClass = module.getClassLoader().loadClass(description.getEJBClassName()); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failToLoadEjbClass(description.getEJBClassName(), e); } if (!MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { handleAnnotations(deploymentUnit, applicationClasses, deploymentReflectionIndex, componentClass, description); } handleDeploymentDescriptor(deploymentUnit, deploymentReflectionIndex, componentClass, description); }