Session

wvlet.airframe.Session
See theSession companion object
trait Session extends AutoCloseable

Session manages injected objects (e.g., Singleton)

Attributes

Companion
object
Graph
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def design: Design

Reference to the design used for creating this session.

Reference to the design used for creating this session.

Attributes

def get[A](surface: Surface)(implicit sourceCode: SourceCode): A

Internal method for building an instance of type A. This method does not inject the session to A at first hand.

Internal method for building an instance of type A. This method does not inject the session to A at first hand.

Attributes

def getInstanceOf(surface: Surface)(implicit sourceCode: SourceCode): Any
def getOrElse[A](surface: Surface, traitInstanceFactory: => A)(implicit sourceCode: SourceCode): A

Internal method for building an instance of type A, or if no binding is found, use the given trait instance factory

Internal method for building an instance of type A, or if no binding is found, use the given trait instance factory

Attributes

Get the object LifeCycleManager of this session.

Get the object LifeCycleManager of this session.

Attributes

def name: String

Name of the session (default: object hash code)

Name of the session (default: object hash code)

Attributes

def newChildSession(d: Design, inheritParentDesignOptions: Boolean): Session

Create a child session with an additional design. The created session has its own singleton holder and a lifecycle manager.

Create a child session with an additional design. The created session has its own singleton holder and a lifecycle manager.

  • Child sessions tries to delegate the object binding to the parent (or ancestor) session if no corresponding binding is defined in the child design.
  • If the parent and ancestors ve no binding for a given type, it will creates a new object in the child session.
  • If the parent or an ancestor session already initialized a target binding, lifecycle hooks for that binding will not be called in the child session.

Value parameters

d

Additional design for child session

inheritParentDesignOptions

if true (default) use the same design options (e.g., production mode, life cycle logging) with the parent design

Attributes

Create a child session with an additional design. The created session shares the same singleton holder and the lifecycle manager with this session.

Create a child session with an additional design. The created session shares the same singleton holder and the lifecycle manager with this session.

Attributes

def sessionId: Long

Id of the sesion (= object hash id)

Id of the sesion (= object hash id)

Attributes

Concrete methods

override def close(): Unit

Attributes

Definition Classes
AutoCloseable
def createNewInstanceOf[A](surface: Surface)(implicit sourceCode: SourceCode): A
Implicitly added by SessionAccess
def createNewInstanceOf[A](surface: Surface, traitInstanceFactory: => A)(implicit sourceCode: SourceCode): A
Implicitly added by SessionAccess
def get[A](surface: Surface)(implicit sourceCode: SourceCode): A
Implicitly added by SessionAccess
def getOrElse[A](surface: Surface, obj: => A)(implicit sourceCode: SourceCode): A
Implicitly added by SessionAccess
def shutdown: Unit
def start[U](body: => U): U
def start: Unit
def withChildSession[U](d: Design)(body: Session => U): U

Create a child session and execute the body part. The created session has its own singleton holder and lifecycle manager.

Create a child session and execute the body part. The created session has its own singleton holder and lifecycle manager.

Value parameters

d

Additional design for child session.

Attributes

Inherited methods

inline def build[A]: A

Build an instance of A. In general this method is necessary only when creating an entry point of your application. When feasible avoid using this method so that Airframe can inject objects where bind[X] is used.

Build an instance of A. In general this method is necessary only when creating an entry point of your application. When feasible avoid using this method so that Airframe can inject objects where bind[X] is used.

Attributes

Returns

object

Inherited from:
SessionImpl (hidden)
def register[A](instance: A): Unit

Register an instance to the session to control the life cycle of the object under this session.

Register an instance to the session to control the life cycle of the object under this session.

Attributes

Inherited from:
SessionImpl (hidden)

Concrete fields

Implicitly added by SessionAccess