Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

IM
Class IMTopic  view IMTopic download IMTopic.java

java.lang.Object
  extended byjava.lang.Thread
      extended byIM.IMTopic
All Implemented Interfaces:
java.lang.Runnable

public class IMTopic
extends java.lang.Thread

IMTopic is thread, which serves messages delivered to Topic. Messages are taken away from object topicSubscriber using subscribe() method. There is reserved place in Vector IMreceivedMessageQueue before receiving message. Received message is being put in IMreceivedMessageQueue, then thread try to reserve place for next message in IMreceivedMessageQueue and if it is possible, it hangs on subscribe() method of topicSubscriber. In other case thread fall asleep for some time (default : 1 s)

IMTopic makes available objects of class Topic and TopicPublisher, also gives possibility to send messages using publish() method.


Nested Class Summary
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static int DEFAULT_SLEEP
           
private static int DEFAULT_TIMEOUT
           
private  java.lang.String name
           Keeps name of Topic which is kept on topic attribute.
private  boolean stopFlag
           Flag used to order IMTopic to stop work (main thread)
private  mobile.jmsapi.Topic topic
           Represents object of Topic class which is used to service PUB/SUB communication.
private  mobile.jmsapi.TopicPublisher topicPublisher
           Represents object of TopicPublisher class which is used to sending messages.
private  mobile.jmsapi.TopicSubscriber topicSubscriber
           Represents object of TopicSubscriber class which is used to receiving messages.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
IMTopic(java.lang.String name)
           Set name of Topic, which will service and run main thread.
 
Method Summary
 mobile.jmsapi.Topic getTopic()
           Accessor to object of Topic class.
 java.lang.String getTopicName()
           Do nothing.
 mobile.jmsapi.TopicPublisher getTopicPublisher()
           Accessor to attribute topicPublisher of TopicPublisher class.
 mobile.jmsapi.TopicSubscriber getTopicSubscriber()
           Accessor to attribute topicSubscriber of TopicSubscriber class.
 void run()
           Main thread which services received messages and makes them available for Instant-Messenger by putting them to vector called IMreceivedMessageQueue stored in im, object of IM class
 void setTopic(mobile.jmsapi.Topic topic)
           Accessor to attribute object of Topic class.
 void setTopicPublisher(mobile.jmsapi.TopicPublisher topicPublisher)
           Accessor to attribute object of TopicPublisher class.
 void setTopicSubscriber(mobile.jmsapi.TopicSubscriber topicSubscriber)
           Accessor to attribute object of topicSubscriber class.
 void startTopic()
           Set value of stopFlag to false, what indicate that main thread have to start its work.
 void stopTopic()
           Set value of stopFlag to true, what indicate that main thread have to stop its work after clean all of composite attributes.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SLEEP

private static final int DEFAULT_SLEEP
See Also:
Constant Field Values

DEFAULT_TIMEOUT

private static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

stopFlag

private boolean stopFlag

Flag used to order IMTopic to stop work (main thread)


topic

private mobile.jmsapi.Topic topic

Represents object of Topic class which is used to service PUB/SUB communication.


topicPublisher

private mobile.jmsapi.TopicPublisher topicPublisher

Represents object of TopicPublisher class which is used to sending messages.


topicSubscriber

private mobile.jmsapi.TopicSubscriber topicSubscriber

Represents object of TopicSubscriber class which is used to receiving messages.


name

private java.lang.String name

Keeps name of Topic which is kept on topic attribute.

Constructor Detail

IMTopic

public IMTopic(java.lang.String name)

Set name of Topic, which will service and run main thread.

Method Detail

getTopic

public mobile.jmsapi.Topic getTopic()

Accessor to object of Topic class.


setTopic

public void setTopic(mobile.jmsapi.Topic topic)

Accessor to attribute object of Topic class. Set its value to topic gave as a method's parameter.


getTopicPublisher

public mobile.jmsapi.TopicPublisher getTopicPublisher()

Accessor to attribute topicPublisher of TopicPublisher class.


setTopicPublisher

public void setTopicPublisher(mobile.jmsapi.TopicPublisher topicPublisher)

Accessor to attribute object of TopicPublisher class. Set its value to topic gave as a method's parameter.


getTopicSubscriber

public mobile.jmsapi.TopicSubscriber getTopicSubscriber()

Accessor to attribute topicSubscriber of TopicSubscriber class.


setTopicSubscriber

public void setTopicSubscriber(mobile.jmsapi.TopicSubscriber topicSubscriber)

Accessor to attribute object of topicSubscriber class. Set its value to topic gave as a method's parameter.


getTopicName

public java.lang.String getTopicName()

Do nothing.


stopTopic

public void stopTopic()

Set value of stopFlag to true, what indicate that main thread have to stop its work after clean all of composite attributes.


startTopic

public void startTopic()

Set value of stopFlag to false, what indicate that main thread have to start its work.


run

public void run()

Main thread which services received messages and makes them available for Instant-Messenger by putting them to vector called IMreceivedMessageQueue stored in im, object of IM class