From: <st...@us...> - 2006-10-03 15:20:42
|
Revision: 3451 http://svn.sourceforge.net/smartfrog/?rev=3451&view=rev Author: steve_l Date: 2006-10-03 08:20:30 -0700 (Tue, 03 Oct 2006) Log Message: ----------- adding child liveness to the test compound (unfinished). To make this possible (with special handling of the (failing) components), CompoundImpl was refactored to make it possible to override its child pinging policy while still forwarding up to the grandparent PrimImpl. Also, s/system.out/r/sfLog() calls/ on the new update stuff. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java 2006-10-03 15:18:51 UTC (rev 3450) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java 2006-10-03 15:20:30 UTC (rev 3451) @@ -60,7 +60,7 @@ </li></ol> * {@value} */ - String ATTR_ASSERTIONS = "assertions"; + String ATTR_TESTS = "tests"; /** * a component that is run after the tests pass/fail Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2006-10-03 15:18:51 UTC (rev 3450) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2006-10-03 15:20:30 UTC (rev 3451) @@ -25,8 +25,10 @@ import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.workflow.eventbus.EventCompoundImpl; import org.smartfrog.sfcore.utils.ComponentHelper; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import java.rmi.RemoteException; @@ -35,14 +37,17 @@ */ public class TestCompoundImpl extends EventCompoundImpl implements TestCompound { + protected ComponentDescription teardownCD; protected Prim teardown; - protected Prim assertions; + protected ComponentDescription testsCD; + protected Prim tests; protected static final String ACTION_RUNNING = "_actionRunning"; protected long undeployAfter; protected boolean expectTerminate; protected DelayedTerminator actionTerminator; + protected DelayedTerminator testsTerminator; protected Prim actionPrim; protected boolean terminating=false; protected String exitType; @@ -73,12 +78,12 @@ super.sfDeploy(); checkActionDefined(); name = sfCompleteNameSafe(); - assertions = sfResolve(ATTR_ASSERTIONS, assertions, false); - if (assertions != null) { - throw new SmartFrogException("Not yet supported " + ATTR_ASSERTIONS); + testsCD = sfResolve(ATTR_TESTS, testsCD, false); + if (testsCD != null) { + throw new SmartFrogException("Not yet supported " + ATTR_TESTS); } - teardown = sfResolve(ATTR_TEARDOWN, teardown, false); - if (teardown != null) { + teardownCD = sfResolve(ATTR_TEARDOWN, teardownCD, false); + if (teardownCD != null) { throw new SmartFrogException("Not yet supported " + ATTR_TEARDOWN); } undeployAfter = sfResolve(ATTR_UNDEPLOY_AFTER, 0,true); @@ -127,6 +132,11 @@ new ComponentHelper(this).sfSelfDetachAndOrTerminate(TerminationRecord.NORMAL, null,null,exception); } + + //now deploy the tests. + //these are expected to pass + + } /** @@ -139,6 +149,24 @@ super.sfPing(source); } + /** + * Called by {@link #sfPing(Object)} to run through the list + * of children and ping each in turn. If any child fails, + * {@link #sfLivenessFailure(Object, Object, Throwable)} is called and the + * iteration continues. + * <p/> + * Override this method to implement different child ping behaviour. + */ + protected void sfPingChildren() { + + if(actionPrim!=null) { + sfPingChildAndTerminateOnFailure(actionPrim); + } + if (tests != null) { + sfPingChildAndTerminateOnFailure(tests); + } + } + public synchronized void sfTerminateWith(TerminationRecord status) { terminating=true; super.sfTerminateWith(status); Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2006-10-03 15:18:51 UTC (rev 3450) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2006-10-03 15:20:30 UTC (rev 3451) @@ -67,38 +67,43 @@ expectTerminate extends Boolean { description "is the action component expected to terminate itself?"; } - statusType extends OptionalString { - description "string which must be found in the termination errortype attribute using a case sensitive match"; + tests extends OptionalCD { + description ##A component that is deployed after the action component is successfully deployed, + and which contains tests or assertions to deploy. + The components is only deployed if the action deployment was successful. + 1. If this component terminates successfully, then the test is deemed to be successful, and + the TestCompound terminates the tests and runs teardown. + 2. If this component does not terminate, then it is kept running (and pinged during pings) + until the action terminates or the test is undeployed. + #; } - statusText extends OptionalString { - description "string which must be found in the TerminationRecord.description attribute using a case sensitive match"; + testTimeout extends Integer { + description ## + time in milliseconds to trigger an exception if the tests do not finish; + use -1 for no limit" + NOT IMPLEMENTED + #; } - assertions extends OptionalCD { - description ##A component that is deployed after the action component is successfully deployed, - and which contains assertions to deploy. - The assertions are only deployed if the action deployment was successful. - 1. If this component terminates successfully, then the test is deemed to be successful, and - the TestCompound terminates the tests and runs teardown. - 2. If this component does not terminate, then it is kept running (and pinged during pings) - until the action terminates or the test is undeployed. - #; - } teardown extends OptionalCD { description ##a component that is run after the tests pass/fail to perform teardown or post-process. the action will always have been terminated (cleanly or not) by the time this component is deployed. + NOT IMPLEMENTED #; } teardownTimeout extends OptionalInteger { description ## time in milliseconds to complain if the undeploy of the action component or the execution of the teardown component took too long; use -1 for no limit + NOT IMPLEMENTED #; } forcePing extends Boolean { +// NOT IMPLEMENTED description "should we force a set of pings?"; } pingInterval extends OptionalInteger { +// NOT IMPLEMENTED description "time in milliseconds between forced pings"; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2006-10-03 15:18:51 UTC (rev 3450) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2006-10-03 15:20:30 UTC (rev 3451) @@ -257,7 +257,7 @@ RemoteException, SmartFrogDeploymentException { Prim comp = null; - if (parms==null)parms = new ContextImpl(); + if (parms==null) parms = new ContextImpl(); try { // This is needed so that the root component is properly named // when registering with the ProcessCompound @@ -619,9 +619,8 @@ //Deprecated: new TerminateCall((Prim)(sfChildren.elementAt(i)), status); (new TerminatorThread((Prim)(sfChildren.elementAt(i)),status).quietly()).start(); } catch (Exception ex) { - //@TODO: Log + // ignore ignoreThrowable("ignoring during termination", ex); - // ignore } } } @@ -672,39 +671,63 @@ * @exception SmartFrogLivenessException liveness failed */ public void sfPing(Object source) throws SmartFrogLivenessException, - RemoteException { - // check the timing of the parent pings + RemoteException { + // check the timing of the parent pings super.sfPing(source); - // return if children not to be checked + // return if children not to be checked if ((source == null) || (sfLivenessDelay == 0)) { return; } if (sfLivenessSender == null) { - // don't have my own liveness sender, so check if it is my parent - if (!source.equals(sfParent)) { - return; - } - } else { - // have own checker - its my responsibility from here on, so return if not me - if (!source.equals(sfLivenessSender)) { - return; - } - } + // don't have my own liveness sender, so check if it is my parent + if (!source.equals(sfParent)) { + return; + } + } else { + // have own checker - its my responsibility from here on, so return if not me + if (!source.equals(sfLivenessSender)) { + return; + } + } - - // the following, checking children, should only happen if source is own livenes sender or + // the following, checking children, should only happen if the source is + // its own livenes sender or // it is the parent checking and I don't have my own check + sfPingChildren(); + } + + /** + * Called by {@link #sfPing(Object)} to run through the list + * of children and ping each in turn. If any child fails, + * {@link #sfLivenessFailure(Object, Object, Throwable)} is called and the + * iteration continues. + * + * Override this method to implement different child ping behaviour. + */ + protected void sfPingChildren() { for (Enumeration e = sfChildren(); e.hasMoreElements();) { - Object child = e.nextElement(); + Liveness child = (Liveness) e.nextElement(); + sfPingChildAndTerminateOnFailure(child); + } + } - try { - sfPingChild((Liveness) child); - } catch (Exception ex) { - sfLivenessFailure(this, child, ex); - } + /** + * Helper method for children to use if they override + * {@link #sfPingChildren()} + * Pings a child, calls {@link #sfLivenessFailure(Object, Object, Throwable)} if + * an exception gets thrown + * @param child child component + */ + protected final void sfPingChildAndTerminateOnFailure(Liveness child) { + try { + sfPingChild(child); + } catch (SmartFrogLivenessException ex) { + sfLivenessFailure(this, child, ex); + } catch (RemoteException ex) { + sfLivenessFailure(this, child, ex); } } @@ -804,9 +827,9 @@ } } - Vector childrenToTerminate; - Vector childrenToUpdate; - Vector childrenToCreate; + private Vector childrenToTerminate; + private Vector childrenToUpdate; + private Vector childrenToCreate; /** * Validate whether the component (and its children) can be updated @@ -991,22 +1014,24 @@ boolean ready; try { - System.out.println("preparing"); - this.sfPrepareUpdate(); - System.out.println("preparing done"); + sfLog().debug("preparing"); + sfPrepareUpdate(); + sfLog().debug("preparing done"); - System.out.println("update with"); - ready = this.sfUpdateWith(desc.sfContext()); - if (!ready) throw new SmartFrogUpdateException("top level component must accept update", null); - System.out.println("update with done"); + sfLog().debug("update with"); + ready = sfUpdateWith(desc.sfContext()); + if (!ready) { + throw new SmartFrogUpdateException("top level component must accept update", null); + } + sfLog().debug("update with done"); } catch (Exception e) { - e.printStackTrace(); + sfLog().error(e); try { - System.out.println("abandoning"); - this.sfAbandonUpdate(); - System.out.println("abandoning done"); + sfLog().debug("abandoning"); + sfAbandonUpdate(); + sfLog().debug("abandoning done"); } catch (RemoteException e1) { - // ignore? + ignoreThrowable("when abandoning", e1); } if (e instanceof SmartFrogUpdateException) @@ -1017,20 +1042,19 @@ if (ready) { try { - System.out.println("update"); - this.sfUpdate(); - System.out.println("update done\nupdate deploy"); - this.sfUpdateDeploy(); - System.out.println("update deploy done\nupdate start"); - this.sfUpdateStart(); - System.out.println("update start done"); + sfLog().debug("update"); + sfUpdate(); + sfLog().debug("update done\nupdate deploy"); + sfUpdateDeploy(); + sfLog().debug("update deploy done\nupdate start"); + sfUpdateStart(); + sfLog().debug("update start done"); } catch (Exception e) { - System.out.println("failed"); - e.printStackTrace(); + sfLog().error(e); try { - this.sfTerminate(TerminationRecord.abnormal("fatal error in update - terminated comopnents", sfCompleteNameSafe(), e)); + sfTerminate(TerminationRecord.abnormal("fatal error in update - terminated comopnents", sfCompleteNameSafe(), e)); } catch (Exception e1) { - // ignore? + ignoreThrowable("when terminating",e1); } throw new SmartFrogUpdateException("fatal error in update, terminating application", e); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2006-10-16 16:53:08
|
Revision: 3480 http://svn.sourceforge.net/smartfrog/?rev=3480&view=rev Author: steve_l Date: 2006-10-16 09:53:00 -0700 (Mon, 16 Oct 2006) Log Message: ----------- reentrancy hooks, move load class method in Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/os/java/LoadClassImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/java/LoadClassImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/java/LoadClassImpl.java 2006-10-16 16:51:59 UTC (rev 3479) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/java/LoadClassImpl.java 2006-10-16 16:53:00 UTC (rev 3480) @@ -198,13 +198,7 @@ */ public static Class loadClass(Prim owner, String classname) throws RemoteException, SmartFrogException { Class loadedClass; - try { - ComponentHelper helper = new ComponentHelper(owner); - String codebase = helper.getCodebase(); - loadedClass = SFClassLoader.forName(classname, codebase, true); - } catch (ClassNotFoundException e) { - throw SmartFrogException.forward(e); - } - return loadedClass; + ComponentHelper helper = new ComponentHelper(owner); + return helper.loadClass(classname); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2006-10-16 16:51:59 UTC (rev 3479) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2006-10-16 16:53:00 UTC (rev 3480) @@ -34,7 +34,6 @@ import java.rmi.RemoteException; import java.io.InputStream; import java.io.IOException; -import java.io.InputStreamReader; import java.nio.charset.Charset; /** @@ -144,8 +143,8 @@ attribute, defval, false); - } catch (RemoteException ex) { - } catch (SmartFrogResolutionException ex) { + } catch (RemoteException ignored) { + } catch (SmartFrogResolutionException ignored) { } return false; } @@ -178,7 +177,8 @@ /** * Method that can be invoked in any PrimImpl to trigger the detach and/or termination of a component * according to the values of the boolean attributes 'sfShouldDetach', 'sfShouldTerminate' - * and 'sfShouldTerminateQuietly' + * and 'sfShouldTerminateQuietly'. + * * @param record the pre-constructed termination record to use if termination is started * @return true if termination has been scheduled. */ @@ -207,7 +207,8 @@ /** * - * @param terminationType - termination type, system recognized types are "normal", "abnormal" and "externalReferenceDead". + * @param terminationType - termination type, system recognized types + * are "normal", "abnormal" and "externalReferenceDead". * If this is null, then normal/abnormal is chosen based on whether thrown is null or not * @param terminationMessage - description of termination. Can be null * @param refId Reference - id of terminating component. If null, triggers a call to sfCompleteNameSafe. @@ -259,7 +260,6 @@ * mark this task for termination by spawning a separate thread to do it. * as {@link Prim#sfTerminate} and {@link Prim#sfStart()} are synchronized, * the thread blocks until sfStart has finished. - * * @param record record to terminate with * @param dontTerminate set to true to not actually terminate * @param detach detach first? @@ -268,6 +268,17 @@ public void targetForTermination(TerminationRecord record, boolean dontTerminate, boolean detach, boolean quietly) { + + try { + if(isComponentTerminating()) { + return; + } + } catch (RemoteException ignored) { + //that didn't work. We had either a transient or permanent + //fault talking to the far end. what to do? Right now we + //take the cautious option of running the termination thread + //anyway, just in case the far end is reachable again in a moment. + } TerminatorThread terminator = new TerminatorThread(owner, record); if (detach) { terminator.detach(); @@ -298,6 +309,8 @@ * as {@link Prim#sfTerminate} and {@link Prim#sfStart()} are synchronized, * the thread blocks until sfStart has finished. * Note that we detach before terminating; this stops our timely end propagating. + * <i>Important.</i> This operation is implicitly harmless to use during termination. It will + * not interfere with a component that is already closing down, nor with its notification options. */ public void targetForTermination() { @@ -307,6 +320,20 @@ } /** + * Checks for the component terminating or being terminated. There is + * a possible race condition, because the component (in a separate thread) + * may enter the terminating phase during the test, and we wont pick it up. + * As termination is one way, we do know that if this method returns true + * then termination is underway and irreversible. + * @return true if the owner is in termination phase or has terminated. + * + * @throws RemoteException for networking trouble + */ + public boolean isComponentTerminating() throws RemoteException { + return owner.sfIsTerminating() || owner.sfIsTerminated(); + } + + /** * load a resource using the classpath of the component * at question. * @@ -321,7 +348,7 @@ InputStream in = SFClassLoader.getResourceAsStream(resourcename, targetCodeBase, true); if (in == null) { - throw new SmartFrogException("Not found: " + resourcename); + throw new SmartFrogException("Not found: " + resourcename+" in "+targetCodeBase); } return in; } @@ -355,7 +382,27 @@ return (String) owner.sfResolve(SmartFrogCoreKeys.SF_CODE_BASE); } + /** + * Load a class in the classloader, using the SmartFrog classloader. + * {@link SFClassLoader#forName(String, String, boolean)} + * @param classname + * @return + * @throws SmartFrogResolutionException if the class could not be found + * @throws RemoteException for network problems + */ + public Class loadClass(String classname) throws SmartFrogResolutionException, RemoteException { + String targetCodeBase = getCodebase(); + + try { + return SFClassLoader.forName(classname, targetCodeBase, true); + } catch (ClassNotFoundException ignored) { + throw new SmartFrogResolutionException("Not found: " + classname + " in " + targetCodeBase); + + } + } + + /** * find an ancestor of a given type * @param node node to look for * @param interfaceName full name of interface to look for This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2006-10-17 20:22:59
|
Revision: 3492 http://svn.sourceforge.net/smartfrog/?rev=3492&view=rev Author: steve_l Date: 2006-10-17 13:22:38 -0700 (Tue, 17 Oct 2006) Log Message: ----------- mostly some replacements of Throwable.printStackTrace() with some logging. One exception, ApplyReference, which adds a printStackTrace in an otherwise empty catch statement, and lays out better for step-by-step debugging. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/ApplyReference.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventPrimImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -126,7 +126,7 @@ } } } catch (Exception e) { - e.printStackTrace(); + sfLog().error(e); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -1010,7 +1010,7 @@ sfLog().debug("New ProcessCompound "+name+" created: "+ newPc.sfCompleteName()); } catch (Throwable thr) { sfLog().debug("New ProcessCompound "+name+" created."); - thr.printStackTrace(); + sfLog().error(thr); } } return newPc; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/ApplyReference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/ApplyReference.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/ApplyReference.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -167,12 +167,15 @@ String functionClass = null; Object result; - if (getData()) return this; + if (getData()) { + return this; + } - if (rr instanceof ComponentDescription) + if (rr instanceof ComponentDescription) { comp.setParent((ComponentDescription) rr); - else if (rr instanceof Prim) + } else if (rr instanceof Prim) { comp.setPrimParent((Prim) rr); + } try { functionClass = (String) comp.sfResolveHere("sfFunctionClass"); @@ -188,7 +191,8 @@ try { forFunction.sfAddAttribute(name, value); } catch (SmartFrogContextException e) { - //shouldn't happen + //shouldn't happen. but when it does... + e.printStackTrace(); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -61,7 +61,7 @@ try { s.event(messages.get(i)); } catch (Exception ex) { - ex.printStackTrace(); + sfLog().error(ex); } } synchronized (registrationMessages) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -248,10 +248,16 @@ forward = onWorkflowTerminating(status, comp); } else { //check to see what the subclass wants - if (sfContainsChild(comp)) { - forward = onChildTerminated(status, comp); - } else { - forward = onNonChildTerminated(status, comp); + try { + if (sfContainsChild(comp)) { + forward = onChildTerminated(status, comp); + } else { + forward = onNonChildTerminated(status, comp); + } + } catch (Exception e) { + sfLog().error("Exception ",e); + forward=true; + } } if (forward) { @@ -290,7 +296,8 @@ * @param comp child component that is terminating * @return true if the termination event is to be forwarded up the chain. */ - protected boolean onChildTerminated(TerminationRecord status, Prim comp) { + protected boolean onChildTerminated(TerminationRecord status, Prim comp) + throws SmartFrogRuntimeException, RemoteException { return true; } @@ -304,7 +311,8 @@ * @param comp non-child component that is terminating * @return true if the termination event is to be forwarded up the chain. */ - protected boolean onNonChildTerminated(TerminationRecord status, Prim comp) { + protected boolean onNonChildTerminated(TerminationRecord status, Prim comp) + throws SmartFrogRuntimeException, RemoteException { return true; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventPrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventPrimImpl.java 2006-10-17 20:18:11 UTC (rev 3491) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventPrimImpl.java 2006-10-17 20:22:38 UTC (rev 3492) @@ -200,7 +200,7 @@ try { s.deregister(this); } catch (RemoteException ex) { - ex.printStackTrace(); + sfLog().error(ex); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-10-24 14:38:56
|
Revision: 3517 http://svn.sourceforge.net/smartfrog/?rev=3517&view=rev Author: julgui Date: 2006-10-24 07:38:41 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Improved use of SimpleDateFormat() Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/gui/progresspanel/ProgressPanel.java trunk/core/smartfrog/src/org/smartfrog/services/comm/mcast/SFMCastClientImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/gui/progresspanel/ProgressPanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/gui/progresspanel/ProgressPanel.java 2006-10-24 14:29:06 UTC (rev 3516) +++ trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/gui/progresspanel/ProgressPanel.java 2006-10-24 14:38:41 UTC (rev 3517) @@ -44,6 +44,12 @@ */ public class ProgressPanel extends JPanel { + + /* + Date format + */ + static SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS yyyy/MM/dd"); + static int i = 0; ImageIcon redBall; ImageIcon grnBall; @@ -98,9 +104,7 @@ if (status == 0) { label.setIcon((Icon) this.redBall); } else if (status == 1) { - message = "[" + - (new SimpleDateFormat("HH:mm:ss.SSS dd/MM/yy").format(new Date( - System.currentTimeMillis()))) + "] " + message; + message = "[" +dateFormat.format(new Date(System.currentTimeMillis())) + "] " + message; label.setToolTipText(message); label.setIcon((Icon) this.yelBall); } else if (status == 2) { Modified: trunk/core/smartfrog/src/org/smartfrog/services/comm/mcast/SFMCastClientImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/comm/mcast/SFMCastClientImpl.java 2006-10-24 14:29:06 UTC (rev 3516) +++ trunk/core/smartfrog/src/org/smartfrog/services/comm/mcast/SFMCastClientImpl.java 2006-10-24 14:38:41 UTC (rev 3517) @@ -56,6 +56,11 @@ public class SFMCastClientImpl extends PrimImpl implements Prim, SFMCastClient, Runnable { + /* + Date format + */ + static SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS z yyyy/MM/dd"); + /** Muilticast socket. */ MulticastSocket sock; @@ -249,8 +254,7 @@ msg.append ("."); msg.append (method); msg.append ( " [" ); - msg.append ((new SimpleDateFormat("HH:mm:ss.SSS z, yyyy/MM/dd"). - format(new Date()))); + msg.append (dateFormat.format(new Date())); msg.append ("]> "); msg.append (message); System.err.println(msg.toString()); @@ -268,8 +272,7 @@ msg.append ("."); msg.append (method); msg.append ( " [" ); - msg.append ((new SimpleDateFormat("HH:mm:ss.SSS z, yyyy/MM/dd"). - format(new Date()))); + msg.append (dateFormat.format(new Date())); msg.append ("]> "); msg.append (message); System.out.println(msg.toString()); @@ -287,8 +290,7 @@ msg.append ("."); msg.append ( "Exception"); msg.append ( " [" ); - msg.append ((new SimpleDateFormat("HH:mm:ss.SSS z, yyyy/MM/dd"). - format(new Date()))); + msg.append (dateFormat.format(new Date())); msg.append ("]> "); //msg.append (exception.getMessage()); msg.append("\n StackTrace: "); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-10-26 16:02:27
|
Revision: 3528 http://svn.sourceforge.net/smartfrog/?rev=3528&view=rev Author: julgui Date: 2006-10-26 09:02:11 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Changes in Log for management console. Fixing bug introduced two days ago. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogFactory.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -753,11 +753,7 @@ private void initLog (){ try { - if (entry instanceof Prim) { - this.sfLog=LogFactory.getLog((Prim)entry); - } else { - this.sfLog=LogFactory.getLog((String)entry); - } + this.sfLog=LogFactory.getLog("sfManagementConsole"); } catch (Exception e) { sfLog.error(e); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -36,7 +36,7 @@ public class DeployEntryCellRenderer extends DefaultTreeCellRenderer { /** Log for this class, created using class name*/ - static LogSF sfLogStatic = LogFactory.getLog(DefaultTreeCellRenderer.class); + static LogSF sfLogStatic = LogFactory.getLog("sfManagementConsole"); // icons for the Tree ImageIcon icon = null; Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -36,7 +36,7 @@ */ public class DeployTreeModelSF implements TreeModel { /** Log for this class, created using class name*/ - LogSF sfLog = LogFactory.getLog(DeployTreeModelSF.class); + LogSF sfLog = LogFactory.getLog("sfManagementConsole"); DeployEntry entry = null; Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -45,7 +45,7 @@ public class DeployTreePanel extends JPanel implements TreeSelectionListener { /** Log for this class, created using class name*/ - LogSF sfLog = LogFactory.getLog(this.getClass()); + LogSF sfLog = LogFactory.getLog("sfManagementConsole"); BorderLayout borderLayout1 = new BorderLayout(); JSplitPane jSplitPane1 = new JSplitPane(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -39,7 +39,7 @@ */ public class NewAttributeDialog extends JDialog { /** Log for this class, created using class name*/ - LogSF sfLog = LogFactory.getLog(this.getClass()); + LogSF sfLog = LogFactory.getLog("sfManagementConsole"); /** Panel. */ private JPanel panel = new JPanel(); /** Save button. */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -315,7 +315,7 @@ } } /** Log for this class, created using class name*/ - LogSF sfLog = LogFactory.getLog(this.getClass()); + LogSF sfLog = LogFactory.getLog("sfManagementConsole"); /** * Log for this class Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -471,7 +471,7 @@ pane.show(true); } /** Log for this class, created using class name*/ - LogSF sfLog = LogFactory.getLog(this.getClass()); + LogSF sfLog = LogFactory.getLog("sfManagementConsole"); /** * Log for this class Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -77,7 +77,7 @@ //Init system org.smartfrog.SFSystem.initSystem(); //Logger.log("Starting management window..."); - LogSF sflog = LogFactory.getLog("SFManagamentConsole"); + LogSF sflog = LogFactory.getLog("sfManagementConsole"); sflog.out("Starting management window..."); String nameDisplay = "sfManagementConsole"; @@ -103,7 +103,7 @@ } catch (java.rmi.ConnectException cex) { exitWith("Error: " + cex.getMessage(), ExitCodes.EXIT_ERROR_CODE_GENERAL); } catch (Exception e) { - LogFactory.getLog(SFDeployDisplay.class).error("Error in SFDeployDisplay.main():" + e,e); + LogFactory.getLog("sfManagementConsole").error("Error in SFDeployDisplay.main():" + e,e); exitWith("Error in SFDeployDisplay.main():" + e, ExitCodes.EXIT_ERROR_CODE_GENERAL); } @@ -140,12 +140,12 @@ String infoConnection = ("sfManagementConsole connecting to " + hostname + ":" + port); //Logger.log(infoConnection); - LogFactory.getLog("SFManagamentConsole").out(infoConnection); + LogFactory.getLog("sfManagementConsole").out(infoConnection); nameDisplay = nameDisplay + " [" + "sfManagementConsole connected to " + hostname + ":" + port + "]"; if (showRootProcess) { - LogFactory.getLog("SFManagamentConsole").warn(" showing rootProcess"); + LogFactory.getLog("sfManagementConsole").warn(" showing rootProcess"); //Logger.log(" showing rootProcess"); } else { //System.out.println(""); @@ -390,8 +390,8 @@ ((DeployTreePanel) panelTree).refresh(); } catch (Throwable ex) { // Logger.logQuietly("Failure refresh() SFDeployDisplay!",ex); - if (LogFactory.getLog("SFManagamentConsole").isIgnoreEnabled()){ - LogFactory.getLog("SFManagamentConsole").ignore("Failure refresh() SFDeployDisplay!",ex); + if (LogFactory.getLog("sfManagementConsole").isIgnoreEnabled()){ + LogFactory.getLog("sfManagementConsole").ignore("Failure refresh() SFDeployDisplay!",ex); } } } @@ -404,8 +404,8 @@ */ public void actionPerformed(ActionEvent e) { //Logger.log("ActionEvent SFDEployDisplay: "+ e); - if (LogFactory.getLog("SFManagamentConsole").isTraceEnabled()){ - LogFactory.getLog("SFManagamentConsole").trace("ActionEvent SFDEployDisplay: "+ e); + if (LogFactory.getLog("sfManagementConsole").isTraceEnabled()){ + LogFactory.getLog("sfManagementConsole").trace("ActionEvent SFDEployDisplay: "+ e); } if ((e.getActionCommand()).equals("refreshButton")) { refresh(e); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogFactory.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogFactory.java 2006-10-26 16:01:45 UTC (rev 3527) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogFactory.java 2006-10-26 16:02:11 UTC (rev 3528) @@ -7,6 +7,7 @@ import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import java.rmi.RemoteException; import java.util.Hashtable; @@ -54,6 +55,58 @@ } /** + * Get a log for an object. + * Prim and ComponentDescription will use sfCompletename + * An unkwon object uses its class name. + * @param obj (Prim, ComponentDescription, object.) + * @return a new log. + * @throws SmartFrogLogException when something went wrong with getting a log + */ + public static synchronized LogSF getLog(Object obj) throws SmartFrogLogException + { + LogSF log=null; + try { + if (obj instanceof Prim) { + getLog(obj); + } else if (obj instanceof ComponentDescription){ + getLog((ComponentDescription)obj); + } else { + getLog(obj.getClass().toString()); + } + } catch (Exception e){ + throw (SmartFrogLogException)SmartFrogLogException.forward(e); + } + return log; + } + + /** + * get a log for a component + * @param cd component description + * @return a new log. + * @throws SmartFrogLogException when something went wrong with getting a log + */ + public static synchronized LogSF getLog(ComponentDescription cd) throws SmartFrogLogException + { + LogSF log=null; + try { + final Reference completeName = cd.sfCompleteName(); + //look for a log + log = (LogSF)loggers.get(completeName); + //if found, return it + if (log!=null) { + return log; + } + //else create a new one + log = new LogImpl (completeName.toString()); + //and remember it + loggers.put(cd, log); + } catch (Exception e){ + throw (SmartFrogLogException)SmartFrogLogException.forward(e); + } + return log; + } + + /** * get a named log. * @param name log name * @return a log from cache or new. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ali...@us...> - 2006-10-26 15:50:18
|
Revision: 3526 http://svn.sourceforge.net/smartfrog/?rev=3526&view=rev Author: alistair_c Date: 2006-10-26 08:50:09 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Enable DATA nodes to be removed from management console tree view. Fix management console: attribute modify/add popup not appearing when no attributes exist. Fix management console: DATA added via add/modify dialog are SFComponentDescription, should be ComponentDescription. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2006-10-26 13:19:00 UTC (rev 3525) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2006-10-26 15:50:09 UTC (rev 3526) @@ -161,6 +161,15 @@ this.add(statusPanel, BorderLayout.SOUTH); statusPanel.add(completeName, BorderLayout.SOUTH); this.add(jSplitPane1, BorderLayout.CENTER); + tableScrollPane.getViewport().addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(MouseEvent e) { + table_mouseClicked(e); + } + public void mousePressed(MouseEvent e) { + table_mouseClicked(e); + } + }); + table.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(MouseEvent e) { table_mouseClicked(e); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-10-26 13:19:00 UTC (rev 3525) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-10-26 15:50:09 UTC (rev 3526) @@ -48,6 +48,7 @@ import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.services.display.WindowUtilities; +import org.smartfrog.sfcore.common.*; /** @@ -69,7 +70,7 @@ JMenuItem menuItemAddAttribute = new JMenuItem(); // JMenuItem menuItemModifyAttribute = new JMenuItem(); - // JMenuItem menuItemRemoveAttribute = new JMenuItem(); + JMenuItem menuItemRemoveAttribute = new JMenuItem(); /** Item for Tree popup menu - normal terminate. */ JMenuItem menuItemTerminateNormal = new JMenuItem(); /** Item for Tree popup menu - abnormal terminate . */ @@ -101,7 +102,7 @@ // Tree: options menuItemAddAttribute.setText("Add Attribute"); - // menuItemRemoveAttribute.setText("Remove Attribute"); + menuItemRemoveAttribute.setText("Remove Data"); // menuItemModifyAttribute.setText("Modify Attribute"); menuItemDetach.setText("Detach Component"); menuItemTerminateNormal.setText("Terminate Component - NORMAL"); @@ -113,7 +114,7 @@ // Tree: options // popupTree.add(menuItemAddAttribute); - // popupTree.add(menuItemRemoveAttribute); + popupTree.add(menuItemRemoveAttribute); // popupTree.add(menuItemModifyAttribute); popupTree.add(menuItemTerminateNormal); popupTree.add(menuItemTerminateAbnormal); @@ -128,7 +129,7 @@ // Add action listeners for tree popup menuItemAddAttribute.addActionListener(this); - // menuItemRemoveAttribute.addActionListener(this); + menuItemRemoveAttribute.addActionListener(this); // menuItemModifyAttribute.addActionListener(this); menuItemTerminateNormal.addActionListener(this); menuItemTerminateAbnormal.addActionListener(this); @@ -163,6 +164,7 @@ tempX = x; tempY = y; if ( getNode() instanceof Prim){ + menuItemRemoveAttribute.setVisible(false); menuItemDetach.setVisible(true); menuItemTerminateNormal.setVisible(true); menuItemTerminateAbnormal.setVisible(true); @@ -171,6 +173,7 @@ menuItemParentageChanged.setVisible(true); menuItemIntrospector.setVisible(true); }else if (getNode()instanceof ComponentDescription){ + menuItemRemoveAttribute.setVisible(true); menuItemDetach.setVisible(false); menuItemTerminateNormal.setVisible(false); menuItemTerminateAbnormal.setVisible(false); @@ -201,7 +204,10 @@ //System.out.println("Tree PopUp(source): "+e.getSource()+", Path: //"+path); // Launch it - if (source == menuItemAddAttribute) { + if (source == menuItemRemoveAttribute) { + remove(); + } else + if (source == menuItemAddAttribute) { addAttrib(); } else if (source == menuItemTerminateNormal) { terminate(node, TerminationRecord.NORMAL , "Console Management Action"); @@ -352,6 +358,27 @@ if (sfLog().isWarnEnabled()) sfLog().warn("ADD ATTRIBUTE! @Todo Complete!!!!!!!!!!1"); } + void remove() { + Object obj = getNode(); + System.out.println("remove() "+obj); + if (obj instanceof ComponentDescription) { + ComponentDescription cd = (ComponentDescription)obj; + ComponentDescription CDparent = cd.sfParent(); + Prim primParent = cd.sfPrimParent(); + try { + if (CDparent != null) { + CDparent.sfRemoveAttribute(CDparent.sfAttributeKeyFor(cd)); + } else if (primParent != null) { + primParent.sfRemoveAttribute(primParent.sfAttributeKeyFor(cd)); + } + parent.refresh(); + } + catch (Exception ex) { + if (sfLog().isErrorEnabled()) sfLog().error ("Problem when trying to remove '"+cd); + WindowUtilities.showError(this,"Problem when trying to remove '"+cd+"'. \n"+ex.toString()); + } + } + } /** * Terminates the deploy management * Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2006-10-26 13:19:00 UTC (rev 3525) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2006-10-26 15:50:09 UTC (rev 3526) @@ -30,6 +30,7 @@ import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.security.SFClassLoader; import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import org.smartfrog.sfcore.languages.sf.sfcomponentdescription.*; /** @@ -287,7 +288,10 @@ Object o = parser.sfParseAnyValue(is); if (o instanceof ReferencePhases) { o = ((ReferencePhases)o).sfAsReference(); - } + } else if (o instanceof SFComponentDescription) { + o = ((SFComponentDescription)o).sfAsComponentDescription(); + } + return o; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-10-26 16:50:56
|
Revision: 3531 http://svn.sourceforge.net/smartfrog/?rev=3531&view=rev Author: julgui Date: 2006-10-26 09:50:33 -0700 (Thu, 26 Oct 2006) Log Message: ----------- javadoc fixes. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/LocalFilestoreImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ReplaceVar.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/SFReplaceFileVar.java trunk/core/smartfrog/src/org/smartfrog/services/os/java/JavaPackage.java trunk/core/smartfrog/src/org/smartfrog/services/os/java/RemoteCachePolicy.java trunk/core/smartfrog/src/org/smartfrog/services/os/java/RunJavaUtils.java trunk/core/smartfrog/src/org/smartfrog/services/shellscript/SFScriptExecutionImpl.java trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptLockImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Date.java trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/SFProcess.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/LocalFilestoreImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/LocalFilestoreImpl.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/LocalFilestoreImpl.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -169,7 +169,7 @@ * look up a file from a URI * * @param uri - * @return + * @return FileEntry * @throws SmartFrogException error while lookup * @throws RemoteException In case of network/rmi error */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ReplaceVar.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ReplaceVar.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ReplaceVar.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -61,6 +61,7 @@ * Passes the filename to the object on creation * * @param filename the name of the file to use + * @param newfilename the name of the new file */ public ReplaceVar (String filename, String newfilename) { this.filename = filename; @@ -71,6 +72,7 @@ * Passes the filename to the object on creation * * @param filename the name of the file to use + * @param newfilename the name of the new file * @param cached whether the file is cached in memory or not */ @@ -258,11 +260,6 @@ //---------------------------------------------------------------------------- /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. * * @param data the hashmap @@ -284,11 +281,6 @@ //---------------------------------------------------------------------------- /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. * * @param data hashmap to write @@ -306,18 +298,11 @@ //---------------------------------------------------------------------------- - /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. - * - * @param section the section in the file - * @param key the name of the key to change - * @param value the String value to change the key to - */ + /** + * + * @param data + */ public void setSetting(Vector data) { if (data==null) return; //If the file is cached in memory @@ -335,17 +320,9 @@ } //---------------------------------------------------------------------------- - /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. + /** * - * @param section the section in the file - * @param key the name of the key to change - * @param value the String value to change the key to - + * @param data */ public void setSettingCached(Vector data) { if (data==null) return; @@ -370,18 +347,10 @@ //---------------------------------------------------------------------------- - /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. - * - * @param section the section in the file - * @param key the name of the key to change - * @param value the String value to change the key to - - */ + /** + * + * @param data + */ public void append(Vector data) { if (data==null) return; //If the file is cached in memory @@ -398,19 +367,10 @@ } } - //---------------------------------------------------------------------------- - /** - * Sets a value for a specified key. This temporarily loads the entire - * file into memory if it is not already cached. If - * the file is cached, the change is only in memory until the - * <code>flush()</code> method is called. If the file is not cached, - * then writes happen immediately. - * - * @param section the section in the file - * @param key the name of the key to change - * @param value the String value to change the key to - - */ + /** + * + * @param data + */ public void appendCached(Vector data) { if (data==null) return; String key = null; Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/SFReplaceFileVar.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/SFReplaceFileVar.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/SFReplaceFileVar.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -34,10 +34,8 @@ import java.rmi.RemoteException; /** - * Description of the Class + * Component to replace text attributes in a text file * - *@author julgui - *@created 19 October 2001 */ public class SFReplaceFileVar extends PrimImpl implements Prim { Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/java/JavaPackage.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/java/JavaPackage.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/java/JavaPackage.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -51,7 +51,7 @@ /** * get the vector of uris - * @return + * @return vector */ public Vector getUriClasspathList() throws RemoteException; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/java/RemoteCachePolicy.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/java/RemoteCachePolicy.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/java/RemoteCachePolicy.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -34,7 +34,7 @@ * create a path to the remote system, all but the base URL, * using the artifact as the * @param artifact - * @return + * @return String path * @throws RemoteException */ public String createRemotePath(SerializedArtifact artifact) throws RemoteException,SmartFrogException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/java/RunJavaUtils.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/java/RunJavaUtils.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/java/RunJavaUtils.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -102,7 +102,7 @@ * eliminate all duplicate entries from a vector. * uses a hash table, O(n*(O(hashtable add)+O(hashtable lookup)) * @param source - * @return + * @return Vector */ public static Vector mergeDuplicates(Collection source) { HashMap map=new HashMap(source.size()); @@ -124,7 +124,7 @@ /** * turn a vector of strings into a space separated list * @param source - * @return + * @return String */ public static String makeSpaceSeparatedString(Vector source) { //the classpath; space separated values Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/SFScriptExecutionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/SFScriptExecutionImpl.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/SFScriptExecutionImpl.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -131,7 +131,7 @@ * @param command String * @param lock ScriptLock * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, ScriptLock lock) throws SmartFrogException { @@ -148,7 +148,7 @@ * @param lock ScriptLock * @param verbose determines if results output will be shown using out/err streams. * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, ScriptLock lock, boolean verbose) throws SmartFrogException { @@ -165,7 +165,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, long timeout, boolean verbose) throws SmartFrogException{ @@ -182,7 +182,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, long timeout) throws SmartFrogException{ @@ -198,7 +198,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, long timeout) throws SmartFrogException { @@ -215,7 +215,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, long timeout, boolean verbose) throws SmartFrogException { @@ -231,7 +231,7 @@ * @param commands List * @param lock ScriptLock * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, ScriptLock lock) throws SmartFrogException { @@ -248,7 +248,7 @@ * @param lock ScriptLock * @param verbose determines if results output will be shown using out/err streams. * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, ScriptLock lock, boolean verbose) throws SmartFrogException { @@ -263,7 +263,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptLock - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public synchronized ScriptLock lockShell(long timeout) throws SmartFrogException { @@ -277,7 +277,7 @@ * @param lock the lock object receieved from the lockShell * @throws SmartFrogException if the lock object is not valid, i.e. if it is * not currently holding the l0ck - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public synchronized void releaseShell(ScriptLock lock) throws SmartFrogException { Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -298,7 +298,7 @@ * @param command String * @param lock ScriptLock * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, ScriptLock lock) throws SmartFrogException { @@ -313,7 +313,7 @@ * @param lock ScriptLock * @param verbose script output * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, ScriptLock lock, boolean verbose) throws SmartFrogException { @@ -336,7 +336,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, long timeout) throws SmartFrogException { @@ -353,7 +353,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, long timeout, boolean verbose) throws SmartFrogException { @@ -373,7 +373,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, long timeout, boolean verbose) throws SmartFrogException { @@ -391,7 +391,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(String command, long timeout) throws SmartFrogException { @@ -407,7 +407,7 @@ * @param commands List * @param lock ScriptLock * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, ScriptLock lock) throws SmartFrogException { @@ -425,7 +425,7 @@ * @param lock ScriptLock * @param verbose script output * @return ScriptResults - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public ScriptResults execute(List commands, ScriptLock lock, boolean verbose) throws SmartFrogException { @@ -459,7 +459,7 @@ * @throws SmartFrogException if the lock is not obtained in the requisite * time * @return ScriptLock - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public synchronized ScriptLock lockShell(long timeout) throws @@ -510,7 +510,7 @@ * @param lock the lock object receieved from the lockShell * @throws SmartFrogException if the lock object is not valid, i.e. if it is * not currently holding the l0ck - * @todo Implement this org.smartfrog.services.shellscript.ScriptExecution + // TODO: Implement this org.smartfrog.services.shellscript.ScriptExecution * method */ public synchronized void releaseShell(ScriptLock lock) throws SmartFrogException { Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptLockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptLockImpl.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptLockImpl.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -32,7 +32,7 @@ /** * * @return ScriptExecution - * @todo Implement this org.smartfrog.services.shellscript.ScriptLock method + // TODO: Implement this org.smartfrog.services.shellscript.ScriptLock method */ public ScriptExecution getScriptExecution() { return sexec; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -532,7 +532,7 @@ * @see Action * @throws SmartFrogInitException failure in some part of the process * - * @TODO fix this text for JavaDocs + // TODO fix this text for JavaDocs */ public ConfigurationDescriptor (String deploymentURL) throws SmartFrogInitException { try { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -552,7 +552,7 @@ /** * Report simple remote network diagnostics by default bound to {@link #SMARTFROG_URL} * @param out the stream to print the report to. - * @parm url URI for a host to reach + * @param url URI for a host to reach * @return failed. It reports if the test failed or not. */ public static boolean doReportRemoteNetwork(StringBuffer out, String uriString) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -71,7 +71,7 @@ public static boolean testNetwork = true; /** Property to define a list of remote hosts for remote network test . The default value can be overridden by the - * value specified in default.ini file. Default value {@value } + * value specified in default.ini file. */ public static String[] testURI = {SMARTFROG_URL}; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Date.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Date.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Date.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -30,7 +30,7 @@ * Currently this is in ctime() format * {@link java.util.Date#toString}; it will move to ISO8601/RFC3339 * format with the next release - * @todo generate RFC3339 timestamps + //TODO generate RFC3339 timestamps * @return system date */ protected Object doFunction() { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/SFProcess.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/SFProcess.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/SFProcess.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -391,7 +391,6 @@ * * @throws SmartFrogException if failed to deploy process compound, the root process compound didn't exist or ir the local process compound is not a root process compound * - * @todo test it! */ public static synchronized ProcessCompound resetRootProcessCompound(Reference terminatorCompleteName) throws SmartFrogException,RemoteException { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2006-10-26 16:49:40 UTC (rev 3530) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2006-10-26 16:50:33 UTC (rev 3531) @@ -387,7 +387,7 @@ * Load a class in the classloader, using the SmartFrog classloader. * {@link SFClassLoader#forName(String, String, boolean)} * @param classname - * @return + * @return class * @throws SmartFrogResolutionException if the class could not be found * @throws RemoteException for network problems */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2006-11-01 16:10:52
|
Revision: 3554 http://svn.sourceforge.net/smartfrog/?rev=3554&view=rev Author: steve_l Date: 2006-11-01 08:08:55 -0800 (Wed, 01 Nov 2006) Log Message: ----------- Some tuning of the workflow components. 1. not 100% sure that Sequence exits when a child fails half way through 2. Parallel can be made to terminate on startup if there are no children Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/testblock.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Parallel.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/parallel.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java 2006-11-01 16:08:55 UTC (rev 3554) @@ -59,8 +59,14 @@ String ATTR_TIMEOUT = "timeout"; /** + * Is timeout expected * {@value} */ + String ATTR_EXPECTTIMEOUT = "expectTimeout"; + + /** + * {@value} + */ String ATTR_FORCEDTIMEOUT = "forcedTimeout"; /** * Name that a deployed action goes by Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2006-11-01 16:08:55 UTC (rev 3554) @@ -119,10 +119,11 @@ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); long timeout = sfResolve(ATTR_TIMEOUT,0L,true); + boolean expectTimeout=sfResolve(ATTR_EXPECTTIMEOUT,false,true); try { child=sfCreateNewChild(ACTION,action, null); if(timeout>0) { - actionTerminator=new DelayedTerminator(child, timeout, sfLog(),"timeout",false ); + actionTerminator=new DelayedTerminator(child, timeout, sfLog(),"timeout",expectTimeout); } } catch (RemoteException e) { startupException(e); @@ -188,7 +189,10 @@ protected boolean onChildTerminated(TerminationRecord status, Prim comp) throws SmartFrogRuntimeException, RemoteException { if(comp==child) { - //this is the action terminating, so log the closure and continue + //this is the action terminating, + //forget about our now-terminated child (it cannot be serialized any more) + child=null; + //log the closure and continue end(status); return false; } else { Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/testblock.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/testblock.sf 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/testblock.sf 2006-11-01 16:08:55 UTC (rev 3554) @@ -45,6 +45,8 @@ sfClass "org.smartfrog.services.assertions.TestBlockImpl"; //timeout in milliseconds timeout 0; + //should timeout be expected? + expectTimeout false; //finished: boolean //status -> exit status Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2006-11-01 16:08:55 UTC (rev 3554) @@ -52,11 +52,11 @@ * Create a delayed time. * If the time is -1, then the wait is for {@link Long#MAX_VALUE}, otherwise it * is for as many milliseconds as needed. - * @param prim - * @param time - * @param log - * @param description - * @param normalTermination + * @param prim component to shut down + * @param time how long to sleep + * @param log a log to log to + * @param description text to use in the termination record (or null to have something made up) + * @param normalTermination should the termination be normal. */ public DelayedTerminator(Prim prim, long time, LogSF log, String description, boolean normalTermination) { if(time<0) { @@ -107,7 +107,7 @@ public synchronized void shutdown(boolean terminateTarget) { if (self != null) { shutdown = true; - this.shouldTerminate = terminateTarget; + shouldTerminate = terminateTarget; self.interrupt(); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Parallel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Parallel.java 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Parallel.java 2006-11-01 16:08:55 UTC (rev 3554) @@ -35,6 +35,7 @@ import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.workflow.eventbus.EventCompoundImpl; +import org.smartfrog.sfcore.utils.ComponentHelper; /** * Parallel is a modified compound which differs in that the sub-components @@ -55,8 +56,11 @@ public class Parallel extends EventCompoundImpl implements Compound { private static Reference asynchCreateChildRef = new Reference ("asynchCreateChild"); - + /** {@value} */ + public static final String ATTR_TERMINATE_IF_EMPTY = "terminateOnEmptyDeploy"; + private static Reference terminateIfEmptyRef = new Reference(ATTR_TERMINATE_IF_EMPTY); private boolean asynchCreateChild=false; + private boolean terminateIfEmpty=false; private Vector asynchChildren = null; /** @@ -64,7 +68,7 @@ * * @throws java.rmi.RemoteException In case of network or RMI failure. */ - public Parallel() throws java.rmi.RemoteException { + public Parallel() throws RemoteException { super(); } @@ -78,6 +82,7 @@ public synchronized void sfDeploy() throws SmartFrogException, RemoteException { super.sfDeploy(); asynchCreateChild = sfResolve(asynchCreateChildRef,asynchCreateChild,false); + terminateIfEmpty = sfResolve(terminateIfEmptyRef, terminateIfEmpty, false); } /** @@ -88,22 +93,36 @@ */ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - - // let any errors be thrown and caught by SmartFrog for abnormal termination - including empty actions - try { - if (!asynchCreateChild){ - if (sfLog().isDebugEnabled()){sfLog().debug(" Parallel Synch");}; - synchCreateChild(); - } else { - if (sfLog().isDebugEnabled()){sfLog().debug(" Parallel Asynch");}; - asynchCreateChild(); + TerminationRecord terminationRecord = null; + if (!actions.isEmpty()) { +// let any errors be thrown and caught by SmartFrog for abnormal termination - including empty actions + try { + if (!asynchCreateChild){ + if (sfLog().isDebugEnabled()){sfLog().debug(" Parallel Synch");}; + synchCreateChild(); + } else { + if (sfLog().isDebugEnabled()){sfLog().debug(" Parallel Asynch");}; + asynchCreateChild(); + } + } catch (Exception ex) { + if (sfLog().isErrorEnabled()){ + sfLog().error(sfCompleteNameSafe()+" - Failed to start sub-components ",ex); + } + terminationRecord = TerminationRecord + .abnormal("Failed to start sub-components " + ex, name); + //sfTerminate(terminationRecord); } - } catch (Exception ex) { - if (sfLog().isErrorEnabled()){ - sfLog().error(sfCompleteNameSafe()+" - Failed to start sub-components ",ex); + } else { + //no actions. Maybe terminate + if(terminateIfEmpty) { + terminationRecord = new TerminationRecord(TerminationRecord.NORMAL, + "Parallel component is empty",name); } - sfTerminate(TerminationRecord.abnormal("Failed to start sub-components " + ex, name)); } + if (terminationRecord!=null) { + new ComponentHelper(this).targetForWorkflowTermination(terminationRecord); + } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/parallel.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/parallel.sf 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/parallel.sf 2006-11-01 16:08:55 UTC (rev 3554) @@ -34,8 +34,14 @@ sfClass "org.smartfrog.sfcore.workflow.combinators.Parallel"; parallelSchema extends Schema { asynchCreateChild extends OptionalBoolean; + terminateOnEmptyDeploy extends OptionalBoolean { + description ##flag which indicates that the parallel component + should terminate immediately if there are no children to deploy#; + } +} } // Deploy children in parallel? Set to true to deploy every child component //in a new thread - asynchCreateChild false; + asynchCreateChild false; + terminateOnEmptyDeploy false; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf 2006-11-01 16:08:55 UTC (rev 3554) @@ -22,6 +22,9 @@ /** * the list of the sequence goes into the actions component */ -Sequence extends ActionsCompound { +//Sequence extends ActionCompound { +Sequence extends Compound { sfClass "org.smartfrog.sfcore.workflow.combinators.Sequence"; + sendTo extends LAZY {} + registerWith extends LAZY {} } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2006-10-31 17:27:30 UTC (rev 3553) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2006-11-01 16:08:55 UTC (rev 3554) @@ -44,27 +44,31 @@ */ public class EventCompoundImpl extends CompoundImpl implements EventBus, EventRegistration, EventSink, Compound { - static Reference receiveRef = new Reference( "registerWith"); - static Reference sendRef = new Reference("sendTo"); - Vector receiveFrom = new Vector(); - Vector sendTo = new Vector(); + protected static final String ATTR_REGISTER_WITH = "registerWith"; + protected static final String ATTR_SEND_TO = "sendTo"; + protected static final String ATTR_ACTIONS = "actions"; + protected static final String ATTR_ACTION = "action"; + private static Reference receiveRef = new Reference(ATTR_REGISTER_WITH); + private static Reference sendRef = new Reference(ATTR_SEND_TO); + private Vector receiveFrom = new Vector(); + private Vector sendTo = new Vector(); protected ComponentDescription action=null; protected Context actions=null; protected Enumeration actionKeys=null; + protected Reference name=null; + private boolean oldNotation = true; + private static final Reference actionsRef = new Reference(ATTR_ACTIONS); + private static final Reference actionRef = new Reference(ATTR_ACTION); - boolean oldNotation = true; - static final Reference actionsRef = new Reference("actions"); - static final Reference actionRef = new Reference("action"); - /** * Constructs EventCompoundImpl. * * @throws java.rmi.RemoteException In case of RMI or network failure. */ - public EventCompoundImpl() throws java.rmi.RemoteException { + public EventCompoundImpl() throws RemoteException { super(); } @@ -74,7 +78,7 @@ * If action or actions atributes are present then it behaves like compound and loads all eager components. */ protected void sfDeployWithChildren() throws SmartFrogDeploymentException { - if (sfContext().containsKey("actions")){ + if (sfContext().containsKey(ATTR_ACTIONS)){ oldNotation=true; //Old WF notation using actions // Here follows normal CompoundImpl deployment @@ -200,27 +204,30 @@ super.sfDeploy(); /* find local registrations and register them */ - ComponentDescription sends = (ComponentDescription) sfResolve(sendRef); - Context scxt = sends.sfContext(); + ComponentDescription sends = (ComponentDescription) sfResolve(sendRef,false); + if (sends != null) { + Context scxt = sends.sfContext(); - for (Enumeration e = scxt.keys(); e.hasMoreElements();) { - Object k = e.nextElement(); - Reference l = (Reference) scxt.get(k); - EventSink s = (EventSink) sfResolve(l); - sendTo.addElement(s); + for (Enumeration e = scxt.keys(); e.hasMoreElements();) { + Object k = e.nextElement(); + Reference l = (Reference) scxt.get(k); + EventSink s = (EventSink) sfResolve(l); + sendTo.addElement(s); + } } /* find own registrations, and register remotely */ - ComponentDescription regs = (ComponentDescription) sfResolve(receiveRef); + ComponentDescription regs = (ComponentDescription) sfResolve(receiveRef, false); + if (regs!=null) { + Context rcxt = regs.sfContext(); - Context rcxt = regs.sfContext(); - - for (Enumeration e = rcxt.keys(); e.hasMoreElements();) { - Object k = e.nextElement(); - Reference l = (Reference) rcxt.get(k); - EventRegistration s = (EventRegistration) sfResolve(l); - receiveFrom.addElement(s); - s.register(this); + for (Enumeration e = rcxt.keys(); e.hasMoreElements();) { + Object k = e.nextElement(); + Reference l = (Reference) rcxt.get(k); + EventRegistration s = (EventRegistration) sfResolve(l); + receiveFrom.addElement(s); + s.register(this); + } } if (oldNotation) { @@ -244,8 +251,14 @@ public void sfTerminatedWith(TerminationRecord status, Prim comp) { boolean terminate; if (isWorkflowTerminating()) { - //during termination, always forward - terminate = onWorkflowTerminating(status, comp); + try { + //let subclasses decide what to do here + terminate = onWorkflowTerminating(status, comp); + } catch (Exception e) { + //but if that fails, we terminate + sfLog().error("Exception ", e); + terminate = true; + } } else { //check to see what the subclass wants try { @@ -275,9 +288,12 @@ * @param status exit record of the component * @param comp child component that is terminating * @return true if the termination event is to be forwarded up the chain. + * @throws SmartFrogRuntimeException for runtime exceptions + * @throws RemoteException for network problems */ - protected boolean onWorkflowTerminating(TerminationRecord status, Prim comp) { + protected boolean onWorkflowTerminating(TerminationRecord status, Prim comp) + throws SmartFrogRuntimeException, RemoteException { return true; } @@ -293,6 +309,8 @@ * @param status exit record of the component * @param comp child component that is terminating * @return true if the termination event is to be forwarded up the chain. + * @throws SmartFrogRuntimeException for runtime exceptions + * @throws RemoteException for network problems */ protected boolean onChildTerminated(TerminationRecord status, Prim comp) throws SmartFrogRuntimeException, RemoteException { @@ -308,6 +326,8 @@ * @param status exit record of the component * @param comp non-child component that is terminating * @return true if the component is to be terminated + * @throws SmartFrogRuntimeException for runtime exceptions + * @throws RemoteException for network problems */ protected boolean onNonChildTerminated(TerminationRecord status, Prim comp) throws SmartFrogRuntimeException, RemoteException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2006-11-02 14:39:03
|
Revision: 3556 http://svn.sourceforge.net/smartfrog/?rev=3556&view=rev Author: steve_l Date: 2006-11-02 06:37:14 -0800 (Thu, 02 Nov 2006) Log Message: ----------- Changes to the new TestBlockcompound so it terminates cleanly. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Sequence.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/retry.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2006-11-02 14:37:14 UTC (rev 3556) @@ -36,7 +36,6 @@ public class TestBlockImpl extends EventCompoundImpl implements TestBlock { - private volatile boolean finished=false; private volatile boolean failed = false; private volatile boolean succeeded = false; @@ -124,6 +123,7 @@ child=sfCreateNewChild(ACTION,action, null); if(timeout>0) { actionTerminator=new DelayedTerminator(child, timeout, sfLog(),"timeout",expectTimeout); + actionTerminator.start(); } } catch (RemoteException e) { startupException(e); @@ -165,7 +165,7 @@ actionTerminator.shutdown(false); actionTerminator = null; } - setTestBlockAttributes(this,record, forcedTimeout); + setTestBlockAttributes(record, forcedTimeout); //this can trigger a shutdown if we want it new ComponentHelper(this).sfSelfDetachAndOrTerminate(record); } @@ -204,20 +204,21 @@ /** * Set the various attributes of the component * based on whether the test record was success or not - * @param prim * @param record + * @param timeout did we time out * @throws SmartFrogRuntimeException * @throws RemoteException */ - public static void setTestBlockAttributes(Prim prim, - TerminationRecord record, - boolean timeout) + public void setTestBlockAttributes( + TerminationRecord record, + boolean timeout) throws SmartFrogRuntimeException, RemoteException { boolean success=record.isNormal(); - prim.sfReplaceAttribute(ATTR_STATUS,record); - prim.sfReplaceAttribute(ATTR_FINISHED, Boolean.TRUE); - prim.sfReplaceAttribute(ATTR_SUCCEEDED, Boolean.valueOf(success)); - prim.sfReplaceAttribute(ATTR_FAILED, Boolean.valueOf(!success)); - prim.sfReplaceAttribute(ATTR_FORCEDTIMEOUT, Boolean.valueOf(timeout)); + sfLog().debug("Terminated Test with status "+record+" timeout="+timeout); + sfReplaceAttribute(ATTR_STATUS,record); + sfReplaceAttribute(ATTR_FINISHED, Boolean.TRUE); + sfReplaceAttribute(ATTR_SUCCEEDED, Boolean.valueOf(success)); + sfReplaceAttribute(ATTR_FAILED, Boolean.valueOf(!success)); + sfReplaceAttribute(ATTR_FORCEDTIMEOUT, Boolean.valueOf(timeout)); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2006-11-02 14:37:14 UTC (rev 3556) @@ -147,6 +147,7 @@ testsTerminator = new DelayedTerminator(testsPrim, testTimeout, logSF, FORCED_TERMINATION, false); + testsTerminator.start(); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2006-11-02 14:37:14 UTC (rev 3556) @@ -52,6 +52,8 @@ * Create a delayed time. * If the time is -1, then the wait is for {@link Long#MAX_VALUE}, otherwise it * is for as many milliseconds as needed. + * + * <i>Important</i> This does not start the thread. Call {@link #start()} to do that. * @param prim component to shut down * @param time how long to sleep * @param log a log to log to @@ -117,14 +119,12 @@ * Start the new thread */ public synchronized void start() { - if(self!=null) { - if (self != null) { - self = new Thread(this); - if(name!=null) { - self.setName(name); - } - self.start(); + if(self==null) { + self = new Thread(this); + if(name!=null) { + self.setName(name); } + self.start(); } } @@ -142,7 +142,7 @@ synchronized (this) { try { - if (shutdown == true) { + if (shutdown) { //initiated shutdown log.debug("initiated shutdown " + description); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Sequence.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Sequence.java 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Sequence.java 2006-11-02 14:37:14 UTC (rev 3556) @@ -142,6 +142,7 @@ .abnormal("error in starting next component: exception " + e, name, e); sfTerminate(tr); //we've triggered an abnormal shutdown, so no forwarding of the earlier event + //as that would use the (normal) terminator used. terminate = false; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/retry.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/retry.sf 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/retry.sf 2006-11-02 14:37:14 UTC (rev 3556) @@ -26,6 +26,5 @@ description "retry interval in milliseconds"; } } - // action retry 1; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf 2006-11-01 16:18:17 UTC (rev 3555) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/sequence.sf 2006-11-02 14:37:14 UTC (rev 3556) @@ -22,9 +22,6 @@ /** * the list of the sequence goes into the actions component */ -//Sequence extends ActionCompound { -Sequence extends Compound { +Sequence extends ActionsCompound { sfClass "org.smartfrog.sfcore.workflow.combinators.Sequence"; - sendTo extends LAZY {} - registerWith extends LAZY {} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pau...@us...> - 2006-11-09 16:19:31
|
Revision: 3580 http://svn.sourceforge.net/smartfrog/?rev=3580&view=rev Author: paul_murray Date: 2006-11-09 08:19:08 -0800 (Thu, 09 Nov 2006) Log Message: ----------- Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/components.sf Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/SFPersist.java trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example1.sf trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example2.sf Removed Paths: ------------- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example.sf trunk/core/smartfrog/src/org/smartfrog/services/persistence/SFPersist.java trunk/core/smartfrog/src/org/smartfrog/services/persistence/components.sf trunk/core/smartfrog/src/org/smartfrog/services/persistence/example.sf Added: trunk/core/smartfrog/src/org/smartfrog/examples/persistence/SFPersist.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/SFPersist.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/examples/persistence/SFPersist.java 2006-11-09 16:19:08 UTC (rev 3580) @@ -0,0 +1,249 @@ +/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ + +package org.smartfrog.examples.persistence; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.FilenameFilter; +import java.io.Writer; +import java.rmi.RemoteException; +import java.util.Date; + +import org.smartfrog.sfcore.common.Context; +import org.smartfrog.sfcore.common.PrettyPrinting; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import org.smartfrog.sfcore.logging.LogSF; +import org.smartfrog.sfcore.parser.Phases; +import org.smartfrog.sfcore.parser.SFParser; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.PrimHook; +import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.processcompound.SFProcess; + +/** + * Persist a component to a file + */ +public class SFPersist extends PrimImpl implements Prim { + + /** + * the firectory for persistng the contexts + */ + private String directory; + + /* the hook objects */ + private PrimHook sfPersister = new SfPersister(); + private PrimHook sfDePersister = new SfDePersister(); + + /** + * the log component to which to generate the trace logs + */ + private LogSF log = null; + + /* number to add to filename to make unique */ + private int nextInt = 0; + + /** + * Constructor. + * + * @throws RemoteException in case of network/rmi error + */ + public SFPersist() throws RemoteException { + } + + /** + * Deploys the component. + * + * @throws SmartFrogException in case of error while deploying + * @throws RemoteException in case of network/rmi error + */ + public synchronized void sfDeploy() throws SmartFrogException, + RemoteException { + super.sfDeploy(); + + log = sfGetCoreLog(); + + directory = sfResolve("directory", directory, true); + } + + /** + * Starts the component. + * + * @throws SmartFrogException in case of error in starting + * @throws RemoteException in case of network/rmi error + */ + public synchronized void sfStart() throws SmartFrogException, + RemoteException { + super.sfStart(); + + restartComponents(); + + // applied by default + sfDeployWithHooks.addHook(sfPersister); + sfTerminateWithHooks.addHook(sfDePersister); + } + + /** + * Terminate the component. + * + * @param r TerminationRecord object + */ + public synchronized void sfTerminateWith(TerminationRecord r) { + try { + sfDeployWithHooks.removeHook(sfPersister); + sfTerminateWithHooks.removeHook(sfDePersister); + // remove file + } catch (Exception e) { + + } + super.sfTerminateWith(r); + } + + + private void restartComponents() throws SmartFrogException { + File restartDirectory = new File(directory); + File[] files = restartDirectory.listFiles(new sfFileFilter()); + + for (int i = 0; i < files.length; i++) { + deployFile(files[i]); + } + } + + private void deployFile(File f) throws SmartFrogException { + try { + if (log.isInfoEnabled()) { + log.info("Restart description from file " + f); + } + Phases top = (new SFParser("sf")).sfParse(new FileInputStream(f)); + ComponentDescription topd = top.sfAsComponentDescription(); // should b fully resolved,,, + System.out.println("topd " + topd); + SFProcess.getProcessCompound().sfCreateNewApp(null, topd, null); + } catch (Exception e) { + SmartFrogException.forward("Error redeploying persisted component from file " + + f, e); + } + } + + private class sfFileFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith(".sf"); + } + } + + /** + * Utility inner class- persister functinoality + */ + private class SfPersister implements PrimHook { + /** + * sfHookAction for deploying + * + * @param prim prim component + * @param terminationRecord TerminationRecord object + * @throws SmartFrogException in case of any error + */ + public void sfHookAction(Prim prim, + TerminationRecord terminationRecord) + throws SmartFrogException { + boolean sfPersist = false; + // write the context to the file relative to the directory... + try { + System.out.println("running hook"); + if (prim.sfParent() instanceof ProcessCompound) { + sfPersist = prim.sfResolve("sfPersist", sfPersist, false); + if (sfPersist) { + String time = new Long(new Date().getTime()).toString(); + String filename = "sfPersist." + + time + + "." + + nextInt++ + + ".sf"; + prim.sfReplaceAttribute("sfPersisted", filename); + prim.sfReplaceAttribute("sfPersistedDirectory", + directory); + Context context = prim.sfContext(); + + if (log.isInfoEnabled()) { + log.info("persisting description to file " + + filename); + } + Writer out = new FileWriter(new File(directory, + filename)); + ((PrettyPrinting) context).writeOn(out, 1); + out.close(); + } + } + } catch (Exception e) { + // ignore + if (log.isErrorEnabled()) { + log.error("Error persisting component to file " + + sfPersist, + e); + } + throw new SmartFrogException("Error persisting component to file " + + sfPersist, e); + } + } + } + + /** + * Utility inner class- removing persister functinoality + */ + private class SfDePersister implements PrimHook { + /** + * sfHookAction for terminating + * + * @param prim prim component + * @param terminationRecord TerminationRecord object + * @throws SmartFrogException in case of any error + */ + public void sfHookAction(Prim prim, + TerminationRecord terminationRecord) + throws SmartFrogException { + File file = null; + // write the context to the file relative to the directory... + try { + System.out.println("running termination hook"); + String filename = prim.sfResolve("sfPersisted", "", false); + if (!filename.equals("")) { + file = new File(directory, filename); + boolean deleted = file.delete(); + if (log.isDebugEnabled()) { + log.debug("Persisted file " + + file + + " removal: result: " + + deleted); + } + } + } catch (Exception e) { + // ignore + if (log.isErrorEnabled()) { + log.error("Error persisting component to file " + file, e); + } + throw new SmartFrogException("Error persisting component to file " + + file, e); + } + } + } + +} Modified: trunk/core/smartfrog/src/org/smartfrog/examples/persistence/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/components.sf 2006-11-09 07:49:07 UTC (rev 3579) +++ trunk/core/smartfrog/src/org/smartfrog/examples/persistence/components.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -24,9 +24,11 @@ * The PersistentCounter component is a basic primitive component. */ +#include "/org/smartfrog/components.sf" #include "/org/smartfrog/predicates.sf" -#include "/org/smartfrog/examples/counter/components.sf" +#include "org/smartfrog/services/display/components.sf" + PersistentCounter extends Counter { /** * Mandatory attribute: the class for component description @@ -34,3 +36,19 @@ sfClass "org.smartfrog.examples.persistence.PersistentCounterImpl"; } + +/** + * Persist a component to a directory + */ + +SFPersist extends Prim { + sfClass "org.smartfrog.services.persistence.SFPersist"; + persistSchema extends Schema { + + //this is the axis configuration file for a service + directory extends String; + } + + directory LAZY PROPERTY java.io.tmpdir; + +} Deleted: trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example.sf 2006-11-09 07:49:07 UTC (rev 3579) +++ trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -1,26 +0,0 @@ -#include "org/smartfrog/components.sf" -#include "org/smartfrog/examples/persistence/components.sf" - - -sfConfig extends Compound { - sfPersist true; - counter extends PersistentCounter { - pause false; - limit 10000; - sleep 1000; - message "counter 1"; - - checkpointDirectory LAZY sfPersistedDirectory; - checkpointFileRoot LAZY sfPersisted; - - } - counter2 extends PersistentCounter { - pause false; - limit 10000; - sleep 5000; - message "counter 2"; - - checkpointDirectory LAZY sfPersistedDirectory; - checkpointFileRoot LAZY sfPersisted; - } -} Added: trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example1.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example1.sf (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example1.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -0,0 +1,26 @@ +#include "org/smartfrog/components.sf" +#include "org/smartfrog/examples/persistence/components.sf" + + +sfConfig extends Compound { + sfPersist true; + counter extends PersistentCounter { + pause false; + limit 10000; + sleep 1000; + message "counter 1"; + + checkpointDirectory LAZY sfPersistedDirectory; + checkpointFileRoot LAZY sfPersisted; + + } + counter2 extends PersistentCounter { + pause false; + limit 10000; + sleep 5000; + message "counter 2"; + + checkpointDirectory LAZY sfPersistedDirectory; + checkpointFileRoot LAZY sfPersisted; + } +} Added: trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example2.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example2.sf (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/examples/persistence/example2.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -0,0 +1,33 @@ +/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ + +#include "org/smartfrog/components.sf" + +//Trace Component +#include "org/smartfrog/examples/persistence/components.sf" + + + +sfConfig extends Compound { + persistenceHook extends SFPersist { + sfExport false; + directory "/tmp/persist/"; + } +} Deleted: trunk/core/smartfrog/src/org/smartfrog/services/persistence/SFPersist.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/persistence/SFPersist.java 2006-11-09 07:49:07 UTC (rev 3579) +++ trunk/core/smartfrog/src/org/smartfrog/services/persistence/SFPersist.java 2006-11-09 16:19:08 UTC (rev 3580) @@ -1,249 +0,0 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ - -package org.smartfrog.services.persistence; - -import java.rmi.RemoteException; -import java.io.Writer; -import java.io.FileWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilenameFilter; -import java.util.Date; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.Context; -import org.smartfrog.sfcore.common.PrettyPrinting; -import org.smartfrog.sfcore.logging.LogSF; -import org.smartfrog.sfcore.parser.Phases; -import org.smartfrog.sfcore.parser.SFParser; -import org.smartfrog.sfcore.componentdescription.ComponentDescription; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.prim.PrimHook; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.processcompound.SFProcess; -import org.smartfrog.sfcore.processcompound.ProcessCompound; - -/** - * Persist a component to a file - */ -public class SFPersist extends PrimImpl implements Prim { - - /** - * the firectory for persistng the contexts - */ - private String directory; - - /* the hook objects */ - private PrimHook sfPersister = new SfPersister(); - private PrimHook sfDePersister = new SfDePersister(); - - /** - * the log component to which to generate the trace logs - */ - private LogSF log = null; - - /* number to add to filename to make unique */ - private int nextInt = 0; - - /** - * Constructor. - * - * @throws RemoteException in case of network/rmi error - */ - public SFPersist() throws RemoteException { - } - - /** - * Deploys the component. - * - * @throws SmartFrogException in case of error while deploying - * @throws RemoteException in case of network/rmi error - */ - public synchronized void sfDeploy() throws SmartFrogException, - RemoteException { - super.sfDeploy(); - - log = sfGetCoreLog(); - - directory = sfResolve("directory", directory, true); - } - - /** - * Starts the component. - * - * @throws SmartFrogException in case of error in starting - * @throws RemoteException in case of network/rmi error - */ - public synchronized void sfStart() throws SmartFrogException, - RemoteException { - super.sfStart(); - - restartComponents(); - - // applied by default - sfDeployWithHooks.addHook(sfPersister); - sfTerminateWithHooks.addHook(sfDePersister); - } - - /** - * Terminate the component. - * - * @param r TerminationRecord object - */ - public synchronized void sfTerminateWith(TerminationRecord r) { - try { - sfDeployWithHooks.removeHook(sfPersister); - sfTerminateWithHooks.removeHook(sfDePersister); - // remove file - } catch (Exception e) { - - } - super.sfTerminateWith(r); - } - - - private void restartComponents() throws SmartFrogException { - File restartDirectory = new File(directory); - File[] files = restartDirectory.listFiles(new sfFileFilter()); - - for (int i = 0; i < files.length; i++) { - deployFile(files[i]); - } - } - - private void deployFile(File f) throws SmartFrogException { - try { - if (log.isInfoEnabled()) { - log.info("Restart description from file " + f); - } - Phases top = (new SFParser("sf")).sfParse(new FileInputStream(f)); - ComponentDescription topd = top.sfAsComponentDescription(); // should b fully resolved,,, - System.out.println("topd " + topd); - SFProcess.getProcessCompound().sfCreateNewApp(null, topd, null); - } catch (Exception e) { - SmartFrogException.forward("Error redeploying persisted component from file " + - f, e); - } - } - - private class sfFileFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.endsWith(".sf"); - } - } - - /** - * Utility inner class- persister functinoality - */ - private class SfPersister implements PrimHook { - /** - * sfHookAction for deploying - * - * @param prim prim component - * @param terminationRecord TerminationRecord object - * @throws SmartFrogException in case of any error - */ - public void sfHookAction(Prim prim, - TerminationRecord terminationRecord) - throws SmartFrogException { - boolean sfPersist = false; - // write the context to the file relative to the directory... - try { - System.out.println("running hook"); - if (prim.sfParent() instanceof ProcessCompound) { - sfPersist = prim.sfResolve("sfPersist", sfPersist, false); - if (sfPersist) { - String time = new Long(new Date().getTime()).toString(); - String filename = "sfPersist." + - time + - "." + - nextInt++ + - ".sf"; - prim.sfReplaceAttribute("sfPersisted", filename); - prim.sfReplaceAttribute("sfPersistedDirectory", - directory); - Context context = prim.sfContext(); - - if (log.isInfoEnabled()) { - log.info("persisting description to file " + - filename); - } - Writer out = new FileWriter(new File(directory, - filename)); - ((PrettyPrinting) context).writeOn(out, 1); - out.close(); - } - } - } catch (Exception e) { - // ignore - if (log.isErrorEnabled()) { - log.error("Error persisting component to file " + - sfPersist, - e); - } - throw new SmartFrogException("Error persisting component to file " + - sfPersist, e); - } - } - } - - /** - * Utility inner class- removing persister functinoality - */ - private class SfDePersister implements PrimHook { - /** - * sfHookAction for terminating - * - * @param prim prim component - * @param terminationRecord TerminationRecord object - * @throws SmartFrogException in case of any error - */ - public void sfHookAction(Prim prim, - TerminationRecord terminationRecord) - throws SmartFrogException { - File file = null; - // write the context to the file relative to the directory... - try { - System.out.println("running termination hook"); - String filename = prim.sfResolve("sfPersisted", "", false); - if (!filename.equals("")) { - file = new File(directory, filename); - boolean deleted = file.delete(); - if (log.isDebugEnabled()) { - log.debug("Persisted file " + - file + - " removal: result: " + - deleted); - } - } - } catch (Exception e) { - // ignore - if (log.isErrorEnabled()) { - log.error("Error persisting component to file " + file, e); - } - throw new SmartFrogException("Error persisting component to file " + - file, e); - } - } - } - -} Deleted: trunk/core/smartfrog/src/org/smartfrog/services/persistence/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/persistence/components.sf 2006-11-09 07:49:07 UTC (rev 3579) +++ trunk/core/smartfrog/src/org/smartfrog/services/persistence/components.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -1,41 +0,0 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ - -#include "/org/smartfrog/components.sf" -#include "/org/smartfrog/predicates.sf" -#include "org/smartfrog/services/display/components.sf" - -/** - * Persist a component to a directory - */ - - -SFPersist extends Prim { - sfClass "org.smartfrog.services.persistence.SFPersist"; - persistSchema extends Schema { - - //this is the axis configuration file for a service - directory extends String; - } - - directory LAZY PROPERTY java.io.tmpdir; - -} - Deleted: trunk/core/smartfrog/src/org/smartfrog/services/persistence/example.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/persistence/example.sf 2006-11-09 07:49:07 UTC (rev 3579) +++ trunk/core/smartfrog/src/org/smartfrog/services/persistence/example.sf 2006-11-09 16:19:08 UTC (rev 3580) @@ -1,33 +0,0 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ - -#include "org/smartfrog/components.sf" - -//Trace Component -#include "/org/smartfrog/services/persistence/components.sf" - - - -sfConfig extends Compound { - persistenceHook extends SFPersist { - sfExport false; - directory "/tmp/persist/"; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-11-16 15:04:34
|
Revision: 3602 http://svn.sourceforge.net/smartfrog/?rev=3602&view=rev Author: julgui Date: 2006-11-16 07:04:32 -0800 (Thu, 16 Nov 2006) Log Message: ----------- Console will not allow to modify ComponentDescription that are remote and new attribute to enable/disable Ask to Save Changes (default:off) SFOS-37 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java trunk/core/smartfrog/src/org/smartfrog/services/display/components.sf trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -149,6 +149,11 @@ */ JCheckBoxMenuItem jCheckBoxMenuItemPause = new JCheckBoxMenuItem(); /** + * Check box AskSaveChages + */ + JCheckBoxMenuItem jCheckBoxMenuItemAskSaveChanges = new JCheckBoxMenuItem(); + + /** * Menu item - clean all. */ JMenuItem jMenuItemCleanAll = new JMenuItem(); @@ -237,7 +242,6 @@ Display mngConsole = null; private JMenuItem jMenuItemMngConsole = new JMenuItem(); - /** * Constructs Display object with title. * @@ -364,8 +368,6 @@ Timer t = new Timer(1 * 1000, new ActionListener() { SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss"); - - public void actionPerformed(ActionEvent evt) { String message = "timer..." + fmt.format(new Date()); if (logStatic.isInfoEnabled()) logStatic.info("Stdout:" + message); @@ -604,6 +606,9 @@ * @return boolean true or false */ boolean okToAbandon() { + if ((!jCheckBoxMenuItemAskSaveChanges.isSelected())) { + return true; + } if (!dirty) { return true; } @@ -1359,10 +1364,15 @@ jCheckBoxMenuItemPause.setToolTipText("Pause AutoScroll (Alt+P)"); jCheckBoxMenuItemPause.setText("AutoScroll"); jCheckBoxMenuItemPause.setSelected(true); - // AutoScroll by default jCheckBoxMenuItemPause.setAccelerator(javax.swing.KeyStroke.getKeyStroke( 80, java.awt.event.KeyEvent.ALT_MASK, false)); + + jCheckBoxMenuItemAskSaveChanges.setToolTipText("Ask to Save Changes?"); + jCheckBoxMenuItemAskSaveChanges.setText("Ask Save Changes?"); + jCheckBoxMenuItemAskSaveChanges.setSelected(true); + + jMenuItemMngConsole.setText("SF Management Console"); jMenuItemMngConsole.addActionListener( new java.awt.event.ActionListener() { @@ -1373,6 +1383,7 @@ jMenuBarDisplay.add(jMenuFile); jMenuBarDisplay.add(jMenuHelp); jMenuFile.add(jCheckBoxMenuItemPause); + jMenuFile.add(jCheckBoxMenuItemAskSaveChanges); jMenuFile.addSeparator(); jMenuFile.add(jMenuItemCleanAll); jMenuFile.add(jMenuItemSaveAs); @@ -1401,6 +1412,9 @@ mainToolBar.add(stopResume, null); } + public void setAskSaveChanges(boolean askSaveChanges){ + jCheckBoxMenuItemAskSaveChanges.setSelected(askSaveChanges); + } public static Image createImage(String imagesPath) { try { Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -79,6 +79,8 @@ private static final String EXTERNAL_PRINTER = "externalPrinter"; /** String name for attribute screenEditable. */ private static final String SCREEN_EDITABLE = "screenEditable"; + /** String name for attribute askSaveChanges. */ + private static final String ASK_SAVE_CHANGES = "askSaveChanges"; /** * Definition of components attribute - display. @@ -108,10 +110,12 @@ private boolean redirectStd = false; /** Definition of component attribute - formatMsg. */ private boolean formatMsg = false; - /** Definition of component attribute - screenEditable. */ + /** Definition of component attribute - screenEditable. @value*/ private boolean screenEditable = true; - /** Definition of component attribute - terminateSFProcessOnExit. */ + /** Definition of component attribute - terminateSFProcessOnExit. @value*/ boolean terminateSFProcessOnExit = false; + /** Definition of component attribute - ask save changes. Default: @value */ + private boolean askSaveChanges = false; /** Should clean the screen every "cleanEveryNumSec"?. */ private boolean autoClean = true; @@ -188,6 +192,7 @@ display.setTextScreen(text); setPositionDisplay(positionDisplay, display); display.setVisible(true); + display.setAskSaveChanges(askSaveChanges); // Redirecting standard output: // TODO: redirect to other objects here??? @@ -204,8 +209,7 @@ System.setOut(out); System.setErr(out); } - } - if (autoClean) { + if (autoClean) { timerAutoClean = new Timer(cleanEveryNumSec * 1000, new ActionListener() { @@ -225,7 +229,9 @@ if (autoSave) { display.resetScreenFile(directoryAutoSave); } + } } + } catch (Exception e) { System.setErr(sysErr); // TODO: Get the message from message bundle @@ -271,6 +277,9 @@ attribToRead = EXTERNAL_PRINTER; havePrinter = sfResolve(EXTERNAL_PRINTER,havePrinter, false); + attribToRead = ASK_SAVE_CHANGES; + askSaveChanges = sfResolve(ASK_SAVE_CHANGES,askSaveChanges, false); + attribToRead = AUTO_CLEAN; autoClean = sfResolve(AUTO_CLEAN, autoClean, false); Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/components.sf 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/components.sf 2006-11-16 15:04:32 UTC (rev 3602) @@ -43,6 +43,7 @@ //showSfProcess false; // shows sfProcessName in title; //externalPrinter ; //Component implementing PrintMsfInf // terminateSFProcessOnExit true;// Terminates SF process when window is closed + askSaveChanges false; //Ask to save changes? } // end Display Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -83,6 +83,7 @@ this.showRootProcessName = showRootProcessName; this.showCDasChild=showCDasChild; initLog(); + //sfLog().info("DeployEntry created: "+entry+", copy: "+isCopy); } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error("sfManagementConsole (DeployEntry1): "+ex.toString(),ex); } @@ -160,7 +161,7 @@ *@return The root value */ public DeployEntry getRoot() { - //System.out.println("getRoot():"+this.toString()); + //sfLog().info("getRoot():"+this.toString()); // Needs to the the real ROOT of the system try { if ((entry instanceof ProcessCompound)&& this.showRootProcessName){ @@ -373,16 +374,23 @@ String[][] empty = { { "", "" } }; - + boolean isContextCopy = isCopy; try { Context context = null; + Object contextCopy=null; if (entry instanceof Prim){ context = ((Prim) entry).sfContext(); + contextCopy= ((Prim) entry).sfContext(); } else if (entry instanceof ComponentDescription){ context = (( ComponentDescription) entry).sfContext(); + contextCopy = (( ComponentDescription) entry).sfContext(); } else { return(empty); } + //Check for copy + if (context!=contextCopy){ + isContextCopy = true; + } String name = ""; Object obj = null; @@ -396,7 +404,7 @@ obj = context.get(name); if ((isChild(obj))) { data[index][0] = name; - data[index][1] = obj2Entry(obj,false); + data[index][1] = obj2Entry(obj,isContextCopy); index++; } } catch (Exception ex1) { @@ -762,21 +770,24 @@ boolean newShowRootProcessName = (this.showRootProcessName&&(entry instanceof ProcessCompound)); if ((value instanceof Prim)||(value instanceof ComponentDescription)) { return (new DeployEntry(value, isCopy, newShowRootProcessName,this.showCDasChild)); - } else if (value instanceof Reference) { - do { - ((Reference) value).setEager(true); - value = ((Prim) entry).sfResolve((Reference) value); - //Check if we are getting a copy - if (value instanceof ComponentDescription) { - Object value2 = ((Prim) entry).sfResolve((Reference) value); - if (!value.equals(value2)){ - isCopy = true; - } - sfLog().info("JULIO- Checking if we got a copy: " + isCopy); - } - } while (value instanceof Reference); - return (new DeployEntry(value,isCopy, newShowRootProcessName,this.showCDasChild)); } +// else if (value instanceof Reference) { +// //sfLog().info("resolving reference..."); +// do { +// ((Reference) value).setEager(true); +// value = ((Prim) entry).sfResolve((Reference) value); +// //Check if we are getting a copy +// if (value instanceof ComponentDescription) { +// Object value2 = ((Prim) entry).sfResolve((Reference) value); +// if (value!=value2){ +// //once a cd is a copy all the children CDs will be copies +// isCopy = true; +// } +// } +// +// } while (value instanceof Reference); +// return (new DeployEntry(value,isCopy, newShowRootProcessName,this.showCDasChild)); +// } } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error("Error building mgt info: " + ex,ex); //return new DeployEntry((ex.getMessage()+(value.toString()))); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -78,9 +78,9 @@ public DeployTreeModelSF(Object entry, boolean isCopy, boolean showRootProcessName,boolean showCDasChild) { try { boolean newShowRootProcessName = (showRootProcessName&&(entry instanceof ProcessCompound)); - this.entry = new DeployEntry(entry, isCopy, newShowRootProcessName,showCDasChild); - this.listeners = new Vector(); - initLog(); + this.entry = new DeployEntry(entry, isCopy, newShowRootProcessName,showCDasChild); + this.listeners = new Vector(); + initLog(); //System.out.println("DeployTreeModel created"); } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error("sfManagementConsole (DeployTreeModel): "+ex.toString(),ex); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -140,11 +140,18 @@ WindowUtilities.showError(this,"No selected Cell"); return; } + if (isNodeACopy()){ + WindowUtilities.showError(this,"The node selected is a copy and no 'remove' action can be applied\n Use a console running in the local process of this node"); + return; + } + remove(getNode(), (String) (tempTable.getValueAt(row, 0))); - remove((((DeployEntry) (tpath.getLastPathComponent())).getEntry()), (String) (tempTable.getValueAt(row, 0))); - // Entry pointed in the tree } else if (source == menuItemModifyAttribute) { + if (isNodeACopy()){ + WindowUtilities.showError(this,"The node selected is a copy and no 'modify' action can be applied\n Use a console running in the local process of this node"); + return; + } Object name = null; Object value = null; @@ -238,6 +245,19 @@ return node; } + public boolean isNodeACopy(){ + TreePath tpath = (tempTree).getSelectionPath(); + DeployEntry node = (((DeployEntry) (tpath.getLastPathComponent()))); + return node.isCopy(); + + } + + public boolean isParentNodeACopy(){ + TreePath tpath = (tempTree).getSelectionPath(); + DeployEntry parentNode = (((DeployEntry) (tpath.getParentPath().getLastPathComponent()))); + return parentNode.isCopy(); + } + /** * Converts tree path to path * Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -311,6 +311,19 @@ return node; } + public boolean isNodeACopy(){ + TreePath tpath = ((JTree) tempComp).getPathForLocation(tempX, tempY); + DeployEntry node = (((DeployEntry) (tpath.getLastPathComponent()))); + return node.isCopy(); + + } + + public boolean isParentNodeACopy(){ + TreePath tpath = ((JTree) tempComp).getPathForLocation(tempX, tempY); + DeployEntry parentNode = (((DeployEntry) (tpath.getParentPath().getLastPathComponent()))); + return parentNode.isCopy(); + } + /** * Converts tree path to path *@param tpath Tree path object @@ -360,14 +373,20 @@ void remove() { Object obj = getNode(); - System.out.println("remove() "+obj); + //System.out.println("remove() "+obj); if (obj instanceof ComponentDescription) { ComponentDescription cd = (ComponentDescription)obj; ComponentDescription CDparent = cd.sfParent(); Prim primParent = cd.sfPrimParent(); try { if (CDparent != null) { + //we need to check is the parent is a copy + if (isParentNodeACopy() || isNodeACopy()) { + WindowUtilities.showError(this,"The node selected is a copy and no action can be applied\n Use a console running in the local process of this node"); + return; + } CDparent.sfRemoveAttribute(CDparent.sfAttributeKeyFor(cd)); + } else if (primParent != null) { primParent.sfRemoveAttribute(primParent.sfAttributeKeyFor(cd)); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -136,7 +136,7 @@ int width, String positionDisplay, final boolean showRootProcess, final boolean showCDasChild, final String hostname, final int port, boolean shouldSystemExit) throws Exception { - final JButton refreshButton; + final JButton refreshButton = new JButton(); JMenu jMenuMng = new JMenu(); final JCheckBoxMenuItem jCheckBoxMenuItemShowRootProcessPanel = new JCheckBoxMenuItem(); final JCheckBoxMenuItem jCheckBoxMenuItemShowCDasChild = new JCheckBoxMenuItem(); @@ -164,11 +164,10 @@ newDisplay.setShouldSystemExit(shouldSystemExit); newDisplay.setVisible(false); newDisplay.setSize(width, height); - org.smartfrog.services.display.WindowUtilities.setPositionDisplay(null, - newDisplay, positionDisplay); + newDisplay.setAskSaveChanges(false); + org.smartfrog.services.display.WindowUtilities.setPositionDisplay(null, newDisplay, positionDisplay); // Button for Refresh view ... - refreshButton = new JButton(); refreshButton.setText("Refresh"); refreshButton.setActionCommand("refreshButton"); refreshButton.addActionListener( @@ -181,6 +180,7 @@ addProcessesPanels(newDisplay, jCheckBoxMenuItemShowRootProcessPanel.isSelected(), //showRootProcess, jCheckBoxMenuItemShowCDasChild.isSelected(),hostname, port); } catch (Exception ex) { + ex.printStackTrace(); if (LogFactory.getLog("SFManagamentConsole").isErrorEnabled()){ LogFactory.getLog("SFManagamentConsole").error(ex); } @@ -279,7 +279,7 @@ deployPanel.setEnabled(true); display.tabPane.add(deployPanel, "rootProcess", indexPanel++); //Add Local Process Panel - if (!SFProcess.getProcessCompound().sfIsRoot()) { + if (SFProcess.getProcessCompound()!=null && (!SFProcess.getProcessCompound().sfIsRoot())) { String processName = "localSubProcess"; try { processName = SFProcess.getProcessCompound().sfCompleteName().toString(); @@ -291,9 +291,7 @@ } - Context context = SFProcess.getRootLocator() - .getRootProcessCompound(InetAddress.getByName( - hostname), port).sfContext(); + Context context = SFProcess.getRootLocator().getRootProcessCompound(InetAddress.getByName(hostname), port).sfContext(); java.util.Enumeration keys = context.keys(); Object key = ""; Object value = ""; @@ -350,13 +348,13 @@ } catch (Exception ex){ sfLog().ignore(ex);} Object value2 = sfResolve("root",false); - if (!root.equals(value2)){ + if (root != value2){ isObjCopy = true; } - sfLog().info("JULIO- Checking if we got a copy: " + isObjCopy); //TODO to remove when finished + } else if (root instanceof Prim) { try { - name = ((Prim)root).sfCompleteName().toString(); + name = sfResolve(SmartFrogCoreKeys.SF_PROCESS, sfProcessName, false); } catch (Exception ex){ sfLog().ignore(ex);} if (root instanceof ProcessCompound){ isPC =true; @@ -376,6 +374,18 @@ refresh.setActionCommand("refreshButton"); refresh.addActionListener(this); display.mainToolBar.add(this.refresh); + JMenu jMenuMng = new JMenu(); + final JCheckBoxMenuItem jCheckBoxMenuItemShowCDasChild = new JCheckBoxMenuItem(); + jMenuMng.setText("Mng. Console"); + display.jMenuBarDisplay.add(jMenuMng); + jCheckBoxMenuItemShowCDasChild.setSelected(true); + jCheckBoxMenuItemShowCDasChild.setText("Show show CD as child"); + jCheckBoxMenuItemShowCDasChild.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + refresh(); + } + }); + jMenuMng.add(jCheckBoxMenuItemShowCDasChild); display.showToolbar(true); //end panelTree example } @@ -437,10 +447,9 @@ if (root instanceof ComponentDescription) { Object value2 = sfResolve("root",false); - if (!root.equals(value2)){ + if (root!=value2){ isObjCopy = true; } - sfLog().info("JULIO- Checking if we got a copy: " + isObjCopy); } //System.out.println("Refreshing info"); ((DeployTreePanel) panelTree).setModel(root,isObjCopy); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2006-11-16 14:05:11 UTC (rev 3601) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2006-11-16 15:04:32 UTC (rev 3602) @@ -119,8 +119,6 @@ * @return reference of attribute names to this component */ public Reference sfCompleteName() { -// if (sfCompleteName==null) { //No cache. Conflict with Schema error report - Object cdParent = sfResolveParent(); if (cdParent == null) { return new Reference(); @@ -148,12 +146,11 @@ if (key!=null) { sfCompleteName.addElement(ReferencePart.here(key)); } else { - sfCompleteName.addElement(new HereReferencePart("*unknown*")); + sfCompleteName.addElement(new HereReferencePart("*copy*")); if (((sfLog()!= null) && sfLog().isTraceEnabled())){ - sfLog().trace("Internal error generating CD complete name - child not named in parent yet: "+sfCompleteName); + sfLog().trace("Internal error generating CD complete name - CD is a copy: "+sfCompleteName); //or child not named in parent yet } } -// } //cache return sfCompleteName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-12-08 14:39:12
|
Revision: 3705 http://svn.sourceforge.net/smartfrog/?rev=3705&view=rev Author: julgui Date: 2006-12-08 06:39:09 -0800 (Fri, 08 Dec 2006) Log Message: ----------- Minor change to add getEvn to PROPERTY and IPROPERTY Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2006-12-07 17:16:00 UTC (rev 3704) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2006-12-08 14:39:09 UTC (rev 3705) @@ -53,6 +53,7 @@ import java.util.Properties; import java.util.Vector; import org.smartfrog.sfcore.common.Diagnostics; +import org.smartfrog.sfcore.parser.SFParser; /** @@ -121,6 +122,37 @@ } /** + * Entry point to get system environment properties. + * @since java 1.5 + * + * @param key property key to look up + * @param def default to return if key not present + * + * @return property value under key or default if not present + */ + public static String getEnv (String key, String def) { + String res = System.getenv(key); + + if (res == null) { + return def; + } + + return res; + } + + /** + * Common entry point to get environment properties. + * @since java 1.5 + * + * @param key key to look up + * + * @return property value under key + */ + public static String getEnv(String key) { + return System.getenv(key); + } + + /** * Reads properties given a system property "org.smartfrog.iniFile". * * @throws SmartFrogException if failed to read properties from the @@ -601,6 +633,23 @@ } /** + * Creates an object from a String using the language parser selected by language. + * + * @param textToParse text to be parsed + * @param language language. If null then "sf" is used by default. + * @return Object + */ + public static Object parseValue(String textToParse, String language) { + try { + SFParser parser = new SFParser(language); + return parser.sfParseAnyValue( textToParse); + } catch (Throwable ex) { + if (sfLog().isErrorEnabled()) sfLog().error (ex); + } + return null; + } + + /** * get the root process * @return the root process, null for none. */ Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2006-12-07 17:16:00 UTC (rev 3704) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2006-12-08 14:39:09 UTC (rev 3705) @@ -88,12 +88,17 @@ * Constructor for an instance of the parser for the given language. * * @param languageOrUrl the name of the language to use or the url - * with suffixed by language extension. + * with suffixed by language extension. if null the uses sf language by default * * @throws SmartFrogException error crearing instance of parser */ public SFParser(String languageOrUrl) throws SmartFrogException { - theLanguage = getLanguageFromUrl(languageOrUrl); + if (languageOrUrl!=null) { + theLanguage = getLanguageFromUrl(languageOrUrl); + } else { + theLanguage = getLanguageFromUrl("sf"); + } + parser = getParser(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2006-12-11 13:43:27
|
Revision: 3708 http://svn.sourceforge.net/smartfrog/?rev=3708&view=rev Author: steve_l Date: 2006-12-11 05:43:24 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Improving javadocs, including a missing header Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/InterruptHandlerImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2006-12-11 05:18:37 UTC (rev 3707) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2006-12-11 13:43:24 UTC (rev 3708) @@ -243,6 +243,7 @@ * Prints given error string and exits system. * * @param str string to print on out + * @param exitCode exit code to exit with */ public void exitWith(String str, int exitCode) { if (str != null) { @@ -253,9 +254,11 @@ /** - * exit with an error code that depends on the status of the execution - * + * Exit with an error code that depends on the status of the execution + * If somethingFailed==false, we exit with {@link ExitCodes#EXIT_CODE_SUCCESS}. + * Otherwise, the exit code is passed down. * @param somethingFailed flag to indicate trouble + * @param exitCode exit code to exit with. */ public static void exitWithStatus(boolean somethingFailed, int exitCode) { if(somethingFailed) { @@ -290,6 +293,8 @@ * Runs a configuration descripor trapping any possible exception * @param cfgDesc ConfigurationDescriptor * @see ConfigurationDescriptor + * @return whatever came back from calling + * {@link ConfigurationDescriptor#execute(ProcessCompound)} */ public static Object runConfigurationDescriptor (ConfigurationDescriptor cfgDesc) { try { @@ -302,11 +307,12 @@ /** * run whatever action is configured - * @param configuration - * @param throwException + * @param configuration the configuration to run + * @param throwException a flag to control whether exceptions should be thrown or + * caught and logged. * @return whatever came back from calling * {@link ConfigurationDescriptor#execute(ProcessCompound)} - * @throws SmartFrogException + * @throws SmartFrogException if something went wrong and throwException==true. */ public static Object runConfigurationDescriptor(ConfigurationDescriptor configuration, boolean throwException) throws SmartFrogException { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/InterruptHandlerImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/InterruptHandlerImpl.java 2006-12-11 05:18:37 UTC (rev 3707) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/InterruptHandlerImpl.java 2006-12-11 13:43:24 UTC (rev 3708) @@ -1,3 +1,34 @@ +/** (C) Copyright 2006 Hewlett-Packard Development Company, LP + +Disclaimer of Warranty + +The Software is provided "AS IS," without a warranty of any kind. ALL +EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, +INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY +EXCLUDED. SmartFrog is not a Hewlett-Packard Product. The Software has +not undergone complete testing and may contain errors and defects. It +may not function properly and is subject to change or withdrawal at +any time. The user must assume the entire risk of using the +Software. No support or maintenance is provided with the Software by +Hewlett-Packard. Do not install the Software if you are not accustomed +to using experimental software. + +Limitation of Liability + +TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL HEWLETT-PACKARD +OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR +FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, +HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF +OR RELATED TO THE FURNISHING, PERFORMANCE, OR USE OF THE SOFTWARE, OR +THE INABILITY TO USE THE SOFTWARE, EVEN IF HEWLETT-PACKARD HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. FURTHERMORE, SINCE THE +SOFTWARE IS PROVIDED WITHOUT CHARGE, YOU AGREE THAT THERE HAS BEEN NO +BARGAIN MADE FOR ANY ASSUMPTIONS OF LIABILITY OR DAMAGES BY +HEWLETT-PACKARD FOR ANY REASON WHATSOEVER, RELATING TO THE SOFTWARE OR +ITS MEDIA, AND YOU HEREBY WAIVE ANY CLAIM IN THIS REGARD. + +*/ package org.smartfrog.sfcore.processcompound; import sun.misc.SignalHandler; @@ -15,6 +46,9 @@ */ class InterruptHandlerImpl implements SignalHandler,InterruptHandler { + /** + * The old handler. Nothing is done with this this + */ private SignalHandler oldHandler; protected LogSF log; @@ -25,27 +59,23 @@ if (!SFProcess.markProcessCompoundTerminated()) { if (SFProcess.processCompound != null) { try { - //Logger.log("Terminating sfDaemon gracefully!!"); log.out("Terminating sfDaemon gracefully!!"); SFProcess.processCompound.sfTerminate(new TerminationRecord(TerminationRecord.NORMAL, "sfDaemon forced to terminate ", SFProcess.processCompound.sfCompleteName())); } catch (RemoteException re) { - //Logger.log(re); //log and ignore if (log.isIgnoreEnabled()) { log.ignore(re); } } catch (Throwable thr) { - //Logger.log(thr); if (log.isIgnoreEnabled()) { log.ignore(thr); } } } } else { - //Logger.log("sfDaemon killed!"); log.out("sfDaemon killed!"); //http://www.tldp.org/LDP/abs/html/exitcodes.html // 130 - Control-C is fatal error signal 2, (130 = 128 + 2) @@ -59,7 +89,7 @@ * This handler catches the exception and logs it, so that smartfrog * keeps running even if graceful shutdown is broken. * @param name name of interrupt to bind to. - * @param log + * @param log log to log messages to */ public void bind(String name, LogSF log) { this.log=log; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-12-21 16:14:49
|
Revision: 3750 http://svn.sourceforge.net/smartfrog/?rev=3750&view=rev Author: julgui Date: 2006-12-21 08:14:44 -0800 (Thu, 21 Dec 2006) Log Message: ----------- Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFSecurity.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2006-12-21 16:12:14 UTC (rev 3749) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2006-12-21 16:14:44 UTC (rev 3750) @@ -116,6 +116,7 @@ if (attribute[1] != null) { String value = attribute[1].toString(); + System.out.println("value "+attribute[1]+", "+attribute[1].getClass()); if (attribute[1] instanceof ComponentDescription) { StringWriter sw = new StringWriter(); try { @@ -124,8 +125,10 @@ // ignore should not happen if (sfLog().isIgnoreEnabled()) sfLog().ignore (ioex); } + System.out.println("valueAdd "+value+", "+value.getClass()); value = "extends DATA {\n"+ sw.toString()+"\n}"; } + System.out.println("value "+value+", "+value.getClass()); this.ValuejTextArea.setText(value); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java 2006-12-21 16:12:14 UTC (rev 3749) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java 2006-12-21 16:14:44 UTC (rev 3750) @@ -45,7 +45,15 @@ import java.util.Vector; public class LogImpl implements LogSF, LogRegistration, Serializable { +// //check Local java.util.looging log record +// static ThreadLocal localThreadLog = +// new ThreadLocal() { +// protected Log[] initialValue() { +// return new Log[1]; +// } +// }; + /** Default Log object */ protected Log localLog = null; @@ -111,6 +119,36 @@ * @param args args to invoke */ public void invoke (Method method, Object[] args) { +// // Local Thread log/debug info +// Log thrLog = null; +// try { +// Object[] thrCtx = localThreadLog.get(); +// if (thrCtx[0]==null) { +// try { +// thrCtx[0]= new Object[]; +// +// } finally { +// thrCtx[0]=null; +// } +// +// } else { +// thrLog = (Log)localThreadLog[0]; +// method.invoke(thrLog,args); +// } +// } catch (Throwable thr){ +// if(thr instanceof InvocationTargetException) { +// //get a sub throwable here +// thr=thr.getCause(); +// } +// if (localThreadLog!=null) { +// thrLog.error("Error Invoke LogImpl for LocalThread",thr); +// } +// else { +// thr.printStackTrace(); +// } +// } +// // end - Local Thread log/debug info + try { if (localLog!=null) { method.invoke(localLog,args); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFSecurity.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFSecurity.java 2006-12-21 16:12:14 UTC (rev 3749) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFSecurity.java 2006-12-21 16:14:44 UTC (rev 3750) @@ -25,6 +25,8 @@ import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.RMISocketFactory; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMIServerSocketFactory; import java.net.InetAddress; import org.smartfrog.sfcore.processcompound.SFServerSocketFactory; @@ -113,7 +115,12 @@ RMISocketFactory.setSocketFactory(securityEnv.getRMISocketFactory()); securityOn = true; } else { - // Activate a security manager that allows everything. + +// InetAddress rmissfBindAddr = InetAddress.getByName("guijarro-j-3.hpl.hp.com"); +// RMIClientSocketFactory rmicsf = new org.smartfrog.sfcore.processcompound.SFClientSocketFactory(); +// RMIServerSocketFactory rmissf = new org.smartfrog.sfcore.processcompound.SFServerSocketFactory(rmissfBindAddr); +// RMISocketFactory rmisf = new SFRMISocketFactory(rmicsf, rmissf); + System.setSecurityManager(new DummySecurityManager()); securityOn = false; //Notification moved to SFSyten after the ini file is read. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2007-01-15 20:39:47
|
Revision: 3807 http://svn.sourceforge.net/smartfrog/?rev=3807&view=rev Author: steve_l Date: 2007-01-15 12:39:45 -0800 (Mon, 15 Jan 2007) Log Message: ----------- 1. workflow components go into their own file 2. test component moving towards getting a built in condition to wait for the deployment before running the tests. 3. Some work on runshell, nothing major (yet) Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf trunk/core/smartfrog/src/org/smartfrog/services/os/java/library.sf trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShell.java trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/components.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components.sf Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/components.sf Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2007-01-15 20:39:45 UTC (rev 3807) @@ -31,23 +31,22 @@ */ - /** - * Include the core smartfrog components. - */ #include "/org/smartfrog/sfcore/workflow/combinators/sequence.sf" +#include "/org/smartfrog/sfcore/workflow/conditional/conditional.sf" - /* this file declares components that can act as test deployers. - This isthe */ TestCompound extends ActionCompound { TestCompoundSchema extends Schema { + condition extends OptionalCondition { + description "a condition to wait for before running the tests"; + } description extends String { description "description of the test"; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/java/library.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/java/library.sf 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/java/library.sf 2007-01-15 20:39:45 UTC (rev 3807) @@ -247,7 +247,7 @@ //if we do a download, we want it and not some dated version. A limit of ten minutes lets //clients in a cluster share some workload. - maxCacheAge = "600"; + maxCacheAge "600"; //dont download if it is present downloadAlways false; @@ -272,7 +272,7 @@ */ ForcedDownloadArtifact extends LibraryArtifact { downloadAlways true; - maxCacheAge = 0; + maxCacheAge 0; } /** Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShell.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShell.java 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShell.java 2007-01-15 20:39:45 UTC (rev 3807) @@ -31,66 +31,66 @@ */ public interface RunShell extends Remote { /** String for process id. */ - final static String varSFProcessId = "processId"; + String varSFProcessId = "processId"; /** String for process name. */ - final static String varSFProcessName = "processName"; + String varSFProcessName = "processName"; /** String for shell command. */ - final static String varShellCommand = "shellCmd"; + String varShellCommand = "shellCmd"; /** String for commands. They could be Strings or Vectors of Strings. */ - final static String varCMDs = "cmd"; + String varCMDs = "cmd"; /** String for exit command . They could be Strings or * Vectors of Strings. */ - final static String varExitCmd = "exitCmd"; + String varExitCmd = "exitCmd"; /** * String for exit command. Should I use exitCmd at the end of the script? */ - final static String varUseExitCmd = "useExitCmd"; + String varUseExitCmd = "useExitCmd"; /** String for env properties. They could be Strings or * Vectors of Strings. */ - final static String varEnvProp = "envProperties"; + String varEnvProp = "envProperties"; /** * Vector of strings for arguments. */ - final static String varShellArguments = "shellArguments"; + String varShellArguments = "shellArguments"; /** ProcessWorkingDirectory. */ - final static String varSFWorkDir = "workDir"; + String varSFWorkDir = "workDir"; /** LineReturn. */ - final static String varLineReturn = "lineReturn"; + String varLineReturn = "lineReturn"; /** Delay between commands. */ - final static String varDelayBetweenCmds = "delayBetweenCmds"; + String varDelayBetweenCmds = "delayBetweenCmds"; /** Output message to. */ - final static String varOutputMsgTo = "outputMsgTo"; + String varOutputMsgTo = "outputMsgTo"; /** Object that implements org.smartfrog.services.display.PrintMsgInt * /sfServices.sfDisplay uses it. */ - final static String varErrorMsgTo = "errorMsgTo"; + String varErrorMsgTo = "errorMsgTo"; /** Object that implements org.smartfrog.services.display.PrintErrMsgInt * /sfServices.sfDisplay uses it. */ - final static String varOutputStreamTo = "OutputStreamTo"; + String varOutputStreamTo = "OutputStreamTo"; /** Object that implements * org.smartfrog.services.os.runCmd.OutputStreamInt. */ - final static String varErrorStreamTo = "errorStreamTo"; + String varErrorStreamTo = "errorStreamTo"; /** Object that implements * org.smartfrog.services.os.runCmd.InfoStreamInt. */ - final static String varWaitSignalGoAhead = "waitSignalGoAhead"; + String varWaitSignalGoAhead = "waitSignalGoAhead"; /** Should the batch be done step by step?. This indicates if the process * should detach when the spanned shell finishes and before terminating * the component*/ - final static String varShouldDetach = "shouldDetach"; - final static String varShouldTerminate = "shouldTerminate"; + String varShouldDetach = "shouldDetach"; + String varShouldTerminate = "shouldTerminate"; /** Level log. */ - final static String varLogger = "logLevel"; + String varLogger = "logLevel"; /** Print Stack. */ - final static String varPrintStack = "printStack"; + String varPrintStack = "printStack"; /** * status attribute; runtime */ @@ -124,6 +124,6 @@ */ public void execBatch(Vector cmds) throws RemoteException; - // public static final static String SCHEDULER="scheduler"; + // public static String SCHEDULER="scheduler"; // public void shutdown(); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java 2007-01-15 20:39:45 UTC (rev 3807) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2005 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -47,16 +47,7 @@ /** - * This class implements the Compound interface because it can "contain" - * Virtual Hosts components. The Apache interface is the Remoteable interface - * and the Runnable interface is used to monitor the httpd process. The httpd - * process is started in sfStart by setting the apacheState variable to true - * and ended in sfTerminate by setting the apacheState variable to false. The - * Internet Activator scripts are used to edit the httpd.conf file. These rely - * on certain environment variables being set, these variables are defined in - * the sf file and are passed to the common.executeScript() method. Adding them - * to the sf file avoids the need to hard code these paramters. The scripts are - * downloaded from a webserver and are then saved locally. + * This class implements the RunShell component to run a shell of things * */ public class RunShellImpl extends PrimImpl implements Prim, RunShell, Runnable { @@ -169,7 +160,7 @@ * @exception RemoteException In case of network/rmi error */ public synchronized void sfDeploy() throws SmartFrogException, - RemoteException { + RemoteException { try { super.sfDeploy(); helper=new ComponentHelper(this); @@ -178,8 +169,21 @@ //Create subProcess File workDirFile = new File(workDir); + String[] commands = createCmd(shellPrefix, shellCommand, shellCommandAtt); + if (log.isDebugEnabled()) { + StringBuffer buffer=new StringBuffer(); + buffer.append("Running in dir "); + buffer.append(workDirFile); + buffer.append('\n'); + for(int i=0;i<commands.length;i++) { + buffer.append(" '"); + buffer.append(commands[i]); + buffer.append("'\n"); + } + log.debug(buffer); + } subProcess = runtime.exec( - createCmd(shellPrefix,shellCommand, shellCommandAtt), + commands, envProp, workDirFile); dos = new DataOutputStream(subProcess.getOutputStream()); @@ -273,6 +277,8 @@ * Reads SF description = initial configuration. * Override this to read/set properties before we read ours, but remember to call * the superclass afterwards + * @throws SmartFrogException + * @throws RemoteException */ protected void readSFAttributes() throws SmartFrogException, RemoteException { Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/components.sf 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/components.sf 2007-01-15 20:39:45 UTC (rev 3807) @@ -22,40 +22,41 @@ #include "/org/smartfrog/predicates.sf" RunShellSchema extends Schema { - shellCmd extends String; + delayBetweenCmds extends OptionalInteger; + envProperties extends OptionalVector; + errorMsgTo extends Optional; exitCmd extends OptionalString; - workDir extends OptionalString; - envProperties extends OptionalVector; lineReturn extends OptionalString; + logLevel extends OptionalInteger { + description "Log level: 5- info log, 1 - Critical. Use -1 to avoid logging"; + } + outputMsgTo extends Optional; + printStack extends OptionalBoolean; + processID extends OptionalString; + processName extends String; + shellCmd extends String; + shouldDetach extends OptionalBoolean; + shouldTerminate extends OptionalBoolean { + description "terminate the component when the program finishes"; + } + terminateOnFailure extends OptionalBoolean { + description "if shouldTerminate=false, but the program failed, terminate with an error"; + } useExitCmd extends Boolean; + waitSignalGoAhead extends OptionalBoolean; - // 5- info log, 1 - Critical. Use -1 to avoid log - logLevel extends OptionalInteger; - printStack extends OptionalBoolean; - delayBetweenCmds extends OptionalInteger; - shouldDetach extends OptionalBoolean; - processID extends OptionalString; - - /** - * any arguments to the shell - */ - shellArguments extends OptionalVector; + workDir extends OptionalString; + + shellArguments extends OptionalVector { + description "any arguments to the shell"; + } //also, every nested element beginnng with shellCmdAtt //will be added to the list of arguments *after* the shellArguments vector //and every nested element beginnng with shellCmdAtt and ending in 'b' //will be appended to the previous argument. - /** - * terminate on completion - */ - shouldTerminate extends OptionalBoolean; - /** - terminate if the exec failed (only valid if shouldTerminate=false) - */ - terminateOnFailure extends OptionalBoolean; - //some are runtime only /* status extends OptionalString; Added: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/components.sf (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/components.sf 2007-01-15 20:39:45 UTC (rev 3807) @@ -0,0 +1,38 @@ +/** (C) Copyright 2007 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + + +#include "org/smartfrog/sfcore/workflow/combinators/container.sf" +#include "org/smartfrog/sfcore/workflow/combinators/delay.sf" +#include "org/smartfrog/sfcore/workflow/combinators/deployer.sf" +#include "org/smartfrog/sfcore/workflow/combinators/detachingcompound.sf" +#include "org/smartfrog/sfcore/workflow/combinators/during.sf" +#include "org/smartfrog/sfcore/workflow/combinators/finally.sf" +#include "org/smartfrog/sfcore/workflow/combinators/firebreak.sf" +#include "org/smartfrog/sfcore/workflow/combinators/parallel.sf" +#include "org/smartfrog/sfcore/workflow/combinators/randomsequence.sf" +#include "org/smartfrog/sfcore/workflow/combinators/repeat.sf" +#include "org/smartfrog/sfcore/workflow/combinators/retract.sf" +#include "org/smartfrog/sfcore/workflow/combinators/retry.sf" +#include "org/smartfrog/sfcore/workflow/combinators/run.sf" +#include "org/smartfrog/sfcore/workflow/combinators/sequence.sf" +#include "org/smartfrog/sfcore/workflow/combinators/timeout.sf" +#include "org/smartfrog/sfcore/workflow/combinators/try.sf" + Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components.sf 2007-01-15 20:36:34 UTC (rev 3806) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components.sf 2007-01-15 20:39:45 UTC (rev 3807) @@ -20,28 +20,14 @@ /** Defines the basic smartflow components */ -#include "org/smartfrog/sfcore/workflow/eventbus/eventbus.sf" -#include "org/smartfrog/sfcore/workflow/combinators/detachingcompound.sf" -#include "org/smartfrog/sfcore/workflow/combinators/sequence.sf" -#include "org/smartfrog/sfcore/workflow/combinators/container.sf" -#include "org/smartfrog/sfcore/workflow/combinators/firebreak.sf" -#include "org/smartfrog/sfcore/workflow/combinators/parallel.sf" -#include "org/smartfrog/sfcore/workflow/combinators/deployer.sf" -#include "org/smartfrog/sfcore/workflow/combinators/run.sf" -#include "org/smartfrog/sfcore/workflow/combinators/timeout.sf" -#include "org/smartfrog/sfcore/workflow/combinators/delay.sf" -#include "org/smartfrog/sfcore/workflow/combinators/during.sf" -#include "org/smartfrog/sfcore/workflow/combinators/retry.sf" -#include "org/smartfrog/sfcore/workflow/combinators/repeat.sf" -#include "org/smartfrog/sfcore/workflow/combinators/try.sf" -#include "org/smartfrog/sfcore/workflow/combinators/randomsequence.sf" -#include "org/smartfrog/sfcore/workflow/combinators/retract.sf" -#include "org/smartfrog/sfcore/workflow/components/doNothing.sf" -#include "org/smartfrog/sfcore/workflow/components/eventSend.sf" -#include "org/smartfrog/sfcore/workflow/components/onEvent.sf" -#include "org/smartfrog/sfcore/workflow/components/terminator.sf" -#include "org/smartfrog/sfcore/workflow/components/attribute.sf" -#include "org/smartfrog/sfcore/workflow/components/eventCounter.sf" -#include "org/smartfrog/sfcore/workflow/components/eventQueue.sf" +#include "/org/smartfrog/sfcore/workflow/eventbus/eventbus.sf" +#include "/org/smartfrog/sfcore/workflow/combinators/components.sf" +#include "/org/smartfrog/sfcore/workflow/components/doNothing.sf" +#include "/org/smartfrog/sfcore/workflow/components/eventSend.sf" +#include "/org/smartfrog/sfcore/workflow/components/onEvent.sf" +#include "/org/smartfrog/sfcore/workflow/components/terminator.sf" +#include "/org/smartfrog/sfcore/workflow/components/attribute.sf" +#include "/org/smartfrog/sfcore/workflow/components/eventCounter.sf" +#include "/org/smartfrog/sfcore/workflow/components/eventQueue.sf" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2007-01-18 14:47:39
|
Revision: 3816 http://svn.sourceforge.net/smartfrog/?rev=3816&view=rev Author: steve_l Date: 2007-01-18 06:47:32 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Lots of condition work. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Finally.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/ConditionCompound.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/Conditional.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/LivenessTestImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/components.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/conditional.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateCondition.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateConditionImpl.java Removed Paths: ------------- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestCondition.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestConditionImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlock.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -116,4 +116,11 @@ * @throws SmartFrogException on other problems */ Prim getAction() throws RemoteException, SmartFrogException; + + /** + * turn true if a test is skipped; if some condition caused + * it not to run + * @return whether or not the test block skipped deployment of children. + */ + boolean isSkipped() throws RemoteException, SmartFrogException; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -90,6 +90,13 @@ return child; } + /** + * {@inheritDoc} + * @return false always + */ + public boolean isSkipped() { + return false; + } /** * Registers components referenced in the SendTo sub-component registers Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompound.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -19,16 +19,24 @@ */ package org.smartfrog.services.assertions; +import org.smartfrog.sfcore.workflow.conditional.Conditional; + /** * created 22-Sep-2006 16:13:38 */ -public interface TestCompound extends TestBlock { +public interface TestCompound extends TestBlock, Conditional { /** + * A condition to wait for, before running the tests. + * {@value} + */ + String ATTR_WAITFOR ="waitFor"; + + /** * time in milliseconds to undeploy the action; use -1 for no limit. * {@value} */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -22,11 +22,10 @@ import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLivenessException; -import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.workflow.eventbus.EventCompoundImpl; import org.smartfrog.sfcore.workflow.combinators.DelayedTerminator; +import org.smartfrog.sfcore.workflow.conditional.ConditionCompound; import org.smartfrog.sfcore.utils.ComponentHelper; import org.smartfrog.sfcore.utils.ShouldDetachOrTerminate; import org.smartfrog.sfcore.componentdescription.ComponentDescription; @@ -37,13 +36,13 @@ * created 22-Sep-2006 16:43:35 */ -public class TestCompoundImpl extends EventCompoundImpl +public class TestCompoundImpl extends ConditionCompound implements TestCompound { private ComponentDescription teardownCD; private Prim teardown; - + private ComponentDescription waitForCD; private ComponentDescription tests; - private Prim testsPrim; + private Prim waitFor,testsPrim; protected static final String ACTION_RUNNING = ATTR_ACTION; protected static final String TESTS_RUNNING = ATTR_TESTS; @@ -60,6 +59,7 @@ private volatile boolean failed = false; private volatile boolean succeeded = false; private volatile boolean forcedTimeout = false; + private volatile boolean skipped = false; private volatile TerminationRecord status; /** @@ -74,13 +74,13 @@ public TestCompoundImpl() throws RemoteException { } - /** * {@inheritDoc} - * @return false + * + * @return the skipped state */ - protected boolean isOldNotationSupported() { - return false; + public boolean isSkipped() { + return skipped; } /** @@ -95,14 +95,14 @@ public synchronized void sfDeploy() throws SmartFrogException, RemoteException { super.sfDeploy(); + //look for the action checkActionDefined(); name = sfCompleteNameSafe(); + + waitForCD = sfResolve(ATTR_WAITFOR, waitForCD, false); tests = sfResolve(ATTR_TESTS, tests, false); testTimeout = sfResolve(ATTR_TEST_TIMEOUT, 0L, true); - teardownCD = sfResolve(ATTR_TEARDOWN, teardownCD, false); - if (teardownCD != null) { - throw new SmartFrogException("Not yet supported " + ATTR_TEARDOWN); - } + //teardownCD = sfResolve(ATTR_TEARDOWN, teardownCD, false); undeployAfter = sfResolve(ATTR_UNDEPLOY_AFTER, 0L, true); expectTerminate = sfResolve(ATTR_EXPECT_TERMINATE, false, true); exitType = sfResolve(ATTR_EXIT_TYPE, exitType, true); @@ -112,27 +112,54 @@ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - LogSF logSF = sfLog(); Exception exception=null; + //deploy and evaluate the condition. + //then decide whether to run or not. + if (!evaluate()) { + skipped=true; + sfLog().info("Skipping test run " + name); + finish(); + //end do not deploy anything else + return; + } + //deploy the action under a terminator, then the assertions, finally teardown afterwards. try { - actionPrim = deployAction(); - actionTerminator = new DelayedTerminator(actionPrim, undeployAfter, logSF, - FORCED_TERMINATION, - !expectTerminate); - actionTerminator.start(); - } catch (RemoteException e) { - if (TerminationRecord.NORMAL.equals(exitType)) { - throw e; - } - exception=e; + actionPrim = deployComponentDescription(ACTION_RUNNING, action); } catch (SmartFrogDeploymentException e) { //split on normal/abnormal. - if(TerminationRecord.NORMAL.equals(exitType)) { + if (TerminationRecord.NORMAL.equals(exitType)) { throw e; } exception = e; } + + if(exception==null) { + //the teardown CD is deployed at this time, but not started. + //it is brought to life during termination. + if (teardownCD != null) { + teardown = deployComponentDescription(ATTR_TEARDOWN, teardownCD); + } + + //if we get here. then it is time to start the action. + //exceptions are caught and compared to expectations. + try { + actionPrim.sfStart(); + } catch (SmartFrogException e) { + //split on normal/abnormal. + if (TerminationRecord.NORMAL.equals(exitType)) { + throw e; + } + exception = e; + + } catch (RemoteException e) { + if (TerminationRecord.NORMAL.equals(exitType)) { + throw e; + } + exception = e; + } + } + //did we catch something during deployment? if (exception!=null) { //get the message and check it against expections @@ -151,13 +178,28 @@ null,null,exception); } + //start the terminator + actionTerminator.start(); + actionTerminator = new DelayedTerminator(actionPrim, undeployAfter, sfLog(), + FORCED_TERMINATION, + !expectTerminate); + //now deploy the tests. //any failure in tests is something to report, as is any failure of the tests to finish. + startTests(); + } + + /** + * Start the test runner and a terminator + * @throws RemoteException + * @throws SmartFrogDeploymentException + */ + private void startTests() throws RemoteException, SmartFrogDeploymentException { if(tests !=null) { testsPrim = sfCreateNewChild(TESTS_RUNNING, tests, null); //the test terminator reports a termination as a failure - testsTerminator = new DelayedTerminator(testsPrim, testTimeout, logSF, + testsTerminator = new DelayedTerminator(testsPrim, testTimeout, sfLog(), FORCED_TERMINATION, false); testsTerminator.start(); @@ -198,6 +240,15 @@ */ public synchronized void sfTerminateWith(TerminationRecord status) { super.sfTerminateWith(status); + if (teardown != null) { + try { + teardown.sfStart(); + } catch (SmartFrogException e) { + sfLog().info("When starting the teardown action", e); + } catch (RemoteException e) { + sfLog().info("When starting the teardown action", e); + } + } shutdown(actionTerminator); shutdown(testsTerminator); } @@ -328,12 +379,6 @@ } - protected Prim deployAction() throws RemoteException, SmartFrogDeploymentException { - Prim child = sfCreateNewChild(ACTION_RUNNING, action, null); - return child; - } - - /** * Return true iff the component is finished. Spin on this, with a (delay) * between calls Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/testcomponents.sf 2007-01-18 14:47:32 UTC (rev 3816) @@ -31,22 +31,50 @@ */ -#include "/org/smartfrog/sfcore/workflow/combinators/sequence.sf" -#include "/org/smartfrog/sfcore/workflow/conditional/conditional.sf" +#include "/org/smartfrog/sfcore/workflow/conditional/components.sf" +#include "/org/smartfrog/sfcore/workflow/combinators/components.sf" +#include "/org/smartfrog/sfcore/workflow/conditional/conditions/components.sf" - /* this file declares components that can act as test deployers. + * This is the workflow implemented by this component + * sfDeploy: + * -all attributes are read, validated. + * sfStart: + * -"condition" is deployed and evaluated. If false, the component skips all other work and goes to + * workflow termination. + * -"action" is deployed. + * -"teardown" is deployed, for starting later + * -"action" is started. + * -if action deployment or startup raised an exception, if exitType=="normal" then + * the exception is rethrown. If exitType=="abnormal", then exitText is looked for + * in the exception string; a match implies an expected failure => normal termination + * -the action terminator is started + * -the tests are run + * + * The effect is only run the tests if startup worked. + * + * sfTerminateWith + * -the teardown component is started + * -the application is terminated + * -the tests are terminated + * 2007-01: the teardown code is disabled. Use the workflow to better + * choreograph teardown */ TestCompound extends ActionCompound { TestCompoundSchema extends Schema { condition extends OptionalCondition { - description "a condition to wait for before running the tests"; + description "a condition to evaluate to decide whether to run this test or not"; } + /* + waitFor extends OptionalCondition { + description "a condition to wait for, before running the tests"; + } + */ description extends String { description "description of the test"; } @@ -137,8 +165,34 @@ } +/** + * This component uses workflow components to delay the tests + * until the waitFor condition evaluates to true. + */ DeploySequence extends TestCompound { + waitFor extends True; + //time in ms to give up + waitForTimeout 10000; + //interval in ms between checks + waitForInterval 200; + + testrun extends Sequence { + //insert tests here + } + + //override the normal sequence with the waiting one + tests extends Sequence { + + wait extends FailingWaitFor { + condition PARENT:PARENT:waitFor; + interval waitForInterval; + timeout waitForTimeout; + } + + testrun PARENT:PARENT:sequence; + + } } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ComponentHelper.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -29,6 +29,7 @@ import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.common.TerminatorThread; import org.smartfrog.sfcore.security.SFClassLoader; +import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.services.filesystem.FileSystem; import java.rmi.RemoteException; @@ -131,6 +132,26 @@ } /** + * Get the short name of a component. + * + * @return the final name in the list, or null for no match + * @throws RemoteException network trouble + */ + public String shortName() throws RemoteException { + Object key; + if (owner.sfParent() == null) { + key = SFProcess.getProcessCompound().sfAttributeKeyFor(this); + } else { + key = owner.sfParent().sfAttributeKeyFor(this); + } + if (key != null) { + return key.toString(); + } else { + return null; + } + } + + /** * Resolve an attribute without complaining if something went wrong * even a remote exception. * @param attribute attribute name @@ -456,4 +477,5 @@ return implementsInterface(clazz.getSuperclass(),interfaceName); } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Finally.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Finally.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/Finally.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -5,11 +5,11 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLifecycleException; import org.smartfrog.sfcore.common.ContextImpl; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.utils.ComponentHelper; -import org.smartfrog.sfcore.logging.Log; import java.rmi.RemoteException; @@ -26,7 +26,6 @@ private Prim finallyPrim; private static final String FINALLY_CHILD_NAME = "action"; - protected ComponentHelper helper; /** * Constructs Try. @@ -58,21 +57,9 @@ */ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - sfCreateNewChild(FINALLY_CHILD_NAME, action, null); //Copies component description before deploying it! - finallyPrim = sfDeployComponentDescription(FINALLY_CHILD_NAME, this, (ComponentDescription) action.copy(), new ContextImpl()); - // it is now a child, so need to guard against double calling of lifecycle... - try { - finallyPrim.sfDeploy(); - } catch (Throwable thrown) { - //forget about the finally component as we did not deploy properly. - helper = new ComponentHelper(finallyPrim); - finallyPrim = null; - helper.sfSelfDetachAndOrTerminate(TerminationRecord.ABNORMAL, - "failed to create", null, thrown); - throw (SmartFrogLifecycleException) SmartFrogLifecycleException.forward(thrown); - } + finallyPrim= deployComponentDescription(FINALLY_CHILD_NAME, action); } public synchronized void sfTerminateWith(TerminationRecord status) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/ConditionCompound.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/ConditionCompound.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/ConditionCompound.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -66,14 +66,29 @@ deployCondition(); } + /** + * Override point: is the condition required. IF not, there is no attemtp to deploy it at startup + * @return + */ + protected boolean isConditionRequired() { + return true; + } + + /** + * Deploy the condition. + * @see #isConditionRequired() + * @throws SmartFrogResolutionException if the condition is required, and it is not there, or the condition + * itself fails to deploy. + * @throws RemoteException network problems + * @throws SmartFrogDeploymentException deployment problems + */ protected void deployCondition() throws SmartFrogResolutionException, RemoteException, SmartFrogDeploymentException { - condition = (Condition) deployChildCD(ATTR_CONDITION, true); + condition = (Condition) deployChildCD(ATTR_CONDITION, isConditionRequired()); } - /** * Get the condition - * @return + * @return the deployed condition or null if there is none active */ public Condition getCondition() { return condition; @@ -82,20 +97,36 @@ /** * Evaluate the condition by delegating to the underlying condition. - * + * throws an exception if there is no deployed condition. * @return true if it is successful, false if not * @throws java.rmi.RemoteException for network problems * @throws org.smartfrog.sfcore.common.SmartFrogException * for any other problem */ public synchronized boolean evaluate() throws RemoteException, SmartFrogException { + if(condition==null) { + return onEvaluateNoCondition(); + } return condition.evaluate(); } /** - * called after our work is done to trigger termination + * Override point. Handle a missing condition + * @return the value of the condition. + * @throws SmartFrogException throws an exception as there is no deployed condition. */ + protected boolean onEvaluateNoCondition() throws SmartFrogException { + throw new SmartFrogException("Cannot evaluate the condition as it is not present, or has not been deployed"); + } + + /** + * called after our work is done to trigger termination if the sfTerminate attribute + * recommends it. + */ protected synchronized void finish() { - new ComponentHelper(this).targetForWorkflowTermination(TerminationRecord.normal(this.name)); + new ComponentHelper(this).sfSelfDetachAndOrTerminate(TerminationRecord.normal(name)); } + + + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/Conditional.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/Conditional.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/Conditional.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -29,6 +29,10 @@ public interface Conditional extends Remote { + /** + * attribute containing a condition + * {@value} + * */ String ATTR_CONDITION="condition"; } Copied: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateCondition.java (from rev 3811, trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestCondition.java) =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateCondition.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateCondition.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -0,0 +1,37 @@ +/** (C) Copyright 2006 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ +package org.smartfrog.sfcore.workflow.conditional; + +/** + * created 30-Nov-2006 13:25:58 + */ + + +public interface EvaluateCondition extends Conditional { + + /** {@value} */ + String ATTR_MESSAGE="message"; + + /** {@value} */ + String ATTR_FAIL_ON_FALSE="failOnFalse"; + + /** {@value} */ + String ATTR_RESULT="result"; +} Copied: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateConditionImpl.java (from rev 3811, trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestConditionImpl.java) =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateConditionImpl.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/EvaluateConditionImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -0,0 +1,69 @@ +/** (C) Copyright 2006-2007 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ +package org.smartfrog.sfcore.workflow.conditional; + +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.rmi.RemoteException; + +/** + * created 30-Nov-2006 13:26:41 + */ + +public class EvaluateConditionImpl extends ConditionCompound implements EvaluateCondition { + private String message; + private boolean failOnFalse; + + + public EvaluateConditionImpl() throws RemoteException { + + } + + /** + * Starts the component by deploying the condition + * + * @throws SmartFrogException in case of problems + * @throws RemoteException In case of network/rmi error + */ + public synchronized void sfStart() throws SmartFrogException, RemoteException { + super.sfStart(); + message =sfResolve(ATTR_MESSAGE, "",true); + failOnFalse = sfResolve(ATTR_FAIL_ON_FALSE, false, true); + startupTest(); + } + + /** + * This is the test that runs on startup. Override it to change the startup behaviour + * @throws SmartFrogException in case of problems + * @throws RemoteException In case of network/rmi error + */ + protected void startupTest() throws SmartFrogException, RemoteException { + testCondition(); + finish(); + } + + protected void testCondition() throws SmartFrogException, RemoteException { + boolean result = evaluate(); + sfReplaceAttribute(ATTR_RESULT,Boolean.valueOf(result)); + if(!result && failOnFalse) { + throw new SmartFrogException(message); + } + } +} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/LivenessTestImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/LivenessTestImpl.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/LivenessTestImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -28,7 +28,7 @@ * created 30-Nov-2006 13:33:13 */ -public class LivenessTestImpl extends TestConditionImpl implements TestCondition { +public class LivenessTestImpl extends EvaluateConditionImpl implements EvaluateCondition { public LivenessTestImpl() throws RemoteException { Deleted: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestCondition.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestCondition.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestCondition.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -1,30 +0,0 @@ -/** (C) Copyright 2006 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ -package org.smartfrog.sfcore.workflow.conditional; - -/** - * created 30-Nov-2006 13:25:58 - */ - - -public interface TestCondition extends Conditional { - - String ATTR_MESSAGE="message"; -} Deleted: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestConditionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestConditionImpl.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/TestConditionImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -1,60 +0,0 @@ -/** (C) Copyright 2006 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ -package org.smartfrog.sfcore.workflow.conditional; - -import org.smartfrog.sfcore.common.SmartFrogException; - -import java.rmi.RemoteException; - -/** - * created 30-Nov-2006 13:26:41 - */ - -public class TestConditionImpl extends ConditionCompound implements TestCondition { - private String message; - - - public TestConditionImpl() throws RemoteException { - - } - - /** - * Starts the component by deploying the condition - * - * @throws org.smartfrog.sfcore.common.SmartFrogException - * in case of problems creating the child - * @throws java.rmi.RemoteException In case of network/rmi error - */ - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - message =sfResolve(ATTR_MESSAGE, "",true); - } - - protected void startupTest() throws SmartFrogException, RemoteException { - testCondition(); - finish(); - } - - protected void testCondition() throws SmartFrogException, RemoteException { - if(!evaluate()) { - throw new SmartFrogException(message); - } - } -} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/components.sf 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/components.sf 2007-01-18 14:47:32 UTC (rev 3816) @@ -41,11 +41,8 @@ * unless sfShouldTerminate is set to false. */ -ConditionalEventCompound extends EventCompound { - conditionalSchema extends ConditionalSchema; - sfShouldTerminate true; -} + /** * Deploy one of two children, depending upon the result of the condition */ @@ -90,17 +87,26 @@ /** - * This component tests the condition at startup, and fails if it - * is not met + * This component tests the condition at startup, and can fail if it + * is not met. + * + * After evaluation, the attribute "result" is set to the outcome. This + * lets the component be used to generate a LAZY binding attribute for + * feeding in to components that take a simple boolean attribute instead + * of a full condition. */ -TestCondition extends ConditionalEventCompound { - testConditionSchema extends Schema { +EvaluateCondition extends ConditionalEventCompound { + evaluateConditionSchema extends Schema { + failOnFalse extends Boolean { + description "flag to indicate that the component should terminate with an error on a false condition"; + } message extends String { description "error text on failure"; }; } sfClass "org.smartfrog.sfcore.workflow.conditional.TestConditionImpl"; - message "Test condition failed"; + message "Condition evaluated to false"; + failOnFalse true; } /** @@ -112,7 +118,7 @@ * The component declares itself non-terminating, so that it remains deployed until * its parent is terminated. */ -LivenessTest extends TestCondition { +LivenessTest extends EvaluateCondition { message "Liveness condition failed"; sfClass "org.smartfrog.sfcore.workflow.conditional.TestConditionImpl"; sfShouldTerminate false; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/conditional.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/conditional.sf 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/conditional.sf 2007-01-18 14:47:32 UTC (rev 3816) @@ -46,7 +46,14 @@ */ ConditionalEventCompound extends EventCompound { - sfClass "org.smartfrog.sfcore.workflow.conditions.ConditionalEventCompound"; + sfClass "org.smartfrog.sfcore.workflow.conditional.ConditionCompound"; conditionalSchema extends ConditionalSchema; sfShouldTerminate true; +} + +/** + * a conditional event compound with an optional schema + */ +OptionalConditionalEventCompound extends ConditionalEventCompound { + conditionalSchema:condition extends OptionalCondition; } \ No newline at end of file Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2007-01-18 14:44:58 UTC (rev 3815) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/eventbus/EventCompoundImpl.java 2007-01-18 14:47:32 UTC (rev 3816) @@ -37,6 +37,7 @@ import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.ContextImpl; import org.smartfrog.sfcore.common.*; +import org.smartfrog.sfcore.utils.ComponentHelper; /** @@ -447,4 +448,29 @@ return null; } } + + /** + * Deploy but do not start a component. If something went wrong with sfDeploy(), we start a termination of the errant + * component and raise a lifecycle exception. + * @param name + * @param description + * @return the new child + * @throws SmartFrogDeploymentException + * @throws SmartFrogLifecycleException + */ + protected Prim deployComponentDescription(String name, ComponentDescription description) throws SmartFrogDeploymentException, SmartFrogLifecycleException { + Prim child = sfDeployComponentDescription(name, this, (ComponentDescription) description.copy(), new ContextImpl()); + // it is now a child, so need to guard against double calling of lifecycle... + try { + child.sfDeploy(); + } catch (Throwable thrown) { + //forget about the finally component as we did not deploy properly. + ComponentHelper helper = new ComponentHelper(child); + child = null; + helper.sfSelfDetachAndOrTerminate(TerminationRecord.ABNORMAL, + "failed to create "+name, null, thrown); + throw (SmartFrogLifecycleException) SmartFrogLifecycleException.forward(thrown); + } + return child; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-02-07 16:44:06
|
Revision: 3871 http://svn.sourceforge.net/smartfrog/?rev=3871&view=rev Author: julgui Date: 2007-02-07 08:43:55 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Added: new "sfFunctionLazy" attribute to functions to delay resolution until runtime. SFOS-68 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/functions.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/ConstructFunction.java Modified: trunk/core/smartfrog/src/org/smartfrog/functions.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/functions.sf 2007-02-07 16:14:44 UTC (rev 3870) +++ trunk/core/smartfrog/src/org/smartfrog/functions.sf 2007-02-07 16:43:55 UTC (rev 3871) @@ -22,6 +22,7 @@ Function extends { phase.function "org.smartfrog.sfcore.languages.sf.ConstructFunction"; sfFunctionClass ""; + //sfFunctionLazy false; } vector extends Function{ Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/ConstructFunction.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/ConstructFunction.java 2007-02-07 16:14:44 UTC (rev 3870) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/ConstructFunction.java 2007-02-07 16:43:55 UTC (rev 3871) @@ -8,6 +8,7 @@ import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.common.SmartFrogFunctionResolutionException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.reference.Reference; import java.util.Stack; import java.util.Iterator; @@ -17,6 +18,7 @@ */ public class ConstructFunction implements PhaseAction { final static String functionClass = "sfFunctionClass"; + final static String functionLazy = "sfFunctionLazy"; final static String functionPhase = "phase.function"; // do the work @@ -57,7 +59,14 @@ ComponentDescription parent = cd.sfParent(); if (parent != null) { Object name = parent.sfContext().keyFor(cd); - parent.sfContext().put(name, new SFApplyReference(comp)); + Reference newRef = new SFApplyReference(comp); + try { + // LAZY = false eager; + newRef.setEager(!cd.sfResolve(functionLazy,false,false)); + } catch (SmartFrogRuntimeException e) { + throw new SmartFrogFunctionResolutionException("Problem reading ("+functionLazy+"): " + phaseName + " for component: " + cd.sfCompleteName(), e); + } + parent.sfContext().put(name, newRef ); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-03-14 18:42:38
|
Revision: 3983 http://svn.sourceforge.net/smartfrog/?rev=3983&view=rev Author: julgui Date: 2007-03-14 11:41:25 -0700 (Wed, 14 Mar 2007) Log Message: ----------- Improved sfCompleteName for copied CD. from "*copy*" to "name*copy*" when possible. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-03-14 17:49:20 UTC (rev 3982) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-03-14 18:41:25 UTC (rev 3983) @@ -427,7 +427,7 @@ void remove() { Object obj = getNode(); //we need to check is the parent is a copy - if (isParentNodeACopy() || getRDNNode().equals("*copy*") ) { + if (isParentNodeACopy() || getRDNNode().endsWith("*copy*") ) { String msg = "The node selected is a copy and no action can be applied\n Use a console running in the local process of this node"; if (sfLog().isErrorEnabled()) sfLog().error (msg); WindowUtilities.showError(this,msg); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-03-14 17:49:20 UTC (rev 3982) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-03-14 18:41:25 UTC (rev 3983) @@ -144,7 +144,20 @@ if (key!=null) { sfCompleteName.addElement(ReferencePart.here(key)); } else { - sfCompleteName.addElement(new HereReferencePart("*copy*")); + //NOTE: this is a best effort name. It will not work if there are two attributes with equal + // descriptions because it will always use the name of the first one. Not so relevant because + // we cannot make changes in a copy that would have effect in the remote component. + String name = ""; + try { + // we only obtain a copy when going through a remote object + if (cdParent instanceof Prim){ + Object keyName = ((Prim)cdParent).sfContext().sfAttributeKeyForEqual(this); + if (keyName!=null) name=keyName.toString(); + } + } catch (Throwable e) { + if (sfLog().isIgnoreEnabled()) { sfLog().ignore("Problem trying to get the real name of a copied CD",e);} + } + sfCompleteName.addElement(new HereReferencePart(name+"*copy*")); if (((sfLog()!= null) && sfLog().isTraceEnabled())){ sfLog().trace("Internal error generating CD complete name - CD is a copy: "+sfCompleteName); //or child not named in parent yet } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2007-03-21 17:04:32
|
Revision: 3998 http://svn.sourceforge.net/smartfrog/?rev=3998&view=rev Author: steve_l Date: 2007-03-21 10:02:49 -0700 (Wed, 21 Mar 2007) Log Message: ----------- maybe this will make an intermittent failure in the parallel tests (Assumed to be a race condition) go away Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2007-03-21 15:14:56 UTC (rev 3997) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2007-03-21 17:02:49 UTC (rev 3998) @@ -43,7 +43,7 @@ private volatile boolean forcedTimeout = false; private volatile TerminationRecord status; private DelayedTerminator actionTerminator; - private volatile Prim child; + private volatile Prim actionPrim; public static final String ERROR_STARTUP_FAILURE = "Failed to start up action"; public TestBlockImpl() throws RemoteException { @@ -88,7 +88,7 @@ * @return the child component. this will be null after termination. */ public Prim getAction() { - return child; + return actionPrim; } /** @@ -128,9 +128,9 @@ long timeout = sfResolve(ATTR_TIMEOUT,0L,true); boolean expectTimeout=sfResolve(ATTR_EXPECTTIMEOUT,false,true); try { - child=sfCreateNewChild(ACTION,action, null); + actionPrim =sfCreateNewChild(ACTION,action, null); if(timeout>0) { - actionTerminator=new DelayedTerminator(child, timeout, sfLog(),"timeout",expectTimeout); + actionTerminator=new DelayedTerminator(actionPrim, timeout, sfLog(),"timeout",expectTimeout); actionTerminator.start(); } } catch (RemoteException e) { @@ -202,10 +202,10 @@ */ protected boolean onChildTerminated(TerminationRecord status, Prim comp) throws SmartFrogRuntimeException, RemoteException { - if(comp==child) { + if(comp == actionPrim) { //this is the action terminating, //forget about our now-terminated child (it cannot be serialized any more) - child=null; + actionPrim =null; //log the closure and continue end(status); return false; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2007-03-21 15:14:56 UTC (rev 3997) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/DelayedTerminator.java 2007-03-21 17:02:49 UTC (rev 3998) @@ -140,25 +140,25 @@ log.debug("Interrupted " + description); } + Prim target=null; + TerminationRecord record=null; synchronized (this) { try { if (shutdown) { - //initiated shutdown log.debug("initiated shutdown " + description); } if (shouldTerminate) { //termination time - Prim target = getTarget(); + target = getTarget(); if (target == null) { log.debug("Target no longer exists for " + description); } else { try { if (target.sfIsStarted()) { - forcedShutdown = true; - TerminationRecord record = createTerminationRecord(target); - target.sfTerminate(record); + setForcedShutdown(true); + record = createTerminationRecord(target); } } catch (RemoteException e) { terminationFault = e; @@ -170,6 +170,15 @@ self = null; primref = null; } + //now do a shutdown, outside the sychronized area. This means we have updated our expectations before + //we actually force the termination + if(record!=null) { + try { + target.sfTerminate(record); + } catch (RemoteException e) { + terminationFault = e; + } + } } } @@ -194,4 +203,9 @@ public synchronized boolean isForcedShutdown() { return forcedShutdown; } + + + public synchronized void setForcedShutdown(boolean forcedShutdown) { + this.forcedShutdown = forcedShutdown; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-05-16 15:57:55
|
Revision: 4140 http://svn.sourceforge.net/smartfrog/?rev=4140&view=rev Author: julgui Date: 2007-05-16 08:57:53 -0700 (Wed, 16 May 2007) Log Message: ----------- SFOS-130 Management Console: Added support for editing attribute tags Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployMgnt.java trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/DefaultParser.jj trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/SFParser.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/DefaultParser.jj trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/SFParser.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/Parser.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamLanguageParser.java trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamParser.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployMgnt.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployMgnt.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployMgnt.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -24,7 +24,9 @@ import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import java.util.Set; + /** * Class used for deploy management. * Proxy for management operations in Prim SmartFrog components. @@ -77,11 +79,17 @@ *@param attribValue Value of the attribute *@throws Exception If any error */ - public static void modifyAttribute(Object obj, Object attribName, Object attribValue) throws Exception { + public static void modifyAttribute(Object obj, Object attribName, Object attribValue, Object attribTags) throws Exception { if (obj instanceof Prim) { ((Prim)obj).sfReplaceAttribute(attribName, attribValue); + if (attribTags != null){ + ((Prim)obj).sfAddTags(attribName,(Set)attribTags); + } } else if (obj instanceof ComponentDescription){ ((ComponentDescription)obj).sfReplaceAttribute(attribName, attribValue); + if (attribTags != null){ + ((ComponentDescription)obj).sfAddTags(attribName,(Set)attribTags); + } } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -32,6 +32,7 @@ import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.common.ContextImpl; +import org.smartfrog.services.display.WindowUtilities; import javax.swing.*; import java.awt.*; @@ -50,12 +51,15 @@ private JButton jButtonSave = new JButton(); /** Cancel Button. */ private JButton jButtonCancel = new JButton(); - /** Label type. */ - private JLabel jLabelType = new JLabel(); + /** Label name. */ private JLabel jLabelName = new JLabel(); /** Text filed. */ private JTextField NamejTextField = new JTextField(); + /** Label name. */ + private JLabel jLabelTags = new JLabel(); + /** Text filed. */ + private JTextField tagsjTextField = new JTextField(); /** Label value. */ private JLabel jLabelValue = new JLabel(); /** Scrool pane. */ @@ -78,8 +82,7 @@ * @param modal modal * @param attribute set of attributes */ - public NewAttributeDialog(Frame frame, String title, boolean modal, - Object[] attribute) { + public NewAttributeDialog(Frame frame, String title, boolean modal, Object[] attribute) { super(frame, title, modal); this.attribute = attribute; @@ -106,6 +109,9 @@ } this.ValuejTextArea.setText(value); } + if (attribute[2] != null) { + this.tagsjTextField.setText(attribute[2].toString()); + } } } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error (ex); @@ -132,43 +138,54 @@ jButtonCancel_actionPerformed(e); } }); - //jLabelType.setText("Value"); + jLabelName.setText("Name"); - NamejTextField.setNextFocusableComponent(ValuejTextArea); + NamejTextField.setNextFocusableComponent(tagsjTextField); NamejTextField.setText(""); + + jLabelTags.setText("Tags"); + tagsjTextField.setNextFocusableComponent(ValuejTextArea); + tagsjTextField.setText(""); + jLabelValue.setText("Value"); ValuejTextArea.setNextFocusableComponent(jButtonSave); panel.setMinimumSize(new Dimension(550, 300)); panel.setPreferredSize(new Dimension(550, 300)); jLabel1.setText("(use SF syntax)"); - getContentPane().add(panel); -// panel.add(TypejComboBox, -// new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, -// GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, -// new Insets(15, 13, 0, 23), 151, 0)); + getContentPane().add(panel); + //Name panel.add(NamejTextField, - new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(17, 13, 0, 23), 302, 0)); + new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(17, 13, 0, 23), 302, 0)); panel.add(jLabelName, - new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(17, 24, 0, 0), 0, 0)); - // panel.add(jLabelType, - // new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - // ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(17, 24, 0, 8), 0, 0)); + new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(17, 24, 0, 0), 0, 0)); + //Tags + panel.add(jLabelTags, + new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(17, 24, 0, 8), 0, 0)); + panel.add(tagsjTextField, + new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, + GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(15, 13, 0, 23), 151, 0)); + //Buttons panel.add(jButtonCancel, - new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 22, 13, 89), 0, 0)); + new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 22, 13, 89), 0, 0)); panel.add(jButtonSave, - new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 85, 13, 0), 12, 0)); - panel.add(jScrollPane1, - new GridBagConstraints(1, 1, 2, 2, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(19, 13, 0, 23), 300, 130)); - panel.add(jLabelValue, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(13, 24, 0, 0), 0, 0)); - panel.add(jLabel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - jScrollPane1.getViewport().add(ValuejTextArea, null); + new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 85, 13, 0), 12, 0)); + //Value + panel.add(jScrollPane1, + new GridBagConstraints(1, 2, 2, 2, 1.0, 1.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(19, 13, 0, 23), 300, 130)); + panel.add(jLabelValue, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(13, 24, 0, 0), 0, 0)); + panel.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 + , GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + + jScrollPane1.getViewport().add(ValuejTextArea, null); + } /** @@ -178,13 +195,20 @@ void jButtonSave_actionPerformed(ActionEvent e) { //Save values in parent! //Return with attribute value pair. Array[]; - if ((this.NamejTextField.getText() != null) && - (!this.NamejTextField.getText().equals(""))) { - attribute[0] = this.NamejTextField.getText(); - attribute[1] = parseValue(ValuejTextArea.getText(),"sf"); - } else { - attribute[0] = null; - attribute[1] = null; + try { + if ((this.NamejTextField.getText() != null) && + (!this.NamejTextField.getText().equals(""))) { + attribute[0] = this.NamejTextField.getText(); + attribute[1] = parseValue(ValuejTextArea.getText(),"sf"); + attribute[2] = parseTags(tagsjTextField.getText(),"sf"); + } else { + attribute[0] = null; + attribute[1] = null; + attribute[2] = null; + } + } catch (Exception e1) { + if (sfLog().isErrorEnabled()) sfLog().error (e1); + WindowUtilities.showError(this,"Failed to modify attribute '"+attribute.toString()+"'. \n"+e1.toString()); } this.dispose(); @@ -282,16 +306,34 @@ return null; } + /** + * Parse + * @param textToParse text to be parsed + * @param language language + * @return Object + */ + public Object parseTags(String textToParse, String language) { + try { + SFParser parser = new SFParser(language); + return parser.sfParseTags( textToParse); + } catch (Throwable ex) { + if (sfLog().isErrorEnabled()) sfLog().error (ex); + } + return null; + } - /** * Interface Method. * @param e event */ void jButtonCancel_actionPerformed(ActionEvent e) { - //Return null - attribute[0] = null; - attribute[1] = null; + try { + attribute[0] = null; + attribute[1] = null; + attribute[2] = null; + } catch (Exception e1) { + if (sfLog().isErrorEnabled()) sfLog().error (e1); + } this.dispose(); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTable.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -156,15 +156,17 @@ } Object name = null; Object value = null; + Object tags = null; if (row == -1) { name = ""; } else { name = (tempTable.getValueAt(row, 0)); value = tempTable.getValueAt(row, 1); + tags = tempTable.getValueAt(row, 2); } - modifyAttribute(name, value); + modifyAttribute(name, value, tags); // Entry pointed in the tree } else if (source==menuItemInstrospectValue){ @@ -200,18 +202,21 @@ *@param name Name of the object *@param value Value of the object */ - void modifyAttribute(Object name, Object value) { - Object[] attribute = new Object[2]; + void modifyAttribute(Object name, Object value, Object tags) { + Object[] attribute = new Object[3]; attribute[0] = name; attribute[1] = value; + attribute[2] = tags; // try to get the object value try { TreePath tpath = (tempTree).getSelectionPath(); Object node = getNode(); if (node instanceof Prim) { attribute[1] = ((Prim)node).sfResolve(name.toString()); + attribute[2] = ((Prim)node).sfGetTags(name.toString()); } else if (node instanceof ComponentDescription) { attribute[1] = ((ComponentDescription)node).sfResolve(name.toString()); + attribute[2] = ((ComponentDescription)node).sfGetTags(name.toString()); } } catch (Exception ex) { if (sfLog().isIgnoreEnabled()) sfLog().ignore ("Failed to read real value during modify attribute '"+name,ex); @@ -224,8 +229,8 @@ if (attribute != null) { if (attribute[0] == null) { - if (sfLog().isTraceEnabled()) sfLog().trace ("No attribute to modify"); - WindowUtilities.showError(this,"No attribute to modify"); + if (sfLog().isTraceEnabled()) sfLog().trace ("No attribute was modified"); + WindowUtilities.showError(this,"No attribute was modified"); return; } if (attribute[1] == null) { @@ -237,7 +242,7 @@ try { TreePath tpath = (tempTree).getSelectionPath(); Object node = getNode(); - modify(node,attribute[0],attribute[1]); + modify(node,attribute[0],attribute[1],attribute[2]); //((Prim) (((DeployEntry) (tpath.getLastPathComponent())).getEntry())).sfReplaceAttribute(attribute[0],attribute[1]); } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error ("Failed to modify '"+name,ex); @@ -342,10 +347,10 @@ *@param attribName Attribute Name *@param value Attribute value */ - void modify(Object obj, Object attribName, Object value) { + void modify(Object obj, Object attribName, Object value, Object tags) { if ((obj instanceof Prim)||(obj instanceof ComponentDescription)) { try { - org.smartfrog.services.management.DeployMgnt.modifyAttribute(obj, attribName, value); + org.smartfrog.services.management.DeployMgnt.modifyAttribute(obj, attribName, value, tags); parent.refreshTable(); } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error ("Failed to modify '"+attribName,ex); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/DefaultParser.jj =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/DefaultParser.jj 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/DefaultParser.jj 2007-05-16 15:57:53 UTC (rev 4140) @@ -502,6 +502,18 @@ { return res; } } + /* + * Entry point for tags parser (e.g. for tags in management console) + */ + Object TagsSet() : +{ + Set tags = new HashSet(); +} +{ + [ <LBRACKET> Tags(tags) <RBRACKET> ] <EOF> + { return tags; } +} + /* * Main body of grammar */ Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/SFParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/SFParser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/csf/SFParser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,8 +23,6 @@ import java.io.InputStream; import org.smartfrog.SFSystem; -import org.smartfrog.sfcore.common.SmartFrogParseException; -import org.smartfrog.sfcore.common.SmartFrogCoreProperty; import org.smartfrog.sfcore.languages.csf.csfcomponentdescription.CSFComponentDescription; import org.smartfrog.sfcore.languages.sf.IncludeHandler; import org.smartfrog.sfcore.parser.Phases; @@ -34,13 +32,17 @@ import org.smartfrog.sfcore.security.SFClassLoader; -import java.lang.reflect.Constructor; - +import org.smartfrog.sfcore.common.SmartFrogParseException; +import org.smartfrog.sfcore.common.MessageKeys; import org.smartfrog.sfcore.common.MessageUtil; -import org.smartfrog.sfcore.common.MessageKeys; +import org.smartfrog.sfcore.common.SmartFrogCoreProperty; import org.smartfrog.sfcore.common.SmartFrogException; +import java.lang.reflect.Constructor; + + + /** * Implements the default Parser interface for SmartFrog parsers. This * implementation uses DefaultParser (generated by sfparser.jj) to parse @@ -286,4 +288,20 @@ throw new SmartFrogParseException("Error parsing primitive value from InputStream", pe); } } + + /** + * Parses tags from given string. This is NOT a cheap method since a + * new DefaultParser will be constructed to create the reference. + * + *@param is input stream to parse + *@return parsed value + *@exception SmartFrogParseException failure while parsing value + */ + public Object sfParseTags(InputStream is) throws SmartFrogParseException { + try { + return (new org.smartfrog.sfcore.languages.csf.DefaultParser(is, null)).TagsSet(); + } catch (ParseException pe){ + throw new SmartFrogParseException ("Error parsing Tags from InputStream", pe); + } + } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/DefaultParser.jj =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/DefaultParser.jj 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/DefaultParser.jj 2007-05-16 15:57:53 UTC (rev 4140) @@ -434,6 +434,18 @@ { return res; } } + /* + * Entry point for tags parser (e.g. for tags in management console) + */ + Object TagsSet() : +{ + Set tags = new HashSet(); +} +{ + [ <LBRACKET> Tags(tags) <RBRACKET> ] <EOF> + { return tags; } +} + /* * Main body of grammar */ Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/SFParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/SFParser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/SFParser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -287,4 +287,21 @@ throw new SmartFrogParseException ("Error parsing primitive value from InputStream", pe); } } + + /** + * Parses tags from given string. This is NOT a cheap method since a + * new DefaultParser will be constructed to create the reference. + * + *@param is input stream to parse + *@return parsed value + *@exception SmartFrogParseException failure while parsing value + */ + public Object sfParseTags(InputStream is) throws SmartFrogParseException { + try { + return (new DefaultParser(is, null)).TagsSet(); + } catch (ParseException pe){ + throw new SmartFrogParseException ("Error parsing Tags from InputStream", pe); + } + } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/Parser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/Parser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/Parser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -103,4 +103,16 @@ * @exception SmartFrogParseException failed to parse primtiive value */ public ComponentDescription sfParseComponentDescription(String txt) throws SmartFrogCompilationException; + + /** + * Parses tags from a string. + * + * @param txt string to parse for a value + * + * @return parsed value + * + * @exception SmartFrogParseException failed to parse primtiive value + */ + public Object sfParseTags(String txt) throws SmartFrogCompilationException; + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/SFParser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -26,12 +26,21 @@ import java.io.IOException; import org.smartfrog.SFSystem; -import org.smartfrog.sfcore.common.*; +import org.smartfrog.sfcore.common.SmartFrogParseException; +import org.smartfrog.sfcore.common.MessageKeys; +import org.smartfrog.sfcore.common.MessageUtil; +import org.smartfrog.sfcore.common.SmartFrogCoreProperty; +import org.smartfrog.sfcore.common.SmartFrogCompilationException; +import org.smartfrog.sfcore.common.SmartFrogRuntimeException; +import org.smartfrog.sfcore.common.SmartFrogException; + + import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.security.SFClassLoader; + import org.smartfrog.sfcore.componentdescription.ComponentDescription; -import org.smartfrog.sfcore.languages.sf.sfcomponentdescription.*; +import org.smartfrog.sfcore.languages.sf.sfcomponentdescription.SFComponentDescription; /** * Implements the Parser interface for SmartFrog parsers. This implementation @@ -280,7 +289,7 @@ } - /** + /** * Parses any value from an input stream. (the meaning of "any" is language dependant) * * @param is input stream to parse for a value @@ -331,8 +340,6 @@ return o; } - - /** * Parses a primitive value from a string. (the meaning of primitive is language dependant) * @@ -347,6 +354,33 @@ } /** + * Parses tags from an input stream. + * + * @param is input stream to parse for a value + * + * @return parsed value + * + * @exception org.smartfrog.sfcore.common.SmartFrogParseException failed to parse tags + */ + public Object sfParseTags(InputStream is) throws SmartFrogCompilationException { + Object o = parser.sfParseTags(is); + return o; + } + + /** + * Parses tags from a string. + * + * @param txt string to parse for a value + * + * @return parsed value + * + * @exception SmartFrogParseException failed to parse any value + */ + public Object sfParseTags(String txt) throws SmartFrogCompilationException { + return sfParseTags(new ByteArrayInputStream(txt.getBytes())); + } + + /** * Parses a component description from an input stream. * All the langauge phases will have been applied, and the conversion to ComponentDescription * carried out. Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamLanguageParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamLanguageParser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamLanguageParser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -23,9 +23,9 @@ import java.io.InputStream; import org.smartfrog.sfcore.common.SmartFrogParseException; -import org.smartfrog.sfcore.reference.Reference; + /** * Defines the actual low-level parser interface. Objects that implement this * interface provide the means to parse SmartFrog text into component @@ -91,7 +91,18 @@ * * @return parsed value * - * @exception org.smartfrog.sfcore.common.SmartFrogParseException failed to parse primtiive value + * @exception org.smartfrog.sfcore.common.SmartFrogParseException failed to parse primitive value */ public Object sfParsePrimitiveValue(InputStream is) throws SmartFrogParseException; + + /** + * Parses tags from an input stream. + * + * @param is string to parse for a value + * + * @return parsed value + * + * @exception org.smartfrog.sfcore.common.SmartFrogParseException failed to parse tags + */ + public Object sfParseTags(InputStream is) throws SmartFrogParseException; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamParser.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamParser.java 2007-05-15 15:38:14 UTC (rev 4139) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/parser/StreamParser.java 2007-05-16 15:57:53 UTC (rev 4140) @@ -98,6 +98,17 @@ public Object sfParsePrimitiveValue(InputStream is) throws SmartFrogCompilationException; /** + * Parses tags from an input stream. + * + * @param is string to parse for a value + * + * @return parsed value + * + * @exception org.smartfrog.sfcore.common.SmartFrogParseException failed to parse tags + */ + public Object sfParseTags(InputStream is) throws SmartFrogCompilationException; + + /** * Parses a component description from an input stream. * All the language phases will have been applied, and the conversion to ComponentDescription * carried out. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-06-08 17:40:22
|
Revision: 4276 http://svn.sourceforge.net/smartfrog/?rev=4276&view=rev Author: julgui Date: 2007-06-08 10:40:19 -0700 (Fri, 08 Jun 2007) Log Message: ----------- SFOS-155 Modified console to edit tags in tree nodes. Modified Tags api to allow modification of tags in container using NULL values (not final). Also, reverting changes in Reference.java Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -558,7 +558,7 @@ */ public String toString() { Object tags = getEntryTags(); - if ((tags!=null)&&(!tags.toString().equals(""))){ + if ((tags!=null)&&(!tags.toString().equals(""))&&(!tags.toString().equals("[]"))){ return getRDN()+" "+getEntryTags(); } return getRDN(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -34,6 +34,7 @@ import java.rmi.RemoteException; import java.util.ArrayList; +import java.util.Set; import org.smartfrog.sfcore.componentdescription.ComponentDescription; @@ -46,6 +47,7 @@ import org.smartfrog.sfcore.common.*; import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.parser.SFParser; /** @@ -88,6 +90,9 @@ /** Item for Tree popup menu - add ScriptingPanel. */ JMenuItem menuItemAddScriptingPanel = new JMenuItem(); + /** Item for Tree popup menu - edit Tags. */ + JMenuItem menuItemEditTags = new JMenuItem(); + /** * Constructs PopUpTree object */ @@ -112,6 +117,7 @@ menuItemParentageChanged.setText("sfParentageChanged()"); menuItemAddScriptingPanel.setText("Add Scripting Panel"); menuItemIntrospector.setText("Instrospector"); + menuItemEditTags.setText("Edit Tags"); // Tree: options // popupTree.add(menuItemAddAttribute); @@ -127,6 +133,7 @@ popupTree.add(menuItemParentageChanged); popupTree.add(menuItemAddScriptingPanel); popupTree.add(menuItemIntrospector); + popupTree.add(menuItemEditTags); // Add action listeners for tree popup menuItemAddAttribute.addActionListener(this); @@ -143,6 +150,7 @@ menuItemParentageChanged.addActionListener(this); menuItemAddScriptingPanel.addActionListener(this); menuItemIntrospector.addActionListener(this); + menuItemEditTags.addActionListener(this); } /** @@ -176,8 +184,9 @@ menuItemParentageChanged.setVisible(true); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemEditTags.setVisible(true); }else if (getNode()instanceof ComponentDescription){ - menuItemRemoveAttribute.setVisible(true); + menuItemRemoveAttribute.setVisible(true); menuItemDetach.setVisible(false); menuItemTerminateNormal.setVisible(false); menuItemTerminateAbnormal.setVisible(false); @@ -186,6 +195,7 @@ menuItemParentageChanged.setVisible(false); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemEditTags.setVisible(true); } popupTree.show(comp, x, y); this.parent = parent; @@ -227,6 +237,9 @@ } else if (source == menuItemDetach) { detach(node); // Entry selected in the tree + } else if (source == menuItemEditTags) { + editTags(node); + // Entry selected in the tree } else if (source == menuItemParentageChanged) { if (node instanceof Prim){ try { @@ -513,7 +526,7 @@ org.smartfrog.services.management.DeployMgnt.detach((Prim) obj); parent.refresh(); } catch (Exception ex){ - String msg = "Problem when trying to Detach and Terminate '"+name; + String msg = "Problem when trying to Detach and Terminate "+name; if (sfLog().isErrorEnabled()) sfLog().error (msg); WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); } @@ -522,8 +535,49 @@ } } + void editTags (Object obj) { + //System.out.println("Detatching: "+obj.toString()); + if (obj instanceof Prim) { + String name =""; + try { + name = ((Prim)obj).sfCompleteName().toString(); + Object tags = ((Prim)obj).sfGetTags(null); + tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); + Set newTags = (Set)parseTags(tags.toString(),"sf"); + ((Prim)obj).sfSetTags(null, newTags); + } catch (Exception ex){ + String msg = "Problem when trying to edit tags on "+name; + if (sfLog().isErrorEnabled()) sfLog().error (msg); + WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); + } + // Refresh Console. + // To do: automatic Refresh ;-) + } else if (obj instanceof ComponentDescription){ + } else { + WindowUtilities.showError(this, "Error when editing tags on object: "+obj.toString()+"\n "+obj.getClass().getName()); + } + } + + + /** + * Parse + * @param textToParse text to be parsed + * @param language language + * @return Object + */ + public Object parseTags(String textToParse, String language) { + try { + SFParser parser = new SFParser(language); + return parser.sfParseTags( textToParse); + } catch (Throwable ex) { + if (sfLog().isErrorEnabled()) sfLog().error (ex); + } + return null; + } + + /** * Prepares option dialog box * *@param title title displayed on the dialog box Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -16,7 +16,7 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -27,7 +27,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -37,7 +37,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; @@ -47,7 +47,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -58,7 +58,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -68,7 +68,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -78,7 +78,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to container's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -14,7 +14,7 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -25,7 +25,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -35,7 +35,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to add to the set * * @throws SmartFrogContextException the attribute does not exist; @@ -45,7 +45,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -56,7 +56,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -66,7 +66,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -76,7 +76,7 @@ /** * Return an iterator over the tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Throws exception if name is NULL * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; @@ -86,7 +86,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to container's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -1264,99 +1264,190 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags * @throws SmartFrogException * the attribute does not exist; */ public void sfSetTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfSetTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfSetTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfSetTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfSetTags(name, tags); } /** * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @return the set of tags * @throws SmartFrogException * the attribute does not exist; */ public Set sfGetTags(Object name) throws SmartFrogContextException { - return sfContext.sfGetTags(name); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfGetTags(key); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfGetTags(key); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + return sfContext.sfGetTags(name); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to add to the set * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTag(Object name, String tag) throws SmartFrogContextException { - sfContext.sfAddTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfAddTag(name, tag); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException { - sfContext.sfRemoveTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfRemoveTag(name, tag); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfAddTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfAddTags(name, tags); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfRemoveTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfRemoveTags(name, tags); } /** * Return an iterator over the tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Null throws an exception * @return an iterator over the tags * @throws SmartFrogException * the attribute does not exist; */ public Iterator sfTags(Object name) throws SmartFrogContextException { - return sfContext.sfTags(name); + return sfContext.sfTags(name); } /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to this object's tag * @param tag the tag to chack * @return whether or not the attribute has that tag * @throws SmartFrogException * the attribute does not exist */ public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException { - return sfContext.sfContainsTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfContainsTag(key, tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfContainsTag(key, tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + return sfContext.sfContainsTag(name, tag); } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -1707,16 +1707,22 @@ // implementation of the RemoteTags interface + + /** * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags. * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; */ public void sfSetTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfSetTags(key,tags); + } else sfContext.sfSetTags(name, tags); } @@ -1724,87 +1730,111 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; */ public Set sfGetTags(Object name) throws SmartFrogContextException, RemoteException { - return sfContext.sfGetTags(name); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfGetTags(key); + } else + return sfContext.sfGetTags(name); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; */ public void sfAddTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - sfContext.sfAddTag(name,tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTag(key,tag); + } else + sfContext.sfAddTag(name,tag); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; * */ public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - sfContext.sfRemoveTag(name, tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTag(key,tag); + } else + sfContext.sfRemoveTag(name, tag); } /** * add a tag to the tag set of an attribute * * @param name attribute key for tags - * @param tags a set of tags to add to the set + * @param tags a set of tags to add to the set. Use "NULL" to refer to this object's tags * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - sfContext.sfAddTags(name, tags); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTags(key,tags); + } else + sfContext.sfAddTags(name, tags); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - sfContext.sfRemoveTags(name, tags); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTags(key,tags); + } else + sfContext.sfRemoveTags(name, tags); } /** * Return an iterator over the tags for an attribute - not part of RemoteTags, but is part of Tags * - * @param name the name of the attribute + * @param name the name of the attribute. If name is null then it throws exception * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; */ public Iterator sfTags(Object name) throws SmartFrogException { - return sfContext.sfTags(name); + return sfContext.sfTags(name); } /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to this object's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag * @throws SmartFrogException the attribute does not exist */ public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - return sfContext.sfContainsTag(name, tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfContainsTag(key,tag); + } else + return sfContext.sfContainsTag(name, tag); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -79,16 +79,16 @@ /** - * Constructs a reference with a single attrib reference part from a String. + * Constructs a reference with a single reference part from a String. * - * @param attributeName part to be put in reference + * @param referencePart part to be put in reference */ - public Reference(Object attributeName) { - this(ReferencePart.attrib(attributeName)); + public Reference(Object referencePart) { + this(ReferencePart.here(referencePart)); } /** - * Constructs a reference with a single attrib reference part from a String + * Constructs a reference with a single reference part from a String * or from a string in cannonical form using the parser. * * @param refString to be put/used in reference @@ -97,12 +97,11 @@ */ public Reference(String refString, boolean parse) throws SmartFrogResolutionException{ if (!parse) { - ref.addElement(ReferencePart.attrib(refString)); + ref.addElement(ReferencePart.here(refString)); } else { ref = fromString(refString).ref; } } - /** * Constructs a reference with a single reference part. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-06-08 18:35:08
|
Revision: 4277 http://svn.sourceforge.net/smartfrog/?rev=4277&view=rev Author: julgui Date: 2007-06-08 11:35:03 -0700 (Fri, 08 Jun 2007) Log Message: ----------- SFOS-155 Added new interfaces for enhanced Tags api to allow modification of tags in container (not final). Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescription.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/Prim.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTagsComponent.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/TagsComponent.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -541,20 +541,30 @@ String name =""; try { name = ((Prim)obj).sfCompleteName().toString(); - Object tags = ((Prim)obj).sfGetTags(null); + Object tags = ((Prim)obj).sfGetTags(); tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); Set newTags = (Set)parseTags(tags.toString(),"sf"); - ((Prim)obj).sfSetTags(null, newTags); + ((Prim)obj).sfSetTags(newTags); } catch (Exception ex){ - String msg = "Problem when trying to edit tags on "+name; + String msg = "Problem when trying to edit tags on Component "+name; if (sfLog().isErrorEnabled()) sfLog().error (msg); WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); } - // Refresh Console. - // To do: automatic Refresh ;-) } else if (obj instanceof ComponentDescription){ - + String name =""; + try { + name = ((ComponentDescription)obj).sfCompleteName().toString(); + Object tags = ((ComponentDescription)obj).sfGetTags(); + tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); + Set newTags = (Set)parseTags(tags.toString(),"sf"); + ((ComponentDescription)obj).sfSetTags(newTags); + } catch (Exception ex){ + String msg = "Problem when trying to edit tags on ComponentDescription "+name; + if (sfLog().isErrorEnabled()) sfLog().error (msg); + WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); + } } else { + if (sfLog().isErrorEnabled()) sfLog().error ( "Error when editing tags on object: "+obj.toString()+"\n "+obj.getClass().getName()); WindowUtilities.showError(this, "Error when editing tags on object: "+obj.toString()+"\n "+obj.getClass().getName()); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -10,13 +10,13 @@ * contexts, component descriptions and (in its remote form) prims. */ public interface RemoteTags extends Remote { + // TAGS interface for a context - /** * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -27,7 +27,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -37,7 +37,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; @@ -47,7 +47,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -58,7 +58,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -68,7 +68,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -78,7 +78,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute. Use "NULL" to refer to container's tags + * @param name the name of the attribute * @param tag the tag to chack * * @return whether or not the attribute has that tag Added: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTagsComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTagsComponent.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTagsComponent.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -0,0 +1,80 @@ +package org.smartfrog.sfcore.common; + +import java.util.Set; +import java.util.Iterator; +import java.rmi.Remote; +import java.rmi.RemoteException; + +/** + * Interface that defines the access to, and manipulation of, tags of + * component descriptions and (in its remote form) prims. + */ +public interface RemoteTagsComponent extends Remote { + + /** + * Set the TAGS for this Component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @param tags a set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfSetTags( Set tags) throws SmartFrogContextException, RemoteException; + + /** + * Get the TAGS for this Component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @return the set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public Set sfGetTags() throws SmartFrogContextException, RemoteException; + + /** + * add a tag to the tag set of this component + * + * @param tag a tag to add to the set + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfAddTag( String tag) throws SmartFrogContextException, RemoteException; + + /** + * remove a tag from the tag set of this component if it exists + * @param tag a tag to remove from the set + * + * @throws SmartFrogException the attribute does not exist; + * + */ + public void sfRemoveTag( String tag) throws SmartFrogContextException, RemoteException; + + /** + * add a tag to the tag set of this component + * + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags( Set tags) throws SmartFrogContextException, RemoteException; + + /** + * remove a tag from the tag set of this component if it exists + * + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTags(Set tags) throws SmartFrogContextException, RemoteException; + + /** + * Return whether or not a tag is in the list of tags for this component + * + * @param tag the tag to chack + * + * @return whether or not the attribute has that tag + * @throws SmartFrogException the attribute does not exist + */ + public boolean sfContainsTag( String tag) throws SmartFrogContextException, RemoteException; + +} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -14,7 +14,7 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -25,7 +25,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -35,7 +35,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tag a tag to add to the set * * @throws SmartFrogContextException the attribute does not exist; @@ -45,7 +45,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -56,7 +56,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -66,7 +66,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to container's tags + * @param name attribute key for tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -76,7 +76,7 @@ /** * Return an iterator over the tags for an attribute * - * @param name the name of the attribute. Throws exception if name is NULL + * @param name the name of the attribute * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; @@ -86,7 +86,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute. Use "NULL" to refer to container's tags + * @param name the name of the attribute * @param tag the tag to chack * * @return whether or not the attribute has that tag Added: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/TagsComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/TagsComponent.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/TagsComponent.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -0,0 +1,77 @@ +package org.smartfrog.sfcore.common; + +import java.util.Set; +import java.util.Iterator; + +/** + * Interface that defines the access to, and manipulation of, tags + * in component descriptions and (in its remote form) prims. + */ +public interface TagsComponent { + /** + * Set the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @param tags a set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfSetTags( Set tags) throws SmartFrogContextException; + + /** + * Get the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @return the set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public Set sfGetTags() throws SmartFrogContextException; + + /** + * add a tag to the tag set of this component + * + * @param tag a tag to add to the set + * + * @throws SmartFrogContextException the attribute does not exist; + */ + public void sfAddTag( String tag) throws SmartFrogContextException; + + /** + * remove a tag from the tag set of this component if it exists + * + * @param tag a tag to remove from the set + * + * @throws SmartFrogException the attribute does not exist; + * + */ + public void sfRemoveTag( String tag) throws SmartFrogContextException; + + /** + * add a tag to the tag set of this component + * + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags( Set tags) throws SmartFrogContextException; + + /** + * remove a tag from the tag set of this component if it exists + * + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTags( Set tags) throws SmartFrogContextException; + + /** + * Return whether or not a tag is in the list of tags for this component + * + * @param tag the tag to chack + * + * @return whether or not the attribute has that tag + * @throws SmartFrogException the attribute does not exist + */ + public boolean sfContainsTag( String tag) throws SmartFrogContextException; +} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescription.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescription.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescription.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -40,7 +40,7 @@ * Components. * @see Copying */ -public interface ComponentDescription extends Tags, PrettyPrinting, Copying, ReferenceResolver, ReferenceResolverHelper { +public interface ComponentDescription extends Tags, TagsComponent, PrettyPrinting, Copying, ReferenceResolver, ReferenceResolverHelper { /** * Add an attribute to the component description context. Values should be Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -1260,249 +1260,313 @@ // implementation of the TAGS interface - /** - * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated - * with each attribute. - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags - * @param tags a set of tags - * @throws SmartFrogException - * the attribute does not exist; - */ - public void sfSetTags(Object name, Set tags) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - parent.sfSetTags(key,tags); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - primParent.sfSetTags(key,tags); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - sfContext.sfSetTags(name, tags); - } + /** + * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @param name attribute key for tags. + * @param tags a set of tags + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfSetTags(Object name, Set tags) throws SmartFrogContextException { + sfContext.sfSetTags(name, tags); + } - /** - * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated - * with each attribute. - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags - * @return the set of tags - * @throws SmartFrogException - * the attribute does not exist; - */ - public Set sfGetTags(Object name) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - return parent.sfGetTags(key); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - return primParent.sfGetTags(key); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - return sfContext.sfGetTags(name); - } + /** + * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @param name attribute key for tags. + * @return the set of tags + * @throws SmartFrogException + * the attribute does not exist; + */ + public Set sfGetTags(Object name) throws SmartFrogContextException { + return sfContext.sfGetTags(name); + } - /** - * add a tag to the tag set of an attribute - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tag - * @param tag a tag to add to the set - * @throws SmartFrogException - * the attribute does not exist; - */ - public void sfAddTag(Object name, String tag) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - parent.sfAddTag(key,tag); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - primParent.sfAddTag(key,tag); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - sfContext.sfAddTag(name, tag); - } + /** + * add a tag to the tag set of an attribute + * + * @param name attribute key for tags. + * @param tag a tag to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTag(Object name, String tag) throws SmartFrogContextException { + sfContext.sfAddTag(name, tag); + } - /** - * remove a tag from the tag set of an attribute if it exists - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tag - * @param tag a tag to remove from the set - * @throws SmartFrogException - * the attribute does not exist; - */ - public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - parent.sfRemoveTag(key,tag); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - primParent.sfRemoveTag(key,tag); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - sfContext.sfRemoveTag(name, tag); - } + /** + * remove a tag from the tag set of an attribute if it exists + * + * @param name attribute key for tags. + * @param tag a tag to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException { + sfContext.sfRemoveTag(name, tag); + } - /** - * add a tag to the tag set of an attribute - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags - * @param tags a set of tags to add to the set - * @throws SmartFrogException - * the attribute does not exist; - */ -public void sfAddTags(Object name, Set tags) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - parent.sfAddTags(key,tags); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - primParent.sfAddTags(key,tags); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - sfContext.sfAddTags(name, tags); - } + /** + * add a tag to the tag set of an attribute + * + * @param name attribute key for tags. + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags(Object name, Set tags) throws SmartFrogContextException { + sfContext.sfAddTags(name, tags); + } - /** - * remove a tag from the tag set of an attribute if it exists - * - * @param name attribute key for tags. Use "NULL" to refer to this object's tag - * @param tags a set of tags to remove from the set - * @throws SmartFrogException - * the attribute does not exist; - */ - public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - parent.sfRemoveTags(key,tags); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - primParent.sfRemoveTags(key,tags); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - sfContext.sfRemoveTags(name, tags); - } + /** + * remove a tag from the tag set of an attribute if it exists + * + * @param name attribute key for tags. + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException { + sfContext.sfRemoveTags(name, tags); + } - /** - * Return an iterator over the tags for an attribute - * - * @param name the name of the attribute. Null throws an exception - * @return an iterator over the tags - * @throws SmartFrogException - * the attribute does not exist; - */ - public Iterator sfTags(Object name) throws SmartFrogContextException { - return sfContext.sfTags(name); - } + /** + * Return an iterator over the tags for an attribute + * + * @param name the name of the attribute. + * @return an iterator over the tags + * @throws SmartFrogException + * the attribute does not exist; + */ + public Iterator sfTags(Object name) throws SmartFrogContextException { + return sfContext.sfTags(name); + } - /** - * Return whether or not a tag is in the list of tags for an attribute - * - * @param name the name of the attribute. Use "NULL" to refer to this object's tag - * @param tag the tag to chack - * @return whether or not the attribute has that tag - * @throws SmartFrogException - * the attribute does not exist - */ - public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException { - if (name==null){ - if (parent!=null) { - Object key = parent.sfAttributeKeyFor(this); - return parent.sfContainsTag(key, tag); - }else { - try { - Object key = primParent.sfAttributeKeyFor(this); - return primParent.sfContainsTag(key, tag); - } catch (RemoteException e) { - throw (SmartFrogContextException)SmartFrogContextException.forward(e); - } - } - } else - return sfContext.sfContainsTag(name, tag); - } + /** + * Return whether or not a tag is in the list of tags for an attribute + * + * @param name the name of the attribute. + * @param tag the tag to chack + * @return whether or not the attribute has that tag + * @throws SmartFrogException + * the attribute does not exist + */ + public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException { + return sfContext.sfContainsTag(name, tag); + } + // implementation of the TAGSComponent interface + + /** - * Compares the specified Object with this ComponentDescription for equality - * Does not compare parentage but it compares LAZY. + * Set the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. * - * @param o object to be compared for equality with this ComponentDescription - * @return true if the specified Object is equal to this ComponentDescription + * @param tags a set of tags + * @throws SmartFrogException + * the attribute does not exist; */ - public synchronized boolean equals(Object o) { - if (o == this) - return true; + public void sfSetTags( Set tags) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfSetTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfSetTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } - if (!(o instanceof ComponentDescription)) - return false; + /** + * Get the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @return the set of tags + * @throws SmartFrogException + * the attribute does not exist; + */ + public Set sfGetTags() throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfGetTags(key); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfGetTags(key); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } - if (eager != ((ComponentDescription)o).getEager() ){ - return false; - } + /** + * add a tag to the tag set of this component + * + * @param tag a tag to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTag(String tag) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } - if (!((sfContext).equals((((ComponentDescription)o).sfContext())))){ - return false; - } + /** + * remove a tag from the tag set of this component if it exists + * + * @param tag a tag to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTag(String tag) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } - return true; + /** + * add a tag to the tag set of this component + * + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags(Set tags) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } } /** - * Checks component description for same parentage - * @param o parent to compare with - * @return + * remove a tag from the tag set of this component if it exists + * + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; */ - public boolean hasSameParent(ComponentDescription o) { - if (primParent==null) { - if (!(parent == (((ComponentDescription)o).sfParent()))){ - return true; - } - } else { - if (!(primParent == (((ComponentDescription)o).sfPrimParent()))){ - return true; - } - } - return false; + public void sfRemoveTags(Set tags) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } } /** - * Returns the hash code value for this ComponentDescription - * Parentage is not included but LAZY is. + * Return whether or not a tag is in the list of tags for this component + * + * @param tag the tag to chack + * @return whether or not the attribute has that tag + * @throws SmartFrogException + * the attribute does not exist */ - public synchronized int hashCode() { - // Simple hashcode using Joshua Bloch's recommendation - int result = 17; - result = 37 * result + sfContext.hashCode(); - result = 37 * result + (eager ? 0 :1 ); - return result; + public boolean sfContainsTag(String tag) throws SmartFrogContextException { + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfContainsTag(key, tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfContainsTag(key, tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } } + + // hash code and equals + /** + * Compares the specified Object with this ComponentDescription for equality + * Does not compare parentage but it compares LAZY. + * + * @param o object to be compared for equality with this ComponentDescription + * @return true if the specified Object is equal to this ComponentDescription + */ + public synchronized boolean equals(Object o) { + if (o == this) + return true; + + if (!(o instanceof ComponentDescription)) + return false; + + if (eager != ((ComponentDescription)o).getEager() ){ + return false; + } + + if (!((sfContext).equals((((ComponentDescription)o).sfContext())))){ + return false; + } + + return true; + } + + /** + * Checks component description for same parentage + * @param o parent to compare with + * @return + */ + public boolean hasSameParent(ComponentDescription o) { + if (primParent==null) { + if (!(parent == (((ComponentDescription)o).sfParent()))){ + return true; + } + } else { + if (!(primParent == (((ComponentDescription)o).sfPrimParent()))){ + return true; + } + } + return false; + } + + /** + * Returns the hash code value for this ComponentDescription + * Parentage is not included but LAZY is. + */ + public synchronized int hashCode() { + // Simple hashcode using Joshua Bloch's recommendation + int result = 17; + result = 37 * result + sfContext.hashCode(); + result = 37 * result + (eager ? 0 :1 ); + return result; + } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/Prim.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/Prim.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/Prim.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -36,7 +36,7 @@ * component knows how to react to termination, liveness, etc. * */ -public interface Prim extends Update, Liveness, RemoteReferenceResolver, RemoteReferenceResolverHelper, RemoteTags, Diagnostics, Remote { +public interface Prim extends Update, Liveness, RemoteReferenceResolver, RemoteReferenceResolverHelper, RemoteTags, RemoteTagsComponent, Diagnostics, Remote { /** * Add an attribute to the component's context. Values should be * marshallable types if they are to be referenced remotely at run-time. Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 17:40:19 UTC (rev 4276) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 18:35:03 UTC (rev 4277) @@ -1707,22 +1707,16 @@ // implementation of the RemoteTags interface - - /** * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags. + * @param name attribute key for tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; */ public void sfSetTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfSetTags(key,tags); - } else sfContext.sfSetTags(name, tags); } @@ -1730,49 +1724,37 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags + * @param name attribute key for tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; */ public Set sfGetTags(Object name) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - return sfParent.sfGetTags(key); - } else return sfContext.sfGetTags(name); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags. Use "NULL" to refer to this object's tag + * @param name attribute key for tags * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; */ public void sfAddTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfAddTag(key,tag); - } else sfContext.sfAddTag(name,tag); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to this object's tag + * @param name attribute key for tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; * */ public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfRemoveTag(key,tag); - } else sfContext.sfRemoveTag(name, tag); } @@ -1780,38 +1762,30 @@ * add a tag to the tag set of an attribute * * @param name attribute key for tags - * @param tags a set of tags to add to the set. Use "NULL" to refer to this object's tags + * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfAddTags(key,tags); - } else sfContext.sfAddTags(name, tags); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags. Use "NULL" to refer to this object's tags + * @param name attribute key for tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - if (name==null){ - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfRemoveTags(key,tags); - } else sfContext.sfRemoveTags(name, tags); } /** * Return an iterator over the tags for an attribute - not part of RemoteTags, but is part of Tags * - * @param name the name of the attribute. If name is null then it throws exception + * @param name the name of the attribute * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; @@ -1823,18 +1797,105 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute. Use "NULL" to refer to this object's tags + * @param name the name of the attribute * @param tag the tag to chack * * @return whether or not the attribute has that tag * @throws SmartFrogException the attribute does not exist */ public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - if (name==null){ + return sfContext.sfContainsTag(name, tag); + } + + // implementation of the RemoteTagsComponent interface + + /** + * Set the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @param tags a set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfSetTags(Set tags) throws SmartFrogContextException, RemoteException { Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfSetTags(key,tags); + } + + /** + * Get the TAGS for this component. TAGS are simply uninterpreted strings associated + * with each attribute. + * + * @return the set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public Set sfGetTags() throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfGetTags(key); + } + + /** + * add a tag to the tag set of this component + * + * @param tag a tag to add to the set + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfAddTag( String tag) throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTag(key,tag); + } + + /** + * remove a tag from the tag set of this component if it exists + * + * @param tag a tag to remove from the set + * + * @throws SmartFrogException the attribute does not exist; + * + */ + public void sfRemoveTag( String tag) throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTag(key, tag); + } + + /** + * add a tag to the tag set of this component + * + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags( Set tags) throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTags(key,tags); + } + + /** + * remove a tag from the tag set of this component if it exists + * + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTags( Set tags) throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTags(key,tags); + } + + + /** + * Return whether or not a tag is in the list of tags for this component + * + * @param tag the tag to chack + * + * @return whether or not the attribute has that tag + * @throws SmartFrogException the attribute does not exist + */ + public boolean sfContainsTag(String tag) throws SmartFrogContextException, RemoteException { + Object key = sfParent.sfAttributeKeyFor(this); return sfParent.sfContainsTag(key,tag); - } else - return sfContext.sfContainsTag(name, tag); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-06-10 23:33:29
|
Revision: 4279 http://svn.sourceforge.net/smartfrog/?rev=4279&view=rev Author: julgui Date: 2007-06-10 16:33:19 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Improvement: tag editing. SFOS-155 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-08 18:56:26 UTC (rev 4278) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-10 23:33:19 UTC (rev 4279) @@ -473,17 +473,12 @@ Object tags = ""; try { if (entry instanceof Prim){ - parent = ((Prim) entry).sfParent(); + tags = ((Prim) entry).sfGetTags(); } else if (entry instanceof ComponentDescription){ - parent = (( ComponentDescription) entry).sfParent(); + tags = (( ComponentDescription) entry).sfGetTags(); } else { return tags; } - if (parent instanceof Prim){ - tags = ((Prim)parent).sfGetTags(getRDN()); - } else if (parent instanceof ComponentDescription){ - tags = (( ComponentDescription) parent).sfGetTags(getRDN()); - } if (tags==null) tags=""; return tags; Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 18:56:26 UTC (rev 4278) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-10 23:33:19 UTC (rev 4279) @@ -543,8 +543,10 @@ name = ((Prim)obj).sfCompleteName().toString(); Object tags = ((Prim)obj).sfGetTags(); tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); - Set newTags = (Set)parseTags(tags.toString(),"sf"); - ((Prim)obj).sfSetTags(newTags); + if (tags!=null) { + Set newTags = (Set)parseTags(tags.toString(),"sf"); + ((Prim)obj).sfSetTags(newTags); + } } catch (Exception ex){ String msg = "Problem when trying to edit tags on Component "+name; if (sfLog().isErrorEnabled()) sfLog().error (msg); @@ -556,8 +558,10 @@ name = ((ComponentDescription)obj).sfCompleteName().toString(); Object tags = ((ComponentDescription)obj).sfGetTags(); tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); - Set newTags = (Set)parseTags(tags.toString(),"sf"); - ((ComponentDescription)obj).sfSetTags(newTags); + if (tags!=null) { + Set newTags = (Set)parseTags(tags.toString(),"sf"); + ((ComponentDescription)obj).sfSetTags(newTags); + } } catch (Exception ex){ String msg = "Problem when trying to edit tags on ComponentDescription "+name; if (sfLog().isErrorEnabled()) sfLog().error (msg); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 18:56:26 UTC (rev 4278) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-10 23:33:19 UTC (rev 4279) @@ -1831,8 +1831,16 @@ * @throws SmartFrogException the attribute does not exist; */ public Set sfGetTags() throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - return sfParent.sfGetTags(key); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfGetTags(key); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + return parent.sfGetTags(key); + } + } /** @@ -1843,8 +1851,15 @@ * @throws SmartFrogException the attribute does not exist; */ public void sfAddTag( String tag) throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfAddTag(key,tag); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTag(key,tag); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + parent.sfAddTag(key,tag); + } } /** @@ -1856,11 +1871,18 @@ * */ public void sfRemoveTag( String tag) throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfRemoveTag(key, tag); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTag(key,tag); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTag(key,tag); + } } - /** + /** * add a tag to the tag set of this component * * @param tags a set of tags to add to the set @@ -1868,8 +1890,15 @@ * the attribute does not exist; */ public void sfAddTags( Set tags) throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfAddTags(key,tags); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTags(key,tags); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + parent.sfAddTags(key,tags); + } } /** @@ -1880,8 +1909,15 @@ * the attribute does not exist; */ public void sfRemoveTags( Set tags) throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - sfParent.sfRemoveTags(key,tags); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTags(tags); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTags(tags); + } } @@ -1894,8 +1930,15 @@ * @throws SmartFrogException the attribute does not exist */ public boolean sfContainsTag(String tag) throws SmartFrogContextException, RemoteException { - Object key = sfParent.sfAttributeKeyFor(this); - return sfParent.sfContainsTag(key,tag); + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfContainsTag(tag); + } else { + Prim parent = SFProcess.getProcessCompound(); + key = parent.sfAttributeKeyFor(this); + return parent.sfContainsTag(tag); + } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2007-06-08 18:56:26 UTC (rev 4278) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2007-06-10 23:33:19 UTC (rev 4279) @@ -32,19 +32,6 @@ import java.net.InetAddress; import org.smartfrog.SFSystem; -import org.smartfrog.sfcore.common.Logger; -import org.smartfrog.sfcore.common.Context; -import org.smartfrog.sfcore.common.ContextImpl; -import org.smartfrog.sfcore.common.TerminatorThread; -import org.smartfrog.sfcore.common.MessageKeys; -import org.smartfrog.sfcore.common.MessageUtil; -import org.smartfrog.sfcore.common.SmartFrogCoreKeys; -import org.smartfrog.sfcore.common.SmartFrogCoreProperty; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogLivenessException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl; import org.smartfrog.sfcore.compound.CompoundImpl; @@ -55,11 +42,9 @@ import org.smartfrog.sfcore.reference.ReferencePart; import org.smartfrog.sfcore.security.SFSecurity; import org.smartfrog.sfcore.security.SFSecurityProperties; -import org.smartfrog.sfcore.common.ExitCodes; -import org.smartfrog.sfcore.common.JarUtil; +import org.smartfrog.sfcore.common.*; - /** * Implements deployment behaviour for a process. There is a single process * compound allowed per process. SFSystem asks SFProcess to make the @@ -1405,10 +1390,115 @@ for (Iterator i = sfProcessEnvVars.sfAttributes(); i.hasNext();) { key = i.next().toString(); value = sfProcessEnvVars.sfResolveHere(key); - cmd.addElement("-D"+ - key.toString() + "=" + - value.toString()); + cmd.addElement("-D"+ key.toString() + "=" + value.toString()); } } + + + //Tags - Special case for rootProcess: rootProcess does not have tags. + /** + * Get the TAGS for this process compound. TAGS are simply uninterpreted strings associated + * with each attribute. rooProcess returns null. rootProcess does not have tags. + * + * @return the set of tags + * + * @throws SmartFrogException the attribute does not exist; + */ + public Set sfGetTags() throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfGetTags(key); + } else { + return null; + } + } + /** + * add a tag to the tag set of this component + * rootProcess does not have tags. + * + * @param tag a tag to add to the set + * + * @throws SmartFrogException the attribute does not exist; + */ + public void sfAddTag( String tag) throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTag(key,tag); + } else { + } + } + + /** + * remove a tag from the tag set of this component if it exists + * rootProcess does not have tags. + * + * @param tag a tag to remove from the set + * + * @throws SmartFrogException the attribute does not exist; + * + */ + public void sfRemoveTag( String tag) throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTag(key,tag); + } else { + } + } + + /** + * add a tag to the tag set of this component + * rootProcess does not have tags. + * @param tags a set of tags to add to the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfAddTags( Set tags) throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTags(key,tags); + } else { + } + } + + /** + * remove a tag from the tag set of this component if it exists + * rootProcess does not have tags. + * + * @param tags a set of tags to remove from the set + * @throws SmartFrogException + * the attribute does not exist; + */ + public void sfRemoveTags( Set tags) throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTags(tags); + } else { + } + } + + + /** + * Return whether or not a tag is in the list of tags for this component + * rootProcess returns false. rootProcess does not have tags. + * @param tag the tag to chack + * + * @return whether or not the attribute has that tag + * @throws SmartFrogException the attribute does not exist + */ + public boolean sfContainsTag(String tag) throws SmartFrogContextException, RemoteException { + Object key = null; + if (sfParent!=null) { + key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfContainsTag(tag); + } else { + return false; + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-06-11 00:11:54
|
Revision: 4281 http://svn.sourceforge.net/smartfrog/?rev=4281&view=rev Author: julgui Date: 2007-06-10 17:11:53 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Improvement: tag editing. SFOS-155 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-10 23:45:00 UTC (rev 4280) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-11 00:11:53 UTC (rev 4281) @@ -549,7 +549,7 @@ } } catch (Exception ex){ String msg = "Problem when trying to edit tags on Component "+name; - if (sfLog().isErrorEnabled()) sfLog().error (msg); + if (sfLog().isErrorEnabled()) sfLog().error (msg,ex); WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); } } else if (obj instanceof ComponentDescription){ @@ -564,7 +564,7 @@ } } catch (Exception ex){ String msg = "Problem when trying to edit tags on ComponentDescription "+name; - if (sfLog().isErrorEnabled()) sfLog().error (msg); + if (sfLog().isErrorEnabled()) sfLog().error (msg,ex); WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); } } else { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-10 23:45:00 UTC (rev 4280) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-11 00:11:53 UTC (rev 4281) @@ -1821,11 +1821,11 @@ Object key = null; if (sfParent!=null) { key = sfParent.sfAttributeKeyFor(this); - sfParent.sfSetTags(tags); + sfParent.sfSetTags(key,tags); } else { Prim parent = SFProcess.getProcessCompound(); key = parent.sfAttributeKeyFor(this); - parent.sfSetTags(tags); + parent.sfSetTags(key, tags); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2007-06-12 18:51:10
|
Revision: 4300 http://svn.sourceforge.net/smartfrog/?rev=4300&view=rev Author: julgui Date: 2007-06-12 11:51:05 -0700 (Tue, 12 Jun 2007) Log Message: ----------- In progress: DumpState object example. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/DefaultDumper.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-12 18:04:56 UTC (rev 4299) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-12 18:51:05 UTC (rev 4300) @@ -31,10 +31,13 @@ import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.Dump; +import org.smartfrog.sfcore.prim.DefaultDumper; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Set; +import java.io.StringWriter; import org.smartfrog.sfcore.componentdescription.ComponentDescription; @@ -90,6 +93,9 @@ /** Item for Tree popup menu - add ScriptingPanel. */ JMenuItem menuItemAddScriptingPanel = new JMenuItem(); + /** Item for Tree popup menu - dump State. */ + JMenuItem menuItemDumpState = new JMenuItem(); + /** Item for Tree popup menu - edit Tags. */ JMenuItem menuItemEditTags = new JMenuItem(); @@ -117,6 +123,7 @@ menuItemParentageChanged.setText("sfParentageChanged()"); menuItemAddScriptingPanel.setText("Add Scripting Panel"); menuItemIntrospector.setText("Instrospector"); + menuItemDumpState.setText("Dump State"); menuItemEditTags.setText("Edit Tags"); // Tree: options @@ -133,6 +140,7 @@ popupTree.add(menuItemParentageChanged); popupTree.add(menuItemAddScriptingPanel); popupTree.add(menuItemIntrospector); + popupTree.add(menuItemDumpState); popupTree.add(menuItemEditTags); // Add action listeners for tree popup @@ -150,6 +158,7 @@ menuItemParentageChanged.addActionListener(this); menuItemAddScriptingPanel.addActionListener(this); menuItemIntrospector.addActionListener(this); + menuItemDumpState.addActionListener(this); menuItemEditTags.addActionListener(this); } @@ -184,6 +193,7 @@ menuItemParentageChanged.setVisible(true); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemDumpState.setVisible(true); menuItemEditTags.setVisible(true); }else if (getNode()instanceof ComponentDescription){ menuItemRemoveAttribute.setVisible(true); @@ -195,6 +205,7 @@ menuItemParentageChanged.setVisible(false); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemDumpState.setVisible(false); menuItemEditTags.setVisible(true); } popupTree.show(comp, x, y); @@ -237,6 +248,9 @@ } else if (source == menuItemDetach) { detach(node); // Entry selected in the tree + } else if (source == menuItemDumpState) { + dumpState(node,source); + // Entry selected in the tree } else if (source == menuItemEditTags) { editTags(node); // Entry selected in the tree @@ -252,89 +266,131 @@ } // Entry selected in the tree } else if (source == menuItemDumpContext) { - StringBuffer message=new StringBuffer(); - String name = "error"; - if (node instanceof Prim) { - try { - Prim objPrim = ((Prim)node); - message.append(objPrim.sfDiagnosticsReport()); - name = ((Prim)objPrim).sfCompleteName().toString(); - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); - } - } else { - try { - ComponentDescription objCD = ((ComponentDescription)node); - message.append(((ComponentDescriptionImpl)objCD).sfDiagnosticsReport()); - name = ((ComponentDescription)objCD).sfCompleteName().toString(); - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); - } - - } - modalDialog("Context info for "+ name , message.toString(), "", source); + diagnosticsReport(node, source); } else if (source == menuItemIntrospector) { - StringBuffer message=new StringBuffer(); - String name = "error"; - if (node instanceof Prim) { - try { - Prim objPrim = ((Prim)node); - name = ((Prim)objPrim).sfCompleteName().toString(); - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); + instrospect(node, source); + } else if (source == menuItemAddScriptingPanel) { + addScriptingPanel(node); + + } + + } + + private void addScriptingPanel(Object node) { + StringBuffer message=new StringBuffer(); + String name = "error"; + String hostname = "localhost"; + int port = 3800; + if (node instanceof Prim) { + try { + Prim objPrim = ((Prim)node); + name = ((Prim)objPrim).sfCompleteName().toString(); + name = name.substring(name.lastIndexOf(".")); + hostname = objPrim.sfResolve("sfHost",hostname,false); + ProcessCompound pc = SFProcess.getProcessCompound(); + if (pc!=null) { + port = pc.sfResolve("sfRootLocatorPort",port,false); } - } else { - try { - ComponentDescription objCD = ((ComponentDescription)node); - name = ((ComponentDescription)objCD).sfCompleteName().toString(); - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); - } + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); + } + } else { + try { + ComponentDescription objCD = ((ComponentDescription)node); + name = ((ComponentDescription)objCD).sfCompleteName().toString(); + name = name.substring(name.lastIndexOf(".")); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); + } + } + + try { + Object obj = (parent.getParent()); + SFDeployDisplay.addScriptingPanel(((JTabbedPane)(obj)) ,name ,node, hostname ,port ); + } catch (Exception e1) { + if (sfLog().isErrorEnabled()) sfLog().error (e1); + WindowUtilities.showError(this,e1.toString()); + } + } + + private void instrospect(Object node, Object source) { + StringBuffer message=new StringBuffer(); + String name = "error"; + if (node instanceof Prim) { + try { + Prim objPrim = ((Prim)node); + name = ((Prim)objPrim).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); } - modalDialog("Introspection "+ name , introspect(node), "", source); - } else if (source == menuItemAddScriptingPanel) { - StringBuffer message=new StringBuffer(); - String name = "error"; - String hostname = "localhost"; - int port = 3800; - if (node instanceof Prim) { - try { - Prim objPrim = ((Prim)node); - name = ((Prim)objPrim).sfCompleteName().toString(); - name = name.substring(name.lastIndexOf(".")); - hostname = objPrim.sfResolve("sfHost",hostname,false); - ProcessCompound pc = SFProcess.getProcessCompound(); - if (pc!=null) { - port = pc.sfResolve("sfRootLocatorPort",port,false); - } - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); - } - } else { - try { - ComponentDescription objCD = ((ComponentDescription)node); - name = ((ComponentDescription)objCD).sfCompleteName().toString(); - name = name.substring(name.lastIndexOf(".")); - } catch (Exception ex) { - message.append("\n Error: "+ex.toString()); - } + } else { + try { + ComponentDescription objCD = ((ComponentDescription)node); + name = ((ComponentDescription)objCD).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); + } + } + modalDialog("Introspection "+ name , introspect(node), "", source); + } + + private void diagnosticsReport(Object node, Object source) { + StringBuffer message=new StringBuffer(); + String name = "error"; + if (node instanceof Prim) { + try { + Prim objPrim = ((Prim)node); + message.append(objPrim.sfDiagnosticsReport()); + name = ((Prim)objPrim).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); } + } else { + try { + ComponentDescription objCD = ((ComponentDescription)node); + message.append(((ComponentDescriptionImpl)objCD).sfDiagnosticsReport()); + name = ((ComponentDescription)objCD).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); + } + } + modalDialog("Context info for "+ name , message.toString(), "", source); + } + + private void dumpState (Object node, Object source) { + StringBuffer message=new StringBuffer(); + String name = "error"; + if (node instanceof Prim) { try { - Object obj = (parent.getParent()); - SFDeployDisplay.addScriptingPanel(((JTabbedPane)(obj)) ,name ,node, hostname ,port ); - } catch (Exception e1) { - if (sfLog().isErrorEnabled()) sfLog().error (e1); - WindowUtilities.showError(this,e1.toString()); + Prim objPrim = ((Prim)node); + message.append ("\n*************** State *****************\n"); + Dump dumpObj = new DefaultDumper(); + objPrim.sfDumpState(dumpObj); + message.append (dumpObj.toString()); + name = ((Prim)objPrim).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); } + } else { + try { + ComponentDescription objCD = ((ComponentDescription)node); + message.append(((ComponentDescriptionImpl)objCD).sfDiagnosticsReport()); + name = ((ComponentDescription)objCD).sfCompleteName().toString(); + } catch (Exception ex) { + message.append("\n Error: "+ex.toString()); + } } + modalDialog("State for "+ name , message.toString(), "", source); } + + public static String introspect(Object node) { StringBuffer message = new StringBuffer(); message.append("\n***** Class****\n"); Added: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/DefaultDumper.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/DefaultDumper.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/DefaultDumper.java 2007-06-12 18:51:05 UTC (rev 4300) @@ -0,0 +1,229 @@ +/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ + +package org.smartfrog.sfcore.prim; + +import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl; +import org.smartfrog.sfcore.common.*; + +import java.rmi.RemoteException; +import java.util.Hashtable; +import java.util.Date; +import java.util.Set; +import java.util.HashSet; + + +public class DefaultDumper implements Dump { + + ComponentDescription cd = null; + + ComponentDescription lastCD =null; + + ComponentDescription lastChild = null; + + Hashtable visiting = new Hashtable(); + + public void DefaultDumper (Context context){ + //cd = new ComponentDescriptionImpl(null,context,false); + } + + /** + * Components use this methods to dump their state to when requested (using + * sfDumpState). + * + * @param state state of component (application specific) + * @param from source of this call + * + * @throws java.rmi.RemoteException In case of Remote/nework error + */ + public void dumpState(Object state, Prim from) throws RemoteException { + visiting(""); + +// System.out.println("\n *******************************"); +// System.out.println("***"+from.sfCompleteName()+" \n"+state); +// System.out.println("\n *******************************"); +// System.out.println("------Before------"); +// System.out.println("From \n"+from.sfCompleteName()+""); +// System.out.println("---"); +// System.out.println("cd\n"+cd); +// System.out.println("---"); +// System.out.println("lastCD\n"+lastCD); +// System.out.println("---"); +// System.out.println("lastChild (what we added)\n"+lastChild); +// System.out.println("--end-Before------"); + Context stateClone = (Context)((Context)state).clone(); + if (cd==null){ + cd = new ComponentDescriptionImpl(null,(Context)stateClone,false); + lastCD = cd; + System.out.println("Created new cd for: "+from.sfCompleteName()+"\n"+cd.toString()); + } else { + if (lastCD.sfContainsValue(from)){ +// System.out.println("for: "+from.sfCompleteName()+" using lastCD."); + } else if (lastChild.sfContainsValue(from)) { + lastCD=lastChild; +// System.out.println("for: "+from.sfCompleteName()+" using lastChild."); + } else if (lastCD.sfParent().sfContainsValue(from)) { + lastCD=lastCD.sfParent(); +// System.out.println("for: "+from.sfCompleteName()+" using lastParent."); + } else { +// System.out.println("I don't know what is going on" + from.sfCompleteName()); + } + Object key = lastCD.sfAttributeKeyFor(from); + lastChild = new ComponentDescriptionImpl (lastCD,stateClone,false); + try { + lastCD.sfReplaceAttribute(key,lastChild); + System.out.println("lastChild (what we added) "+"name "+ key +" \n"+lastChild.toString()); + } catch (SmartFrogRuntimeException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } +// System.out.println("------after------"); +// System.out.println("From \n"+from.sfCompleteName()+""); +// System.out.println("---"); +// System.out.println("cd\n"+cd); +// System.out.println("---"); +// System.out.println("lastCD\n"+lastCD); +// System.out.println("---"); +// System.out.println("lastChild (what we added)\n"+lastChild); +// System.out.println("---end after----"); +// System.out.println("\n *******************************"); + visited(from.sfCompleteName().toString()); + } + + + protected Long visitingLocks = new Long(0); + /** + * Tries to get the the String once the object finished visiting all nodes + * or until given timeout expires. + * + * @param timeout max time to wait in millis + * + * @return The string representation of the description + * + * @throws Exception attribute not found after timeout + * @throws RemoteException if there is any network or remote error + * + */ + public String toString( long timeout) throws Exception { + long endTime = (new Date()).getTime()+timeout; + Thread.sleep(10); + synchronized (visitingLocks) { + //System.out.println("will I wait? #"+visitingLocks); + while (visitingLocks.longValue()!=0L) { + // try to return the String if not visiting logs. + // if name in locks => process not ready, pretend not found... + if (visitingLocks.longValue()==0L){ + //System.out.println("No wait #"+visitingLocks); + return getStringCD(); + } else { + // not found, wait for leftover timeout + long now = (new Date()).getTime(); + if (now>=endTime) { + throw new SmartFrogException("Description creation Timeout"); + } + try { + //System.out.println("Waiting: #"+visitingLocks); + visitingLocks.wait(endTime-now); + //System.out.println("Finished waiting: #"+visitingLocks); + } catch (InterruptedException e) { + //System.out.println(" Done with waiting (expired): #"+visitingLocks); + return getStringCD(); + } + + } + } + } + //System.out.println(" no more waiting return actual cd"); + return getStringCD(); + } + + /** + * Allows a visitor to notify that it is visiting a new node + + * @throws RemoteException if there is any network or remote error + * + */ + public void visiting(String name) throws RemoteException { + // Notify any waiting threads that an attribute was added + synchronized (visitingLocks) { + visitingLocks= new Long (visitingLocks.longValue()+1); + //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Visiting in progress: "+visitingLocks + " "+name); + } + } + + /** + * Allows a visitor to notify that it has fishished + * ready to receive deployment requests. + * + + * @throws RemoteException if there is any network or remote error + * + */ + public void visited(String name) throws RemoteException { + // Notify any waiting threads that an attribute was added + synchronized (visitingLocks) { + visitingLocks= new Long (visitingLocks.longValue()-1); + //System.out.println("------------------------------- Visiting in remaining: "+visitingLocks+ " "+name); + if (visitingLocks.longValue()==0) { + // System.out.println("Done all visits"); + visitingLocks.notifyAll(); + } + } + } + + protected String getStringCD(){ + return "sfConfig extends {\n" + + cd.toString() + + "}"; + } + + /** + * Returns a string representation of the component. This will give a + * description of the component which is parseable, and deployable + * again... Unless someone removed attributes which are essential to + * startup that is. Large description trees should be written out using + * writeOn since memory for large strings runs out quick! + * + * @return string representation of component + */ + public String toString() { + try { +// System.out.println("------------------"); +// System.out.println("---TO STring before: ---"); +// System.out.println("------------------"); + String cdStr = toString(5*1000L); +// System.out.println("------------------"); +// System.out.println("---TO STring after: ---"); +// System.out.println("------------------"); +// System.out.println("cd\n"+cd); +// System.out.println("---"); +// System.out.println("lastCD\n"+lastCD); +// System.out.println("---"); +// System.out.println("lastChild (what we added)\n"+lastChild); +// System.out.println("--end--toString---"); + return cdStr; + } catch (Exception ex){ + ex.printStackTrace(); + return (ex.toString()); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |