Search in sources :

Example 1 with CacheInfo

use of org.jboss.as.ejb3.cache.CacheInfo in project wildfly by wildfly.

the class CacheMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, StatefulComponentDescription description) throws DeploymentUnitProcessingException {
    final String ejbName = description.getEJBName();
    final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (metaData == null) {
        return;
    }
    final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
    if (assemblyDescriptor == null) {
        return;
    }
    // get the pool metadata
    final List<EJBBoundCacheMetaData> caches = assemblyDescriptor.getAny(EJBBoundCacheMetaData.class);
    String cacheName = null;
    if (caches != null) {
        for (final EJBBoundCacheMetaData cacheMetaData : caches) {
            // for the specific bean (i.e. via an ejb-name match)
            if ("*".equals(cacheMetaData.getEjbName()) && cacheName == null) {
                cacheName = cacheMetaData.getCacheName();
            } else if (ejbName.equals(cacheMetaData.getEjbName())) {
                cacheName = cacheMetaData.getCacheName();
            }
        }
    }
    if (cacheName != null) {
        description.setCache(new CacheInfo(cacheName));
    }
}
Also used : EJBBoundCacheMetaData(org.jboss.as.ejb3.cache.EJBBoundCacheMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) CacheInfo(org.jboss.as.ejb3.cache.CacheInfo)

Example 2 with CacheInfo

use of org.jboss.as.ejb3.cache.CacheInfo in project wildfly by wildfly.

the class CacheMergingProcessor method handleAnnotations.

@Override
protected void handleAnnotations(DeploymentUnit deploymentUnit, EEApplicationClasses applicationClasses, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, StatefulComponentDescription componentConfiguration) 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<Cache, CacheInfo> cache = clazz.getAnnotationInformation(Cache.class);
    if (cache == null) {
        return;
    }
    if (!cache.getClassLevelAnnotations().isEmpty()) {
        componentConfiguration.setCache(cache.getClassLevelAnnotations().get(0));
    }
}
Also used : EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) CacheInfo(org.jboss.as.ejb3.cache.CacheInfo) Cache(org.jboss.ejb3.annotation.Cache)

Aggregations

CacheInfo (org.jboss.as.ejb3.cache.CacheInfo)2 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)1 EJBBoundCacheMetaData (org.jboss.as.ejb3.cache.EJBBoundCacheMetaData)1 Cache (org.jboss.ejb3.annotation.Cache)1 AssemblyDescriptorMetaData (org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)1 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)1