public class Service extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ELEM_NAME
XML element name for service nodes.
|
static String |
MAJOR
XML element name for major version.
|
static String |
MAJOR_VALUE
Default major version value.
|
static String |
MINOR
XML element name for minor version.
|
static String |
MINOR_VALUE
Default minor version value.
|
static String |
SCPD_ROOTNODE
Root node name for service control point documents.
|
static String |
SCPD_ROOTNODE_NS
Namespace for service control point documents.
|
static String |
SPEC_VERSION
XML element name for specification version.
|
| Constructor and Description |
|---|
Service()
Creates a new empty Service instance.
|
Service(Node node)
Creates a Service instance from an existing XML node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAction(Action a)
Adds an action to this service.
|
void |
addStateVariable(StateVariable var)
Add the StateVariable to the service.
Note: This method should be used to create a dynamic Device withtout writing any XML that describe the device . |
void |
addSubscriber(Subscriber sub) |
void |
announce(String bindAddr)
Announces this service to the network using SSDP.
|
void |
byebye(String bindAddr) |
void |
clearSID() |
Action |
getAction(String actionName)
Finds an action by name in this service.
|
ActionList |
getActionList()
Gets the list of actions provided by this service.
|
int |
getConfigId()
Gets the configuration ID for this service.
|
String |
getControlURL()
Gets the control URL for this service.
|
String |
getDescriptionURL()
Gets the description URL for this service.
|
Device |
getDevice()
Gets the device containing this service.
|
String |
getEventSubURL()
Gets the event subscription URL for this service.
|
Device |
getRootDevice()
Gets the root device containing this service.
|
byte[] |
getSCPDData()
Gets the SCPD data for this service as a byte array.
|
String |
getSCPDURL()
Gets the SCPD URL for this service.
|
String |
getServiceID()
Gets the service ID of this service.
|
Node |
getServiceNode()
Gets the XML node representing this service.
|
ServiceStateTable |
getServiceStateTable() |
String |
getServiceType()
Gets the service type of this service.
|
String |
getSID() |
StateVariable |
getStateVariable(String name) |
Subscriber |
getSubscriber(String name) |
SubscriberList |
getSubscriberList() |
long |
getTimeout() |
Object |
getUserData() |
boolean |
hasSID() |
boolean |
hasStateVariable(String name) |
boolean |
isControlURL(String url)
Checks if the given URL matches this service's control URL.
|
boolean |
isEventSubURL(String url)
Checks if the given URL matches this service's event subscription URL.
|
boolean |
isSCPDURL(String url)
Checks if the given URL matches this service's SCPD URL.
|
boolean |
isService(String name) |
static boolean |
isServiceNode(Node node)
Checks if the given XML node represents a service.
|
boolean |
isSubscribed() |
boolean |
loadSCPD(File file)
Loads service control point description (SCPD) from a file.
|
boolean |
loadSCPD(InputStream input)
Loads service description (SCPD) from an input stream.
|
boolean |
loadSCPD(String scpdStr)
Loads service control point description (SCPD) from a string.
|
void |
lock()
Acquires exclusive lock on this service for thread-safe operations.
|
void |
notify(StateVariable stateVar) |
void |
notifyAllStateVariables() |
void |
removeSubscriber(Subscriber sub) |
boolean |
serviceSearchResponse(SSDPPacket ssdpPacket) |
void |
setActionListener(ActionListener listener) |
void |
setControlURL(String value)
Sets the control URL for this service.
|
void |
setDescriptionURL(String value)
Sets the description URL for this service.
|
void |
setEventSubURL(String value)
Sets the event subscription URL for this service.
|
void |
setQueryListener(QueryListener queryListener) |
void |
setSCPDURL(String value)
Sets the SCPD URL for this service.
|
void |
setServiceID(String value)
Sets service ID of this service.
|
void |
setServiceType(String value)
Sets service type of this service.
|
void |
setSID(String id) |
void |
setTimeout(long value) |
void |
setUserData(Object data) |
void |
unlock()
Releases exclusive lock on this service.
|
void |
updateConfigId()
Updates the configuration ID for this service based on its SCPD XML.
|
public static final String ELEM_NAME
public static final String MAJOR
public static final String MAJOR_VALUE
public static final String MINOR
public static final String MINOR_VALUE
public static final String SCPD_ROOTNODE
public static final String SCPD_ROOTNODE_NS
public static final String SPEC_VERSION
public Service()
public Service(Node node)
node - XML node representing the servicepublic void addAction(Action a)
This method sets service reference for all arguments in action and adds action to the service's SCPD structure.
a - Action to add to this servicepublic void addStateVariable(StateVariable var)
var - StateVariable that will be addedpublic void addSubscriber(Subscriber sub)
public void announce(String bindAddr)
This method sends SSDP NOTIFY messages to announce the service's presence. The announcement includes the service type, unique service identifier, and location of the root device containing this service.
bindAddr - bind address to send announcement frompublic void byebye(String bindAddr)
public void clearSID()
public Action getAction(String actionName)
actionName - name of action to findpublic ActionList getActionList()
public int getConfigId()
public String getControlURL()
public String getDescriptionURL()
public Device getDevice()
public String getEventSubURL()
public Device getRootDevice()
public byte[] getSCPDData()
public String getSCPDURL()
public String getServiceID()
public Node getServiceNode()
public ServiceStateTable getServiceStateTable()
public String getServiceType()
public String getSID()
public StateVariable getStateVariable(String name)
public Subscriber getSubscriber(String name)
public SubscriberList getSubscriberList()
public long getTimeout()
public Object getUserData()
public boolean hasSID()
public boolean hasStateVariable(String name)
public boolean isControlURL(String url)
url - the URL to checkpublic boolean isEventSubURL(String url)
url - the URL to checkpublic boolean isSCPDURL(String url)
url - the URL to checkpublic boolean isService(String name)
public static boolean isServiceNode(Node node)
node - the XML node to checkpublic boolean isSubscribed()
public boolean loadSCPD(File file) throws ParserException
file - file containing SCPD XMLParserException - if SCPD cannot be parsedpublic boolean loadSCPD(InputStream input) throws ParserException
input - input stream containing SCPD XMLParserException - if SCPD cannot be parsedpublic boolean loadSCPD(String scpdStr) throws InvalidDescriptionException
scpdStr - the SCPD XML string to loadInvalidDescriptionException - if SCPD cannot be parsedpublic void lock()
public void notify(StateVariable stateVar)
public void notifyAllStateVariables()
public void removeSubscriber(Subscriber sub)
public boolean serviceSearchResponse(SSDPPacket ssdpPacket)
public void setActionListener(ActionListener listener)
public void setControlURL(String value)
value - the control URL to setpublic void setDescriptionURL(String value)
value - the description URL to setpublic void setEventSubURL(String value)
value - the event subscription URL to setpublic void setQueryListener(QueryListener queryListener)
public void setSCPDURL(String value)
value - the SCPD URL to setpublic void setServiceID(String value)
value - service ID string to setpublic void setServiceType(String value)
value - service type string to setpublic void setSID(String id)
public void setTimeout(long value)
public void setUserData(Object data)
public void unlock()
public void updateConfigId()