net.sbbi.upnp.jmx
Class UPNPDiscovery

java.lang.Object
  extended bynet.sbbi.upnp.jmx.UPNPDiscovery
All Implemented Interfaces:
DiscoveryEventHandler, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, UPNPDiscoveryMBean

public class UPNPDiscovery
extends java.lang.Object
implements DiscoveryEventHandler, UPNPDiscoveryMBean, javax.management.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
UPNPDiscovery(int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)
          Main constructor, will discover all devices types
UPNPDiscovery(java.lang.String[] searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)
          Discover devices of a given type
UPNPDiscovery(java.lang.String searchTargets, int discoveryTimeout, boolean notifySSDPEvents, boolean registerChildDevices)
          Discover devices of a given type
 
Method Summary
 void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object callback)
           
 void discoverDevices(int timeout)
           
 void eventSSDPAlive(java.lang.String usn, java.lang.String udn, java.lang.String nt, java.lang.String maxAge, java.net.URL location)
          Called when a device joins the network or advertise it is still alive
 void eventSSDPByeBye(java.lang.String usn, java.lang.String udn, java.lang.String nt)
          Called when a device is leaving the network
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
 javax.management.ObjectName[] getRegisteredUPNPServiceMBeans(java.lang.String deviceUDN)
          Computes an array of object names of registered UPNPServiceMBeans for a given UPNP device UDN
 java.lang.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
 java.util.Set getSearchTargets()
          The registered devices search targets
 void postDeregister()
           
 void postRegister(java.lang.Boolean arg0)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName objectname)
           
 void removeNotificationListener(javax.management.NotificationListener listener)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 responding
notifySSDPEvents - 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(java.lang.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 commas
discoveryTimeout - devices discoverytimeout in MS, 0 for default timeout, increase this value if devices are not responding
notifySSDPEvents - 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(java.lang.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 responding
notifySSDPEvents - 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
Method Detail

getRegisteredUPNPServiceMBeans

public javax.management.ObjectName[] getRegisteredUPNPServiceMBeans(java.lang.String deviceUDN)
                                                             throws javax.management.MalformedObjectNameException
Computes an array of object names of registered UPNPServiceMBeans for a given UPNP device UDN

Specified by:
getRegisteredUPNPServiceMBeans in interface UPNPDiscoveryMBean
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:
javax.management.MalformedObjectNameException - if an object name cannot be computed for an UPNPServiceMBean

getRegisteredUPNPServiceMBeansUDNs

public java.lang.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:
getRegisteredUPNPServiceMBeansUDNs in interface UPNPDiscoveryMBean
Returns:
a string array of UDN or null if no UPNP device services registered as UPNPServiceMBean

getSearchTargets

public java.util.Set getSearchTargets()
The registered devices search targets

Specified by:
getSearchTargets in interface UPNPDiscoveryMBean
Returns:
a set of search targets

addNotificationListener

public void addNotificationListener(javax.management.NotificationListener listener,
                                    javax.management.NotificationFilter filter,
                                    java.lang.Object callback)
                             throws java.lang.IllegalArgumentException
Specified by:
addNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
java.lang.IllegalArgumentException

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener listener)
                                throws javax.management.ListenerNotFoundException
Specified by:
removeNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
javax.management.ListenerNotFoundException

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean arg0)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName objectname)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

eventSSDPAlive

public void eventSSDPAlive(java.lang.String usn,
                           java.lang.String udn,
                           java.lang.String nt,
                           java.lang.String maxAge,
                           java.net.URL location)
Description copied from interface: DiscoveryEventHandler
Called when a device joins the network or advertise it is still alive

Specified by:
eventSSDPAlive in interface DiscoveryEventHandler
Parameters:
usn - the device USN (udn::nt)
udn - the device UDN
nt - the device NT
maxAge - the device maxAge
location - the device location

eventSSDPByeBye

public void eventSSDPByeBye(java.lang.String usn,
                            java.lang.String udn,
                            java.lang.String nt)
Description copied from interface: DiscoveryEventHandler
Called when a device is leaving the network

Specified by:
eventSSDPByeBye in interface DiscoveryEventHandler
Parameters:
usn - the device USN (udn::nt)
udn - the device UDN
nt - the device NT

discoverDevices

public void discoverDevices(int timeout)
                     throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2005 SuperBonBon Industries. All Rights Reserved.