Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mvn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-24.04, windows-2022, macos-15]
java: [17, 21]
java: [21]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-servlet-server</artifactId>
<version>4.0.2</version>
<version>5.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -214,7 +214,7 @@
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.25.1</version>
<version>0.27.6</version>
<configuration>
<excludes combine.children="append">
<exclude>findbugs:.*</exclude>
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/co/stateful/Atomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
@EqualsAndHashCode(of = { "callable", "lock" })
public final class Atomic<T> implements Callable<T> {

/**
* Default maximum waiting time, in milliseconds (five minutes).
*/
private static final long DEFAULT_MAX = TimeUnit.MINUTES.toMillis(5L);

/**
* Random.
*/
Expand Down Expand Up @@ -92,7 +97,7 @@ public Atomic(final Callable<T> clbl, final Lock lck) {
* @param lbl Label to use for locking and unlocking (can be empty)
*/
public Atomic(final Callable<T> clbl, final Lock lck, final String lbl) {
this(clbl, lck, lbl, TimeUnit.MINUTES.toMillis(5L));
this(clbl, lck, lbl, Atomic.DEFAULT_MAX);
}

// @checkstyle ParameterNumberCheck (15 lines)
Expand Down Expand Up @@ -184,5 +189,4 @@ public T callQuietly() {
throw new IllegalStateException(ex);
}
}

}
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

/**
* Counter.
*
* @since 0.1
*/
@Immutable
Expand All @@ -36,5 +35,4 @@ public interface Counter {
* @throws IOException If some I/O problem
*/
long incrementAndGet(long delta) throws IOException;

}
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/Counters.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

/**
* Counters.
*
* @since 0.1
*/
@Immutable
Expand Down Expand Up @@ -44,5 +43,4 @@ public interface Counters {
* @throws IOException If some I/O problem
*/
Counter get(String name) throws IOException;

}
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/Lock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

/**
* Lock.
*
* @since 0.3
*/
@Immutable
Expand Down Expand Up @@ -47,5 +46,4 @@ public interface Lock {
* @since 0.11
*/
boolean unlock(String label) throws IOException;

}
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/Locks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

/**
* Locks.
*
* @since 0.2
*/
@Immutable
Expand All @@ -31,5 +30,4 @@ public interface Locks {
* @throws IOException If fails
*/
Lock get(String name) throws IOException;

}
17 changes: 8 additions & 9 deletions src/main/java/co/stateful/RtCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* Counter.
*
* @since 0.1
* @checkstyle MultipleStringLiteralsCheck (500 lines)
*/
Expand All @@ -29,6 +28,13 @@
@EqualsAndHashCode(of = { "label", "request" })
final class RtCounter implements Counter {

/**
* XPath template to a counter operation link.
* @checkstyle LineLength (3 lines)
*/
private static final String XPATH =
"/page/counters/counter[name='%s']/links/link[@rel='%s']/@href";

/**
* Its name.
*/
Expand Down Expand Up @@ -95,13 +101,6 @@ private Request front(final String ops) throws IOException {
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.rel(
String.format(
// @checkstyle LineLength (1 line)
"/page/counters/counter[name='%s']/links/link[@rel='%s']/@href",
this.label, ops
)
);
.rel(String.format(RtCounter.XPATH, this.label, ops));
}

}
16 changes: 8 additions & 8 deletions src/main/java/co/stateful/RtCounters.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* Counters.
*
* @since 0.1
* @checkstyle MultipleStringLiteralsCheck (500 lines)
*/
Expand All @@ -29,6 +28,13 @@
@EqualsAndHashCode(of = "request")
final class RtCounters implements Counters {

/**
* XPath template to a counter delete link.
* @checkstyle LineLength (3 lines)
*/
private static final String XPATH_DELETE =
"/page/counters/counter[name='%s']/links/link[@rel='delete']/@href";

/**
* Entry request.
*/
Expand Down Expand Up @@ -81,13 +87,7 @@ public void delete(final String name) throws IOException {
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.rel(
String.format(
// @checkstyle LineLength (1 line)
"/page/counters/counter[name='%s']/links/link[@rel='delete']/@href",
name
)
)
.rel(String.format(RtCounters.XPATH_DELETE, name))
.header(HttpHeaders.ACCEPT, MediaType.TEXT_XML)
.uri().queryParam("name", name).back()
.fetch()
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/RtLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

/**
* Lock.
*
* @since 0.3
* @checkstyle MultipleStringLiteralsCheck (500 lines)
*/
Expand Down Expand Up @@ -111,5 +110,4 @@ private Request front(final String label) throws IOException {
.as(XmlResponse.class)
.rel(String.format("/page/links/link[@rel='%s']/@href", label));
}

}
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/RtLocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

/**
* Locks.
*
* @since 0.2
* @checkstyle MultipleStringLiteralsCheck (500 lines)
*/
Expand Down Expand Up @@ -58,5 +57,4 @@ public boolean exists(final String name) throws IOException {
public Lock get(final String name) {
return new RtLock(name, this.request);
}

}
63 changes: 41 additions & 22 deletions src/main/java/co/stateful/RtSttc.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,16 @@ public final class RtSttc implements Sttc {
* @param token Security token
*/
public RtSttc(final URN urn, final String token) {
this.request = new JdkRequest("https://www.stateful.co")
.through(OneMinuteWire.class)
.through(RetryWire.class)
.through(VerboseWire.class)
.through(CachingWire.class, "((POST|PUT|PATCH) .*|.*\\?.*)")
.header("X-Sttc-URN", urn.toString())
.header("X-Sttc-Token", token)
.header(HttpHeaders.ACCEPT, MediaType.TEXT_XML)
.header(HttpHeaders.USER_AGENT, "java-sdk.stateful.co");
// @checkstyle ConstructorsCodeFreeCheck (1 line)
this(RtSttc.entry(urn, token));
}

/**
* Make an instance of it.
* @param urn Owner URN
* @param token Security token
* @return Sttc
* Ctor.
* @param req Entry request
*/
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Sttc make(final URN urn, final String token) {
final Sttc sttc;
if (token.matches("[A-F0-9\\-]{19}")) {
sttc = new RtSttc(urn, token);
} else {
sttc = new MkSttc();
}
return sttc;
private RtSttc(final Request req) {
this.request = req;
}

@Override
Expand All @@ -118,4 +102,39 @@ public Locks locks() throws IOException {
.rel("/page/links/link[@rel='menu:locks']/@href")
);
}

/**
* Make an instance of it.
* @param urn Owner URN
* @param token Security token
* @return Sttc
*/
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Sttc make(final URN urn, final String token) {
final Sttc sttc;
if (token.matches("[A-F0-9\\-]{19}")) {
sttc = new RtSttc(urn, token);
} else {
sttc = new MkSttc();
}
return sttc;
}

/**
* Build entry request.
* @param urn Owner URN
* @param token Security token
* @return Request
*/
private static Request entry(final URN urn, final String token) {
return new JdkRequest("https://www.stateful.co")
.through(OneMinuteWire.class)
.through(RetryWire.class)
.through(VerboseWire.class)
.through(CachingWire.class, "((POST|PUT|PATCH) .*|.*\\?.*)")
.header("X-Sttc-URN", urn.toString())
.header("X-Sttc-Token", token)
.header(HttpHeaders.ACCEPT, MediaType.TEXT_XML)
.header(HttpHeaders.USER_AGENT, "java-sdk.stateful.co");
}
}
1 change: 0 additions & 1 deletion src/main/java/co/stateful/Sttc.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ public interface Sttc {
* @throws IOException If some I/O problem
*/
Locks locks() throws IOException;

}
1 change: 0 additions & 1 deletion src/main/java/co/stateful/cached/CdCounters.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* Cached counters.
*
* @since 0.7
*/
@Immutable
Expand Down
1 change: 0 additions & 1 deletion src/main/java/co/stateful/cached/CdLocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* Cached locks.
*
* @since 0.7
*/
@Immutable
Expand Down
1 change: 0 additions & 1 deletion src/main/java/co/stateful/cached/CdSttc.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

/**
* Cached Sttc.
*
* @since 0.7
*/
@Immutable
Expand Down
1 change: 0 additions & 1 deletion src/main/java/co/stateful/cached/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

/**
* Cached SDK interfaces (highly recommended to use in production).
*
* @since 0.7
*/
package co.stateful.cached;
1 change: 0 additions & 1 deletion src/main/java/co/stateful/mock/MkCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

/**
* Mock counter.
*
* @since 0.1
*/
@Immutable
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/mock/MkCounters.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

/**
* Mock counters.
*
* @since 0.1
*/
@Immutable
Expand Down Expand Up @@ -42,5 +41,4 @@ public void delete(final String name) {
public Counter get(final String name) {
return new MkCounter();
}

}
1 change: 0 additions & 1 deletion src/main/java/co/stateful/mock/MkLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

/**
* Mock lock.
*
* @since 0.3
*/
@Immutable
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/co/stateful/mock/MkLocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

/**
* Mock locks.
*
* @since 0.2
*/
@Immutable
Expand All @@ -31,5 +30,4 @@ public boolean exists(final String name) {
public Lock get(final String name) {
return new MkLock();
}

}
1 change: 0 additions & 1 deletion src/main/java/co/stateful/mock/MkSttc.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

/**
* Mock.
*
* @since 0.1
*/
@Immutable
Expand Down
1 change: 0 additions & 1 deletion src/main/java/co/stateful/retry/ReCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/**
* Retriable counter.
*
* @since 0.5
*/
@Immutable
Expand Down
1 change: 0 additions & 1 deletion src/main/java/co/stateful/retry/ReCounters.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* Retriable counters.
*
* @since 0.5
*/
@Immutable
Expand Down
Loading
Loading