@SuppressWarnings("unchecked")
 @Override
 public K createIdentifier() {
   K id = this.manager.getIdentifierFactory().createIdentifier();
   K group = (K) CURRENT_GROUP.get();
   if (group == null) {
     group = id;
     CURRENT_GROUP.set(group);
   }
   return id;
 }
Beispiel #2
0
 @Override
 public V create() {
   if (CURRENT_GROUP.get() != null) {
     // An SFSB that uses a distributable cache cannot contain an SFSB that uses a simple cache
     throw EjbLogger.ROOT_LOGGER.incompatibleCaches();
   }
   V bean = this.factory.createInstance();
   this.entries.put(bean.getId(), new Entry<>(bean));
   return bean;
 }
 @SuppressWarnings("unchecked")
 @Override
 public V create() {
   boolean newGroup = CURRENT_GROUP.get() == null;
   try (Batch batch = this.manager.getBatcher().createBatch()) {
     try {
       // This will invoke Cache.create() for nested beans
       // Nested beans will share the same group identifier
       V instance = this.factory.createInstance();
       K id = instance.getId();
       this.manager.createBean(id, (K) CURRENT_GROUP.get(), instance).close();
       return instance;
     } catch (RuntimeException | Error e) {
       batch.discard();
       throw e;
     }
   } finally {
     if (newGroup) {
       CURRENT_GROUP.remove();
     }
   }
 }