Java Doc for DataShareServer.java in  » Groupware » Data-share » org » datashare » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » Data share » org.datashare 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.datashare.DataShareServer

DataShareServer
public class DataShareServer implements DataReceiverInterface,TreeViewServerInterface,FifoConsumer(Code)
For now, a limitation of this design is that it uses a separate port for each Session and Channel. This will be changed in the future so that better 'in band' information will let a single server port serve more that one purpose. Trying to keep it simple for now.
author:
   Charles Wood
version:
   1.0


Field Summary
static  intTCPSocketReadTimeout
    
static  StringchannelTypesFile
    
static  TcpSocketServercommandStatusServerThread
    
static  intcurrentPort
    
 booleandataLoopFinished
    
static  booleanlogInAdapterFound
    
static  LogInInterfacelogInInterface
    
static  StringlogInInterfaceClassName
    
static  LoggingInterfaceloggingInterface
    
static  StringloggingInterfaceClassName
    
static  StringmultiCastIPaddress
    
static  intobjectCount
    
protected static  booleanpersistData
     true if we will be using a database to save info about DataShare objects.
static  booleanpersistenceAdapterFound
    
static  PersistenceInterfacepersistenceInterface
    
static  StringpersistenceInterfaceClassName
    
static  Hashtableproperties
     this is where we will store our configurable data, can be overwritten by Java defines.
static  StringpropertiesFile
    
static  PropertiesInterfacepropertiesInterface
    
static  StringpropertiesInterfaceClassName
    
static  StringserverInfoString
    
static  booleanserviceAdapterFound
    
static  ServiceInterfaceserviceInterface
    
static  StringserviceInterfaceClassName
    
static  booleanshowArchivedSessionsToAdmin
    
 Hashtabletokens
    
static  TreeViewtreeView
    
 ListwaitingForTokens
     if a client has to wait for a token, their request goes into this item.

Constructor Summary
public  DataShareServer()
    

Method Summary
public  ServerInfoaddClient(RegistrationInfo ri, SocketAdapter ts)
     Takes client username, makes it unique, puts client's unique name into our Hashtable of clients, keeps a copy of what machine IP they registered from, and sends back to the client information about their unique name and server info.
public  voidaddConsumer(String clientKey, String sessionKey, String channelKey, boolean channelActive)
     Called when a new consumer had been detected on a ThreadedServer socket (this is called from DataReceiverAdapter instances via the TreeViewServerInterface), puts the consumer in the list of consumers for the channel, notifies all registered clients, and creates the consumer EJB if not already created.
public  voidclientDataReceived(DataShareObject dsObject, SocketAdapter ts)
     All DataShare connections require that the user 'register' on the channel before it will be made 'active' by the server.
public  voidconnectionLost(SocketAdapter ts)
    
public  ClientSessionInfocreateSession(SocketAdapter ts, CreateSessionRequest csr)
     Used to create a Session that contains the Channels described by the CreateSessionRequest object.
 voiddeleteEmptySessions()
     this method will delete any sessions that do not have saved data.
public  ClientInfogetClientInfo(String clientKey)
    
public synchronized  intgetNextPort()
     used to provide the next port number to use for a Channel connection.
public  booleangetPersistData()
    
public  PersistenceInterfacegetPersistenceInterface()
    
public  StringgetServerInfo()
    
public  HashtablegetSessionTable()
    
public  booleangetShowArchivedSessionsToAdmin()
    
public  HashtablegetSpecialClientTable()
    
public  voidinitialize()
    
 voidinitializeValues(String args)
    
public  booleanisClientAdmin(String clientKey)
    
public  booleanisClientRegistered(String clientKey)
    
public  voidlostServerSocket(String keyValue)
     This is called when we lose our serverSocket, we can no longer make new connections, and may have lost the ability to use old ones for this socket.
public static  voidmain(String args)
    
public  voidnewConnection(SocketAdapter ts)
     called when someone new connects to our commandStatus Connection.
public  voidnewFifoDataAvailable(Object obj)
     called from the Fifo thread when data is available in the FIFO.
public  voidremoveAndDisconnectConsumer(String clientKey, String sessionKey, String channelKey)
     Called when a consumer closes a Channel connection for which the server cannot detect that the connection is closed (i.e.
public  voidremoveClient(String clientKeyValue)
     removes all references to a Client, takes care of closing its connections and notifying other Clients.
public  voidremoveConsumer(String clientKey, String sessionKey, String channelKey)
    
public  voidsaveDataToDatabase(String tableName, Hashtable props, PersistDataCallbackInterface callback)
     This method saveds the specified data to the database and puts the data's key value into the PersistDataCallbackInterface instance after the data is created.
public  voidshutDownConnectionsAndThreads()
     called when we need to shutdown all client connections and threads (i.e.

Field Detail
TCPSocketReadTimeout
static int TCPSocketReadTimeout(Code)



channelTypesFile
static String channelTypesFile(Code)



commandStatusServerThread
static TcpSocketServer commandStatusServerThread(Code)



currentPort
static int currentPort(Code)



dataLoopFinished
boolean dataLoopFinished(Code)



logInAdapterFound
static boolean logInAdapterFound(Code)



logInInterface
static LogInInterface logInInterface(Code)



logInInterfaceClassName
static String logInInterfaceClassName(Code)



loggingInterface
static LoggingInterface loggingInterface(Code)



loggingInterfaceClassName
static String loggingInterfaceClassName(Code)



multiCastIPaddress
static String multiCastIPaddress(Code)



objectCount
static int objectCount(Code)



persistData
protected static boolean persistData(Code)
true if we will be using a database to save info about DataShare objects. Must be false if useDatabase is false. Note that individual channels have their own control over saving data. This value is set at startup and must not change. Cannot be true if useDatabase is false. If useDatabase is true and this is false, then information about Clients and Sessions (and their associated info) will not be saved. This can be initialized as a command line parameter.



persistenceAdapterFound
static boolean persistenceAdapterFound(Code)



persistenceInterface
static PersistenceInterface persistenceInterface(Code)



persistenceInterfaceClassName
static String persistenceInterfaceClassName(Code)



properties
static Hashtable properties(Code)
this is where we will store our configurable data, can be overwritten by Java defines. May also be overwritten by command line options. Normal SystemProperties may be added into this if a propertiesManager is loaded.



propertiesFile
static String propertiesFile(Code)



propertiesInterface
static PropertiesInterface propertiesInterface(Code)



propertiesInterfaceClassName
static String propertiesInterfaceClassName(Code)



serverInfoString
static String serverInfoString(Code)



serviceAdapterFound
static boolean serviceAdapterFound(Code)



serviceInterface
static ServiceInterface serviceInterface(Code)



serviceInterfaceClassName
static String serviceInterfaceClassName(Code)



showArchivedSessionsToAdmin
static boolean showArchivedSessionsToAdmin(Code)



tokens
Hashtable tokens(Code)
TokenReqest objects indexed by tokenKey



treeView
static TreeView treeView(Code)



waitingForTokens
List waitingForTokens(Code)
if a client has to wait for a token, their request goes into this item. want to use linked list so we can better manage taking items out of the middle and append to the end.




Constructor Detail
DataShareServer
public DataShareServer()(Code)
Constructor, creates our DataShare server




Method Detail
addClient
public ServerInfo addClient(RegistrationInfo ri, SocketAdapter ts)(Code)
Takes client username, makes it unique, puts client's unique name into our Hashtable of clients, keeps a copy of what machine IP they registered from, and sends back to the client information about their unique name and server info. Note that all clients must have unique clientKey, even clients of dissimilar classes/types



addConsumer
public void addConsumer(String clientKey, String sessionKey, String channelKey, boolean channelActive)(Code)
Called when a new consumer had been detected on a ThreadedServer socket (this is called from DataReceiverAdapter instances via the TreeViewServerInterface), puts the consumer in the list of consumers for the channel, notifies all registered clients, and creates the consumer EJB if not already created.



clientDataReceived
public void clientDataReceived(DataShareObject dsObject, SocketAdapter ts)(Code)
All DataShare connections require that the user 'register' on the channel before it will be made 'active' by the server. this is so the server can associate a unique client name with each socket. The client must register with the server before it will be added as a Client that other Clients can see. The data received here is from the clients commandStatusConnection channel. Note that when we call ts.sendData() here, the object sent goes to client the message was received from only. Also note that calls to this method come from the Thread of the Socket from which the data was received.



connectionLost
public void connectionLost(SocketAdapter ts)(Code)
This is called when we lose a client's commandStatus connection to our server



createSession
public ClientSessionInfo createSession(SocketAdapter ts, CreateSessionRequest csr)(Code)
Used to create a Session that contains the Channels described by the CreateSessionRequest object.



deleteEmptySessions
void deleteEmptySessions()(Code)
this method will delete any sessions that do not have saved data. If data is not being saved (i.e. no database, etc.), no action is taken. This method should not be called if there are active consumers in any of the channels as it will not gracefully remove them (call shutdownConnectionsAndThreads first). Also note that this method will not clean up the sessionTable by removing the sessions whose data has been deleted. This method is designed to be called at shutdown to clean up the database prior to the next startup of the DataShare server.



getClientInfo
public ClientInfo getClientInfo(String clientKey)(Code)
Returns the ClientInfo for this client is this client is found in specialClients table, or null if not found



getNextPort
public synchronized int getNextPort()(Code)
used to provide the next port number to use for a Channel connection. Currently, no distinction is made between a UDP and a TCP connection (we could have UDP and TCP use the same port for different sockets).



getPersistData
public boolean getPersistData()(Code)
Used to determine if this server instance supports persisting data true if server supports persisting data, false otherwise



getPersistenceInterface
public PersistenceInterface getPersistenceInterface()(Code)
returns reference to persistence interface, should be non-null if getPersistData() returns true, may be null otherwise



getServerInfo
public String getServerInfo()(Code)



getSessionTable
public Hashtable getSessionTable()(Code)
returns the table of sessions



getShowArchivedSessionsToAdmin
public boolean getShowArchivedSessionsToAdmin()(Code)



getSpecialClientTable
public Hashtable getSpecialClientTable()(Code)
returns the table of clients



initialize
public void initialize()(Code)
Creates the CommandStatus Channel for communicating with Clients



initializeValues
void initializeValues(String args)(Code)
give default values to properties



isClientAdmin
public boolean isClientAdmin(String clientKey)(Code)

Parameters:
  clientKey - keyValue of client to be checked for Admin privileges true if client has Admin privileges, false otherwise



isClientRegistered
public boolean isClientRegistered(String clientKey)(Code)
Returns true if this client is in the list of clients who have registered, false otherwise



lostServerSocket
public void lostServerSocket(String keyValue)(Code)
This is called when we lose our serverSocket, we can no longer make new connections, and may have lost the ability to use old ones for this socket. This particular serverSocket is the overall commandStatusPort connection socket.



main
public static void main(String args)(Code)



newConnection
public void newConnection(SocketAdapter ts)(Code)
called when someone new connects to our commandStatus Connection. At this point, we know IP and port, but not who is using it. ThreadedSocket is saved in Hashtable keyed by clientKey (unique Client name)



newFifoDataAvailable
public void newFifoDataAvailable(Object obj)(Code)
called from the Fifo thread when data is available in the FIFO. Data was put into the FIFO by the persistDataQueue.write() method. This is called when the Fifo thread has finished with waiting for the previous database key to be created?



removeAndDisconnectConsumer
public void removeAndDisconnectConsumer(String clientKey, String sessionKey, String channelKey)(Code)
Called when a consumer closes a Channel connection for which the server cannot detect that the connection is closed (i.e. UDP), this will remove the consumer from our tables, our tree, and cause the connection to close for that client in that channel



removeClient
public void removeClient(String clientKeyValue)(Code)
removes all references to a Client, takes care of closing its connections and notifying other Clients.



removeConsumer
public void removeConsumer(String clientKey, String sessionKey, String channelKey)(Code)
Called when a consumer had closed a Channel connection (this is called from DataReceiverAdapter instances via the TreeViewServerInterface)



saveDataToDatabase
public void saveDataToDatabase(String tableName, Hashtable props, PersistDataCallbackInterface callback)(Code)
This method saveds the specified data to the database and puts the data's key value into the PersistDataCallbackInterface instance after the data is created.
Parameters:
  tableName - the name of the table this data should be added to
Parameters:
  props - describes what is to be persisted in the database
Parameters:
  callback - the interface that supplies the methods used to set the Key for this data



shutDownConnectionsAndThreads
public void shutDownConnectionsAndThreads()(Code)
called when we need to shutdown all client connections and threads (i.e. we are exiting)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.