asgaard.skid
Class Skid

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--asgaard.skid.Skid

public class Skid
extends java.rmi.server.UnicastRemoteObject
implements RemoteBroker

Servertask (Objectbroker) of the Asgaard - Databaselayer - API "Skid".

Before starting asgaard.skid.Skid the rmiregistry need to be started!

When Skid is started, aware that the uses .property files are in the local directory.

See Also:
Serialized Form

Field Summary
static java.lang.String CONNECT_FLATFILE
           
static java.lang.String connect_string
           
static java.lang.String COPYRIGHT
          The Copyright message
static boolean debug
           
static java.lang.String driver_class
           
static java.lang.String local_db_path
           
static java.lang.Boolean localDB
           
protected static asgaard.utils.log.LogClient log
          LOGFILE of this Server
static byte LogLevel
           
static byte MailLevel
           
static java.lang.String SERVER
          The Service Name
static java.lang.String ServerName
          Name for the Binding-service.
static java.lang.String VERSION
          The version number
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
Skid()
          Instanciates an Server-Object
 
Method Summary
 void addEvent(RemoteBean producer, RemoteBean event)
          Adding an Event and replicating it to all suscribed Objects.
 boolean beanExist(int key)
          Returns whether an Bean is available within the Broker or not.
 java.lang.String checkUser(java.lang.String userName, java.lang.String encr)
          Checks if the given username exists or not
static java.lang.String format(java.lang.String key)
           
static java.lang.String format(java.lang.String key, java.lang.Object[] args)
           
static java.lang.String format(java.lang.String key, java.lang.String arg)
           
 RemoteBean getBean(int key)
          Searches for a Bean by a given key.
 RemoteBean[] getBean(int[] key)
          Searches for Beans by a given set of keys.
 int[] getBeanKey(java.lang.String aClass, java.lang.String[] paramName, java.lang.Object[] searchValue, byte[] searchOp)
          Searches for a Bean by a given key.
 BeanKeyCall getBeanKeyCall(java.lang.Class aClass)
          Returns the Key-Call-Adapter for a asked Class (represented by it's key).
 int getClassKey(java.lang.Class aClass)
          Class-Key of the Bean, differ between different classes.
 int getClassKey(RemoteBean aBean)
          Class-Key of the Bean, differ between different classes.
 SkidEvent[] getEvent(RemoteBean consumer, long newer)
          Returns the Events for a consumer object which are newer than the given time
 BeanLink[] getLink(BeanLinkFilter filter)
          Searches for a set of Links using the filter - capabilities of BeanLink.
 BeanLink getLink(int from, int to, int by)
          Searches for a specific Link using it's primary key.
static java.util.Date getNow()
           
 java.lang.Object getUser(java.lang.Object o, java.lang.String name, java.lang.String encr)
          Excanges an user with an authorised object (hardcoded)
 java.lang.Object getUser(java.lang.String name, java.lang.String encr)
          Excanges an user with an authorised object (hardcoded)
 java.lang.Object invokeCall(java.lang.Class beanClass, java.lang.String name, java.lang.Object[] args, java.lang.String[] classnames)
          Invokes the called method of the filterinterface.
 boolean linkExist(int from, int to, int by)
          Returns if a specific Key exists, hiding all Exceptions.
 boolean logMsg(java.lang.String server, java.lang.String point, byte typ, boolean ok, java.lang.String msg)
          Puts a Message to the LOG-Server if available and returns whether it was sent or not
static void main(java.lang.String[] args)
          Application - main, follows start of the Commandline.
static void out(java.lang.String key)
          Prints a Message referenced by key to a global standard out.
static void out(java.lang.String key, java.lang.Object[] args)
          Prints a Message referenced by key to a global standard out, enriched by given args.
static void out(java.lang.String key, java.lang.String arg)
          Prints a Message referenced by key to a global standard out, enriched by a given arg.
 java.lang.Object[] putBean(RemoteBean aObj)
          Puts the Bean into the Chache and saves it do not use manually.
 boolean putLink(BeanLink link)
          Adds a new Relation between Beans.
 boolean putUser(java.lang.Object o)
          Excanges an user with an authorised object (hardcoded)
 void setEvent(RemoteBean producer, RemoteBean event, RemoteBean consumer, byte fromState, byte toState)
          Changing the State of an specific event.
 void suscribeEvent(RemoteBean producer, RemoteBean event, RemoteBean consumer)
          Adding an Event-Pattern and suscribing this type of event.
 void testMode(boolean on)
          Switches the test - mode on / off.
static void usage(boolean longusage)
           
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ServerName

public static java.lang.String ServerName
Name for the Binding-service.

SERVER

public static final java.lang.String SERVER
The Service Name

VERSION

public static final java.lang.String VERSION
The version number

COPYRIGHT

public static final java.lang.String COPYRIGHT
The Copyright message

LogLevel

public static byte LogLevel

MailLevel

public static byte MailLevel

debug

public static final boolean debug

driver_class

public static java.lang.String driver_class

CONNECT_FLATFILE

public static final java.lang.String CONNECT_FLATFILE

connect_string

public static java.lang.String connect_string

local_db_path

public static java.lang.String local_db_path

log

protected static asgaard.utils.log.LogClient log
LOGFILE of this Server

localDB

public static java.lang.Boolean localDB
Constructor Detail

Skid

public Skid()
     throws java.rmi.RemoteException
Instanciates an Server-Object
Method Detail

main

public static void main(java.lang.String[] args)
Application - main, follows start of the Commandline. Never called directly.
Parameters:
argv - Commandlineparameters given within Start of the Servertask

getClassKey

public int getClassKey(RemoteBean aBean)
                throws java.rmi.RemoteException
Class-Key of the Bean, differ between different classes.
Specified by:
getClassKey in interface RemoteBroker
Parameters:
aBean - a Bean asked for the class-id

getClassKey

public int getClassKey(java.lang.Class aClass)
                throws java.rmi.RemoteException
Class-Key of the Bean, differ between different classes.
Specified by:
getClassKey in interface RemoteBroker
Parameters:
aClass - the Bean-Class asked for the class-id

getUser

public final java.lang.Object getUser(java.lang.String name,
                                      java.lang.String encr)
                               throws SkidException,
                                      java.rmi.RemoteException,
                                      java.sql.SQLException
Excanges an user with an authorised object (hardcoded)
Specified by:
getUser in interface RemoteBroker

getUser

public final java.lang.Object getUser(java.lang.Object o,
                                      java.lang.String name,
                                      java.lang.String encr)
                               throws SkidException,
                                      java.rmi.RemoteException,
                                      java.sql.SQLException
Excanges an user with an authorised object (hardcoded)
Specified by:
getUser in interface RemoteBroker

putUser

public final boolean putUser(java.lang.Object o)
                      throws SkidException,
                             java.rmi.RemoteException,
                             java.sql.SQLException
Excanges an user with an authorised object (hardcoded)
Specified by:
putUser in interface RemoteBroker

checkUser

public final java.lang.String checkUser(java.lang.String userName,
                                        java.lang.String encr)
                                 throws SkidException,
                                        java.rmi.RemoteException,
                                        java.sql.SQLException
Checks if the given username exists or not
Specified by:
checkUser in interface RemoteBroker
Parameters:
userName - name of the user
encr - the encrypted password (optional)
Throws:
java.rmi.RemoteException - if RMI doesen't work
java.sql.SQLException - the db doesen't work

putBean

public java.lang.Object[] putBean(RemoteBean aObj)
                           throws java.lang.Exception
Puts the Bean into the Chache and saves it do not use manually. Checks the Timestamps according to a update-policy given by the Bean and saves al modifications permanently. To enforce a Bean's saving use the Bean's saving method. flush

Remark: A System-Object cannot be modified and carries the created-Timestamp 0

Specified by:
putBean in interface RemoteBroker
Parameters:
aObj - the calling Bean
Returns:
wether an update is possible or not.
Throws:
java.lang.Exception - if an error occoured during the writeback.
See Also:
asgaard.skid.RemoteBean#saveflush

getBeanKey

public int[] getBeanKey(java.lang.String aClass,
                        java.lang.String[] paramName,
                        java.lang.Object[] searchValue,
                        byte[] searchOp)
                 throws SkidException
Searches for a Bean by a given key.
Specified by:
getBeanKey in interface RemoteBroker
Parameters:
aClass - the searched class
paramName - list of the parameter to search for
searchValues - values to fit
search-operator -  
Returns:
a set of Bean as result of the search
Throws:
java.lang.Exception - if anything fails

getBean

public RemoteBean getBean(int key)
                   throws java.lang.Exception
Searches for a Bean by a given key.
Specified by:
getBean in interface RemoteBroker
Parameters:
key - the primary key of the object
Returns:
the searched Bean if the key exist
Throws:
java.lang.Exception - if anything fails

getBean

public RemoteBean[] getBean(int[] key)
                     throws java.lang.Exception
Searches for Beans by a given set of keys. Simply calles the primitive getBean method.
Specified by:
getBean in interface RemoteBroker
Parameters:
key - the primary key of the object
Returns:
the searched Bean if the key exist
Throws:
java.lang.Exception - if anything fails

beanExist

public boolean beanExist(int key)
Returns whether an Bean is available within the Broker or not.
Specified by:
beanExist in interface RemoteBroker
Parameters:
key - the unique key of the Bean
Returns:
true for an existing Bean with the given key

getBeanKeyCall

public BeanKeyCall getBeanKeyCall(java.lang.Class aClass)
                           throws java.lang.Exception
Returns the Key-Call-Adapter for a asked Class (represented by it's key).
Specified by:
getBeanKeyCall in interface RemoteBroker
Parameters:
classkey - the id of the class
Throws:
java.lang.Exception - if the key's couldn't be mapped

putLink

public boolean putLink(BeanLink link)
                throws java.lang.Exception
Adds a new Relation between Beans.
Specified by:
putLink in interface RemoteBroker
Parameters:
link - one relation
Returns:
wether an update is possible or not.
Throws:
java.lang.Exception - if the key is not valid or anything else fails

getLink

public BeanLink getLink(int from,
                        int to,
                        int by)
                 throws java.lang.Exception
Searches for a specific Link using it's primary key.
Specified by:
getLink in interface RemoteBroker
Parameters:
from - key of the origin Bean
to - key of the target Bean
by - key of the link-Bean (kind of Link)
Returns:
the link if found
Throws:
java.lang.Exception - if anything goes wrong.

getLink

public BeanLink[] getLink(BeanLinkFilter filter)
                   throws java.lang.Exception
Searches for a set of Links using the filter - capabilities of BeanLink.
Specified by:
getLink in interface RemoteBroker
Parameters:
filter - the BeanLink used as Filter
Returns:
the links if any found
Throws:
java.lang.Exception - if anything goes wrong.

linkExist

public boolean linkExist(int from,
                         int to,
                         int by)
Returns if a specific Key exists, hiding all Exceptions.
Specified by:
linkExist in interface RemoteBroker
Parameters:
from - key of the origin Bean
to - key of the target Bean
by - key of the link-Bean (kind of Link)
Returns:
the link if found

addEvent

public void addEvent(RemoteBean producer,
                     RemoteBean event)
              throws java.lang.Exception
Adding an Event and replicating it to all suscribed Objects.
Specified by:
addEvent in interface RemoteBroker
Parameters:
producer - of the event (not null)
event - the kond of the event (not null)
Throws:
java.lang.Exception - if it doesen't work

setEvent

public void setEvent(RemoteBean producer,
                     RemoteBean event,
                     RemoteBean consumer,
                     byte fromState,
                     byte toState)
              throws java.lang.Exception
Changing the State of an specific event.
Specified by:
setEvent in interface RemoteBroker
Parameters:
producer - of the event (not null)
event - the kond of the event (not null)
consumer - of the event (not null)
fromState - ols State of the event
toState - ols State of the event
Throws:
java.lang.Exception - if it doesen't work

suscribeEvent

public void suscribeEvent(RemoteBean producer,
                          RemoteBean event,
                          RemoteBean consumer)
                   throws java.lang.Exception
Adding an Event-Pattern and suscribing this type of event.
Specified by:
suscribeEvent in interface RemoteBroker
Parameters:
producer - of the event (not null)
event - the kond of the event (not null)
consumer - of the event (not null)
Throws:
java.lang.Exception - if it doesen't work

getEvent

public SkidEvent[] getEvent(RemoteBean consumer,
                            long newer)
                     throws java.lang.Exception
Returns the Events for a consumer object which are newer than the given time
Specified by:
getEvent in interface RemoteBroker
Parameters:
consumer - of the events
newer - than the given time
Throws:
java.lang.Exception -  

invokeCall

public java.lang.Object invokeCall(java.lang.Class beanClass,
                                   java.lang.String name,
                                   java.lang.Object[] args,
                                   java.lang.String[] classnames)
                            throws java.lang.Exception
Invokes the called method of the filterinterface. The BeanKeyCall-Objects are cached by the BeanBroker and available via this one-method interface
Specified by:
invokeCall in interface RemoteBroker
Parameters:
beanClass - the class which the asked BeanKeyCall object is for
name - the name of the Method
args - the Arguments
Returns:
a result returned (if any)
Throws:
java.lang.IllegalAccessException - if the underlying method is inaccessible.
java.lang.IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.
InvocationTargetException - if the underlying method throws an exception.
java.lang.NoSuchMethodException - if there is no Method with this name
See Also:
Method.invoke(java.lang.Object, java.lang.Object[])

testMode

public void testMode(boolean on)
Switches the test - mode on / off. All changes at the Database between on and off will be deleted.
Specified by:
testMode in interface RemoteBroker

logMsg

public boolean logMsg(java.lang.String server,
                      java.lang.String point,
                      byte typ,
                      boolean ok,
                      java.lang.String msg)
Puts a Message to the LOG-Server if available and returns whether it was sent or not
Specified by:
logMsg in interface RemoteBroker
Parameters:
server - The calling Java-Serverclass
point - The Method / place where the statement was created
typ - The Type of the LOG-Statement
ok - Was the ServicePoint passed successfuly
msg - Human redable Message of the Statement
See Also:
LogMsg

usage

public static void usage(boolean longusage)

out

public static void out(java.lang.String key,
                       java.lang.Object[] args)
Prints a Message referenced by key to a global standard out, enriched by given args.
Parameters:
key - Search key
key - Set of arguments integrated into the message

out

public static void out(java.lang.String key,
                       java.lang.String arg)
Prints a Message referenced by key to a global standard out, enriched by a given arg.
Parameters:
key - Search key
key - a argument integrated into the message

out

public static void out(java.lang.String key)
Prints a Message referenced by key to a global standard out.
Parameters:
key - Search key

format

public static java.lang.String format(java.lang.String key,
                                      java.lang.Object[] args)

format

public static java.lang.String format(java.lang.String key,
                                      java.lang.String arg)

format

public static java.lang.String format(java.lang.String key)

getNow

public static java.util.Date getNow()