Skip to content

Commit

Permalink
Added a common definition of a Scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowwoc committed Dec 29, 2024
1 parent 91cf4c8 commit edfc7ad
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To get started, add this Maven dependency:

## Scopes

[Service Locators](docs/Frequently_Asked_Questions.md#not-your-mothers-service-locator) are registries
[Service Locators](docs/frequently_asked_questions.md#not-your-mothers-service-locator) are registries
that contain one or more *values*.
Values can be bound to one or more *scopes*.
A scope is the context within which a value is defined.
Expand Down
33 changes: 33 additions & 0 deletions core/src/main/java/com/github/cowwoc/pouch/core/Scope.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.github.cowwoc.pouch.core;

/**
* The lifespan of one or more variables.
* <p>
* Child scopes must call {@link #addChild(Scope)} at the end of their constructor and
* {@link #removeChild(Scope)} at the end of their {@link #close()} method.
*/
public interface Scope extends AutoCloseable
{
/**
* Adds a child scope.
*
* @param child the child scope
* @throws IllegalStateException if the scope is closed
*/
void addChild(Scope child);

/**
* Removes a child scope.
*
* @param child the child scope
*/
void removeChild(Scope child);

/**
* @return {@code true} if the scope is closed
*/
boolean isClosed();

@Override
void close();
}
4 changes: 4 additions & 0 deletions docs/Changelog.md → docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Minor updates involving cosmetic changes have been omitted from this list. See [commits](../../commits/master)
for a full list.

## Version 5.3 - 2024/12/29

* Added a common definition of a `Scope`.

## Version 5.2 - 2024/12/12

* Bugfix: [Fail on WrappedCheckedException validation before calling super](https://github.com/cowwoc/pouch/pull/9) by [Berk Koprucu](https://github.com/bkoprucu)
Expand Down
File renamed without changes.

0 comments on commit edfc7ad

Please sign in to comment.