Methods Summary |
---|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener l)
if( listeners == null ) {
listeners = new ArrayList();
}
listeners.add(l);
|
public void | addPropertyChangeListener(java.lang.String p, java.beans.PropertyChangeListener l)
if( listeners == null ) {
listeners = new ArrayList();
}
listeners.add(l);
|
public void | assign(long oid)
if( objectID != -1L ) {
throw new FacadeReuseException("Facade already assigned.");
}
else {
objectID = oid;
}
|
public void | assign(long oid, Entity ent)
assign(oid);
entity = ent;
|
public void | assign(long oid, java.util.HashMap vals)
assign(oid);
|
protected boolean | contains(java.lang.String attr)
return cache.containsKey(attr);
|
public boolean | equals(java.lang.Object ob)
if( ob instanceof BaseFacade ) {
BaseFacade ref = (BaseFacade)ob;
return (ref.getObjectID() == getObjectID());
}
else {
return false;
}
|
protected void | firePropertyChange()
firePropertyChange(new PropertyChangeEvent(this, null, null, null));
|
protected void | firePropertyChange(java.beans.PropertyChangeEvent evt)
Iterator it;
if( listeners == null ) {
return;
}
it = listeners.iterator();
while( it.hasNext() ) {
PropertyChangeListener l = (PropertyChangeListener)it.next();
l.propertyChange(evt);
}
|
protected java.lang.Object | get(java.lang.String attr)
return cache.get(attr);
|
public Entity | getEntity()
if( entity == null ) {
reconnect();
}
return entity;
|
public java.lang.String | getLastUpdateID()
if( lastUpdateID == null ) {
try {
lastUpdateID = getEntity().getLastUpdateID();
}
catch( RemoteException e ) {
reconnect();
lastUpdateID = getEntity().getLastUpdateID();
}
}
return lastUpdateID;
|
public long | getLastUpdateTime()
if( lastUpdateTime == -1L ) {
try {
lastUpdateTime = getEntity().getLastUpdateTime();
}
catch( RemoteException e ) {
reconnect();
lastUpdateTime = getEntity().getLastUpdateTime();
}
}
return lastUpdateTime;
|
public long | getObjectID()
return objectID;
|
public boolean | hasListeners(java.lang.String prop)
if( listeners == null ) {
return false;
}
if( listeners.size() > 0 ) {
return true;
}
else {
return false;
}
|
public int | hashCode()
Long l = new Long(getObjectID());
return l.hashCode();
|
protected void | put(java.lang.String attr, java.lang.Object val)
cache.put(attr, val);
|
protected void | reconnect()
final BaseFacade ref = this;
Thread t;
if( home == null ) {
String url = System.getProperty(LWPProperties.RMI_URL);
ObjectServer svr;
try {
svr = (ObjectServer)Naming.lookup(url);
}
catch( MalformedURLException e ) {
throw new RemoteException(e.getMessage());
}
catch( NotBoundException e ) {
throw new RemoteException(e.getMessage());
}
try {
Identifier id = Identifier.currentIdentifier();
if( id == null ) {
id = Identifier.getServerID();
}
home = (Home)svr.lookup(id, getClass().getName());
}
catch( LookupException e ) {
throw new RemoteException(e.getMessage());
}
}
try {
Identifier id = Identifier.currentIdentifier();
entity = home.findByObjectID(id, objectID);
lastUpdateID = entity.getLastUpdateID();
lastUpdateTime = entity.getLastUpdateTime();
}
catch( PersistenceException e ) {
throw new RemoteException(e.getMessage());
}
catch( FindException e ) {
throw new RemoteException(e.getMessage());
}
catch( RemoteException e ) {
e.printStackTrace();
String url = System.getProperty(LWPProperties.RMI_URL);
ObjectServer svr;
try {
svr = (ObjectServer)Naming.lookup(url);
}
catch( MalformedURLException salt ) {
throw new RemoteException(salt.getMessage());
}
catch( NotBoundException salt ) {
throw new RemoteException(salt.getMessage());
}
try {
Identifier id = Identifier.currentIdentifier();
if( id == null ) {
id = Identifier.getServerID();
}
home = (Home)svr.lookup(id, getClass().getName());
entity = home.findByObjectID(id, objectID);
lastUpdateID = entity.getLastUpdateID();
lastUpdateTime = entity.getLastUpdateTime();
}
catch( LookupException salt ) {
throw new RemoteException(salt.getMessage());
}
catch( PersistenceException salt ) {
throw new RemoteException(salt.getMessage());
}
catch( FindException salt ) {
throw new RemoteException(salt.getMessage());
}
}
t = new Thread() {
public void run() {
while( true ) {
synchronized( ref ) {
if( entity == null ) {
return;
}
try {
if( lastUpdateTime == -1L ) {
lastUpdateTime = entity.getLastUpdateTime();
}
if( entity.isChanged(lastUpdateTime) ) {
lastUpdateTime = entity.getLastUpdateTime();
lastUpdateID = entity.getLastUpdateID();
firePropertyChange();
}
}
catch( RemoteException e ) {
// this will force a reload
entity = null;
return;
}
}
try { Thread.sleep(30000); }
catch( InterruptedException e ) { }
}
}
};
t.setPriority(Thread.MIN_PRIORITY);
t.start();
|
public void | removePropertyChangeListener(java.beans.PropertyChangeListener l)
if( listeners == null ) {
return;
}
listeners.remove(l);
|
public void | removePropertyChangeListener(java.lang.String p, java.beans.PropertyChangeListener l)
if( listeners == null ) {
return;
}
listeners.remove(l);
|
public synchronized void | reset()
cache.clear();
lastUpdateTime = -1L;
lastUpdateID = null;
|