|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.aduna.gee.publication.net.OutputHandler
public class OutputHandler
Central point for uploading ZPad specific files. These are the files that are of particular importance to content extractors and the transport module.
| Field Summary | |
|---|---|
protected Job |
_activeJob
The active job |
protected static Hashtable |
_checkedLogins
The checked login objects are saved to prevent unnecessary URL requests. |
protected boolean |
_closeOnSync
When I'm closed but contain data that should be stored, remember that I should be closed |
protected static Hashtable |
_jobs
The job queues, per location. |
protected Vector |
_listeners
Audience interested in io events |
protected static Vector |
_peers
A pool of active output handlers |
protected Hashtable |
_postRequests
Stream to URLConnection mapping for POST requests |
protected Vector |
_queue
The job queue for this location |
protected Thread |
_thread
The transfer thread |
boolean |
active
Is this an active outputhandler ? An active outputhandler is an outputhandler connected to "something" that is capable of storing (e.g. |
InputHandler |
inputHandler
The corresponding input handler |
WURL |
location
the ZPad location to transfer to. |
String |
userName
Only the OutputHandler knows the user's name. |
| Fields inherited from interface info.aduna.gee.publication.net.IOListener |
|---|
CACHE_UPDATE, LOGIN_ADDED, PASSWORD_ERROR, QUEUE_UPDATE, SHOW_OBJECT, STORE_DONE, STORE_STARTED |
| Constructor Summary | |
|---|---|
OutputHandler(InputHandler input,
boolean active)
Creates a new output handler. |
|
| Method Summary | |
|---|---|
protected Hashtable |
_getCheckedLogins()
|
protected Hashtable |
_getJobs()
|
protected Vector |
_getPeers()
|
protected void |
_internalStore()
|
protected void |
_notify(int info,
String filename,
Object arg)
Notify this io handler of a change that applies to the way the database should be handled. |
protected void |
_notifyPeers(boolean all,
int info,
String filename,
Object arg)
Notify peer output handlers. |
protected void |
_processJob(Job job)
Process a store job. |
protected void |
_reallyClose()
|
protected boolean |
_shouldStore(Job job)
Should we really store the Job ? |
protected static OutputStream |
_writeTo(WStorable object,
OutputStream output)
|
void |
addListener(IOListener listener)
Adds an IOListener interested in feedback about io. |
protected WOutputStream |
authorizedOutputStream(String filename,
Login login,
boolean force)
Get a WOutputStream that already contains the authorization information. |
static int |
checkResponse(String response)
Check the response line of the HTTPD. |
void |
close()
Deregisters this OutputHandler from the pool of OutputHandlers. |
void |
finalize()
Called at garbage collection time. |
Login |
getLogin()
Get the current Login for this location. |
int |
getLoginCount()
How many logins are there ? |
OutputStream |
getOutputStream(String filename,
boolean force)
Open an output stream on a remote file. |
boolean |
hasActivePeers()
Does the outputHandler have any active peers? |
boolean |
hasPassword(boolean personally)
Has the current OutputHandler a password. |
void |
ioStateChanged(WURL location,
int info,
String filename,
Object arg)
Implements interface IOListener. |
boolean |
isLoggedIn(String name,
boolean personally)
Check whether a person is logged in. |
int |
jobCount()
Counts the number of pending jobs. |
Vector |
jobNames()
List the names of the pending jobs. |
WURL |
locationOf(String name)
Get the location of a person. |
boolean |
login(Login login)
Checks the authorization of supplied login information on the remote host. |
void |
logout()
For whatever reason, remove the current login for the current location. |
static String |
nameOf(WURL hislocation)
Get a person's name from his location. |
void |
notifyListeners(Exception exc,
String filename)
Notifies all listeners of an exception. |
void |
notifyListeners(int info,
String filename,
Object arg)
Notify all listener with io information. |
void |
onException(WURL location,
Exception e,
String filename)
Implements interface IOListener. |
void |
onStreamClose(Object stream)
Implements part of the interface of StreamListener. |
void |
onStreamException(Exception e,
Object stream)
Implements interface StreamListener. |
byte[] |
post(String path,
WProperties headers,
byte[] body)
|
void |
removeJob(Job job)
|
void |
removeJob(String jobName)
|
void |
removeListener(IOListener listener)
Removes a IOListener. |
void |
run()
The starting point of the store thread. |
void |
setStorable(boolean storable)
|
void |
start()
Start storing jobs in the queue. |
void |
store(WStorable object,
String filename,
boolean force,
boolean delay)
Stores a storable object. |
void |
sync()
Removes the delay from all jobs. |
static void |
syncAll()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public WURL location
protected static Vector _peers
protected static Hashtable _jobs
protected Vector _queue
protected Job _activeJob
protected Vector _listeners
protected boolean _closeOnSync
public InputHandler inputHandler
protected Thread _thread
public boolean active
protected Hashtable _postRequests
protected static Hashtable _checkedLogins
public String userName
| Constructor Detail |
|---|
public OutputHandler(InputHandler input,
boolean active)
input - the corresponding input handler.active - specifies whether to create the actual store
thread. If false, the store requests are overtaken by other
ZPad components. Make sure there is at least one running...close()| Method Detail |
|---|
public void store(WStorable object,
String filename,
boolean force,
boolean delay)
object - The object to store.filename - the name of the file to store to.force - overwrite any other intermediate changes yes/no.delay - delay the store request yes/no.public void removeJob(Job job)
job - the job to remove.public void removeJob(String jobName)
jobName - the name of the job to remove.public void start()
public void run()
run in interface Runnable
protected WOutputStream authorizedOutputStream(String filename,
Login login,
boolean force)
throws IOException
IOExceptionpublic boolean hasPassword(boolean personally)
personally - if true, the password must be the personal password,
otherwise it might be of an associate.public int getLoginCount()
public Login getLogin()
public OutputStream getOutputStream(String filename,
boolean force)
throws IOException
filename - the name of the remote file.
IOException
public boolean login(Login login)
throws IOException
login - the login information to check.
IOExceptionpublic void logout()
public boolean isLoggedIn(String name,
boolean personally)
name - the person's name.personally - if true, the person should be logged in personally, otherwise it is sufficient
to be an associate owner of person.public WURL locationOf(String name)
public static String nameOf(WURL hislocation)
public void onStreamClose(Object stream)
throws IOException
stream - the stream that was closed.
IOException
public void onStreamException(Exception e,
Object stream)
stream - an InputStream or OutputStream
public static int checkResponse(String response)
throws IOException
response - the response line of HTTPD.
IOExceptionprotected void _processJob(Job job)
job - the job to processpublic void addListener(IOListener listener)
listener - An IOListener interested in
the changes.public void removeListener(IOListener listener)
listener - The IOListener to remove.public void close()
protected void _reallyClose()
public void notifyListeners(int info,
String filename,
Object arg)
info - the information to send.object - the object the information is about.filename - the filename of the object the info
is about.
public void notifyListeners(Exception exc,
String filename)
exc - the exception to nofify.filename - the name of the file.
protected void _notifyPeers(boolean all,
int info,
String filename,
Object arg)
all - If true, notify all output handlers, if false, notify only the output handlers for this location.info - The kind of information.filename - the name of the file.arg - an optional argument
protected void _notify(int info,
String filename,
Object arg)
info - The kind of information.filename - the name of the file.arg - an optional argument.public void sync()
public int jobCount()
public Vector jobNames()
public void finalize()
throws Throwable
finalize in class ObjectThrowablepublic boolean hasActivePeers()
public void ioStateChanged(WURL location,
int info,
String filename,
Object arg)
ioStateChanged in interface IOListenerinfo - the kind of feedback.filename - the name of the file the info is about.arg - an optional argument.location - the location
public void onException(WURL location,
Exception e,
String filename)
onException in interface IOListenere - the exception to notify.filename - the name of the file the info is about.location - the locationprotected Vector _getPeers()
protected Hashtable _getJobs()
protected Hashtable _getCheckedLogins()
public byte[] post(String path,
WProperties headers,
byte[] body)
throws IOException
IOExceptionpublic static void syncAll()
protected void _internalStore()
protected static OutputStream _writeTo(WStorable object,
OutputStream output)
throws IOException
IOExceptionprotected boolean _shouldStore(Job job)
public void setStorable(boolean storable)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||