Annotation Interface PersistenceAgent


@Repeatable(PersistenceAgents.class) @Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) public @interface PersistenceAgent
Expresses a dependency on a container-managed EntityAgent and its associated persistence unit. When this annotation occurs on a method or field of a managed bean, it declares an injection point of type EntityAgent.
@PersistenceAgent EntityAgent agent;
When the annotation occurs on a managed bean class, it assigns a name to the EntityAgent in the environment referencing context java:comp/env of the containing module.
@PersistenceAgent(name = "LibraryAgent")
class Bean
    ...
    EntityAgent agent =
            new InitialContext()
                    .lookup("java:comp/env/LibraryAgent");
    ...

Every container-managed entity agent is a JTA entity agent.

Since:
4.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    (Optional) The name at which the EntityAgent is accessed in the environment referencing context.
    (Optional) Properties for the container or persistence provider.
    (Optional) The name of the persistence unit as defined in the persistence.xml file.
  • Element Details

    • name

      String name
      (Optional) The name at which the EntityAgent is accessed in the environment referencing context. If the specified name does not begin with java:, then the prefix java:comp/env is assumed. This member is not usually specified when @PersistenceAgent annotates an injection point.
      Default:
      ""
    • unitName

      String unitName
      (Optional) The name of the persistence unit as defined in the persistence.xml file. This member is optional if there is only one persistence unit defined by the containing module.
      Default:
      ""
    • properties

      PersistenceProperty[] properties
      (Optional) Properties for the container or persistence provider. Vendor-specific properties may be included in this set of properties. Properties that are not recognized by a vendor are ignored.
      See Also:
      Default:
      {}