Skip to content

Commit

Permalink
Version 1.0.2
Browse files Browse the repository at this point in the history
- Added Runnable overload for Applocker.Builder#busy
- javadoc and sources are now distributed along with the package
  • Loading branch information
sanyarnd committed May 21, 2019
1 parent 60d65d4 commit 4331488
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 67 deletions.
File renamed without changes.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,22 @@ before_script:
after_success:
- mvn pvsstudio:pvsCredentials
- mvn pvsstudio:pvsAnalyze
- mvn sonar:sonar
- mvn sonar:sonar -DskipTests=true
- fossa init
- fossa analyze


deploy:
- provider: releases
api_key: $GITHUB_API_KEY
file_glob: true
file: "/home/travis/build/sanyarnd/applocker/target/app-locker*.jar"
file:
- /home/travis/build/sanyarnd/applocker/target/app-locker-$TRAVIS_TAG.jar
- /home/travis/build/sanyarnd/applocker/target/app-locker-$TRAVIS_TAG-javadoc.jar
- /home/travis/build/sanyarnd/applocker/target/app-locker-$TRAVIS_TAG-sources.jar
skip_cleanup: true
on:
tags: true
- provider: script
script: "cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy"
script: "cp .m2/settings.xml $HOME/.m2/settings.xml && mvn deploy"
skip_cleanup: true
on:
tags: true
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# 1.0.1
# 1.0.2
- `AppLocker.Builder`'s `busy` method now supports `Runnable` callback
- javadoc and sources are now distributed along with the package

# 1.0.1
- Removed unnecessary builders
- Improved test coverage

# 1.0

- Initial commit

92 changes: 61 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sanyarnd</groupId>
<artifactId>app-locker</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<url>https://github.com/sanyarnd/applocker</url>
<packaging>jar</packaging>

Expand Down Expand Up @@ -52,9 +52,11 @@
<maven-shade-plugin.version>3.2.1</maven-shade-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>

<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<versions-maven-plugin.version>2.7</versions-maven-plugin.version>
<pvsstudio-maven-plugin.version>7.02.32034</pvsstudio-maven-plugin.version>
<jacoco.version>0.8.4</jacoco.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
<sonar-maven-plugin.version>3.6.0.1398</sonar-maven-plugin.version>

<lombok.version>1.18.8</lombok.version>
Expand Down Expand Up @@ -83,6 +85,51 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<outputDirectory>target/reports</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.pvsstudio</groupId>
<artifactId>pvsstudio-maven-plugin</artifactId>
<configuration>
<username>PVS-Studio Free</username>
<serialNumber>FREE-FREE-FREE-FREE</serialNumber>
<analyzer>
<outputType>xml</outputType>
<outputFile>target/reports/pvs-output.xml</outputFile>
</analyzer>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -106,7 +153,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand All @@ -120,7 +166,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -129,30 +174,21 @@
<useFile>false</useFile>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<outputDirectory>target/reports</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.pvsstudio</groupId>
<artifactId>pvsstudio-maven-plugin</artifactId>
<configuration>
<username>PVS-Studio Free</username>
<serialNumber>FREE-FREE-FREE-FREE</serialNumber>
<analyzer>
<outputType>xml</outputType>
<outputFile>target/reports/pvs-output.xml</outputFile>
</analyzer>
</configuration>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>

<plugin>
<groupId>com.pvsstudio</groupId>
<artifactId>pvsstudio-maven-plugin</artifactId>
Expand All @@ -161,7 +197,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
Expand Down Expand Up @@ -234,12 +270,6 @@
</pluginManagement>
</build>

<scm>
<url>https://github.com/sanyarnd/applocker</url>
<connection>scm:git:git@github.com:sanyarnd/applocker.git</connection>
<developerConnection>scm:git:git@github.com:sanyarnd/applocker.git</developerConnection>
</scm>

<distributionManagement>
<repository>
<id>bintray-sanya-rnd-maven-projects</id>
Expand Down
43 changes: 28 additions & 15 deletions src/main/java/io/github/sanyarnd/applocker/AppLocker.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@
import io.github.sanyarnd.applocker.exceptions.LockingFailedException;
import io.github.sanyarnd.applocker.filesystem.LockNameProvider;
import io.github.sanyarnd.applocker.filesystem.Sha1Provider;
import io.github.sanyarnd.applocker.messaging.Client;
import io.github.sanyarnd.applocker.messaging.MessageHandler;
import io.github.sanyarnd.applocker.messaging.Server;

/**
* Locker class, provides methods for locking mechanism and
* encapsulates socket-based message server for IPC.
* <p>
* You don't need call {@link #unlock()} directly, method will be called once JVM is terminated.<br/>
* You don't need call {@link #unlock()} directly, method will be called once JVM is terminated.<br>
* You're free to call {@link #unlock()} any time if it is required by your application logic.
*
* @author Alexander Biryukov
Expand Down Expand Up @@ -157,7 +154,7 @@ public void lock() {
}

/**
* Unlock the lock.<br/>
* Unlock the lock.<br>
* Does nothing if lock is not locked
*/
public void unlock() {
Expand Down Expand Up @@ -246,7 +243,7 @@ public static final class Builder {
public Builder(@Nonnull String id) { this.id = id; }

/**
* Sets the path where the lock file will be stored<br/>
* Sets the path where the lock file will be stored<br>
* Default value is "." (relative)
*
* @param path store path
Expand All @@ -258,8 +255,8 @@ public Builder setPath(@Nonnull Path path) {
}

/**
* Sets the message handler.<br/>
* If not set, AppLocker won't support communication features <br/>
* Sets the message handler.<br>
* If not set, AppLocker won't support communication features <br>
* Default value is null
*
* @param handler message handler
Expand All @@ -271,8 +268,8 @@ public Builder setMessageHandler(@Nonnull MessageHandler<?, ?> handler) {
}

/**
* Sets the name provider.<br/>
* Provider encodes lock id to filesystem-friendly entry<br/>
* Sets the name provider.<br>
* Provider encodes lock id to filesystem-friendly entry<br>
* Default value is {@link Sha1Provider}
*
* @param provider name provider
Expand All @@ -284,8 +281,8 @@ public Builder setNameProvider(@Nonnull LockNameProvider provider) {
}

/**
* Successful locking callback.<br/>
* By default does nothing
* Successful locking callback.<br>
* Does nothing if not set
*
* @param callback the function to call after successful locking
* @return builder
Expand All @@ -296,8 +293,8 @@ public Builder acquired(@Nonnull Runnable callback) {
}

/**
* Lock is already taken callback.<br/>
* By default does nothing (null)
* Lock is already taken callback.<br>
* Default value is null
*
* @param message message for lock holder
* @param handler answer processing function
Expand All @@ -313,7 +310,23 @@ public <T extends Serializable> Builder busy(@Nonnull Serializable message, @Non
}

/**
* Unable to lock for unknown reasons callback.<br/>
* Lock is already taken callback.<br>
* Default value is null
*
* @param message message for lock holder
* @param handler callback which ignores the answer
* @return builder
*/
public Builder busy(@Nonnull Serializable message, @Nonnull Runnable handler) {
busyHandler = (appLocker, ex) -> {
appLocker.sendMessage(message);
handler.run();
};
return this;
}

/**
* Unable to lock for unknown reasons callback.<br>
* By default re-throws the exception
*
* @param handler error processing function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package io.github.sanyarnd.applocker.messaging;
package io.github.sanyarnd.applocker;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand All @@ -33,7 +33,7 @@
*
* @author Alexander Biryukov
*/
public final class Client<I extends Serializable, O extends Serializable> {
final class Client<I extends Serializable, O extends Serializable> {
private final int port;

public Client(int port) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/sanyarnd/applocker/Lock.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.github.sanyarnd.applocker.exceptions.LockingFailedException;

/**
* File-channel based lock <br/>
* File-channel based lock <br>
* Lock is not not thread safe, so you cna easily break
*
* @author Alexander Biryukov
Expand All @@ -61,7 +61,7 @@ public void close() {
}

/**
* Tries to acquire the lock and ignores any {@link LockingBusyException} during the process.<br/>
* Tries to acquire the lock and ignores any {@link LockingBusyException} during the process.<br>
* Be aware that it's easy to get a spin lock if the other Lock won't call {@link #unlock()}, that's
* why loopLock is used only for global lock acquiring.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package io.github.sanyarnd.applocker.messaging;
package io.github.sanyarnd.applocker;

import java.io.Serializable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package io.github.sanyarnd.applocker.messaging;
package io.github.sanyarnd.applocker;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand All @@ -39,7 +39,7 @@
*
* @author Alexander Biryukov
*/
public final class Server<I extends Serializable, O extends Serializable> {
final class Server<I extends Serializable, O extends Serializable> {
@Nonnull
private final MessageHandler<I, O> handler;
@Nonnull
Expand Down Expand Up @@ -110,7 +110,7 @@ public int getPort() {

/**
* Blocking version of {@link #getPort()}, ignores {@link LockingCommunicationException}
* and tries to retrieve the port number.<br/>
* and tries to retrieve the port number.<br>
* This method is useful for situations where you need to retrieve the port number right after the start
*
* @return port number
Expand Down

0 comments on commit 4331488

Please sign in to comment.