Package ball.upnp.ssdp
Class SSDPDiscoveryService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- java.util.concurrent.ScheduledThreadPoolExecutor
-
- ball.upnp.ssdp.SSDPDiscoveryService
-
- All Implemented Interfaces:
Executor
,ExecutorService
,ScheduledExecutorService
public class SSDPDiscoveryService extends ScheduledThreadPoolExecutor
SSDP discoveryScheduledThreadPoolExecutor
implementation.Bean Property Summary
Name Mode Type isHidden isBound isConstrained activeCount R int
false false false bootId R int
false false false completedTaskCount R long
false false false continueExistingPeriodicTasksAfterShutdownPolicy RW boolean
false false false corePoolSize RW int
false false false executeExistingDelayedTasksAfterShutdownPolicy RW boolean
false false false largestPoolSize R int
false false false maximumPoolSize RW int
false false false nextBootId R int
false false false poolSize R int
false false false queue R BlockingQueue
<
Runnable
>
false false false rejectedExecutionHandler RW RejectedExecutionHandler
false false false removeOnCancelPolicy RW boolean
false false false searchPort R int
false false false shutdown R boolean
false false false taskCount R long
false false false terminated R boolean
false false false terminating R boolean
false false false threadFactory RW ThreadFactory
false false false userAgent R String
false false false - Author:
- Allen D. Ball
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SSDPDiscoveryService.Listener
SSDPDiscoveryService
listener interface definition.static class
SSDPDiscoveryService.RequestHandler
SSDPDiscoveryService
SSDPRequest
handler.static class
SSDPDiscoveryService.ResponseHandler
SSDPDiscoveryService
SSDPResponse
handler.-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description SSDPDiscoveryService(String product)
Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SSDPDiscoveryService
addListener(SSDPDiscoveryService.Listener listener)
Method to add aSSDPDiscoveryService.Listener
.SSDPDiscoveryService
advertise(RootDevice device, int rate)
Method to add aRootDevice
to advertise.int
getBootId()
BOOTID.UPNP.ORG
int
getNextBootId()
NEXTBOOTID.UPNP.ORG
int
getSearchPort()
SEARCHPORT.UPNP.ORG
String
getUserAgent()
SERVER
andUSER-AGENT
void
msearch(int mx, URI st)
Send multicastM-SEARCH
messsage.void
multicast(long delay, SSDPMessage message)
Method to queue anSSDPMessage
for multicast with delay.void
multicast(SSDPMessage message)
Method to queue anSSDPMessage
for multicast without delay.SSDPDiscoveryService
removeListener(SSDPDiscoveryService.Listener listener)
Method to remove aSSDPDiscoveryService.Listener
.void
send(int mx, SocketAddress address, List<? extends SSDPMessage> messages)
void
send(long delay, SocketAddress address, SSDPMessage message)
Method to queue anSSDPMessage
for sending with delay.void
send(SocketAddress address, SSDPMessage message)
Method to queue anSSDPMessage
for sending without delay.void
shutdown()
-
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdownNow, submit, submit, submit
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toString
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
-
-
-
Constructor Detail
-
SSDPDiscoveryService
public SSDPDiscoveryService(String product) throws IOException
Sole constructor.- Parameters:
product
- Theproduct/version
String
identifying this UPnP application.- Throws:
IOException
- If the underlyingMulticastSocket
cannot be conditioned.
-
-
Method Detail
-
getUserAgent
public String getUserAgent()
SERVER
andUSER-AGENT
- Returns:
SERVER
andUSER-AGENT
-
getBootId
public int getBootId()
BOOTID.UPNP.ORG
- Returns:
bootId
-
getNextBootId
public int getNextBootId()
NEXTBOOTID.UPNP.ORG
- Returns:
nextBootId
-
getSearchPort
public int getSearchPort()
SEARCHPORT.UPNP.ORG
- Returns:
- Search port.
-
addListener
public SSDPDiscoveryService addListener(SSDPDiscoveryService.Listener listener)
Method to add aSSDPDiscoveryService.Listener
.- Parameters:
listener
- TheSSDPDiscoveryService.Listener
.- Returns:
this
-
removeListener
public SSDPDiscoveryService removeListener(SSDPDiscoveryService.Listener listener)
Method to remove aSSDPDiscoveryService.Listener
.- Parameters:
listener
- TheSSDPDiscoveryService.Listener
.- Returns:
this
-
advertise
public SSDPDiscoveryService advertise(RootDevice device, int rate)
Method to add aRootDevice
to advertise.- Parameters:
device
- TheRootDevice
to advertise.rate
- The rate (in seconds) to repeat advertisements.- Returns:
this
-
msearch
public void msearch(int mx, URI st)
Send multicastM-SEARCH
messsage.- Parameters:
mx
- TheMX
header value.st
- TheST
header value.
-
multicast
public void multicast(SSDPMessage message)
Method to queue anSSDPMessage
for multicast without delay.- Parameters:
message
- TheSSDPMessage
to send.
-
multicast
public void multicast(long delay, SSDPMessage message)
Method to queue anSSDPMessage
for multicast with delay.- Parameters:
delay
- Time to delay (in milliseconds) before sending.message
- TheSSDPMessage
to send.
-
send
public void send(SocketAddress address, SSDPMessage message)
Method to queue anSSDPMessage
for sending without delay.- Parameters:
address
- The destinationSocketAddress
.message
- TheSSDPMessage
to send.
-
send
public void send(long delay, SocketAddress address, SSDPMessage message)
Method to queue anSSDPMessage
for sending with delay.- Parameters:
delay
- Time to delay (in milliseconds) before sending.address
- The destinationSocketAddress
.message
- TheSSDPMessage
to send.
-
send
public void send(int mx, SocketAddress address, List<? extends SSDPMessage> messages)
Method to queue aList
ofSSDPMessage
s for sending with aMX
parameter. Messages are sent in list order with random delays none greater thatMX
seconds.- Parameters:
mx
- Maximum delay (in seconds) before sending.address
- The destinationSocketAddress
.messages
- TheList
ofSSDPMessage
s to send.
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceExecutorService
- Overrides:
shutdown
in classScheduledThreadPoolExecutor
-
-