asgaard.skid
Class LightBean

java.lang.Object
  |
  +--asgaard.skid.LightBean

public class LightBean
extends java.lang.Object
implements java.io.Serializable, RemoteBean

This Class is a special lightweight type of Bean which does not carry any Attributes but it's name (no multilanguage-support). Therefor it is used to hold e.g. String - identifyers used by the System.

See Also:
Serialized Form

Field Summary
protected static RemoteBroker broker
          Link to the RemoteBroker (one per VM).
protected  int cKey
           
protected static boolean debug
           
static int history_policy
          The History - Policy for saving UNDO-information.
protected  int key
           
protected  long tsCreated
           
protected  long tsModified
           
static byte update_policy
          Update Policy for saving modifications.
 
Constructor Summary
LightBean()
          New Instance
 
Method Summary
 void addEvent(RemoteBean event)
          Adding an Event and replicating it to all suscribed Objects.
 java.lang.Object cloneBean()
          Clones nothing Dummy
 void flush()
          Save all modifications (if any) and checks if the update is possible (timestamp of the RemoteBroker).
 long getAge()
          Timestamp "Age" of the Bean (= current version by the Modified-Timestamp).
 byte getBeanType()
          Returns the type of the Bean, used for the loading-signature.
 RemoteBroker getBroker()
          Get Link to the RemoteBroker (one per VM).
 java.lang.String[] getChangeHistory()
          Produces a discription of the last changes which can be undone Dummy.
 int getClassKey()
          Returns the type of the Bean's class, used for the loading-signature.
 long getCreated()
          Timestamp "Created" of the Bean.
 SkidEvent[] getEvent(long newer)
          Returns the Events for this bean which are newer than the given time
 SkidBeanFilter getFilter()
          Returns a Filter for this (and all parent) class.
 java.lang.String getIdentifier()
          Get the Identifier of the Bean which shall be unique worldwide for different Objects (like different Plans with luckily the same Name) and common for identical Objects (like a Person reentered), do not use manually.
 int getKey()
          (Unique) Primary Key of the Bean, created from the attribute name, the value is negative.
 BeanLink[] getLink(BeanLinkFilter filter)
          Returns a set of Links defined by an filterobject.
 java.lang.reflect.Method[] getMethods()
          Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces.
 long getModified()
          Timestamp "Modified" of the Bean.
 java.lang.String getName()
          Returns the name of the Bean which shold be human readable and may be unique in some cases, but this is not strictly required.
 java.lang.Object getObject()
          Returns the wrapped Object, in this case it's the Longname.
 byte getUpdatePolicy()
          Get's the update policy defined by the UPDATE_* constants.
 boolean init(int pKey, int cKey, RemoteBroker broker)
          All Keys of the Bean which are established at the first insert to the RemoteBroker, do not use manually.
 void init(int key, int classKey, java.lang.String name, java.lang.Object content, long tsC, long tsM)
          Initialises a new Lightweight Bean with a given name and timestamps Do not use manually!!!
 java.lang.Object invoke(java.lang.String name, java.lang.Object[] args, boolean modify)
          Invokes the underlying method represented by this Method object, on the specified object with the specified parameters.
 boolean isChanged()
          Has the Bean been changed?
 boolean isNew()
          Is the Bean new?
 boolean isReadOnly()
          Ist the Bean read only?
protected  void modify(java.lang.Object oldValue, java.lang.String fieldName)
          Set the modified flag and savin the old Value for the undo-mechanism (if the history_policy allowes this).
 boolean putLink(BeanLink link)
          Adds a Relaition between Beans
 void setAge()
          Sets the Age to the Modified timestamp, therefor IsChanged = false, Intended usage only from RemoteBroker.
 void setObject(java.lang.Object contain)
          Sets (replaces if any before) the given objects.
 void suscribeEvent(RemoteBean producer, RemoteBean event)
          Adding an Event-Pattern and suscribing this type of event.
 boolean undo(int steps)
          Undo Dummy - HAS TO BE THE LAST METHOD OF A REMOTEBEAN ROOT-IMPLEMENTATION
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

broker

protected static transient RemoteBroker broker
Link to the RemoteBroker (one per VM).

update_policy

public static byte update_policy
Update Policy for saving modifications.
See Also:
asgaard.skid.SkidBean.save, asgaard.skid.SkidBean.checkModification

history_policy

public static int history_policy
The History - Policy for saving UNDO-information. Valid values are HISTORY_ALL, HISTORY_NONE and any number > 0 defining the depth of the history.

key

protected int key

cKey

protected int cKey

tsCreated

protected long tsCreated

tsModified

protected long tsModified

debug

protected static final transient boolean debug
Constructor Detail

LightBean

public LightBean()
New Instance
Method Detail

init

public void init(int key,
                 int classKey,
                 java.lang.String name,
                 java.lang.Object content,
                 long tsC,
                 long tsM)
          throws SkidException
Initialises a new Lightweight Bean with a given name and timestamps Do not use manually!!!
Parameters:
key - of the Bean
calssKey - of the Bean
name - the short name of the def
content - the long name of the def
tsC - created - timestamp
tsM - modified - timestamp
Throws:
SkidException -  

getBroker

public RemoteBroker getBroker()
Get Link to the RemoteBroker (one per VM).
Specified by:
getBroker in interface RemoteBean

getUpdatePolicy

public byte getUpdatePolicy()
Get's the update policy defined by the UPDATE_* constants.
Specified by:
getUpdatePolicy in interface RemoteBean

getIdentifier

public java.lang.String getIdentifier()
Get the Identifier of the Bean which shall be unique worldwide for different Objects (like different Plans with luckily the same Name) and common for identical Objects (like a Person reentered), do not use manually.
Specified by:
getIdentifier in interface RemoteBean

getName

public java.lang.String getName()
Returns the name of the Bean which shold be human readable and may be unique in some cases, but this is not strictly required.
Specified by:
getName in interface RemoteBean

getKey

public int getKey()
           throws SkidException
(Unique) Primary Key of the Bean, created from the attribute name, the value is negative.
Specified by:
getKey in interface RemoteBean
Throws:
SkidException - not used.

getClassKey

public int getClassKey()
                throws SkidException
Returns the type of the Bean's class, used for the loading-signature.
Specified by:
getClassKey in interface RemoteBean
Throws:
SkidException -  

getBeanType

public byte getBeanType()
Returns the type of the Bean, used for the loading-signature.
Specified by:
getBeanType in interface RemoteBean
Throws:
RemoteException -  

getCreated

public long getCreated()
                throws SkidException
Timestamp "Created" of the Bean. Based on System.currentTimeMillis().
Specified by:
getCreated in interface RemoteBean
Throws:
SkidException - not used
See Also:
System#currentTimeMillis

getModified

public long getModified()
                 throws SkidException
Timestamp "Modified" of the Bean. Based on System.currentTimeMillis().
Specified by:
getModified in interface RemoteBean
Throws:
SkidException - not used
See Also:
System#currentTimeMillis

getAge

public long getAge()
            throws SkidException
Timestamp "Age" of the Bean (= current version by the Modified-Timestamp). Based on System.currentTimeMillis().
Specified by:
getAge in interface RemoteBean
Throws:
SkidException - not used
See Also:
System#currentTimeMillis

setAge

public void setAge()
Sets the Age to the Modified timestamp, therefor IsChanged = false, Intended usage only from RemoteBroker.
Specified by:
setAge in interface RemoteBean
See Also:
asgaard.skid.RemoteBroker#put

getLink

public BeanLink[] getLink(BeanLinkFilter filter)
                   throws java.lang.Exception
Returns a set of Links defined by an filterobject. If this filterobject is missing (null) all Links of this Bean are searched.
Specified by:
getLink in interface RemoteBean
Parameters:
filter - the filterobject
Returns:
a set of links
Throws:
java.lang.Exception - if the operation failes
See Also:
BeanLinkFilter

putLink

public boolean putLink(BeanLink link)
                throws java.lang.Exception
Adds a Relaition between Beans
Specified by:
putLink in interface RemoteBean
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

addEvent

public void addEvent(RemoteBean event)
Adding an Event and replicating it to all suscribed Objects.
Specified by:
addEvent in interface RemoteBean
Parameters:
event - the kond of the event (not null)

suscribeEvent

public void suscribeEvent(RemoteBean producer,
                          RemoteBean event)
Adding an Event-Pattern and suscribing this type of event.
Specified by:
suscribeEvent in interface RemoteBean
Parameters:
producer - of the event (not null)
event - the kond of the event (not null)

getEvent

public SkidEvent[] getEvent(long newer)
Returns the Events for this bean which are newer than the given time
Specified by:
getEvent in interface RemoteBean
Parameters:
newer - than the given time

init

public boolean init(int pKey,
                    int cKey,
                    RemoteBroker broker)
All Keys of the Bean which are established at the first insert to the RemoteBroker, do not use manually. Only use in insertBean
Specified by:
init in interface RemoteBean
Parameters:
pKey - the generated unique primary key
broker - defines the owning broker
Returns:
false if the key was set before.
See Also:
asgaard.skid.RemoteBroker.insertBean

modify

protected void modify(java.lang.Object oldValue,
                      java.lang.String fieldName)
Set the modified flag and savin the old Value for the undo-mechanism (if the history_policy allowes this). To avoid storing information you can use the history_policy or use null, null as parameter values.
Parameters:
oldVlaue - the old value (if any)
fieldName - the name of the field which was changed (see getClass.getDeclaredField())
See Also:
UndoHistory

isChanged

public boolean isChanged()
Has the Bean been changed?
Specified by:
isChanged in interface RemoteBean

isNew

public boolean isNew()
Is the Bean new?
Specified by:
isNew in interface RemoteBean

isReadOnly

public boolean isReadOnly()
Ist the Bean read only?
Specified by:
isReadOnly in interface RemoteBean

setObject

public void setObject(java.lang.Object contain)
               throws SkidException
Sets (replaces if any before) the given objects.
Parameters:
contain - the wrapped object
Throws:
SkidException - if the given Object is not Serializable

getObject

public java.lang.Object getObject()
Returns the wrapped Object, in this case it's the Longname.
Specified by:
getObject in interface RemoteBean

getFilter

public SkidBeanFilter getFilter()
Returns a Filter for this (and all parent) class.
Specified by:
getFilter in interface RemoteBean

getMethods

public java.lang.reflect.Method[] getMethods()
                                      throws java.lang.SecurityException
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. Returns an array of length 0 if the class or interface has no public member methods.
Specified by:
getMethods in interface RemoteBean
Throws:
java.lang.SecurityException - if access to the information is denied.

invoke

public java.lang.Object invoke(java.lang.String name,
                               java.lang.Object[] args,
                               boolean modify)
                        throws java.lang.IllegalAccessException,
                               java.lang.IllegalArgumentException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NullPointerException,
                               java.lang.NoSuchMethodException
Invokes the underlying method represented by this Method object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to widening conversions as necessary. The value returned by the underlying method is automatically wrapped in an object if it has a primitive type.
Specified by:
invoke in interface RemoteBean
Parameters:
name - the name of the Method
args - the Arguments
modify - call the modify-method too? (not including undo)
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.
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception.
java.lang.NullPointerException - if the specified object is null.
java.lang.NoSuchMethodException - if there is no Method with this name
See Also:
Method.invoke(java.lang.Object, java.lang.Object[])

flush

public void flush()
           throws java.lang.Exception
Save all modifications (if any) and checks if the update is possible (timestamp of the RemoteBroker). Remove the modified flag, set the modified-timestamp.
Specified by:
flush in interface RemoteBean
Throws:
java.lang.Exception - if the save failed.

getChangeHistory

public java.lang.String[] getChangeHistory()
Produces a discription of the last changes which can be undone Dummy.
Specified by:
getChangeHistory in interface RemoteBean
Returns:
null

cloneBean

public java.lang.Object cloneBean()
                           throws java.lang.CloneNotSupportedException
Clones nothing Dummy
Specified by:
cloneBean in interface RemoteBean
Returns:
null

undo

public boolean undo(int steps)
Undo Dummy - HAS TO BE THE LAST METHOD OF A REMOTEBEAN ROOT-IMPLEMENTATION
Specified by:
undo in interface RemoteBean