Package net.sbbi.upnp.jmx
Class UPNPDiscovery
- java.lang.Object
-
- net.sbbi.upnp.jmx.UPNPDiscovery
-
- All Implemented Interfaces:
MBeanRegistration,NotificationBroadcaster,DiscoveryEventHandler,UPNPDiscoveryMBean
public class UPNPDiscovery extends Object implements DiscoveryEventHandler, UPNPDiscoveryMBean, NotificationBroadcaster
MBean to discover UPNP devices on the network and register the devices service as UPNPServiceMBean objects during the MBean registration. The registered UPNPServiceMBean will also be automatically unregistered when the device is leaving the network ( if notifySSDPEvents constructor param is set to true ) or when the UPNPDiscoveryMBean is unregistered from teh MBeans server.- Version:
- 1.0
- Author:
- SuperBonBon
-
-
Field Summary
-
Fields inherited from interface net.sbbi.upnp.jmx.UPNPDiscoveryMBean
SSDP_ALIVE_NOTIFICATION, SSDP_BYEBYE_NOTIFICATION
-
-
Constructor Summary
Constructors Constructor Description UPNPDiscovery(int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)Main constructor, will discover all devices typesUPNPDiscovery(String[] searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)Discover devices of a given typeUPNPDiscovery(String searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)Discover devices of a given type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotificationListener(NotificationListener listener, NotificationFilter filter, Object callback)voiddiscoverDevices(int timeout)voideventSSDPAlive(String usn, String udn, String nt, String maxAge, URL location)Called when a device joins the network or advertise it is still alivevoideventSSDPByeBye(String usn, String udn, String nt)Called when a device is leaving the networkMBeanNotificationInfo[]getNotificationInfo()ObjectName[]getRegisteredUPNPServiceMBeans(String deviceUDN)Computes an array of object names of registered UPNPServiceMBeans for a given UPNP device UDNString[]getRegisteredUPNPServiceMBeansUDNs()The list of registered devices UDN, the returned UDN can be used with the getRegisteredUPNPServiceMBeans(String deviceUDN) method to retreive UDN bound UPNPServiceMBean object namesSetgetSearchTargets()The registered devices search targetsvoidpostDeregister()voidpostRegister(Boolean arg0)voidpreDeregister()ObjectNamepreRegister(MBeanServer server, ObjectName objectname)voidremoveNotificationListener(NotificationListener listener)
-
-
-
Constructor Detail
-
UPNPDiscovery
public UPNPDiscovery(int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)Main constructor, will discover all devices types- Parameters:
discoveryTimeout- devices discoverytimeout in MS, 0 for default timeout, increase this value if devices are not respondingnotifySSDPEvents- boolean to indicate if the MBean should broadcast JMX UPNPDiscoveryNotifications when an matching device is joining or leaving the network.registerChildDevices- when set to true, discovered device child devices services will also be exposed as UPNPServiceMBean objects
-
UPNPDiscovery
public UPNPDiscovery(String searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)
Discover devices of a given type- Parameters:
searchTargets- a list of devices types URI (I.E : urn:schemas-upnp-org:device:WANDevice:1) that should be handled, list delimited by commasdiscoveryTimeout- devices discoverytimeout in MS, 0 for default timeout, increase this value if devices are not respondingnotifySSDPEvents- boolean to indicate if the MBean should broadcast JMX UPNPDiscoveryNotifications when an matching device is joining or leaving the networkregisterChildDevices- when set to true, discovered device child devices services will also be exposed as UPNPServiceMBean objects
-
UPNPDiscovery
public UPNPDiscovery(String[] searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)
Discover devices of a given type- Parameters:
searchTargets- a list of devices types URI (I.E : urn:schemas-upnp-org:device:WANDevice:1) that should be handled. All discovered device children services will also be automatically registered as UPNPServiceMBean.discoveryTimeout- devices discoverytimeout in MS, 0 for default timeout, increase this value if devices are not respondingnotifySSDPEvents- boolean to indicate if the MBean should broadcast JMX UPNPDiscoveryNotifications when an matching device is joining or leaving the networkregisterChildDevices- when set to true, discovered device child devices services will also be exposed as UPNPServiceMBean objects
-
-
Method Detail
-
getRegisteredUPNPServiceMBeans
public ObjectName[] getRegisteredUPNPServiceMBeans(String deviceUDN) throws MalformedObjectNameException
Computes an array of object names of registered UPNPServiceMBeans for a given UPNP device UDN- Specified by:
getRegisteredUPNPServiceMBeansin interfaceUPNPDiscoveryMBean- Parameters:
deviceUDN- the UPNP device UDN ( unique id on the network )- Returns:
- an array of object names or null if not matchs found for the given UDN
- Throws:
MalformedObjectNameException- if an object name cannot be computed for an UPNPServiceMBean
-
getRegisteredUPNPServiceMBeansUDNs
public String[] getRegisteredUPNPServiceMBeansUDNs()
The list of registered devices UDN, the returned UDN can be used with the getRegisteredUPNPServiceMBeans(String deviceUDN) method to retreive UDN bound UPNPServiceMBean object names- Specified by:
getRegisteredUPNPServiceMBeansUDNsin interfaceUPNPDiscoveryMBean- Returns:
- a string array of UDN or null if no UPNP device services registered as UPNPServiceMBean
-
getSearchTargets
public Set getSearchTargets()
The registered devices search targets- Specified by:
getSearchTargetsin interfaceUPNPDiscoveryMBean- Returns:
- a set of search targets
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object callback) throws IllegalArgumentException
- Specified by:
addNotificationListenerin interfaceNotificationBroadcaster- Throws:
IllegalArgumentException
-
getNotificationInfo
public MBeanNotificationInfo[] getNotificationInfo()
- Specified by:
getNotificationInfoin interfaceNotificationBroadcaster
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
- Specified by:
removeNotificationListenerin interfaceNotificationBroadcaster- Throws:
ListenerNotFoundException
-
postDeregister
public void postDeregister()
- Specified by:
postDeregisterin interfaceMBeanRegistration
-
postRegister
public void postRegister(Boolean arg0)
- Specified by:
postRegisterin interfaceMBeanRegistration
-
preDeregister
public void preDeregister() throws Exception- Specified by:
preDeregisterin interfaceMBeanRegistration- Throws:
Exception
-
preRegister
public ObjectName preRegister(MBeanServer server, ObjectName objectname) throws Exception
- Specified by:
preRegisterin interfaceMBeanRegistration- Throws:
Exception
-
eventSSDPAlive
public void eventSSDPAlive(String usn, String udn, String nt, String maxAge, URL location)
Description copied from interface:DiscoveryEventHandlerCalled when a device joins the network or advertise it is still alive- Specified by:
eventSSDPAlivein interfaceDiscoveryEventHandler- Parameters:
usn- the device USN (udn::nt)udn- the device UDNnt- the device NTmaxAge- the device maxAgelocation- the device location
-
eventSSDPByeBye
public void eventSSDPByeBye(String usn, String udn, String nt)
Description copied from interface:DiscoveryEventHandlerCalled when a device is leaving the network- Specified by:
eventSSDPByeByein interfaceDiscoveryEventHandler- Parameters:
usn- the device USN (udn::nt)udn- the device UDNnt- the device NT
-
-