asgaard.skid
Interface RemoteBean

All Known Implementing Classes:
LightBean, SkidBean

public abstract interface RemoteBean

Interface of an Data-Bean, normaly use SkidBean where all nessacary methods are implemented. This interface is a workaround if polymorpy is nessecary and to implement the Remote-Interface automatically. Therefor all Beans are accessible via RMI.

Important: The Last Method of the ROOT-IMPLEMENTATION of RemoteBean has to implement SkidBean.LAST_METHOD as last method!

Important: public static RemoteBroker THIS has to be defined within each VM to guarantie regular behavior within Skid!

Important: Key values which are accessible via the RemoteBroker have to be defined following the Java-Beans-Convention using the getXXXX methods for key-generation.

Remark: All attribues used by the Object which are not intended to be persitent have to be declared transient and restored by default or the parameterless constructor.

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

See Also:
SkidBean, RemoteBroker

Method Summary
 void addEvent(RemoteBean event)
          Adding an Event and replicating it to all suscribed Objects.
 java.lang.Object cloneBean()
          Clones the Object and does all the settings neccesary to be assigned as a new SkidBean.
 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()
          (Unique) Primary Key of the Bean.
 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.
 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()
          Returns the type of the Bean, used for the loading-signature.
 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 (if wrapped by a container) or the Bean (if it's no wrapper)
 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.
 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()
          Ist das Bean neu?
 boolean isReadOnly()
          Ist the Bean read only?
 boolean putLink(BeanLink link)
          Adds a Relaition between Beans
 void setAge()
          Sets the Age to the Modified timestamp, therefor IsChanged = false, do not use manually!
 void suscribeEvent(RemoteBean producer, RemoteBean event)
          Adding an Event-Pattern and suscribing this type of event.
 boolean undo(int steps)
          Undo the last steps changes (0 = all, -1 no undo but ask if any undos possible).
 

Method Detail

getBroker

public RemoteBroker getBroker()
Get Link to the RemoteBroker (one per VM).

getUpdatePolicy

public byte getUpdatePolicy()
Get's the update policy defined by the UPDATE_* constants.
See Also:
asgaard.skid.RemoteBean.UPDATE_ALL, asgaard.skid.RemoteBean.UPDATE_WEAK, asgaard.skid.RemoteBean.UPDATE_STRONG

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.

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.

getKey

public int getKey()
           throws SkidException
Returns the type of the Bean, used for the loading-signature.
Throws:
SkidException -  

getClassKey

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

getBeanType

public byte getBeanType()
(Unique) Primary Key of the Bean.
Throws:
SkidException - if the key is not valid now.

getCreated

public long getCreated()
                throws SkidException
Timestamp "Created" of the Bean. Based on System.currentTimeMillis().
Throws:
SkidException - if the timestamp is not valid now.
See Also:
System#currentTimeMillis

getModified

public long getModified()
                 throws SkidException
Timestamp "Modified" of the Bean. Based on System.currentTimeMillis().
Throws:
SkidException - if the timestamp is not valid now.
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().
Throws:
SkidException - if the timestamp is not valid now.
See Also:
System#currentTimeMillis

setAge

public void setAge()
Sets the Age to the Modified timestamp, therefor IsChanged = false, do not use manually! Intended usage only from RemoteBroker.
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.
Parameters:
filter - the filterobject
Returns:
a set of links
Throws:
java.lang.Exception - if the search failes
See Also:
BeanLinkFilter

putLink

public boolean putLink(BeanLink link)
                throws java.lang.Exception
Adds a Relaition between Beans
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.
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.
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
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.
Parameters:
pKey - the generated unique primary key
cKey - the class-key
broker - defines the owning broker
Returns:
false if the key was set before.
See Also:
asgaard.skid.RemoteBroker.insertBean

isChanged

public boolean isChanged()
Has the Bean been changed?

isNew

public boolean isNew()
Ist das Bean neu?

isReadOnly

public boolean isReadOnly()
Ist the Bean read only?

getObject

public java.lang.Object getObject()
Returns the wrapped Object (if wrapped by a container) or the Bean (if it's no wrapper)
Returns:
the object, if any.

getFilter

public SkidBeanFilter getFilter()
Returns a Filter for this (and all parent) class.

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.
Throws:
java.lang.SecurityException - if access to the information is denied.
See Also:
java.lang.reflect.Method#getMethods

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.
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.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. The call of this methods resets the UNDO-mechanism and clear all relied information.
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.
Returns:
a set of description-strings

undo

public boolean undo(int steps)
Undo the last steps changes (0 = all, -1 no undo but ask if any undos possible). The call of the flush() methods resets the UNDO-mechanism and clear all relied information.
Parameters:
steps - cont of changes to undo
Returns:
if there are steps left which can be undone

cloneBean

public java.lang.Object cloneBean()
                           throws java.lang.CloneNotSupportedException
Clones the Object and does all the settings neccesary to be assigned as a new SkidBean. To make it persistent use the SkidBean.flush() or the RemoteBroker.put() method.
See Also:
flush(), asgaard.skid.RemoteBroker#put