public final class GoogleCalendarHookService extends java.lang.Thread implements StopableObject
GoogleCalendarHook and awaits external
requests via the ActiveMQ. If a request arises, it will search for fitting results and return them via the ActiveMQ
again. This service is designed as stand-alone application.| Modifier and Type | Field and Description |
|---|---|
private GoogleCalendarHook |
calendar
The connection to the google calendar web-service as
GoogleCalendarHook. |
private static java.lang.String |
GCS_REQUEST_TOPIC
The name of the ActiveMQ topic as
String on which the service expects requests. |
private static java.lang.String |
GCS_RESULT_TOPIC
The name of the ActiveMQ topic as
String on which the service publishes its results. |
private static java.lang.String |
GOOGLE_CALENDAR
The name of the google calendar which shall be used.
|
private static java.lang.String |
GOOGLE_PASSWORD
The (fixed...) password of the google user.
|
private static java.lang.String |
GOOGLE_USER
The (fixed...) name of the google user.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
requestTopic
The
LPSubscriber, which reads requests from the ActiveMQ. |
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
resultTopic
The
LPPublisher, which writes request messags to the ActiveMQ. |
private boolean |
shutDown
Determines if the method
shutDown() has been called. |
| Modifier | Constructor and Description |
|---|---|
private |
GoogleCalendarHookService()
Private constructor method to prevent external created instances of this class.
|
| Modifier and Type | Method and Description |
|---|---|
private JsonGoogleCalendarResult |
createResultMessage(JsonGoogleCalendarRequest request,
java.util.List<com.google.gdata.data.calendar.CalendarEventEntry> entries)
Creates a new
JsonGoogleCalendarResult message object which contains the results of the request forwarded
to the GoogleCalendarHook. |
private void |
end()
Gracefully shutdown all open connections.
|
private void |
getAndPushCalendarEvents(JsonGoogleCalendarRequest request)
This method forwords a request to the
GoogleCalendarHook and publishes its results via the ActiveMQ. |
private void |
handleRequest()
The methods handles arising requests via the ActiveMQ and forwards them to the
GoogleCalendarHook by
using getAndPushCalendarEvents(JsonGoogleCalendarRequest). |
private void |
init()
Initializes connections and class field structures.
|
boolean |
isActive()
Determines whether the method
StopableObject.shutDown() has been called on this object or not. |
static void |
main(java.lang.String[] args)
This method starts a new
GoogleCalendarHookService. |
void |
run()
Runs the google calendar service.
|
void |
shutDown()
Shuts the object down.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, 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, yieldprivate static final java.lang.String GCS_REQUEST_TOPIC
String on which the service expects requests.private static final java.lang.String GCS_RESULT_TOPIC
String on which the service publishes its results.private static final java.lang.String GOOGLE_USER
private static final java.lang.String GOOGLE_PASSWORD
private static final java.lang.String GOOGLE_CALENDAR
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber requestTopic
LPSubscriber, which reads requests from the ActiveMQ.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher resultTopic
LPPublisher, which writes request messags to the ActiveMQ.private GoogleCalendarHook calendar
GoogleCalendarHook.private boolean shutDown
shutDown() has been called.private GoogleCalendarHookService()
main(String[]) method.public boolean isActive()
StopableObjectStopableObject.shutDown() has been called on this object or not.isActive in interface StopableObjecttrue if shutDown() wasn't called, otherwise
false.StopableObject.isActive()public void shutDown()
StopableObjectshutDown in interface StopableObjectStopableObject.shutDown()public void run()
GoogleCalendarHook. It
waits for requests and sends the results via the ActiveMQ if one arises. After the shutDown() method
has been called, it gracefully ends this service.run in interface java.lang.Runnablerun in class java.lang.Threadprivate void init()
private void end()
private void handleRequest()
GoogleCalendarHook by
using getAndPushCalendarEvents(JsonGoogleCalendarRequest).private void getAndPushCalendarEvents(JsonGoogleCalendarRequest request)
GoogleCalendarHook and publishes its results via the ActiveMQ.request - The users request as JsonGoogleCalendarRequest message object.private JsonGoogleCalendarResult createResultMessage(JsonGoogleCalendarRequest request, java.util.List<com.google.gdata.data.calendar.CalendarEventEntry> entries)
JsonGoogleCalendarResult message object which contains the results of the request forwarded
to the GoogleCalendarHook.request - The original request message as JsonGoogleCalendarRequest.entries - The search results of the GoogleCalendarHook as List of
CalendarEventEntry.JsonGoogleCalendarResult containing the request results.public static void main(java.lang.String[] args)
GoogleCalendarHookService.args - The command line arguments as array of String.