Interface DataChannel

All Known Implementing Classes:
DataContextChannel, DataDomain

public interface DataChannel
DataChannel is an abstraction used by ObjectContexts to obtain mapping metadata and access a persistent store. There is rarely a need to use it directly.
Since:
1.2
  • Field Details

    • FLUSH_NOCASCADE_SYNC

      static final int FLUSH_NOCASCADE_SYNC
      A synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel. If the parent is itself an ObjectContext, changes are NOT propagated any further.
      See Also:
    • FLUSH_CASCADE_SYNC

      static final int FLUSH_CASCADE_SYNC
      A synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel. If the parent is itself an ObjectContext, it is expected to send its own sync message to its parent DataChannel to cascade synchronization all the way down the stack.
      See Also:
    • ROLLBACK_CASCADE_SYNC

      static final int ROLLBACK_CASCADE_SYNC
      A synchronization type that results in cascading rollback of changes through the DataChannel stack.
      See Also:
    • GRAPH_CHANGED_SUBJECT

      static final EventSubject GRAPH_CHANGED_SUBJECT
    • GRAPH_FLUSHED_SUBJECT

      static final EventSubject GRAPH_FLUSHED_SUBJECT
    • GRAPH_ROLLEDBACK_SUBJECT

      static final EventSubject GRAPH_ROLLEDBACK_SUBJECT
  • Method Details

    • getEventManager

      EventManager getEventManager()
      Returns an EventManager associated with this channel. Channel may return null if EventManager is not available for any reason.
    • getEntityResolver

      EntityResolver getEntityResolver()
      Returns an EntityResolver instance that contains runtime mapping information.
    • getParent

      DataChannel getParent()
      Returns the parent channel of this channel in the DataChannel stack, or null if this is a root channel (such as a DataDomain).
      Since:
      5.0
    • getDataDomain

      default DataDomain getDataDomain()
      Returns a DataDomain at the root of this channel's stack, looked up by walking the chain of parent channels starting with this channel. Returns null if the root channel is not a DataDomain.
      Since:
      5.0
    • onQuery

      List<QueryResult> onQuery(ObjectContext context, Query query, boolean iteratedResult)
      Executes a query, using provided context to register persistent objects if query returns any objects.
      Parameters:
      context - an ObjectContext that originated the query, used to register result objects.
      query - a query to execute.
      iteratedResult - if true, the result is returned as a ResultIterator item, and the caller is responsible for closing it. If false, the result is fully read into a list.
      Returns:
      all result sets, update counts, iterators and OUT parameters of the execution, in the order they were produced.
      Since:
      5.0
    • onInvalidate

      void onInvalidate(ObjectContext context, Collection<ObjectId> objectIds)
      Invalidates objects with the given ids in this channel and all its parents, so that they are refetched on the next access. In a context, matching registered objects are turned HOLLOW and their uncommitted changes are discarded. At the root of the channel stack, their snapshots are evicted from the snapshot cache, and peer contexts are notified via a snapshot event. Objects unknown to a given channel are ignored.

      This is a callback invoked by a child context after it has invalidated its own objects. Application code should call ObjectContext.invalidateObjects(Collection) instead.

      Parameters:
      context - an ObjectContext that originated the invalidation.
      objectIds - ids of the objects to invalidate.
      Since:
      5.0
    • onIdQuery

      Persistent onIdQuery(ObjectContext context, ObjectId id)
      Resolves an object by id, returning it registered with the originating context. The object is looked up in the caches down the channel stack before being fetched from the database, so the returned object may reflect a cached state.

      This is a callback invoked by a child context to resolve a HOLLOW object, or to look up an object it has no registered copy of. Application code should call ObjectContext.objectForPK(ObjectId) instead.

      Parameters:
      context - an ObjectContext that originated the request and that the returned object belongs to.
      id - id of the object to resolve.
      Returns:
      the object registered with the originating context, or null if no matching row exists.
      Since:
      5.0
    • onRelationshipQuery

      List<? extends Persistent> onRelationshipQuery(ObjectContext context, ObjectId sourceId, String relationshipName)
      Resolves objects related to a given object via a mapped relationship, returning them registered with the originating context.
      Parameters:
      context - an ObjectContext that originated the request and that the returned objects belong to.
      sourceId - id of the object on the source side of the relationship.
      relationshipName - name of the relationship to resolve.
      Returns:
      related objects registered with the originating context. An empty list means that a to-one target is null, or a to-many relationship has no matching objects.
      Since:
      5.0
    • onSync

      GraphDiff onSync(ObjectContext context, GraphDiff changes, int syncType)
      Processes synchronization request from a child ObjectContext, returning a GraphDiff that describes changes to objects made on the receiving end as a result of synchronization.
      Parameters:
      context - an ObjectContext that initiated the sync. Can be null.
      changes - diff from the context that initiated the sync.
      syncType - One of FLUSH_NOCASCADE_SYNC, FLUSH_CASCADE_SYNC, ROLLBACK_CASCADE_SYNC.