Barbary Watch Service for OSX

An implementation of Java 7’s WatchService for Java 6 on Mac OS X

License

License

Categories

Categories

Net
GroupId

GroupId

net.incongru.watchservice
ArtifactId

ArtifactId

barbary-watchservice
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Barbary Watch Service for OSX
An implementation of Java 7’s WatchService for Java 6 on Mac OS X
Project URL

Project URL

https://github.com/gjoseph/BarbaryWatchService
Source Code Management

Source Code Management

https://github.com/gjoseph/BarbaryWatchService

Download barbary-watchservice

How to add to project

<!-- https://jarcasting.com/artifacts/net.incongru.watchservice/barbary-watchservice/ -->
<dependency>
    <groupId>net.incongru.watchservice</groupId>
    <artifactId>barbary-watchservice</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.incongru.watchservice/barbary-watchservice/
implementation 'net.incongru.watchservice:barbary-watchservice:1.0'
// https://jarcasting.com/artifacts/net.incongru.watchservice/barbary-watchservice/
implementation ("net.incongru.watchservice:barbary-watchservice:1.0")
'net.incongru.watchservice:barbary-watchservice:jar:1.0'
<dependency org="net.incongru.watchservice" name="barbary-watchservice" rev="1.0">
  <artifact name="barbary-watchservice" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.incongru.watchservice', module='barbary-watchservice', version='1.0')
)
libraryDependencies += "net.incongru.watchservice" % "barbary-watchservice" % "1.0"
[net.incongru.watchservice/barbary-watchservice "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
net.java.dev.jna : jna jar 3.2.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

BarbaryWatchService

This is the official BarbaryWatchService repository, moved from https://code.google.com/p/barbarywatchservice/

See issues for current plans.

Build Status

An implementation of Java 7’s WatchService for Java 6 on Mac OS X

Java 7 has an API to detect file system changes called Watch Service. This project uses JNA to hook into Apple’s File System Events API.

This is almost a direct drop-in replacement for Java 7’s Watch Service API. I’ve used the API source code from OpenJDK 7 as much as possible.

There’s a Demo example here.

A lot of source code is from OpenJDK.

Differences from Java 7’s API

You obtain a Watch Service instance as follows:

WatchService watcher = WatchService.newWatchService();

Instead of creating Path objects, use WatchableFile objects:

WatchableFile file1 = new WatchableFile(new File("/path/to/watch"));

There is a tutorial for Java 7’s Watch Service API here.

Download

Get the Maven dependency:

  <dependency>
    <groupId>net.incongru.watchservice</groupId>
    <artifactId>barbary-watchservice</artifactId>
    <version>1.0</version>
  </dependency>

Versions

Version
1.0