Packages

p

resource

package resource

Package related methods for managed resources.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. resource
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractManagedResource[R] extends ManagedResource[R] with ManagedResourceOperations[R]

    Abstract class implementing most of the managed resource features in terms of an open and close method.

    Abstract class implementing most of the managed resource features in terms of an open and close method. This is a refinement over ManagedResourceOperations as it defines the acquireForMethod generically using the scala.util.control.Exception API.

  2. final class ConstantManagedResource[V] extends AbstractManagedResource[V]

    ConstantManagedResource encapsulates a constant value with no associated resource management.

  3. final class DefaultManagedResource[R] extends AbstractManagedResource[R]

    This is the default implementation of a ManagedResource that makes use of the Resource type trait.

  4. type ErrorHolder[A] = Either[List[Throwable], A]

    The type used to hold errors and results in the same return value.

  5. trait ExtractableManagedResource[+A] extends ManagedResource[A]

    This trait represents a resource that has been modified (or will be modified) inside an ARM block in such a way that the resulting value can be extracted outside of the "ManagedResource" monad.

    This trait represents a resource that has been modified (or will be modified) inside an ARM block in such a way that the resulting value can be extracted outside of the "ManagedResource" monad. There are two mechanisms for extracting resources. One which returns an optional value, where None is returned if any error occurs during extraction. The other returns an Either where the left side contains any error that occured during extraction and the right side contains the extracted value.

  6. case class ExtractedEither[+A, +B](either: Either[A, B]) extends Product with Serializable

    This is a helper class to work around Either pattern matching issues.

  7. sealed trait LowPriorityResourceImplicits extends AnyRef

    Trait holding type class implementations for Resource.

    Trait holding type class implementations for Resource. These implicits will be looked up last in the line, so they can be easily overriden.

  8. trait ManagedIterable[+B, A] extends Iterable[B]

    This trait provides a means to ensure iterable access to items inside a resource, while ensuring that the resource is opened/closed appropriately before/after the traversal.

    This trait provides a means to ensure iterable access to items inside a resource, while ensuring that the resource is opened/closed appropriately before/after the traversal. This class can be dangerous because it always tries to open and close the resource for every call to foreach. This is practically ever method call on a Iterable besides the "view" method.

    A

    the resource type

  9. trait ManagedResource[+R] extends ManagedResourceCompat[R]

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

    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) }
  10. trait ManagedResourceOperations[+R] extends ManagedResource[R] with OperationsCompat[R]

    This class implements all ManagedResource methods except acquireFor.

    This class implements all ManagedResource methods except acquireFor. This allows all new ManagedResource implementations to be defined in terms of the acquireFor method.

    R

    the resource type

  11. sealed trait MediumPriorityResourceImplicits extends LowPriorityResourceImplicits
  12. trait Resource[R] extends AnyRef

    This is a type trait for types that are considered 'resources'.

    This is a type trait for types that are considered 'resources'. These types must be opened (potentially) and closed at some point.

Value Members

  1. def and[A, B](r1: ManagedResource[A], r2: ManagedResource[B]): ManagedResource[(A, B)]

    Combined two resources such that they are both opened/closed together.

    Combined two resources such that they are both opened/closed together. The first resource is opened before the second resource and closed after the second resource, however the resulting ManagedResource acts like both are opened/closed together.

    returns

    A ManagedResource of a tuple containing the initial two resources.

  2. def constant[V](value: V): ManagedResource[V]

    Use this to encapsulate a constant value inside a ManagedResource with no resource management.

  3. implicit def extractedEitherToEither[A, B](extracted: ExtractedEither[A, B]): Either[A, B]
  4. def join[A, MR, CC](resources: CC)(implicit ev0: <:<[CC, Seq[MR]], ev1: <:<[MR, ManagedResource[A]]): ManagedResource[Seq[A]]

    Takes a sequence of ManagedResource objects and traits them as a ManagedResource of a Sequence of Objects.

    Takes a sequence of ManagedResource objects and traits them as a ManagedResource of a Sequence of Objects.

    This is useful for dealing with many resources within the same scope.

    resources

    A collection of ManageResources of the same type

    returns

    A ManagedResoruce of a collection of types

  5. def makeManagedResource[R](opener: => R)(closer: (R) => Unit)(exceptions: List[Class[_ <: Throwable]])(implicit arg0: OptManifest[R]): DefaultManagedResource[R]

    Constructs a managed resource using function objects for each abstract method.

    Constructs a managed resource using function objects for each abstract method.

    opener

    The by-name parameter that will open the resource.

    closer

    A closure that will close the resource.

    exceptions

    A list of exception classes that cannot be ignored to close a resource.

  6. def managed[A](opener: => A)(implicit arg0: Resource[A], arg1: OptManifest[A]): ManagedResource[A]

    Creates a ManagedResource for any type with a Resource type class implementation.

    Creates a ManagedResource for any type with a Resource type class implementation. This includes all java.lang.AutoCloseable subclasses, and any types that have a close or dispose method. You can also provide your own resource type class implementations in your own scope.

  7. def shared[A](opener: => A)(implicit arg0: Resource[A], arg1: OptManifest[A]): ManagedResource[A]

    Creates a ManagedResource shared by all users for any type with a Resource type class implementation.

    Creates a ManagedResource shared by all users for any type with a Resource type class implementation.

    There is only one instance of the resource at the same time for all the users. The instance will be closed once no user is still using it.

  8. object Resource extends MediumPriorityResourceImplicits

    Companion object to the Resource type trait.

    Companion object to the Resource type trait. This contains all the default implicits in appropriate priority order.

  9. object Using extends UsingCompat

    Convenience methods for common java IO operations.

    Convenience methods for common java IO operations.

    This API attempts to do two things:

    1. Clean up common Java IO operations and conversions, e.g. always returning "Buffered" streams rather than raw ones. 2. Avoid frustrating errors when dealing with the filesystem, e.g. trying to write to a file whose parent directories do not exist yet.

    *Note:* This code is ported from the sbt IO library.

Inherited from AnyRef

Inherited from Any

Ungrouped