|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.fhg.igd.semoa.service.AbstractService
examples.guestbook.GuestbookServiceImpl
This realizes access to a guestbook. The guestbook itself is backed by a file consisting of key-value pairs for each single entry. In SeMoA this service should be published as follows. The command may be entered on the command line or stated in file etc/rc.local (in one line!)
java de.fhg.igd.semoa.bin.Publish
-class examples.GuestbookServiceImpl
-key ${WhatiIs:APPLICATION_SERVICE}/guestbook
\; -setFile myguestbook.txt
| Nested Class Summary | |
(package private) class |
GuestbookServiceImpl.PrivilegedLoad
This privileged action loads the values from a given InputStream and stores them in a Properties instance. |
(package private) class |
GuestbookServiceImpl.PrivilegedStore
This privileged action stores the values of an Properties
instance to a given OutputSteam. |
| Field Summary | |
private static String |
ENTRY_KEY_PREFIX
The entries in the guestbook file are represented as key-value pairs like mesg.12345="Hello dear!". |
private File |
file_
References the file which backs the guestbook. |
private Object |
lock_
This object is used for internal synchronization. |
private Logger |
LOG
The logger instance for writing a log file. |
private static String |
OWNER_KEY
The name of the owner entry in the guestbook. |
| Fields inherited from class de.fhg.igd.semoa.service.AbstractService |
REV_POSTFIX, REV_PREFIX |
| Fields inherited from interface examples.guestbook.GuestbookService |
WHATIS |
| Constructor Summary | |
GuestbookServiceImpl()
|
|
| Method Summary | |
void |
addEntry(String text)
Allows to add an entry to the end of the guestbook. |
String |
author()
Returns the name of the author of the service. |
String[] |
getEntries()
Returns all entries from the guestbook. |
String |
getOwner()
Returns the name of the guestbook's owner. |
private String |
getUniqueKey()
Generates a unique key for an entry in the guestbook file. |
String |
info()
Returns the informative string which should describe the service's essence in a sentence. |
private Properties |
loadGuestbook()
Reads the guestbook from the file and returns it a new instance which holds all key-value-pairs from the file. |
String |
revision()
Returns the revision number of this class as a string. |
private void |
saveGuestbook(Properties gb)
|
void |
setFile(String fn)
Remembers the given file name as new guestbook file. |
String |
toString()
Pretty prints the whole guestbook. |
| Methods inherited from class de.fhg.igd.semoa.service.AbstractService |
checkDependencies, dependencies, docs, doPrivileged, doPrivileged, getACC, getEnvironment, majorVersion, minorVersion |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private static final String ENTRY_KEY_PREFIX
mesg.12345="Hello dear!".
All keys start with the string denoted in this constant. The constant is
used by the method getUniqueKey().
private static final String OWNER_KEY
owner=Snoopy
states that 'Snoopy' is the name of the guestbook's owner.
getOwner(),
Constant Field Valuesprivate final Logger LOG
etc/semoa.logging.
private File file_
setFile(String).
private final Object lock_
loadGuestbook(),
saveGuestbook(Properties)| Constructor Detail |
public GuestbookServiceImpl()
| Method Detail |
public String info()
AbstractService
info in interface Serviceinfo in class AbstractServiceAbstractService.info()public String author()
AbstractService
author in interface Serviceauthor in class AbstractServicepublic String revision()
AbstractServicemajorVersion(), minorVersion
based on the assumption that this method returns a
revision string as generated by rcs(1) for the template
"$Revision: 1.7 $/$Date: 2007-08-08 04:41:53 +0200 (Wed, 08 Aug 2007) $".
revision in class AbstractServicepublic String toString()
Object.toString().
It is very useful to access the service from the SeMoA shell
print ${WhatiIs:APPLICATION_SERVICE}/guestbook
where the path corresponds to the path where the service is
actually published.
toString in class AbstractServicepublic String getOwner()
GuestbookService
getOwner in interface GuestbookServiceGuestbookService.getOwner()public String[] getEntries()
GuestbookService
getEntries in interface GuestbookServiceGuestbookService.getEntries()public void addEntry(String text)
GuestbookService
addEntry in interface GuestbookServicetext - the entry to be addedGuestbookService.addEntry(java.lang.String)public void setFile(String fn)
addEntry(String) operation.
fn - absolute file name of the guestbook fileloadGuestbook(),
saveGuestbook(Properties)private Properties loadGuestbook()
addEntry(String),getEntries(), and
getOwner(). This is because we cannot be sure that the
guestbook returned by this method is still up-to-date in the next moment.
private void saveGuestbook(Properties gb)
private String getUniqueKey()
addEntry(String)each time a new entry has to be added.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||