当前位置: 首页>>代码示例>>Java>>正文


Java ServiceListener类代码示例

本文整理汇总了Java中javax.jmdns.ServiceListener的典型用法代码示例。如果您正苦于以下问题:Java ServiceListener类的具体用法?Java ServiceListener怎么用?Java ServiceListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceListener类属于javax.jmdns包,在下文中一共展示了ServiceListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStopZeroConfService

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Test
public void testStopZeroConfService() throws Exception {
    // Test Desc. : Verify if on stop() of ZeroConfDiscoveryProvider
    // Service, implicitly invoke the removeServiceListener() on JmDns
    // instance,

    DiscoveryFilter filter = new DiscoveryFilter("Apple TV", "_testservicetype._tcp.local.");
    dp.serviceFilters.add(filter);

    ServiceListener listener = dp.jmdnsListener;

    verify(mDNS, Mockito.never()).removeServiceListener(
            filter.getServiceFilter(), listener);
    dp.stop();
    verify(mDNS, Mockito.times(1)).removeServiceListener(
            filter.getServiceFilter(), listener);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:ZeroConfDiscoveryPrividerTest.java

示例2: JmmDNSImpl

import javax.jmdns.ServiceListener; //导入依赖的package包/类
/**
 *
 */
public JmmDNSImpl() {
    super();
    _networkListeners = Collections.synchronizedSet(new HashSet<NetworkTopologyListener>());
    _knownMDNS = new ConcurrentHashMap<InetAddress, JmDNS>();
    _services = new ConcurrentHashMap<String, ServiceInfo>(20);
    _ListenerExecutor = Executors.newSingleThreadExecutor();
    _jmDNSExecutor = Executors.newCachedThreadPool();
    _timer = new Timer("Multihommed mDNS.Timer", true);
    _serviceListeners = new ConcurrentHashMap<String, List<ServiceListener>>();
    _typeListeners = Collections.synchronizedSet(new HashSet<ServiceTypeListener>());
    _serviceTypes = Collections.synchronizedSet(new HashSet<String>());
    (new NetworkChecker(this, NetworkTopologyDiscovery.Factory.getInstance())).start(_timer);
    _isClosing = new AtomicBoolean(false);
    _closed = new AtomicBoolean(false);
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:19,代码来源:JmmDNSImpl.java

示例3: addServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void addServiceListener(String type, ServiceListener listener) {
    final String loType = type.toLowerCase();
    List<ServiceListener> list = _serviceListeners.get(loType);
    if (list == null) {
        _serviceListeners.putIfAbsent(loType, new LinkedList<ServiceListener>());
        list = _serviceListeners.get(loType);
    }
    if (list != null) {
        synchronized (list) {
            if (!list.contains(listener)) {
                list.add(listener);
            }
        }
    }
    for (JmDNS mDNS : _knownMDNS.values()) {
        mDNS.addServiceListener(type, listener);
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:20,代码来源:JmmDNSImpl.java

示例4: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void removeServiceListener(String type, ServiceListener listener) {
    String loType = type.toLowerCase();
    List<ServiceListener> list = _serviceListeners.get(loType);
    if (list != null) {
        synchronized (list) {
            list.remove(listener);
            if (list.isEmpty()) {
                _serviceListeners.remove(loType, list);
            }
        }
    }
    for (JmDNS mDNS : _knownMDNS.values()) {
        mDNS.removeServiceListener(type, listener);
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:17,代码来源:JmmDNSImpl.java

示例5: JmmDNSImpl

import javax.jmdns.ServiceListener; //导入依赖的package包/类
/**
 *
 */
public JmmDNSImpl() {
    super();
    _networkListeners = Collections.synchronizedSet(new HashSet<NetworkTopologyListener>());
    _knownMDNS = new ConcurrentHashMap<InetAddress, JmDNS>();
    _services = new ConcurrentHashMap<String, ServiceInfo>(20);
    _listenerExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("JmmDNS Listeners"));
    _jmDNSExecutor = Executors.newCachedThreadPool(new NamedThreadFactory("JmmDNS"));
    _timer = new Timer("Multihomed mDNS.Timer", true);
    _serviceListeners = new ConcurrentHashMap<String, List<ServiceListener>>();
    _typeListeners = Collections.synchronizedSet(new HashSet<ServiceTypeListener>());
    _serviceTypes = Collections.synchronizedSet(new HashSet<String>());
    (new NetworkChecker(this, NetworkTopologyDiscovery.Factory.getInstance())).start(_timer);
    _isClosing = new AtomicBoolean(false);
    _closed = new AtomicBoolean(false);
}
 
开发者ID:JMRI,项目名称:EngineDriver,代码行数:19,代码来源:JmmDNSImpl.java

示例6: addServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void addServiceListener(String type, ServiceListener listener) {
    final String loType = type.toLowerCase();
    List<ServiceListener> list = _serviceListeners.get(loType);
    if (list == null) {
        _serviceListeners.putIfAbsent(loType, new LinkedList<ServiceListener>());
        list = _serviceListeners.get(loType);
    }
    if (list != null) {
        synchronized (list) {
            if (!list.contains(listener)) {
                list.add(listener);
            }
        }
    }
    for (JmDNS mDNS : this.getDNS()) {
        mDNS.addServiceListener(type, listener);
    }
}
 
开发者ID:JMRI,项目名称:EngineDriver,代码行数:20,代码来源:JmmDNSImpl.java

示例7: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void removeServiceListener(String type, ServiceListener listener) {
    String loType = type.toLowerCase();
    List<ServiceListener> list = _serviceListeners.get(loType);
    if (list != null) {
        synchronized (list) {
            list.remove(listener);
            if (list.isEmpty()) {
                _serviceListeners.remove(loType, list);
            }
        }
    }
    for (JmDNS mDNS : this.getDNS()) {
        mDNS.removeServiceListener(type, listener);
    }
}
 
开发者ID:JMRI,项目名称:EngineDriver,代码行数:17,代码来源:JmmDNSImpl.java

示例8: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void removeServiceListener(String type, ServiceListener listener)
{
    String aType = type.toLowerCase();
    List<ServiceListenerStatus> list = _serviceListeners.get(aType);
    if (list != null)
    {
        synchronized (list)
        {
            ServiceListenerStatus status = new ServiceListenerStatus(listener);
            list.remove(status);
            if (list.isEmpty())
            {
                _serviceListeners.remove(aType, list);
            }
        }
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:22,代码来源:JmDNSImpl.java

示例9: setup

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Before
public void setup() {
    boolean log = false;
    if (log) {
        ConsoleHandler handler = new ConsoleHandler();
        handler.setLevel(Level.FINEST);
        for (Enumeration<String> enumerator = LogManager.getLogManager().getLoggerNames(); enumerator.hasMoreElements();) {
            String loggerName = enumerator.nextElement();
            Logger logger = Logger.getLogger(loggerName);
            logger.addHandler(handler);
            logger.setLevel(Level.FINEST);
        }
    }

    String text = "Test hypothetical web server";
    Map<String, byte[]> properties = new HashMap<String, byte[]>();
    properties.put(serviceKey, text.getBytes());
    service = ServiceInfo.create("_html._tcp.local.", "apache-someuniqueid", 80, 0, 0, true, properties);
    typeListenerMock = createMock(ServiceTypeListener.class);
    serviceListenerMock = createNiceMock("ServiceListener", ServiceListener.class);
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:22,代码来源:JmmDNSTest.java

示例10: addServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
private void addServiceListener(String type, ServiceListener listener, boolean synch) {
    ServiceListenerStatus status = new ServiceListenerStatus(listener, synch);
    final String loType = type.toLowerCase();
    List<ServiceListenerStatus> list = _serviceListeners.get(loType);
    if (list == null) {
        if (_serviceListeners.putIfAbsent(loType, new LinkedList<ServiceListenerStatus>()) == null) {
            if (_serviceCollectors.putIfAbsent(loType, new ServiceCollector(type)) == null) {
                // We have a problem here. The service collectors must be called synchronously so that their cache get cleaned up immediately or we will report .
                this.addServiceListener(loType, _serviceCollectors.get(loType), ListenerStatus.SYNCHONEOUS);
            }
        }
        list = _serviceListeners.get(loType);
    }
    if (list != null) {
        synchronized (list) {
            if (!list.contains(listener)) {
                list.add(status);
            }
        }
    }
    // report cached service types
    final List<ServiceEvent> serviceEvents = new ArrayList<ServiceEvent>();
    Collection<DNSEntry> dnsEntryLits = this.getCache().allValues();
    for (DNSEntry entry : dnsEntryLits) {
        final DNSRecord record = (DNSRecord) entry;
        if (record.getRecordType() == DNSRecordType.TYPE_SRV) {
            if (record.getKey().endsWith(loType)) {
                // Do not used the record embedded method for generating event this will not work.
                // serviceEvents.add(record.getServiceEvent(this));
                serviceEvents.add(new ServiceEventImpl(this, record.getType(), toUnqualifiedName(record.getType(), record.getName()), record.getServiceInfo()));
            }
        }
    }
    // Actually call listener with all service events added above
    for (ServiceEvent serviceEvent : serviceEvents) {
        status.serviceAdded(serviceEvent);
    }
    // Create/start ServiceResolver
    this.startServiceResolver(type);
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:41,代码来源:JmDNSImpl.java

示例11: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void removeServiceListener(String type, ServiceListener listener) {
    String loType = type.toLowerCase();
    List<ServiceListenerStatus> list = _serviceListeners.get(loType);
    if (list != null) {
        synchronized (list) {
            ServiceListenerStatus status = new ServiceListenerStatus(listener, ListenerStatus.ASYNCHONEOUS);
            list.remove(status);
            if (list.isEmpty()) {
                _serviceListeners.remove(loType, list);
            }
        }
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:18,代码来源:JmDNSImpl.java

示例12: addServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void addServiceListener(String type, ServiceListener listener)
{
    for (JmDNS mDNS : _knownMDNS.values())
    {
        mDNS.addServiceListener(type, listener);
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:9,代码来源:JmmDNSImpl.java

示例13: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
@Override
public void removeServiceListener(String type, ServiceListener listener)
{
    for (JmDNS mDNS : _knownMDNS.values())
    {
        mDNS.removeServiceListener(type, listener);
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:9,代码来源:JmmDNSImpl.java

示例14: addServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
private void addServiceListener(final String type, final ServiceListener listener, final boolean synch) {
    final ServiceListenerStatus status = new ServiceListenerStatus(listener, synch);
    final String loType = type.toLowerCase();
    List<ServiceListenerStatus> list = this._serviceListeners.get(loType);
    if (list == null) {
        if (this._serviceListeners.putIfAbsent(loType, new LinkedList<ServiceListenerStatus>()) == null) {
            if (this._serviceCollectors.putIfAbsent(loType, new ServiceCollector(type)) == null) {
                // We have a problem here. The service collectors must be called synchronously so that their cache get cleaned up immediately or we will report .
                this.addServiceListener(loType, this._serviceCollectors.get(loType), ListenerStatus.SYNCHONEOUS);
            }
        }
        list = this._serviceListeners.get(loType);
    }
    if (list != null) {
        synchronized (list) {
            if (!list.contains(listener)) {
                list.add(status);
            }
        }
    }
    // report cached service types
    final List<ServiceEvent> serviceEvents = new ArrayList<ServiceEvent>();
    final Collection<DNSEntry> dnsEntryLits = this.getCache().allValues();
    for (final DNSEntry entry : dnsEntryLits) {
        final DNSRecord record = (DNSRecord) entry;
        if (record.getRecordType() == DNSRecordType.TYPE_SRV) {
            if (record.getKey().endsWith(loType)) {
                // Do not used the record embedded method for generating event this will not work.
                // serviceEvents.add(record.getServiceEvent(this));
                serviceEvents.add(new ServiceEventImpl(this, record.getType(), toUnqualifiedName(record.getType(), record.getName()), record.getServiceInfo()));
            }
        }
    }
    // Actually call listener with all service events added above
    for (final ServiceEvent serviceEvent : serviceEvents) {
        status.serviceAdded(serviceEvent);
    }
    // Create/start ServiceResolver
    this.startServiceResolver(type);
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:41,代码来源:JmDNSImpl.java

示例15: removeServiceListener

import javax.jmdns.ServiceListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void removeServiceListener(final String type, final ServiceListener listener) {
    final String loType = type.toLowerCase();
    final List<ServiceListenerStatus> list = this._serviceListeners.get(loType);
    if (list != null) {
        synchronized (list) {
            final ServiceListenerStatus status = new ServiceListenerStatus(listener, ListenerStatus.ASYNCHONEOUS);
            list.remove(status);
            if (list.isEmpty()) {
                this._serviceListeners.remove(loType, list);
            }
        }
    }
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:18,代码来源:JmDNSImpl.java


注:本文中的javax.jmdns.ServiceListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。