Overview of java-classes

This is not complete documentation but points the classes where to look to understand the functionality of the server.

Startup class

com.fuse.projects.fuse_light.FUSELight is the class which is run when the server is started. It initializes all services such as database, environment-variables (FUSEEnvironment) and starts up the listener-thread and connection manager.

If you plan to customize FUSELight server for your own project you should duplicate this class and move it to package com.fuse.projects. and rename it to your project's name. See connection manager / factory section for more info.

Environment variables

To get environment-variables, call static getProperty()-methods from com.fuse.FUSEEnvironment.

Connection handler

com.fuse.projects.fuse_light.net.FUSELightConnection extends com.fuse.net.FUSEClientConnection. For each connection from a client new instance of FUSELightConnection is created. Its method handleClientMessage(String) processes all the messages sent by the client (investigate this method carefully!). Superclass FUSEClientConnection has all generic methods, such as:

- processFuseMessage(String type, String data) // sends message to client
- release() // disconnects connection
- generateError(int code, String msg) // sends error message to client

Connection manager / factory

com.fuse.net.FUSEConnectionManager keeps track of active connections and returns new connections to the connection-listener (com.fuse.net.FUSEConnectionListener) when needed. com.fuse.net.FUSEConnectionFactory constructs connections for the connection-manager. FUSELightConnections are constructed by class com.fuse.projects.fuse_light.net.FUSELightConnectionFactory.

For your own special projects you probably want to have your own connection-handler which extends FUSELightConnection. To use your own connection-handler you must make your own connectionfactory and pass it to FUSEConnectionManager when it is instantiated. See constructor for com.fuse.projects.fuse_light.FUSELight for an example.

Database

Database architecture of FUSELight is somewhat complicated but very modular. Package is com.fuse.storage Database-manager can be accessed via RMI or locally (default) and data is encapsulated in FUSEDataObject-objects. Implementation is hidden from the programmer of the application logic so you always call generic interfaces / abstract-classes.

Reference to the database is obtaned by calling:

		FUSEDatabase databaseRef = FUSEEnvironment.getDatabaseProxy().getDatabase();

FUSEDatabase has following public methods:

	 Interface: com.fuse.storage.FUSEDatabase 

	
		public FUSEDataObject createNew(String type) throws ClassNotFoundException, RemoteException;

		public FUSEDataObject insert(FUSEDataObject dbObject) throws DatabaseException, RemoteException;

		public void delete(FUSEDataObject dbObject) throws DatabaseException, RemoteException;
			
		public FUSEDataObject update(FUSEDataObject dbObject) throws DatabaseException, RemoteException;
			
		public Vector query(ObjectQueryBean bean) throws DatabaseException, RemoteException;

		public Object querySummary(SummaryQueryBean bean) throws DatabaseException, RemoteException;
Basically you use database like this:

1. Get an dataobject of wanted type like "FUSEUser": dbObject= databaseRef.createNew("FUSEUser")

2. If you want to query for objects of given type, use methods of the dataObject. For example FUSEUser has method findUserByName()

3. If you want to insert object, first set the fields of the created object and then call databaseRef.insert(dbObject)

DataObject implementations
SQL-implementations for the data-objects are in package com.fuse.storage.sql.data_objects. Corresponding implementation is named SQL.java, such as SQL-implementation of "FUSEUser" is SQLFUSEUser.java.
FUSEDatabase-implementations
See com.fuse.storage.sql.SQLDatabaseImpl...
User registry
Access to user-database is conviniently handled by FUSERegister-class. You can get an instance by calling FUSEEnvironment.getRegister().

Secret Keys

Everytime client connects to the server it must decode correctly a secret key sent by the server. The idea is to prevent most hackers from making their own clients to your server. Different services should have their own algorithms for secret keys. Secret key-generators must implement interface com.fuse.secret.SecretKey. With FUSE Light I have provided a very simple implementation com.fuse.secret.VerySimpleSecretKey. Secret key generator to be used is defined in fuse.properties-file.

First Run <<    Overview of Lingo-scripts >>