public abstract class AbstractReceiverTask extends Object implements ReceiverTaskIfc
Constructor and Description |
---|
AbstractReceiverTask() |
Modifier and Type | Method and Description |
---|---|
void |
addNewSubscribers(Queue<Packet> results,
JID... new_subscr)
Describe
addNewSubscribers method here. |
protected boolean |
addOutPacket(Packet packet)
Method description
|
RosterItem |
addToRoster(JID jid)
Method description
|
void |
addToRoster(RosterItem ri)
Method description
|
void |
destroy(Queue<Packet> results)
destroy method is called when the task is being permanently
deleted. |
Map<String,PropertyItem> |
getDefaultParams()
getDefaultParams method return task instance default configuration
parameters. |
String |
getDescription()
getDescription method returns a description for task instance. |
ReceiverTaskIfc |
getInstance()
getInstance method returns new task instance of this type. |
JID |
getJID()
getJID method returns task instance
Jabber ID. |
Map<String,PropertyItem> |
getParams()
getParams method return task instance configuration parameters. |
Map<JID,RosterItem> |
getRoster()
getRoster returns roster that is a collection with
all users subscribed to this task. |
RosterItem |
getRosterItem(JID jid)
Method description
|
void |
getStatistics(StatisticsList list)
Method description
|
List<StatRecord> |
getStats()
getStats method retorns list of statistics records. |
void |
init(Queue<Packet> results)
init method initializes task. |
boolean |
isAdmin(JID jid)
isAdmin method checks whether user given as parameter is one
of defined admins. |
boolean |
isAllowedToPost(JID buddy)
Method description
|
boolean |
isAllowedToSubscribe(JID buddy)
Method description
|
protected void |
processMessage(Packet packet,
Queue<Packet> results)
Method description
|
void |
processPacket(Packet packet,
Queue<Packet> results)
processPacket method takes a packet addressed to this task
as a parameter and does something with the packet. |
RosterItem |
removeFromRoster(JID jid)
Method description
|
void |
removeSubscribers(Queue<Packet> results,
JID... subscr)
Method description
|
void |
setJID(JID jid)
setJID method sets tasks Jabber ID, unique
ID which is used to identify the task. |
void |
setParams(Map<String,Object> map)
setParams method sets Map with configuration
parameters. |
void |
setRosterItemAdmin(RosterItem ri,
boolean admin)
Method description
|
void |
setRosterItemModerationAccepted(RosterItem ri,
boolean accepted)
Method description
|
void |
setRosterItemOnline(RosterItem ri,
boolean online)
Method description
|
void |
setRosterItemOwner(RosterItem ri,
boolean owner)
Method description
|
void |
setRosterItemSubscribed(RosterItem ri,
boolean subscribed)
Method description
|
void |
setStanzaReceiver(StanzaReceiverIfc srecv)
Method description
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHelp, getType
public void addNewSubscribers(Queue<Packet> results, JID... new_subscr)
addNewSubscribers
method here.results
- new_subscr
- a String[]
valuepublic void addToRoster(RosterItem ri)
ri
- public RosterItem addToRoster(JID jid)
jid
- public void destroy(Queue<Packet> results)
ReceiverTaskIfc
destroy
method is called when the task is being permanently
deleted. The method should take care of sending notification to all
subscribed users that the task is being deleted and should also clear
databases from all task data.destroy
in interface ReceiverTaskIfc
results
- a Queue
value with all packets needed to send
upon task deletion.public Map<String,PropertyItem> getDefaultParams()
ReceiverTaskIfc
getDefaultParams
method return task instance default configuration
parameters. The map should contains all possible parameters accepted by
the task in setParams
method. Values may be empty but may
not be null
. All of parameters should be converted to
String
type to make it possible to display them in ad-hoc
command x-form. Parameters then should be converted back to whatever format
is needed when passed back in setParams
method.
For more detailed information about configuration parameters please refer
to setParams
method.getDefaultParams
in interface ReceiverTaskIfc
Map
value with task instance configuration parameters.ReceiverTaskIfc.setParams(Map)
public String getDescription()
ReceiverTaskIfc
getDescription
method returns a description for task instance.
Let's say the user want's to create new Interest group for
cyclists. This property allows to set some more detailed information about
the group like: This is group of ppl interested in mountain cycling
near Cambridge.
The description is set via properties using DESCRIPTION_PROP_KEY
.getDescription
in interface ReceiverTaskIfc
String
value of task instance description;public ReceiverTaskIfc getInstance()
ReceiverTaskIfc
getInstance
method returns new task instance of this type.
This is something like Class.newInstance()
but as this method
is called on the already created instance there is no danger of the number
of exceptions which could be normally thrown.getInstance
in interface ReceiverTaskIfc
ReceiverTaskIfc
new task instance of this type.public JID getJID()
ReceiverTaskIfc
getJID
method returns task instance
Jabber ID. Refer to corresponding set
method for more details.getJID
in interface ReceiverTaskIfc
String
value of task instance JID,ReceiverTaskIfc.setJID(tigase.xmpp.JID)
public Map<String,PropertyItem> getParams()
ReceiverTaskIfc
getParams
method return task instance configuration parameters.
For more detailed information about configuration parameters please refer
to corresponding set
method.getParams
in interface ReceiverTaskIfc
Map
value with task instance configuration parameters.ReceiverTaskIfc.setParams(Map)
public Map<JID,RosterItem> getRoster()
ReceiverTaskIfc
getRoster
returns roster
that is a collection with
all users subscribed to this task.getRoster
in interface ReceiverTaskIfc
Map
value with all user subscribed to this task.public RosterItem getRosterItem(JID jid)
jid
- public void getStatistics(StatisticsList list)
ReceiverTaskIfc
getStatistics
in interface ReceiverTaskIfc
list
- is a StatisticsList
public List<StatRecord> getStats()
ReceiverTaskIfc
getStats
method retorns list of statistics records. Have a look
at StatRecord
description for more details.getStats
in interface ReceiverTaskIfc
List
of statistics records.StatRecord
public void init(Queue<Packet> results)
ReceiverTaskIfc
init
method initializes task. It allows also for a task to
send initial stanzas to user like available
presence or any other stanza which does make sense to
send at startup time.init
in interface ReceiverTaskIfc
results
- a Queue<Packet>
is a collection of
result packets to send out.public boolean isAdmin(JID jid)
ReceiverTaskIfc
isAdmin
method checks whether user given as parameter is one
of defined admins. If user is the task owner it is also considered to be
task administrator.isAdmin
in interface ReceiverTaskIfc
jid
- a String
value of user JID.boolean
value true if given user is either task admin
or task owner.public boolean isAllowedToPost(JID buddy)
buddy
- public boolean isAllowedToSubscribe(JID buddy)
buddy
- public void processPacket(Packet packet, Queue<Packet> results)
ReceiverTaskIfc
processPacket
method takes a packet addressed to this task
as a parameter and does something with the packet. If as a result of
input packet processing it generates some other packets to send they
should be included in the results
queue.processPacket
in interface ReceiverTaskIfc
packet
- a Packet
input packet for processing.results
- a Queue<Packet>
is a collection of
result packets to send out.public RosterItem removeFromRoster(JID jid)
jid
- public void removeSubscribers(Queue<Packet> results, JID... subscr)
ReceiverTaskIfc
removeSubscribers
in interface ReceiverTaskIfc
results
- is a Queue<Packet>
subscr
- is a JID
public void setJID(JID jid)
ReceiverTaskIfc
setJID
method sets tasks Jabber ID, unique
ID which is used to identify the task. Example of the resulting
Jabber ID for domain tigase.org
and
StanzaReceiver
component name srec
would be:
devs@srec.tigase.org
.
There can be many tasks of the same type (having the same
TaskType) but they have to have distinct JIDs.
Examples of possible JIDs names are: "admin-forum@srec.tigase.org",
"cycling-interest-group@srec.tigase.org".setJID
in interface ReceiverTaskIfc
jid
- a String
value of the nick name.public void setParams(Map<String,Object> map)
ReceiverTaskIfc
setParams
method sets Map
with configuration
parameters. Some parameters are predefined and common for most of task
types but some tasks may require/accept extra parameters to work properly.setParams
in interface ReceiverTaskIfc
map
- a Map
value with configuration parameters.public void setRosterItemAdmin(RosterItem ri, boolean admin)
ri
- admin
- public void setRosterItemModerationAccepted(RosterItem ri, boolean accepted)
ReceiverTaskIfc
setRosterItemModerationAccepted
in interface ReceiverTaskIfc
ri
- is a RosterItem
accepted
- is a boolean
public void setRosterItemOnline(RosterItem ri, boolean online)
ri
- online
- public void setRosterItemOwner(RosterItem ri, boolean owner)
ri
- owner
- public void setRosterItemSubscribed(RosterItem ri, boolean subscribed)
ri
- subscribed
- public void setStanzaReceiver(StanzaReceiverIfc srecv)
ReceiverTaskIfc
setStanzaReceiver
in interface ReceiverTaskIfc
srecv
- is a StanzaReceiverIfc
protected boolean addOutPacket(Packet packet)
packet
- Copyright © 2018 "Tigase, Inc.". All rights reserved.