private void addCacheAnnotations(EJBContainer container,
JBossSessionBeanMetaData enterpriseBean) throws Exception
{
if (enterpriseBean.getCacheConfig() != null)
{
CacheConfigMetaData config = enterpriseBean.getCacheConfig();
if (config.getValue() != null && !config.getValue().equals(""))
{
String cacheValue = config.getValue();
CacheImpl cacheAnnotation = new CacheImpl(cacheValue);
addClassAnnotation(container, Cache.class, cacheAnnotation);
// FIXME: Wolf: what the hell is this?
// FIXME: ALR: This shouldn't be hardcoded; configuration needs reworking
if (cacheValue.equals("SimpleStatefulCache"))
{
if (!ejbClass.isAnnotationPresent(PersistenceManager.class))
{
PersistenceManagerImpl persistenceAnnotation = new PersistenceManagerImpl();
if (config.getPersistenceManager() != null)
{
persistenceAnnotation.setValue(config.getPersistenceManager());
}
addClassAnnotation(container, PersistenceManager.class, persistenceAnnotation);
}
}
}
if (config.getName() != null)
{
org.jboss.ejb3.annotation.impl.CacheConfigImpl configAnnotation = new org.jboss.ejb3.annotation.impl.CacheConfigImpl();
configAnnotation.setName(config.getName());
if (config.getMaxSize() != null)
configAnnotation.setMaxSize(config.getMaxSize());
if (config.getIdleTimeoutSeconds() != null)
configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
if (config.getReplicationIsPassivation() != null)
configAnnotation.setReplicationIsPassivation(Boolean.parseBoolean(config.getReplicationIsPassivation()));
if (config.getRemoveTimeoutSeconds() != null)
configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
org.jboss.ejb3.annotation.CacheConfig existingConfig = ejbClass.getAnnotation(org.jboss.ejb3.annotation.CacheConfig.class);
if (existingConfig != null)
configAnnotation.merge(existingConfig);
addClassAnnotation(container, org.jboss.ejb3.annotation.CacheConfig.class, configAnnotation);
}
else
{
org.jboss.ejb3.annotation.impl.CacheConfigImpl configAnnotation = new org.jboss.ejb3.annotation.impl.CacheConfigImpl();
if (config.getMaxSize() != null)
configAnnotation.setMaxSize(config.getMaxSize());
if (config.getIdleTimeoutSeconds() != null)
configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
if (config.getRemoveTimeoutSeconds() != null)
configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
org.jboss.ejb3.annotation.CacheConfig existingConfig = ejbClass.getAnnotation(org.jboss.ejb3.annotation.CacheConfig.class);
if (existingConfig != null)
configAnnotation.merge(existingConfig);