Trait

resource

ManagedResource

Related Doc: package resource

Permalink

trait ManagedResource[+R] extends ManagedResourceCompat[R]

This class encapsulates a method of ensuring a resource is opened/closed during critical stages of its lifecycle.

It is monadic in nature, although not a monad, and provides several combinators to use with other managed resources.

For example:

import resource._

val x = managed(newResource)
val y = managed(newResource)
val z: ManagedResource[Z] = x and y map { case (x,y) => f(x,y) }
Linear Supertypes
ManagedResourceCompat[R], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ManagedResource
  2. ManagedResourceCompat
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def acquireAndGet[B](f: (R) ⇒ B): B

    Permalink

    Acquires the resource for the Duration of a given function, The resource will automatically be opened and closed.

    Acquires the resource for the Duration of a given function, The resource will automatically be opened and closed. The result will be returned immediately, except in the case of an error. Upon error, the resource will be closed, and then the originating exception will be thrown.

    Note: This method will throw the last exception encountered by the managed resource, whatever this happens to be.

    f

    A function to execute against the handle returned by the resource

    returns

    The result of the passed in function

  2. abstract def acquireFor[B](f: (R) ⇒ B): ExtractedEither[List[Throwable], B]

    Permalink

    Aquires the resource for the Duration of a given function, The resource will automatically be opened and closed.

    Aquires the resource for the Duration of a given function, The resource will automatically be opened and closed. The result will be returned immediately in an Either container. This container will hold all errors, if any occurred during execution, or the resulting value.

    f

    A function to execute against the raw resource.

    returns

    The result of the function (right) or the list of exceptions seen during the processing of the resource (left).

  3. abstract def and[B](that: ManagedResource[B]): ManagedResource[(R, B)]

    Permalink

    Creates a new resource that is the aggregation of this resource and another.

    Creates a new resource that is the aggregation of this resource and another.

    that

    the other resource

    returns

    A resource that is a tupled combination of this and that.

  4. abstract def apply[B](f: (R) ⇒ B): B

    Permalink

    Acquires the resource for the Duration of a given function, The resource will automatically be opened and closed.

    Acquires the resource for the Duration of a given function, The resource will automatically be opened and closed. The result will be returned immediately, except in the case of an error. Upon error, the resource will be closed, and then the originating exception will be thrown.

    Note: This method will throw the last exception encountered by the managed resource, whatever this happens to be.

    f

    A function to execute against the handle returned by the resource

    returns

    The result of the passed in function

  5. abstract def flatMap[B](f: (R) ⇒ ManagedResource[B]): ManagedResource[B]

    Permalink

    This method is used to immediately perform operations on a resource while it is open, ensuring the resource is closed before returning.

    This method is used to immediately perform operations on a resource while it is open, ensuring the resource is closed before returning.

    f

    The transformation function to apply against the raw resource.

    returns

    A new ManagedResource with the translated type or some other type if an appropriate translator was found.

  6. abstract def foreach(f: (R) ⇒ Unit): Unit

    Permalink

    This method is used to immediately perform operations on a resource while it is open, ensuring the resource is closed before returning.

    This method is used to immediately perform operations on a resource while it is open, ensuring the resource is closed before returning. Note: This method *will* open and close the resource, performing the body of the method immediately.

    f

    The function to apply against the raw resource.

  7. abstract def map[B](f: (R) ⇒ B): ExtractableManagedResource[B]

    Permalink

    This method is used to perform operations on a resource while the resource is open.

    This method is used to perform operations on a resource while the resource is open.

    f

    The transformation function to apply against the raw resource.

    returns

    A new ManagedResource with the translated type or some other type if an appropriate translator was found.

  8. abstract def toFuture(implicit context: ExecutionContext): Future[R]

    Permalink

    This method creates a Future that will perform operations within the context of an "open" resource.

    This method creates a Future that will perform operations within the context of an "open" resource. Execution of Future will hold error as Failure, otherwise result will be inside a Success.

  9. abstract def toTraversable[B](implicit ev: <:<[R, TraversableOnce[B]]): Traversable[B]

    Permalink

    This method creates a Traversable in which all performed methods are done within the context of an "open" resource.

    This method creates a Traversable in which all performed methods are done within the context of an "open" resource.

    *Note:* Every iteration will attempt to open and close the resource!

    returns

    A Traversable of elements of type B.

    Definition Classes
    ManagedResourceCompat

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ManagedResourceCompat[R]

Inherited from AnyRef

Inherited from Any

Ungrouped