Skip to content

Commit

Permalink
* Fixed Javadoc warnings.
Browse files Browse the repository at this point in the history
* Moved files from /wiki and /documentation into /docs.
* Updated documentation links.
  • Loading branch information
cowwoc committed Oct 30, 2024
1 parent 6e61353 commit 70289d4
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 29 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.cowwoc.pouch/java/badge.svg)](https://search.maven.org/search?q=g:com.github.cowwoc.pouch) [![API](https://img.shields.io/badge/api_docs-5B45D5.svg)](http://cowwoc.github.io/pouch/4.5/docs/api/) [![Changelog](https://img.shields.io/badge/changelog-A345D5.svg)](wiki/Changelog.md)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.cowwoc.pouch/java/badge.svg)](https://search.maven.org/search?q=g:com.github.cowwoc.pouch) [![API](https://img.shields.io/badge/api_docs-5B45D5.svg)](http://cowwoc.github.io/pouch/5.1/docs/api/) [![Changelog](https://img.shields.io/badge/changelog-A345D5.svg)](docs/Changelog.md)
[![build-status](../../workflows/Build/badge.svg)](../../actions?query=workflow%3ABuild)

# <img alt="pouch" src="wiki/pouch.svg" width="128" height="146"/> Pouch: Inversion of Control for the Masses
# <img alt="pouch" src="docs/pouch.svg" width="128" height="146"/> Pouch: Inversion of Control for the Masses

An [Inversion of Control](http://martinfowler.com/articles/injection.html) design pattern that is:

Expand All @@ -20,15 +20,15 @@ To get started, add this Maven dependency:
<dependency>
<groupId>com.github.cowwoc.pouch</groupId>
<artifactId>core</artifactId>
<version>5.0</version>
<version>5.1</version>
</dependency>
```

# Getting Started

## Scopes

[Service Locators](wiki/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 Expand Up @@ -138,7 +138,7 @@ For example, notice how `AbstractDatabaseScope.getRunMode()` delegates to `JvmSc
When running in a multi-threaded environment, such as a web server, you might want to wait for ongoing HTTP
requests to complete before shutting down the server.
You can use the
[ConcurrentChildScopes](https://cowwoc.github.io/pouch/4.5/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConcurrentChildScopes.html)
[ConcurrentChildScopes](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConcurrentChildScopes.html)
class to implement this as follows:

```java
Expand Down Expand Up @@ -415,7 +415,7 @@ public final class TestDataSourceFactory extends ConcurrentLazyFactory<DataSourc
### Scopes that Return Different Values Over Their Lifetime

Scopes that need to return different values over their lifetime can return
a [Builder](https://en.wikipedia.org/wiki/Builder_pattern)
a [Builder](https://en.wikipedia.org/docs/Builder_pattern)
or [Supplier](https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html) that will, in turn,
return different values on every invocation.

Expand Down Expand Up @@ -588,9 +588,9 @@ The scope approach makes it easier to look up multiple values, or pass the scope
The library contains two types of classes: ones that are thread-safe and ones that are not.

For example,
[ConcurrentLazyFactory](https://cowwoc.github.io/pouch/4.5/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConcurrentLazyFactory.html)
[ConcurrentLazyFactory](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConcurrentLazyFactory.html)
is the thread-safe equivalent
of [LazyFactory](https://cowwoc.github.io/pouch/4.5/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyFactory.html).
of [LazyFactory](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyFactory.html).
`LazyFactory` is faster than `ConcurrentLazyFactory`, but doesn't support access from multiple threads.
Classes that are required to support multithreaded access
(such as the application scope) must use the thread-safe classes.
Expand All @@ -601,7 +601,7 @@ The [jersey plugin](jersey/src) contains a working example. Download a copy and

# Class guide

![class-guide.png](wiki/class-guide.png)
![class-guide.png](docs/class-guide.png)

# Plugin modules

Expand Down
15 changes: 8 additions & 7 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.cowwoc.pouch</groupId>
Expand Down Expand Up @@ -42,9 +43,9 @@
<goal>compile</goal>
</goals>
<configuration>
<release>${maven.release.version}</release>
<release>9</release>
<jdkToolchain>
<version>${maven.release.version}</version>
<version>9</version>
</jdkToolchain>
<compileSourceRoots>
<compileSourceRoot>${project.build.sourceDirectory}</compileSourceRoot>
Expand Down Expand Up @@ -73,9 +74,9 @@
<goal>jar</goal>
</goals>
<configuration>
<!-- WARNING: Must use a newer JDK to avoid https://bugs.openjdk.java.net/browse/JDK-8208269 -->
<jdkToolchain>
<version>${maven.release.version}</version>
<!-- WARNING: Must use a newer JDK to avoid https://bugs.openjdk.java.net/browse/JDK-8208269 -->
<version>23</version>
</jdkToolchain>
<source>1.8</source>
<show>public</show>
Expand All @@ -94,9 +95,9 @@
<goal>aggregate</goal>
</goals>
<configuration>
<!-- WARNING: Must use a newer JDK to avoid https://bugs.openjdk.java.net/browse/JDK-8208269 -->
<jdkToolchain>
<version>${maven.release.version}</version>
<!-- WARNING: Must use a newer JDK to avoid https://bugs.openjdk.java.net/browse/JDK-8208269 -->
<version>23</version>
</jdkToolchain>
<show>public</show>
<additionalOptions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
*/
public abstract class ConcurrentLazyFactory<T> implements Factory<T>
{
/**
* Creates a new instance.
*/
protected ConcurrentLazyFactory()
{
}

/**
* Creates a new {@code ConcurrentLazyFactory}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*/
public abstract class ConcurrentLazyReference<T> implements Reference<T>
{
/**
* Creates a new instance.
*/
protected ConcurrentLazyReference()
{
}

/**
* Creates a new {@code ConcurrentLazyReference}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
public abstract class LazyFactory<T> extends AbstractLazyReference<T>
implements Factory<T>
{
/**
* Creates a new instance.
*/
protected LazyFactory()
{
}

/**
* Creates a new {@code LazyFactory}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
*/
public abstract class LazyReference<T> extends AbstractLazyReference<T>
{
/**
* Creates a new instance.
*/
protected LazyReference()
{
}

/**
* Creates a new {@code LazyReference}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ public interface CheckedRunnable

/**
* A {@link Callable} that does not throw any checked exceptions.
*
* @param <V> the return type of the {@code call} method
*/
@FunctionalInterface
public interface UncheckedCallable<V>
{
/**
* Runs the task.
*
* @return computed result
* @throws WrappedCheckedException if unable to compute a result
*/
V call();
Expand Down
4 changes: 4 additions & 0 deletions wiki/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.1 - 2024/10/29

* Javadoc fixes.

## Version 5.0 - 2024/10/29

* `WrappedCheckedException.wrap(Runnable)` and `wrap(Callable)` now returns a wrapped `Runnable`/`Callable`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ Ease of use and substantially reduced size.

Guava provides comparable functionality:

* [Reference](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/Reference.html) <->
* [Reference](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/Reference.html) <->
[Supplier](https://guava.dev/releases/32.1.1-jre/api/docs/com/google/common/base/Supplier.html)
* [ConstantReference](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConstantReference.html)
* [ConstantReference](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/ConstantReference.html)
<->
[Suppliers.ofInstance()](https://guava.dev/releases/32.1.1-jre/api/docs/com/google/common/base/Suppliers.html#ofInstance-T-)
* [LazyReference](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyReference.html) <->
* [LazyReference](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyReference.html) <->
[Suppliers.memoize()](https://guava.dev/releases/32.1.1-jre/api/docs/com/google/common/base/Suppliers.html#memoize-com.google.common.base.Supplier-)

While it is true
Expand All @@ -175,12 +175,12 @@ For example:
1. [Suppliers.memoize()](https://guava.dev/releases/32.1.1-jre/api/docs/com/google/common/base/Suppliers.html#memoize-com.google.common.base.Supplier-)
doesn't provide a mechanism for checking whether the underlying value has been initialized.
This is important because, when implementing
[Factory.close()](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/Factory.html#close()),
[Factory.close()](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/Factory.html#close()),
you'll want to avoid initializing values that have never been initialized before.
2. This library provides convenience classes such as
[LazyFactory](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyFactory.html)
[LazyFactory](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyFactory.html)
which unifies classes
[LazyReference](https://cowwoc.github.io/pouch/4.0/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyReference.html)
[LazyReference](https://cowwoc.github.io/pouch/5.1/docs/api/com.github.cowwoc.pouch.core/com/github/cowwoc/pouch/core/LazyReference.html)
and [Closeable](http://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html) into a single class.

The size of the Guava library is 2.8MB.
Expand Down
File renamed without changes
File renamed without changes
5 changes: 3 additions & 2 deletions dropwizard/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.cowwoc.pouch</groupId>
Expand Down Expand Up @@ -79,7 +80,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${maven.release.version}</release>
<release>9</release>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
Expand Down
5 changes: 3 additions & 2 deletions jersey/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.cowwoc.pouch</groupId>
Expand Down Expand Up @@ -85,7 +86,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${maven.release.version}</release>
<release>9</release>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
Expand Down
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.cowwoc.pouch</groupId>
<artifactId>root</artifactId>
Expand Down Expand Up @@ -52,8 +53,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.version>3.9.9</maven.version>
<!-- Latest LTS version -->
<maven.release.version>21</maven.release.version>
<junit.version>5.11.3</junit.version>
</properties>

Expand Down Expand Up @@ -200,6 +199,9 @@
<goals>
<goal>jar</goal>
</goals>
<configuration>
<javadocVersion>23</javadocVersion>
</configuration>
</execution>
</executions>
</plugin>
Expand Down

0 comments on commit 70289d4

Please sign in to comment.