All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.addc.commons.slp.AdvertiserImpl Maven / Gradle / Ivy

Go to download

The addc-slp library supplies client classes for registering objects with a Service Location Protocol Daemon and for looking theses objects up later.

There is a newer version: 2.6
Show newest version
package com.addc.commons.slp;

import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.addc.commons.slp.configuration.SLPConfig;
import com.addc.commons.slp.messages.ServiceDeregistration;
import com.addc.commons.slp.messages.ServiceRegistration;

/**
 * The AdvertiserImpl class supplies the implementation of the Advertiser
 * interface.
 */
class AdvertiserImpl implements Advertiser {
    private static final Logger LOGGER= LoggerFactory.getLogger(AdvertiserImpl.class);
    private final SLPConfig config;
    private final NetworkManager netManager;

    /**
     * Create a new AdvertiserImpl
     * 
     * @param config
     *            The configuration.
     */
    AdvertiserImpl(SLPConfig config, NetworkManager netManager) {
        this.config= config;
        this.netManager= netManager;
        LOGGER.info("Created new Advertiser");
    }

    @Override
    public Locale getLocale() {
        return config.getLocale();
    }

    @Override
    public void register(ServiceURL url, List attributes) throws ServiceLocationException {
        ServiceRegistration sr= new ServiceRegistration(config, url, attributes);
        sr.sign();
        netManager.saMessage(sr);
    }

    @Override
    public void deregister(ServiceURL url) throws ServiceLocationException {
        ServiceDeregistration sd= new ServiceDeregistration(config, url);
        netManager.saMessage(sd);
    }

    @Override
    public void addAttributes(ServiceURL url, List attributes) throws ServiceLocationException {
        throw new ServiceLocationException("Incremental Registrations are not supported",
                SLPConstants.NOT_IMPLEMENTED);
    }

    @Override
    public void deleteAttributes(ServiceURL url, List attributeIds) throws ServiceLocationException {
        throw new ServiceLocationException("Incremental Deregistrations are not supported",
                SLPConstants.NOT_IMPLEMENTED);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy