/** * Creates the entry. * * @param dataStore The DataStore of the entry. * @param typeName The name of the entry. */ public ContentEntry(ContentDataStore dataStore, Name typeName) { this.typeName = typeName; this.dataStore = dataStore; this.state = new ConcurrentHashMap<Transaction, ContentState>(); // create a state for the auto commit transaction ContentState autoState = dataStore.createContentState(this); autoState.setTransaction(Transaction.AUTO_COMMIT); this.state.put(Transaction.AUTO_COMMIT, autoState); }
/** * Returns state for the entry for a particular transaction. * * <p>In the event that no state exists for the supplied transaction one will be created by * copying the state of {@link Transaction#AUTO_COMMIT}. * * @param transaction A transaction. * @return The state for the transaction. */ public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } }
/** Sets the transaction associated with the state. */ @Override public void setTransaction(Transaction tx) { super.setTransaction(tx); if (tx != Transaction.AUTO_COMMIT) { synchronized (WFSRemoteTransactionState.class) { WFSDataStore dataStore = (WFSDataStore) entry.getDataStore(); WFSRemoteTransactionState remoteStateKeeper; remoteStateKeeper = (WFSRemoteTransactionState) tx.getState(dataStore); if (remoteStateKeeper == null) { remoteStateKeeper = new WFSRemoteTransactionState(dataStore); tx.putState(dataStore, remoteStateKeeper); } WFSLocalTransactionState localTransactionState = getLocalTransactionState(); remoteStateKeeper.watch(localTransactionState.getState()); } } } }
/** * Creates the entry. * * @param dataStore The datastore of the entry. * @param typeName The name of the entry. */ public ContentEntry(ContentDataStore dataStore, Name typeName) { this.typeName = typeName; this.dataStore = dataStore; this.state = new ConcurrentHashMap<Transaction, ContentState>(); //create a state for the auto commit transaction ContentState autoState = dataStore.createContentState(this); autoState.setTransaction(Transaction.AUTO_COMMIT); this.state.put(Transaction.AUTO_COMMIT, autoState); }
/** * Returns state for the entry for a particular transaction. * <p> * In the event that no state exists for the supplied transaction one will * be created by copying the state of {@link Transaction#AUTO_COMMIT}. * </p> * @param transaction A transaction. * * @return The state for the transaction. */ public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } }
/** Sets the transaction associated with the state. */ @Override public void setTransaction(Transaction tx) { super.setTransaction(tx); if (tx != Transaction.AUTO_COMMIT) { synchronized (WFSRemoteTransactionState.class) { WFSDataStore dataStore = (WFSDataStore) entry.getDataStore(); WFSRemoteTransactionState remoteStateKeeper; remoteStateKeeper = (WFSRemoteTransactionState) tx.getState(dataStore); if (remoteStateKeeper == null) { remoteStateKeeper = new WFSRemoteTransactionState(dataStore); tx.putState(dataStore, remoteStateKeeper); } WFSLocalTransactionState localTransactionState = getLocalTransactionState(); remoteStateKeeper.watch(localTransactionState.getState()); } } } }