From: Julio G. <ju...@us...> - 2006-05-25 15:16:01
|
Update of /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/prim In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv1659/smartfrog/src/org/smartfrog/sfcore/prim Modified Files: PrimImpl.java Log Message: modified sfAddAttribute/sfRemoveAttribute/sfReplaceAttribute to set/reset parent when the value of the attribute is a componentdescription Index: PrimImpl.java =================================================================== RCS file: /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** PrimImpl.java 2 May 2006 22:58:35 -0000 1.94 --- PrimImpl.java 25 May 2006 15:15:54 -0000 1.95 *************** *** 340,343 **** --- 340,345 ---- /** * Adds an attribute to this component under given name. + * If the attribute value is a ComponentDescription then + * this component is set as its parent * * @param name name of attribute *************** *** 351,357 **** --- 353,370 ---- public synchronized Object sfAddAttribute(Object name, Object value) throws SmartFrogRuntimeException, RemoteException { + Object valueParent = null; try { + + if (value instanceof ComponentDescription) { + //Set right parentage for ComponentDescription + valueParent = ((ComponentDescription)value).sfPrimParent(); + ((ComponentDescription)value).setPrimParent(this); + } return sfContext.sfAddAttribute(name, value); + } catch (SmartFrogContextException ex) { + if (valueParent!=null){ + ((ComponentDescription)value).setPrimParent((Prim)valueParent); + } ex.init(this); throw ex; *************** *** 360,364 **** /** ! * Removes an attribute from this component. * * @param name of attribute to be removed --- 373,379 ---- /** ! * Removes an attribute from this component. If the attribute ! * value removed is a component description, then its prim parent is ! * removed as well. * * @param name of attribute to be removed *************** *** 372,376 **** throws SmartFrogRuntimeException, RemoteException { try { ! return sfContext.sfRemoveAttribute(name); } catch (SmartFrogContextException ex) { ex.init(this); --- 387,395 ---- throws SmartFrogRuntimeException, RemoteException { try { ! Object value = sfContext.sfRemoveAttribute(name); ! if (value instanceof ComponentDescription) { ! ((ComponentDescription)value).setPrimParent(null); ! } ! return value; } catch (SmartFrogContextException ex) { ex.init(this); *************** *** 381,390 **** /** * Replace named attribute in component context. If attribute is not ! * present it is added to the context. * * @param name of attribute to replace * @param value value to add or replace * ! * @return the old value if present, null otherwise * * @throws SmartFrogRuntimeException when name or value are null --- 400,413 ---- /** * Replace named attribute in component context. If attribute is not ! * present it is added to the context. If the attribute ! * value added is a component description, then its parent is ! * set to this and/or if the one removed is a component description then ! * its parent is reset. * * @param name of attribute to replace * @param value value to add or replace * ! * @return the old value if present, null otherwise. It old value ! * was a component description, then its prim parent is reset. * * @throws SmartFrogRuntimeException when name or value are null *************** *** 393,402 **** public synchronized Object sfReplaceAttribute(Object name, Object value) throws SmartFrogRuntimeException, RemoteException { try { ! return sfContext.sfReplaceAttribute(name, value); } catch (SmartFrogContextException ex) { ex.init(this); throw ex; } } --- 416,440 ---- public synchronized Object sfReplaceAttribute(Object name, Object value) throws SmartFrogRuntimeException, RemoteException { + + Prim valueParent = null; try { ! if (value instanceof ComponentDescription) { ! //Set right parentage for ComponentDescription ! valueParent = ((ComponentDescription)value).sfPrimParent(); ! ((ComponentDescription)value).setPrimParent(this); ! } ! Object oldValue = sfContext.sfReplaceAttribute(name, value); ! if ((oldValue!=null) && (oldValue instanceof ComponentDescription)) { ! ((ComponentDescription)oldValue).setPrimParent(null); ! } ! return oldValue; } catch (SmartFrogContextException ex) { + if (valueParent!=null){ + ((ComponentDescription)value).setPrimParent(valueParent); + } ex.init(this); throw ex; } + } |