SLP-Examples-HelloWorld

The LiveTribe :: SLP Module

How to set up the ServiceAgent to expose services

ServiceAgents expose services. In SLP a service is represented by a ServiceURL, a language, a set of scopes, and its attributes.

Before setting up a ServiceAgent is necessary to figure out at least the ServiceURL of the service that the ServiceAgent will expose; this mostly means to figure out the ServiceURL's URL address, since all other values can have reasonable defaults.
Let's assume we want to expose an administrative web console, that is available at the URL http://myhost:8080/admin.

ServiceAgent sa = SLP.newServiceAgent(null); // Use default configuration
sa.start();

ServiceURL serviceURL = new ServiceURL("service:http://myhost:8080/commands");
String language = Locale.ENGLISH.getLanguage();
Scopes scopes = Scopes.DEFAULT;
Attributes attributes = Attributes.NONE;
ServiceInfo service = new ServiceInfo(serviceURL, language, scopes, attributes);

sa.register(service);

Services can be registered or deregistered at any moment from a ServiceAgent.

How to set up the UserAgent client to discover services

User agents discover services. In SLP services are represented by ServiceURLs, and each ServiceURL references a ServiceType.

Client applications specify to the user agent the ServiceType, language, scopes and attributes they are interested in discovering, and the user agent takes care of the SLP communication.

UserAgentClient uac = SLP.newUserAgentClient(null); // Use default configuration

ServiceType serviceType = new ServiceType("service:http");
String language = null; // Any language
Scopes scopes = Scopes.DEFAULT;
String filter = null;

// A List of ServiceInfos
List<ServiceInfo> services = uac.findServices(serviceType, language, scopes, filter);

Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

or Sign Up  

Other Features

Add Content