Interface InjectionAware

All Superinterfaces:
Serializable
All Known Subinterfaces:
SessionFactory

public interface InjectionAware extends Serializable
Marks objects whose state is serialised but whose collaborators are re-bound locally: such an object is eligible for injection by the deserialisation driver, which populates the fields annotated with Injected from the local environment and then calls afterInjection(). Other drivers decide eligibility their own way, the registry creating a service for instance claims it because it created it.

A class declaring this interface declares an explicit serialVersionUID beforehand, since adding an interface leaves the stream shape untouched but changes a computed serial version UID. A class which already declares one keeps it, unless its fields change in a way which makes the serialised form incompatible anyway. A class without one declares the value serialver computes for the class as it is before this interface is added – not a plain 1L, which would be the very incompatibility the rule prevents. Classes further down the hierarchy are unaffected: a class does not change when an interface it implements gains a superinterface.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Called after all Injected fields of this object have been populated; the complete object graph has been restored by then.
  • Method Details

    • afterInjection

      default void afterInjection() throws InjectionException
      Called after all Injected fields of this object have been populated; the complete object graph has been restored by then. readObject must not use injected fields, they are populated after it ran. Implementations delay the processing that carries the object and run before the received session is validated, so they must be cheap, non-blocking and free of side effects beyond this object – obtain and arm, do not work.
      Throws:
      InjectionException - If the object cannot be completed with the injected environment, an InjectionException will be thrown, failing the processing that carries the object – for remote communication the invocation.