Exemplo n.º 1
0
  /**
   * Constructor, using the ObjectProvider of the "owner" and the field name.
   *
   * @param op The owner ObjectProvider
   * @param mmd Metadata for the member
   */
  public TreeSet(ObjectProvider op, AbstractMemberMetaData mmd) {
    super(op, mmd);

    ExecutionContext ec = op.getExecutionContext();
    allowNulls = SCOUtils.allowNullsInContainer(allowNulls, mmd);
    queued = ec.isDelayDatastoreOperationsEnabled();
    useCache = SCOUtils.useContainerCache(op, mmd);

    if (!SCOUtils.collectionHasSerialisedElements(mmd)
        && mmd.getPersistenceModifier() == FieldPersistenceModifier.PERSISTENT) {
      ClassLoaderResolver clr = ec.getClassLoaderResolver();
      this.backingStore =
          (SetStore)
              ((BackedSCOStoreManager) ec.getStoreManager())
                  .getBackingStoreForField(clr, mmd, java.util.TreeSet.class);
    }
    // Set up our delegate, using a suitable comparator
    Comparator comparator =
        SCOUtils.getComparator(mmd, op.getExecutionContext().getClassLoaderResolver());
    if (comparator != null) {
      this.delegate = new java.util.TreeSet(comparator);
    } else {
      this.delegate = new java.util.TreeSet();
    }

    if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
      NucleusLogger.PERSISTENCE.debug(
          SCOUtils.getContainerInfoMessage(
              op,
              ownerMmd.getName(),
              this,
              useCache,
              queued,
              allowNulls,
              SCOUtils.useCachedLazyLoading(op, ownerMmd)));
    }
  }
 /**
  * Accessor for the current DatastoreService for this ExecutionContext. Each PM/EM has its own
  * DatastoreService.
  *
  * @param ec ExecutionContext
  * @return The DatastoreService
  */
 public DatastoreService getDatastoreService(ExecutionContext ec) {
   ManagedConnection mconn = ec.getStoreManager().getConnection(ec);
   return ((EmulatedXAResource) mconn.getXAResource()).getDatastoreService();
 }
 /**
  * Accessor for the current DatastoreTransaction for this ExecutionContext. Each PM/EM has its own
  * DatastoreService, and consequently can have a current DatastoreTransaction.
  *
  * @param ec ExecutionContext
  * @return The DatastoreTransaction if active, or null
  */
 public DatastoreTransaction getDatastoreTransaction(ExecutionContext ec) {
   ManagedConnection mconn = ec.getStoreManager().getConnection(ec);
   return ((EmulatedXAResource) mconn.getXAResource()).getCurrentTransaction();
 }
 public StoreManager getStoreManager() {
   return (myEC.getNucleusContext().isFederated()
       ? ((FederatedStoreManager) myEC.getStoreManager()).getStoreManagerForClass(cmd)
       : myEC.getStoreManager());
 }