hola

Runtime scanning and initializing utilities for HK2 so you don't have to rely on hk2-locator/default files created by the inhabitant-generator.

License

License

Categories

Categories

Net
GroupId

GroupId

net.sagebits
ArtifactId

ArtifactId

hola
Last Version

Last Version

0.2.4-sagebits
Release Date

Release Date

Type

Type

jar
Description

Description

hola
Runtime scanning and initializing utilities for HK2 so you don't have to rely on hk2-locator/default files created by the inhabitant-generator.
Project URL

Project URL

https://bitbucket.org/sagebits/hk2utilities
Source Code Management

Source Code Management

https://github.com/Sagebits/hola

Download hola

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.30

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

Hola Build Status

Hola is a minimalist Java implementation of Multicast DNS Service Discovery (mDNS-SD). The purpose of Hola is to give Java developers a dead-simple API for finding Zeroconf-enabled services on a local network. It follows RFCs 6762 and 6763 and is compatible with Apple's Bonjour mDNS-SD implementation.

Features

Hola is a work-in-progress. The following features are currently supported:

  • Browse (synchronously) for instances of services on a local network
  • Retrieve information about discovered services, including network addresses, ports, and user-friendly names
  • Supports both IPv4 and IPv6 networks

API Example

To search for services, create a Query specifying the type of service you're looking for and the domain to search. You can execute a blocking search with the runOnce() method; this will return a set of Instance objects representing the discovered instances. As an example, the following code will search for TiVo devices on the user's local network:

public class TivoFinder {
    final static Logger logger = LoggerFactory.getLogger(TivoFinder.class);

    public static void main(String[] args) {
        try {
            Service service = Service.fromName("_tivo-mindrpc._tcp");
            Query query = Query.createFor(service, Domain.LOCAL);
            Set<Instance> instances = query.runOnce();
            instances.stream().forEach(System.out::println);
        } catch (UnknownHostException e) {
            logger.error("Unknown host: ", e);
        } catch (IOException e) {
            logger.error("IO error: ", e);
        }
    }
}

Each Instance will have a user-visible name, a set of IP addresses, a port number, and a map of attributes:

String userVisibleName = instance.getName();
Set<InetAddress> addresses = instance.getAddresses();
int port = instance.getPort();
if (instance.hasAttribute("platform")) {
    String platform = instance.lookupAttribute("platform");
}

An asynchronous run() method is planned for performing a continuous service discovery operation, but this feature is not yet implemented.

Requirements

Hola requires Java 8 or higher. It handles logging via SLF4J, so the slf4j-api.jar must also be in your Hola-enabled project's class path.

License

Hola is free software and released under the MIT License.

net.sagebits

Sagebits LLC

Public repositories for Sagebits

Versions

Version
0.2.4-sagebits