Skip to content

Commit

Permalink
Adjusted configuration and docs for separate adapter library
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvazan committed Apr 11, 2023
1 parent 78d6ebe commit 4695a86
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 104 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Experimental. [Stagean](https://stagean.machinezoo.com/) is used to track progre

## Documentation

There is no javadoc yet. See [source code](src/main/java/com/machinezoo/hookless) for available APIs.
There is no javadoc yet. See [source code](src/main/java/com/machinezoo/hookless/prefs) for available APIs.

## Feedback

Expand Down
55 changes: 3 additions & 52 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,64 +50,15 @@
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.machinezoo.noexception</groupId>
<artifactId>noexception</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.machinezoo.noexception</groupId>
<artifactId>noexception-slf4j</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.6</version>
<groupId>com.machinezoo.hookless</groupId>
<artifactId>hookless</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>0.33.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.github.valfirst</groupId>
<artifactId>slf4j-test</artifactId>
<version>2.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
11 changes: 1 addition & 10 deletions scripts/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ def has_website(self): return False

def dependencies(self):
yield from super().dependencies()
yield self.use_noexception()
yield self.use_noexception_slf4j()
yield self.use_fastutil()
yield self.use_hookless()
yield self.use_guava()
yield self.use('io.micrometer:micrometer-core:1.6.4')
yield self.use('io.opentracing:opentracing-util:0.33.0')
yield self.use_junit()
yield self.use_hamcrest()
yield self.use('org.awaitility:awaitility:4.0.3', 'test')
yield self.use('org.junit-pioneer:junit-pioneer:0.9.0')
yield self.use_slf4j_test()

def javadoc_links(self):
yield from super().javadoc_links()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* Reactive version of {@link AbstractPreferences}.
*/
@StubDocs
@NoTests
public abstract class AbstractReactivePreferences extends ReactivePreferences {
/*
* First we define linking from children to parents.
Expand Down Expand Up @@ -258,12 +257,12 @@ public String get(String key, String def) {
@Override
public boolean getBoolean(String key, boolean def) {
switch (get(key, "").toLowerCase()) {
case "true":
return true;
case "false":
return false;
default:
return def;
case "true":
return true;
case "false":
return false;
default:
return def;
}
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* Reactive version of {@link Preferences}.
*/
@StubDocs
@NoTests
@DraftApi("configurable wrap(), perhaps require strong consistency, export")
public abstract class ReactivePreferences {
public abstract String name();
Expand Down Expand Up @@ -112,10 +111,10 @@ private static String packagePath(Class<?> clazz) {
if (clazz.isArray())
throw new IllegalArgumentException("No preferences node for arrays.");
String name = clazz.getName();
int dot = name.lastIndexOf('.');
if (dot < 0)
return "<unnamed>";
return name.substring(0, dot).replace('.', '/');
int dot = name.lastIndexOf('.');
if (dot < 0)
return "<unnamed>";
return name.substring(0, dot).replace('.', '/');
}
public static ReactivePreferences systemNodeForPackage(Class<?> clazz) {
return systemRoot().node(ReactivePreferences.packagePath(clazz));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import java.util.function.Supplier;
import java.util.prefs.*;
import com.google.common.base.*;
import com.machinezoo.stagean.*;

@NoTests
class ReactivePreferencesFactoryWrapper implements ReactivePreferencesFactory {
/*
* Make the wrappers lazy, so that we don't initialize systemRoot unnecessarily.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import com.machinezoo.hookless.*;
import com.machinezoo.hookless.util.*;
import com.machinezoo.noexception.throwing.*;
import com.machinezoo.stagean.*;

/*
* This is a wrapper around Preferences, but we in fact assume behavior of AbstractPreferences as currently implemented.
* Most importantly, we assume that events are executed asynchronously on separate thread as is done in AbstractPreferences.
* This implementation will still work with inline invocation of listeners as long as no lock is held by Preferences during invocation.
*/
@NoTests
class ReactivePreferencesWrapper extends AbstractReactivePreferences {
/*
* Read-only methods operating on the node tree are easy to define. Let's get that done first.
Expand Down
34 changes: 9 additions & 25 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
// Part of Hookless: https://hookless.machinezoo.com
import com.machinezoo.stagean.*;

/**
* Hookless is a reactive programming library for Java based on invalidate-then-refresh pattern and implemented via thread-local context object.
* See the <a href="https://hookless.machinezoo.com/">website</a> for more information.
* <p>
* The main package {@link com.machinezoo.hookless} contains reactive primitives and other core reactive classes.
* Other packages provide reactive wrappers and reactive alternatives to various JRE classes.
*
* @see <a href="https://hookless.machinezoo.com/">Hookless website</a>
* Reactive versions of classes from {@link java.util.prefs}.
* See {@link com.machinezoo.hookless.prefs} package.
*/
module com.machinezoo.hookless {
exports com.machinezoo.hookless;
exports com.machinezoo.hookless.util;
exports com.machinezoo.hookless.time;
exports com.machinezoo.hookless.noexception;
@StubDocs
@NoTests
@DraftApi
module com.machinezoo.hookless.prefs {
exports com.machinezoo.hookless.prefs;
requires com.machinezoo.hookless;
/*
* Preferences should be moved to separate library along with this dependency.
*/
requires transitive java.prefs;
requires com.machinezoo.stagean;
/*
* This dependency should be downgraded to non-transitive once exception handlers are moved to separate library.
*/
requires transitive com.machinezoo.noexception;
requires com.machinezoo.noexception.slf4j;
/*
* SLF4J is pulled in transitively via noexception, but the transitive dependency will be removed in future versions of noexception.
*/
requires org.slf4j;
requires com.google.common;
requires io.opentracing.api;
requires io.opentracing.util;
requires it.unimi.dsi.fastutil;
requires micrometer.core;
/*
* Default ReactivePreferencesFactory can be configured via SPI just like PreferencesFactory.
*/
Expand Down

0 comments on commit 4695a86

Please sign in to comment.