From: <ju...@us...> - 2008-08-06 14:43:31
|
Revision: 6902 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=6902&view=rev Author: julgui Date: 2008-08-06 14:43:26 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Fix in -p option format check Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2008-08-06 14:11:27 UTC (rev 6901) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2008-08-06 14:43:26 UTC (rev 6902) @@ -252,7 +252,7 @@ */ public void exitWith(String str, int exitCode) { if (str != null) { - System.err.println(str); + System.err.println("\n "+ str); } exitWithStatus(true,exitCode); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2008-08-06 14:11:27 UTC (rev 6901) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2008-08-06 14:43:26 UTC (rev 6902) @@ -184,8 +184,16 @@ } } } else if ("-p".equals(currentArg)|| "-port".equals(currentArg)) { - - System.setProperty("org.smartfrog.sfcore.processcompound.sfRootLocatorPort",readLocationPort(args[++i])); + String port = args[++i]; + try { + System.setProperty("org.smartfrog.sfcore.processcompound.sfRootLocatorPort", readLocationPort(port)); + } catch (NumberFormatException nex) { + exitCode = ExitCodes.EXIT_ERROR_CODE_BAD_ARGS; + errorString = ("Wrong port number (-p option): "+port); + if ((Logger.logStackTrace) && SFSystem.sfLog().isErrorEnabled()) { + SFSystem.sfLog().error(errorString, nex); + } + } } else if ("-d".equals(currentArg) || "-diagnostics".equals(currentArg)) { //diagnostics diagnostics = true; @@ -282,9 +290,9 @@ return cfgDescriptors; } - String readLocationPort(String sfRootLocatorPort) { + String readLocationPort(String sfRootLocatorPort) throws NumberFormatException { //Check that the value is correct - Integer.getInteger(sfRootLocatorPort); + Integer.parseInt(sfRootLocatorPort); return sfRootLocatorPort; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-08-12 16:06:41
|
Revision: 6946 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=6946&view=rev Author: julgui Date: 2008-08-12 16:06:36 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Merge with latest SmartFrog core Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/IncludeHandler.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/container.sf Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesCompoundImpl.java 2008-08-12 15:50:20 UTC (rev 6945) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesCompoundImpl.java 2008-08-12 16:06:36 UTC (rev 6946) @@ -24,14 +24,13 @@ import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.compound.CompoundImpl; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.services.filesystem.FileIntf; +import org.smartfrog.SFSystem; import java.rmi.RemoteException; import java.io.File; -import java.util.Set; -import java.util.HashSet; -import java.util.Arrays; -import java.util.Vector; +import java.util.*; /** * Created 21-Apr-2008 14:44:35 @@ -57,7 +56,16 @@ //start all our children super.sfStart(); - //now run through our children and, for all that implement File or Files, add them to our list. + + Vector<String> fileVector = getFileList(); + + + sfReplaceAttribute(Files.ATTR_FILE_SET_STRING, fileList); + sfReplaceAttribute(Files.ATTR_FILELIST, fileVector); + checkAndUpdateFileCount(); + } + + private Vector<String> getFileList() throws RemoteException, SmartFrogException {//now run through our children and, for all that implement File or Files, add them to our list. aggregateChildFiles(); int filesize = fileset.size(); Vector<String> fileVector = new Vector<String>(filesize); @@ -72,11 +80,36 @@ aggregatePath.append(File.pathSeparatorChar); } fileList = aggregatePath.toString(); - sfReplaceAttribute(Files.ATTR_FILE_SET_STRING, fileList); - sfReplaceAttribute(Files.ATTR_FILELIST, fileVector); - checkAndUpdateFileCount(); + return fileVector; } + //-------- For External use by passing a CD + public static String getFileList(ComponentDescription cd) throws RemoteException, SmartFrogException {//now run through our children and, for all that implement File or Files, add them to our list. + StringBuilder aggregatePath = new StringBuilder(); + for (Iterator values = cd.sfValues(); values.hasNext();) { + Object value = values.next(); + if (value instanceof ComponentDescription) { + try { + Fileset fileset = FilesImpl.resolveFileset((ComponentDescription) value); + if (!aggregatePath.toString().equals("")&& aggregatePath.toString().endsWith(""+File.pathSeparatorChar)){ + aggregatePath.append(File.pathSeparatorChar); + } + aggregatePath.append(fileset.toString()); + return (aggregatePath.toString()); + } catch (Exception rex){ + SFSystem.sfLog().err( rex ); + return null; + } + } + + } + return aggregatePath.toString(); + } + + + + //-------------- end CD ------------- + /** * go through our children and aggregate their files * @throws RemoteException In case of Remote/network error Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/IncludeHandler.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/IncludeHandler.java 2008-08-12 15:50:20 UTC (rev 6945) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/IncludeHandler.java 2008-08-12 16:06:36 UTC (rev 6946) @@ -20,6 +20,8 @@ package org.smartfrog.sfcore.languages.sf; +import org.smartfrog.sfcore.languages.sf.sfreference.SFReference; + import java.util.Vector; /** @@ -38,5 +40,5 @@ * * @exception Exception error while locating or parsing include */ - public Vector parseInclude(String include, String codebase) throws Exception; + public Vector parseInclude(String include, SFReference codebase) throws Exception; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java 2008-08-12 15:50:20 UTC (rev 6945) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java 2008-08-12 16:06:36 UTC (rev 6946) @@ -94,6 +94,9 @@ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } + + + for (Iterator i = cd.sfAttributes(); i.hasNext(); ) { Object next = i.next(); Object value = cd.sfContext().get(next); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/container.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/container.sf 2008-08-12 15:50:20 UTC (rev 6945) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/combinators/container.sf 2008-08-12 16:06:36 UTC (rev 6946) @@ -19,7 +19,7 @@ */ #include "/org/smartfrog/sfcore/workflow/eventbus/eventbus.sf" -Container extends EventCompound { +Container extends EventCompound, Parallel { sfClass "org.smartfrog.sfcore.workflow.combinators.Container"; //actions extends LAZY {} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2008-08-18 14:28:49
|
Revision: 6967 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=6967&view=rev Author: steve_l Date: 2008-08-18 14:28:45 +0000 (Mon, 18 Aug 2008) Log Message: ----------- SFOS-956 some subclasses of ChildMinder don't have a fully typed Enumeration<> on their sfChildren() method Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/legacy/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ParentHelper.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SerializableEnumeration.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/legacy/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/legacy/statemodel/state/Composite.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/legacy/statemodel/state/Composite.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -5,6 +5,7 @@ import org.smartfrog.sfcore.common.Context; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogUpdateException; +import org.smartfrog.sfcore.prim.Liveness; import java.rmi.RemoteException; import java.util.Enumeration; @@ -33,7 +34,7 @@ //child down to State, where it is handled public void handleStateChange() { - for (Enumeration e = sfChildren(); e.hasMoreElements(); ) { + for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { Object c = e.nextElement(); if (c instanceof StateChangeNotification) try { ((StateChangeNotification)c).handleStateChange(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -5,6 +5,7 @@ import org.smartfrog.sfcore.common.Context; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogUpdateException; +import org.smartfrog.sfcore.prim.Liveness; import java.rmi.RemoteException; import java.util.Enumeration; @@ -34,7 +35,7 @@ //child down to State, where it is handled public void handleStateChange() { - for (Enumeration e = sfChildren(); e.hasMoreElements(); ) { + for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { Object c = e.nextElement(); if (c instanceof StateChangeNotification) ((StateChangeNotification)c).handleStateChange(); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -44,6 +44,7 @@ import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.Liveness; import org.smartfrog.sfcore.processcompound.ProcessCompound; import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.security.SFClassLoader; @@ -381,7 +382,7 @@ * @param compound Compound */ public static void doReportCompound(StringBuffer out, Compound compound) { - Enumeration enu = null; + Enumeration<Liveness> enu = null; StringBuilder childrenInfo = new StringBuilder(); Prim child = null; try { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -473,8 +473,9 @@ * * @return enumeration over children */ - public Enumeration sfChildren() { - return new SerializableEnumeration<Prim>(sfChildren); + @SuppressWarnings("unchecked") + public Enumeration<Liveness> sfChildren() { + return new SerializableEnumeration<Liveness>((List) sfChildren); } /** @@ -486,6 +487,7 @@ * @since SmartFrog 3.13.003 * @return a cloned list of all deployed children */ + @SuppressWarnings("unchecked") public List<Prim> sfChildList() { return (List<Prim>)sfChildren.clone(); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ParentHelper.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ParentHelper.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ParentHelper.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -128,6 +128,7 @@ * @return a cloned list of all deployed children * @since SmartFrog 3.13.003 */ + @SuppressWarnings("unchecked") public List<Prim> sfChildList() { return (List<Prim>) sfChildren.clone(); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SerializableEnumeration.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SerializableEnumeration.java 2008-08-18 10:58:55 UTC (rev 6966) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SerializableEnumeration.java 2008-08-18 14:28:45 UTC (rev 6967) @@ -39,7 +39,7 @@ } public SerializableEnumeration(List<T> source) { - iterator=new SerializableIterator<T>(source); + iterator = new SerializableIterator<T>(source); } public SerializableEnumeration(T[] source) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2008-08-29 09:55:02
|
Revision: 7000 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7000&view=rev Author: steve_l Date: 2008-08-29 09:54:57 +0000 (Fri, 29 Aug 2008) Log Message: ----------- fix some javadoc complaints that CC was taking exception to; refomart ConstraintResolutionState and rename one of its (private) fields to be consistent with the rest of the codebase. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintResolutionState.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java 2008-08-28 17:58:44 UTC (rev 6999) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java 2008-08-29 09:54:57 UTC (rev 7000) @@ -148,8 +148,8 @@ } /** - * Flag that is true if the process is consideered active - * @return + * Flag that is true if the process is considered active + * @return true if the the process is working */ public boolean ready() { return (getProcessState() == STATE_PROCESSING); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintResolutionState.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintResolutionState.java 2008-08-28 17:58:44 UTC (rev 6999) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintResolutionState.java 2008-08-29 09:54:57 UTC (rev 7000) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-2008 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 @@ -16,8 +16,7 @@ For more information: www.smartfrog.org -*/ - + */ package org.smartfrog.sfcore.languages.sf.constraints; import java.util.Vector; @@ -33,363 +32,389 @@ * @author anfarr * */ +public class ConstraintResolutionState { -public class ConstraintResolutionState { - /** - * Records link resolution history. Concerned with maintaining undo information when constraints are used - */ - //It is necessary to maintain link history separately as backtracking occurs to a finer granularity than Constraint types - private Vector<LinkHistoryRecord> linkHistory = new Vector<LinkHistoryRecord>(); - - /** - * Maintains a history of Constraint goals that have been (successfully) evaluated - */ - private Vector<ConstraintEvalHistoryRecord> constraintEvalHistory = new Vector<ConstraintEvalHistoryRecord>(); - - /** - * Indicates current link history record being used. - */ + /** + * Records link resolution history. Concerned with maintaining undo information when constraints are used + */ + //It is necessary to maintain link history separately as backtracking occurs to a finer granularity than Constraint types + private Vector<LinkHistoryRecord> linkHistory = new Vector<LinkHistoryRecord>(); + /** + * Maintains a history of Constraint goals that have been (successfully) evaluated + */ + private Vector<ConstraintEvalHistoryRecord> constraintEvalHistory = new Vector<ConstraintEvalHistoryRecord>(); + /** + * Indicates current link history record being used. + */ private LinkHistoryRecord currentLHRecord; - /** * Used to maintain whether backtracking -- as part of constraint solving -- has just occurred in processing current attribute. */ - private Context backtrackedTo=null; - + private Context backtrackedTo = null; + /** - * Gets whether backtracking has occurred recently - * @return backtracking flag - */ - public Context hasBacktrackedTo() { return backtrackedTo; } - + * Gets whether backtracking has occurred recently + * @return backtracking flag + */ + public Context hasBacktrackedTo() { + return backtrackedTo; + } + /** * Resets flag wrt backtracking */ - public void resetDoneBacktracking() { backtrackedTo=null; } - + public void resetDoneBacktracking() { + backtrackedTo = null; + } /** * Indicates whether manipulations of context attributes should currently have undo records created for them */ - private boolean m_constraintsShouldUndo = false; - + private boolean constraintsShouldUndo = false; + /** * Sets whether manipulations of context attributes should currently have undo records created for them * @param shouldUndo */ - public void setConstraintsShouldUndo(boolean shouldUndo){ m_constraintsShouldUndo = shouldUndo; } - + public void setConstraintsShouldUndo(boolean shouldUndo) { + constraintsShouldUndo = shouldUndo; + } + /** * Constructs ConstraintResolutionState, allocating a link history record * */ - ConstraintResolutionState(){ - currentLHRecord = new LinkHistoryRecord(); - linkHistory.add(currentLHRecord); - } - - /** - * Maintains a record pertaining to a single constraint evaluation - * @author anfarr - * - */ - private class ConstraintEvalHistoryRecord { - /** - * Indicates the current LRSRecord being processed - */ - LRSRecord lrsr; - /** - * Indicates the current attribute being processed, triggering constraint evaluation - */ - int idx; - /** - * The context of the component description being processed - */ - Context cxt; - } - - /** - * Link history record - */ - private class LinkHistoryRecord { - /** - * The undo stack for this record - */ - Vector<LRSUndoRecord> undo_stack = new Vector<LRSUndoRecord>(); - /** - * Add a single undo record - * @param lrsu undo record to add - */ - void addUndo(LRSUndoRecord lrsu){ undo_stack.add(lrsu); } - /** - * Undo all actions recorded herein - */ - void undoAll() { - for (int i=undo_stack.size()-1;i>=0;i--){ - undo_stack.remove(i).undo(); - } - } - } + ConstraintResolutionState() { + currentLHRecord = new LinkHistoryRecord(); + linkHistory.add(currentLHRecord); + } /** + * Maintains a record pertaining to a single constraint evaluation + * @author anfarr + * + */ + private class ConstraintEvalHistoryRecord { + + /** + * Indicates the current LRSRecord being processed + */ + LRSRecord lrsr; + /** + * Indicates the current attribute being processed, triggering constraint evaluation + */ + int idx; + /** + * The context of the component description being processed + */ + Context cxt; + } + + /** + * Link history record + */ + private class LinkHistoryRecord { + + /** + * The undo stack for this record + */ + Vector<LRSUndoRecord> undo_stack = new Vector<LRSUndoRecord>(); + + /** + * Add a single undo record + * @param lrsu undo record to add + */ + void addUndo(LRSUndoRecord lrsu) { + undo_stack.add(lrsu); + } + + /** + * Undo all actions recorded herein + */ + void undoAll() { + for ( int i = undo_stack.size() - 1; i >= 0; i-- ) { + undo_stack.remove(i).undo(); + } + } + } + + /** * Abstract class for undo actions */ - abstract private class LRSUndoRecord{ - /** - * Does the undo! - * - */ - abstract void undo(); + private abstract class LRSUndoRecord { + + /** + * Does the undo! + * + */ + abstract void undo(); } - + /** * Put in context undo action */ private class LRSUndoPut extends LRSUndoRecord { + /** * Pertinent context for undo action */ - Context ctxt; - /** - * Key for undo action - */ - Object key; - /** - * Value to eg put back in context for key - */ - Object value; - - /** - * Constructs single undo action to undo attribute setting in a Context - * @param ctxt context for undo action - * @param key key to undo put value - * @param value value to restore - */ - LRSUndoPut(Context ctxt, Object key, Object value){ - this.ctxt=ctxt; this.key=key; this.value=value; - } - - /** - * Does the undo! - * - */ - void undo(){ - if (value!=null) ctxt.put(key, value); - else ctxt.remove(key); - } + Context ctxt; + /** + * Key for undo action + */ + Object key; + /** + * Value to eg put back in context for key + */ + Object value; + + /** + * Constructs single undo action to undo attribute setting in a Context + * @param ctxt context for undo action + * @param key key to undo put value + * @param value value to restore + */ + LRSUndoPut(Context ctxt, Object key, Object value) { + this.ctxt = ctxt; + this.key = key; + this.value = value; + } + + /** + * Does the undo! + * + */ + void undo() { + if ( value != null ) { + ctxt.put(key, value); + } else { + ctxt.remove(key); + } + } } - /** * Undo on FreeVar info setting */ private class LRSUndoFVInfo extends LRSUndoRecord { - /** - * FreeVar to undo information setting on... - */ - FreeVar fv; - - /** - * Constructs single undo action for undoing FreeVar manipulation - * @param fv FreeVar - * @param type What type of undoing should we do? Either undo type setting (g_LRSUndo_PUTFVTYPESTR) or cons eval info (g_LRSUndo_PUTFVINFO) - */ - LRSUndoFVInfo(FreeVar fv){ - this.fv=fv; - } - - /** - * Does the undo! - * - */ - void undo(){ - fv.resetConsEvalInfo(); - } + + /** + * FreeVar to undo information setting on... + */ + FreeVar fv; + + /** + * Constructs single undo action for undoing FreeVar manipulation + * @param fv FreeVar + * @param type What type of undoing should we do? Either undo type setting (g_LRSUndo_PUTFVTYPESTR) or cons eval info (g_LRSUndo_PUTFVINFO) + */ + LRSUndoFVInfo(FreeVar fv) { + this.fv = fv; + } + + /** + * Does the undo! + * + */ + void undo() { + fv.resetConsEvalInfo(); + } } - /** * Undo on FreeVar type string setting */ private class LRSUndoFVTypeStr extends LRSUndoRecord { - /** - * FreeVar to undo type string setting on... - */ - FreeVar fv; - - /** - * Constructs single undo action for undoing FreeVar manipulation - * @param fv FreeVar - * @param type What type of undoing should we do? Either undo type setting (g_LRSUndo_PUTFVTYPESTR) or cons eval info (g_LRSUndo_PUTFVINFO) - */ - LRSUndoFVTypeStr(FreeVar fv){ - this.fv=fv; - } - - /** - * Does the undo! - * - */ - void undo(){ - fv.clearTyping(); - } + + /** + * FreeVar to undo type string setting on... + */ + FreeVar fv; + + /** + * Constructs single undo action for undoing FreeVar manipulation + * @param fv FreeVar + * @param type What type of undoing should we do? Either undo type setting (g_LRSUndo_PUTFVTYPESTR) or cons eval info (g_LRSUndo_PUTFVINFO) + */ + LRSUndoFVTypeStr(FreeVar fv) { + this.fv = fv; + } + + /** + * Does the undo! + * + */ + void undo() { + fv.clearTyping(); + } } - - /** - * Adds single undo action to current lhr for undo attribute setting in a Context - * @param ctxt context for undo action + + /** + * Adds single undo action to current lhr for undo attribute setting in a Context + * @param ctxt context for undo action * @param key key to undo put value - * @param value value to restore - */ - public void addUndoPut(Context ctxt, Object key, Object value){ - if (m_constraintsShouldUndo) currentLHRecord.addUndo(new LRSUndoPut(ctxt, key, value)); - } - - /** - * Adds single undo action to current lhr for undoing FreeVar info stetting - * @param fv FreeVar + * @param value value to restore */ - public void addUndoFVInfo(FreeVar fv){ - currentLHRecord.addUndo(new LRSUndoFVInfo(fv)); - } - - /** - * Adds single undo action to current lhr for undoing FreeVar type string stetting - * @param fv FreeVar + public void addUndoPut(Context ctxt, Object key, Object value) { + if ( constraintsShouldUndo ) { + currentLHRecord.addUndo(new LRSUndoPut(ctxt, key, value)); + } + } + + /** + * Adds single undo action to current lhr for undoing FreeVar info stetting + * @param fv FreeVar */ - public void addUndoFVTypeStr(FreeVar fv){ - currentLHRecord.addUndo(new LRSUndoFVTypeStr(fv)); - } - - /** - * Sets typing for FreeVar attribute in current constraint context - * @param attr FreeVar attribute - * @param types Vector of type references representing typing - */ - public void setTyping(String attr, Vector types){ - //Get current constraint context record - int last_cidx = constraintEvalHistory.size()-1; - ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(last_cidx); - - //Get value object for attribute - Object val = cehr.cxt.get(attr); - if (val instanceof FreeVar){ - //And if FreeVar... - FreeVar fv = (FreeVar) val; - //Set typing information... - fv.setTyping(types); - //need to add an undo record for the typing... - addUndoFVTypeStr(fv); - } - } - - /** - * If a value to-be-set for a FreeVar is the name of an attribute in the current context and which resolves to a component description, then protocol dictates that we want to use this attribute's value... - * @param key Value to be provisionally used in set - * @return Given key unless key is an attrribute in current context which resolves to a component description, then returns value of said attribute - */ - public Object adjustSetValue(Object key){ - //Get current constraint context record - int last_cidx = constraintEvalHistory.size()-1; - ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(last_cidx); - - //Is the key an attribute? - Object val = cehr.cxt.get(key); - - //If so, and component description then return val else return key... - if (val!=null && val instanceof ComponentDescription) return val; - else return key; - } - - /** - * Add an assignment of an attribute within a description - * @param idx The appropriate link history record - * @param key Attribute to set - * @param val Value to set - * @param cidx The appropriate constraint eval record - */ - - public boolean addConstraintAss(ComponentDescription solve_comp, String key, Object val, int cidx) throws SmartFrogResolutionException { - //Get constraint record pertaining to the attribute to be set... - ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(cidx); - - //Get typing information for attribute to be set... - Object cur_val = cehr.cxt.get(key); - Vector types=null; - if (cur_val instanceof FreeVar) types = ((FreeVar) cur_val).getTyping(); - - //If value to be set is not of correct type then bail... - if (types!=null && (!(val instanceof ComponentDescription) || - !ofTypes(solve_comp, (ComponentDescription)val, types))) return false; - - //set the value prescribed - m_constraintsShouldUndo=true; - cehr.cxt.put(key, val); - //System.out.println("Setting "+key+":"+cehr.cxt.get(key)+" in "+cidx); - m_constraintsShouldUndo=false; - - return true; - } - /** Checks that a candidate component description is of a given typing - * @param solve_comp ComponentDescription pertaining to current Constraint context - * @param comp ComponentDescription representing candidate value for setting - * @param types Vector of type references representing typing - * @return true if of given typing, false otherwise - * @throws SmartFrogResolutionException - */ - public boolean ofTypes(ComponentDescription solve_comp, ComponentDescription comp, Vector types) throws SmartFrogResolutionException { - Context type_cxt = null; - //Compose the benchmark type - try { - type_cxt = SFComponentDescriptionImpl.composeTypes(solve_comp, types).sfContext(); - } catch (SmartFrogResolutionException smfre){ - throw new SmartFrogResolutionException("Unable to compose types in sub-type evaluation."); - } - //Return if of composed benchmark type... - return type_cxt.ofType(comp); - } - - public void backtrackConstraintAss(int idx, int cidx){ - //Get constraint record pertaining to current position in constraint solving - ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(cidx); - - //Have we backtracked? - int constraintEvalHistoryLastIdx = constraintEvalHistory.size()-1; - if (backtrackedTo==null && cidx<constraintEvalHistoryLastIdx) backtrackedTo = cehr.cxt; - - //Backtrack constraint record history as appropriate... - for (int i=constraintEvalHistoryLastIdx; i>cidx; i--) constraintEvalHistory.remove(i); - CoreSolver.getInstance().getRootDescription().setLRSIdx(cehr.idx); - CoreSolver.getInstance().getRootDescription().setLRSRecord(cehr.lrsr); - - //Backtrack histroy as approp... - for (int i=linkHistory.size()-1; i>idx; i--) linkHistory.remove(i).undoAll(); - - //Create new history... - currentLHRecord = new LinkHistoryRecord(); - linkHistory.add(currentLHRecord); - } - - /** - * Add a record to cons eval history - * @param cxt Given context - * @return Latest record index - */ - public int addConstraintEval(Context cxt){ - int idx = constraintEvalHistory.size(); - ConstraintEvalHistoryRecord cehr = new ConstraintEvalHistoryRecord(); - cehr.lrsr = CoreSolver.getInstance().getRootDescription().getLRSRecord(); - cehr.idx = CoreSolver.getInstance().getRootDescription().getLRSIdx(); - cehr.cxt = cxt; - constraintEvalHistory.add(cehr); - return idx; + public void addUndoFVInfo(FreeVar fv) { + currentLHRecord.addUndo(new LRSUndoFVInfo(fv)); } - + /** + * Adds single undo action to current lhr for undoing FreeVar type string stetting + * @param fv FreeVar + */ + public void addUndoFVTypeStr(FreeVar fv) { + currentLHRecord.addUndo(new LRSUndoFVTypeStr(fv)); + } + + /** + * Sets typing for FreeVar attribute in current constraint context + * @param attr FreeVar attribute + * @param types Vector of type references representing typing + */ + public void setTyping(String attr, Vector types) { + //Get current constraint context record + int last_cidx = constraintEvalHistory.size() - 1; + ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(last_cidx); + + //Get value object for attribute + Object val = cehr.cxt.get(attr); + if ( val instanceof FreeVar ) { + //And if FreeVar... + FreeVar fv = (FreeVar) val; + //Set typing information... + fv.setTyping(types); + //need to add an undo record for the typing... + addUndoFVTypeStr(fv); + } + } + + /** + * If a value to-be-set for a FreeVar is the name of an attribute in the + * current context and which resolves to a component description, + * then protocol dictates that we want to use this attribute's value... + * @param key Value to be provisionally used in set + * @return Given key unless key is an attrribute in current context which + * resolves to a component description, then returns value of said attribute + */ + public Object adjustSetValue(Object key) { + //Get current constraint context record + int last_cidx = constraintEvalHistory.size() - 1; + ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(last_cidx); + + //Is the key an attribute? + Object val = cehr.cxt.get(key); + + //If so, and component description then return val else return key... + if ( val != null && val instanceof ComponentDescription ) { + return val; + } else { + return key; + } + } + + /** + * Add an assignment of an attribute within a description + * @param solve_comp ComponentDescription pertaining to current Constraint context + * @param key Attribute to set + * @param val Value to set + * @param cidx The appropriate constraint eval record + */ + public boolean addConstraintAss(ComponentDescription solve_comp, String key, Object val, int cidx) + throws SmartFrogResolutionException { + //Get constraint record pertaining to the attribute to be set... + ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(cidx); + + //Get typing information for attribute to be set... + Object cur_val = cehr.cxt.get(key); + Vector types = null; + if ( cur_val instanceof FreeVar ) { + types = ((FreeVar) cur_val).getTyping(); //If value to be set is not of correct type then bail... + } + if ( types != null && (!(val instanceof ComponentDescription) || + !ofTypes(solve_comp, (ComponentDescription) val, types)) ) { + return false; //set the value prescribed + } + constraintsShouldUndo = true; + cehr.cxt.put(key, val); + //System.out.println("Setting "+key+":"+cehr.cxt.get(key)+" in "+cidx); + constraintsShouldUndo = false; + + return true; + } + + /** Checks that a candidate component description is of a given typing + * @param solve_comp ComponentDescription pertaining to current Constraint context + * @param comp ComponentDescription representing candidate value for setting + * @param types Vector of type references representing typing + * @return true if of given typing, false otherwise + * @throws SmartFrogResolutionException if the composition fails + */ + public boolean ofTypes(ComponentDescription solve_comp, ComponentDescription comp, Vector types) + throws SmartFrogResolutionException { + Context type_cxt = null; + //Compose the benchmark type + try { + type_cxt = SFComponentDescriptionImpl.composeTypes(solve_comp, types).sfContext(); + } catch (SmartFrogResolutionException smfre) { + throw new SmartFrogResolutionException("Unable to compose types in sub-type evaluation."); + } + //Return if of composed benchmark type... + return type_cxt.ofType(comp); + } + + public void backtrackConstraintAss(int idx, int cidx) { + //Get constraint record pertaining to current position in constraint solving + ConstraintEvalHistoryRecord cehr = constraintEvalHistory.get(cidx); + + //Have we backtracked? + int constraintEvalHistoryLastIdx = constraintEvalHistory.size() - 1; + if ( backtrackedTo == null && cidx < constraintEvalHistoryLastIdx ) { + backtrackedTo = cehr.cxt; //Backtrack constraint record history as appropriate... + } + for ( int i = constraintEvalHistoryLastIdx; i > cidx; i-- ) { + constraintEvalHistory.remove(i); + } + CoreSolver.getInstance().getRootDescription().setLRSIdx(cehr.idx); + CoreSolver.getInstance().getRootDescription().setLRSRecord(cehr.lrsr); + + //Backtrack histroy as approp... + for ( int i = linkHistory.size() - 1; i > idx; i-- ) { + linkHistory.remove(i).undoAll(); //Create new history... + } + currentLHRecord = new LinkHistoryRecord(); + linkHistory.add(currentLHRecord); + } + + /** + * Add a record to cons eval history + * @param cxt Given context + * @return Latest record index + */ + public int addConstraintEval(Context cxt) { + int idx = constraintEvalHistory.size(); + ConstraintEvalHistoryRecord cehr = new ConstraintEvalHistoryRecord(); + cehr.lrsr = CoreSolver.getInstance().getRootDescription().getLRSRecord(); + cehr.idx = CoreSolver.getInstance().getRootDescription().getLRSIdx(); + cehr.cxt = cxt; + constraintEvalHistory.add(cehr); + return idx; + } + + /** * Gets the latest record index of the cons eval history * @return latest index */ - public int getConsEvalIdx(){ - return constraintEvalHistory.size()-1; + public int getConsEvalIdx() { + return constraintEvalHistory.size() - 1; } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2008-10-24 15:16:24
|
Revision: 7123 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7123&view=rev Author: steve_l Date: 2008-10-24 15:13:53 +0000 (Fri, 24 Oct 2008) Log Message: ----------- SFOS-1009 clean up some name accesses that arent needed 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/conditional/WaitForImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2008-10-23 15:43:02 UTC (rev 7122) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestBlockImpl.java 2008-10-24 15:13:53 UTC (rev 7123) @@ -187,7 +187,7 @@ private void startupException(Exception e) throws SmartFrogRuntimeException, RemoteException { //this is called if we failed during startup - TerminationRecord fault = TerminationRecord.abnormal(ERROR_STARTUP_FAILURE, name, e); + TerminationRecord fault = TerminationRecord.abnormal(ERROR_STARTUP_FAILURE, getName(), e); end(fault); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2008-10-23 15:43:02 UTC (rev 7122) +++ trunk/core/smartfrog/src/org/smartfrog/services/assertions/TestCompoundImpl.java 2008-10-24 15:13:53 UTC (rev 7123) @@ -139,7 +139,6 @@ 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); @@ -213,7 +212,7 @@ sendEvent(new TestStartedEvent(this)); skipped = true; updateFlags(false); - String message = "Skipping test run " + name; + String message = "Skipping test run " + getName(); sfLog().info(message); //send a test started event //followed by a the closing results Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/WaitForImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/WaitForImpl.java 2008-10-23 15:43:02 UTC (rev 7122) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/conditional/WaitForImpl.java 2008-10-24 15:13:53 UTC (rev 7123) @@ -132,7 +132,7 @@ } if (fault != null) { //trouble -fail - sfTerminate(TerminationRecord.abnormal("Trouble during WaitFor", name, fault)); + sfTerminate(TerminationRecord.abnormal("Trouble during WaitFor", getName(), fault)); } } finally { synchronized (this) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-02-09 16:26:03
|
Revision: 7360 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7360&view=rev Author: anfarr Date: 2009-02-09 16:26:00 +0000 (Mon, 09 Feb 2009) Log Message: ----------- SFOS-1100: Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Aggregator.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-02-09 16:23:45 UTC (rev 7359) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-02-09 16:26:00 UTC (rev 7360) @@ -42,7 +42,7 @@ private ThreadPool threadpool; private Future<?> currentActionFuture = null; - private boolean asyncResponse = false; + protected boolean asyncResponse = false; private boolean m_running=false; private ReentrantLock transitionLock = new ReentrantLock(); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Aggregator.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Aggregator.java 2009-02-09 16:23:45 UTC (rev 7359) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Aggregator.java 2009-02-09 16:26:00 UTC (rev 7360) @@ -52,9 +52,11 @@ HashMap<Object, Object> others = new HashMap<Object, Object>(); //System.out.println("Getting sources..."); - + Constraint.getAggregateSources(comp, css); + //System.out.println("***AGGREGATOR***"+css.size()); + //System.out.println("Got sources..."); CoreSolver.getInstance().setShouldUndo(true); @@ -62,9 +64,9 @@ for (int i=0; i<css.size(); i++){ CompositeSource cs = css.get(i); - //System.out.println("****"+cs); + Constraint.extractArgumentsFromSource(cs); - Constraint.extractArgumentsFromSource(cs); + //System.out.println("***cs***"+cs); //Attach arguments to contained function types... Enumeration el_enum = orgContext.keys(); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2009-02-09 16:23:45 UTC (rev 7359) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2009-02-09 16:26:00 UTC (rev 7360) @@ -93,7 +93,7 @@ if (prefix instanceof String) prefix_s= (String) prefix; else throw new SmartFrogFunctionResolutionException("In Array: "+comp+", prefix must be a String..."); - /* PATH's are not currently offered for Arrays for simplicity. Additional measures for link resolution would need to be taken otherwise which I feel complicate matters + /* PATHs are not currently offered for Arrays for simplicity. Additional measures for link resolution would need to be taken otherwise which I feel complicate matters path = orgContext.get(ConstraintConstants.PATH); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-02-09 16:23:45 UTC (rev 7359) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-02-09 16:26:00 UTC (rev 7360) @@ -175,7 +175,7 @@ HashMap<FreeVar, Object> assigns = new HashMap<FreeVar, Object>(); - System.out.println("In constraint..."); + //System.out.println("In constraint..."); if (!CoreSolver.getInstance().getConstraintsPossible()) return comp; @@ -183,7 +183,7 @@ Vector<CompositeSource> aggs=new Vector<CompositeSource>(); - System.out.println("Fetching aggregate sources"); + //System.out.println("Fetching aggregate sources"); getAggregateSources(comp, aggs); for (int i=0;i<aggs.size();i++){ @@ -519,13 +519,14 @@ } public static void getAggregateSources(ComponentDescription comp, Vector<CompositeSource> css) throws SmartFrogFunctionResolutionException{ - System.out.println("YESYES"); + //System.out.println("YESYES"); + //Thread.dumpStack(); Context context = (Context) comp.sfContext().copy(); Enumeration en = context.keys(); Object key=null; - System.out.println("Comp"+comp); + //System.out.println("Comp"+comp); Object array = null; Object path = null; @@ -536,12 +537,12 @@ array = context.remove(ConstraintConstants.ARRAY); path = context.remove(ConstraintConstants.PATH); - System.out.println("111"); + //System.out.println("GAS111"); if (path!=null && path!=SFNull.get()){ //mandatory for aggregates and updates... - System.out.println("222"); + //System.out.println("GAS222"); if (array!=SFNull.get()){ Reference array_ref=null; @@ -558,7 +559,7 @@ if (!(array instanceof ComponentDescription) && !(array instanceof Prim)) throw new SmartFrogFunctionResolutionException("array ref:"+array_ref+" in: "+comp+" does not resolve to a Prim/ComponentDescription"); } else array=comp; - System.out.println("333"); + //System.out.println("GAS333"); if (!(path instanceof Reference)) throw new SmartFrogFunctionResolutionException("path in comp: "+comp+" must be a Reference"); @@ -573,7 +574,7 @@ } } //we assume that if it were present it would be as a cd... - System.out.println("444"); + //System.out.println("GAS444"); //Prefix... @@ -584,9 +585,9 @@ } context.remove(ConstraintConstants.PREFIX); - System.out.println("555"); + //System.out.println("GAS555"); - + boolean aggregated=false; Enumeration restKeys = context.keys(); while (restKeys.hasMoreElements()){ Object restKey = restKeys.nextElement(); @@ -598,7 +599,7 @@ if (restComp.sfContext().get(ConstraintConstants.AGG_SPEC)!=null){ Object unify = restComp.sfContext().get(ConstraintConstants.UNIFY); - System.out.println("ADDING:::"+cihm+":"+array+":"+prefix+":"+path+":"+restKey+":"+restComp+":"+unify); + //System.out.println("ADDING:::"+cihm+":"+array+":"+prefix+":"+path+":"+restKey+":"+restComp+":"+unify); CompositeSource cs = new CompositeSource(cihm, array, (String)prefix, @@ -607,10 +608,21 @@ restComp, unify); css.add(cs); + aggregated=true; } } + if (!aggregated) { + CompositeSource cs = new CompositeSource(cihm, + array, + (String)prefix, + (Reference)path, + null, + null, + null); + css.add(cs); + } } //System.out.println("Leaving getCS"); } @@ -625,6 +637,8 @@ try {en=(p!=null?p.sfContext():c.sfContext()).keys();} catch (Exception e){/*Shouldn't happen*/} while (en.hasMoreElements()){ + //System.out.println("222"); + String key = en.nextElement().toString(); if (key.startsWith(cs.prefix)){ @@ -636,6 +650,9 @@ c = (source instanceof ComponentDescription?(ComponentDescription)source:null); + //System.out.println("333"); + + if (p!=null || c!=null){ Context context = null; @@ -655,60 +672,75 @@ } } + //System.out.println("444"); + + if (loc==null) throw new SmartFrogFunctionResolutionException("No location information available in extracting aggregation from array:"+cssource); - ////System.out.println("111"+cs.context); + //System.out.println("111"+cs.context); - //Add resolving context... - Iterator keys = cs.context.keySet().iterator(); - while (keys.hasNext()){ - Object ckey = keys.next(); - Object cval = cs.context.get(ckey); - try { - if (c instanceof Prim) ((Prim)c).sfReplaceAttribute(ckey, cval); - else ((ComponentDescription)c).sfReplaceAttribute(ckey, cval); - } catch(Exception e){/*Shouldn't happen*/} + if (cs.update!=null){ + + //Add resolving context... + Iterator keys = cs.context.keySet().iterator(); + while (keys.hasNext()){ + Object ckey = keys.next(); + Object cval = cs.context.get(ckey); + try { + if (c instanceof Prim) ((Prim)c).sfReplaceAttribute(ckey, cval); + else ((ComponentDescription)c).sfReplaceAttribute(ckey, cval); + } catch(Exception e){/*Shouldn't happen*/} + } + } + + //System.out.println("555"); + - ////System.out.println("222"+c.sfContext()); + //System.out.println("222"+c.sfContext()); - ////System.out.println("Source not null..."); + //System.out.println("Source not null..."); + + + if (cs.update!=null){ + //Get the update record and pull out pred... + Reference pred = null; + try { pred = (Reference) cs.update.sfContext().get("pred"); } + catch (ClassCastException cce){/*Do nothing*/} + if (pred!=null){ + //System.out.println("Pred not null..."+pred); + //Reference pred = cs.pred.copyandRemoveLazy(); + try { + if (pred instanceof SFReference) pred=((SFReference) pred).sfAsReference(); + } catch (SmartFrogCompilationException sfce){ throw new SmartFrogFunctionResolutionException(sfce);} + ////System.out.println("Pred not null..."+pred); + + Object eval_pred = null; + try { + eval_pred = resolve(p,c,pred); + } catch (Exception e) + { + //System.out.println("FART::::"+e); + /*Intentionally Leave*/ + } + if (eval_pred!=null && eval_pred instanceof Boolean) { + //System.out.println("Is pred false?..."+eval_pred); + if (!((Boolean)eval_pred).booleanValue()) continue; //round while... + } + else if (eval_pred==null || !(eval_pred instanceof SFNull)) throw new SmartFrogFunctionResolutionException("In extracting values as per source, pred "+pred+" should yield Boolean from: "+source); + } + } + + //System.out.println("We have a match..."); + cs.source=source; + ComponentResolution cr = getComponentResolution(cs.source,cs.path); + cs.arguments.put(loc, cr.val); + if (cr.val instanceof FreeVar) cs.freevars=true; - //Get the update record and pull out pred... - Reference pred = null; - try { pred = (Reference) cs.update.sfContext().get("pred"); } - catch (ClassCastException cce){/*Do nothing*/} - if (pred!=null){ - ////System.out.println("Pred not null..."+cs.pred); - //Reference pred = cs.pred.copyandRemoveLazy(); - try { - if (pred instanceof SFReference) pred=((SFReference) pred).sfAsReference(); - } catch (SmartFrogCompilationException sfce){ throw new SmartFrogFunctionResolutionException(sfce);} - ////System.out.println("Pred not null..."+pred); - - Object eval_pred = null; - try { - eval_pred = resolve(p,c,pred); - } catch (Exception e) - { - ////System.out.println("FART::::"+e); - /*Intentionally Leave*/ - } - if (eval_pred!=null && eval_pred instanceof Boolean) { - ////System.out.println("Is pred false?..."+eval_pred); - if (!((Boolean)eval_pred).booleanValue()) continue; //round while... - } - else if (eval_pred==null || !(eval_pred instanceof SFNull)) throw new SmartFrogFunctionResolutionException("In extracting values as per source, pred "+pred+" should yield Boolean from: "+source); - } - ////System.out.println("We have a match..."); - cs.source=source; - ComponentResolution cr = getComponentResolution(cs.source,cs.path); - cs.arguments.put(loc, cr.val); - if (cr.val instanceof FreeVar) cs.freevars=true; - - ////System.out.println("And the other side...1"); + if (cs.update!=null){ + //System.out.println("And the other side...1"); //Remove resolving context... - keys = cs.context.keySet().iterator(); + Iterator keys = cs.context.keySet().iterator(); while (keys.hasNext()){ Object ckey = keys.next(); Object cval = cs.context.get(ckey); @@ -717,7 +749,8 @@ else ((ComponentDescription)c).sfRemoveAttribute(ckey); } catch(Exception e){/*Shouldn't happen*/} } - ////System.out.println("And the other side...2"); + //System.out.println("And the other side...2"); + } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2009-02-09 16:23:45 UTC (rev 7359) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2009-02-09 16:26:00 UTC (rev 7360) @@ -245,6 +245,8 @@ if (isLazy) throw new SmartFrogLazyResolutionException("function has lazy parameter"); + //System.out.println("SFAR:Going in..."+function.getClass().toString()); + forFunction.setOriginatingDescr(comp); try { result = function.doit(forFunction, null, rrcd, this, rrcd.sfAttributeKeyFor(this)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-02-09 17:07:57
|
Revision: 7362 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7362&view=rev Author: anfarr Date: 2009-02-09 17:07:55 +0000 (Mon, 09 Feb 2009) Log Message: ----------- SFOS-1100: Minor code tidy Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/functions.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java Modified: trunk/core/smartfrog/src/org/smartfrog/functions.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/functions.sf 2009-02-09 16:54:13 UTC (rev 7361) +++ trunk/core/smartfrog/src/org/smartfrog/functions.sf 2009-02-09 17:07:55 UTC (rev 7362) @@ -167,6 +167,7 @@ AggregateSpecifier extends AggregateSpecifierArrayPath { sfIsAggregateSpecifier; [sfIgnoreLink] pred; + unify; } AggregateSpecifierArrayPath extends { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-02-09 16:54:13 UTC (rev 7361) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-02-09 17:07:55 UTC (rev 7362) @@ -620,7 +620,7 @@ (Reference)path, null, null, - null); + context.get("pred")); css.add(cs); } } @@ -679,7 +679,7 @@ //System.out.println("111"+cs.context); - if (cs.update!=null){ + if (cs.unify!=null){ //Add resolving context... Iterator keys = cs.context.keySet().iterator(); @@ -702,11 +702,13 @@ //System.out.println("Source not null..."); - if (cs.update!=null){ + if (cs.unify!=null){ //Get the update record and pull out pred... Reference pred = null; - try { pred = (Reference) cs.update.sfContext().get("pred"); } - catch (ClassCastException cce){/*Do nothing*/} + try { + if (cs.update!=null) pred = (Reference) cs.update.sfContext().get("pred"); + else pred= (Reference) cs.unify; + } catch (ClassCastException cce){/*Do nothing*/} if (pred!=null){ //System.out.println("Pred not null..."+pred); //Reference pred = cs.pred.copyandRemoveLazy(); @@ -737,7 +739,7 @@ cs.arguments.put(loc, cr.val); if (cr.val instanceof FreeVar) cs.freevars=true; - if (cs.update!=null){ + if (cs.unify!=null){ //System.out.println("And the other side...1"); //Remove resolving context... Iterator keys = cs.context.keySet().iterator(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-02-16 14:29:26
|
Revision: 7395 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7395&view=rev Author: anfarr Date: 2009-02-16 14:29:21 +0000 (Mon, 16 Feb 2009) Log Message: ----------- SFOS-1100: Minor code tidying Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2009-02-16 11:37:27 UTC (rev 7394) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2009-02-16 14:29:21 UTC (rev 7395) @@ -54,13 +54,13 @@ } public synchronized void sfRun() throws SmartFrogException{ - System.out.println("IN: sfRun: "+name+" registering..."); + //System.out.println("IN: sfRun: "+name+" registering..."); try {by = (StateDependencies) sfResolve("by"); } catch(Exception e) {/*Elaborate*/} - System.out.println("1"); + //System.out.println("1"); try {on = (DependencyValidation) sfResolve("on"); } catch(Exception e) {/*Elaborate*/} - System.out.println("2:"+by); + //System.out.println("2:"+by); by.register(this); - System.out.println("OUT: sfRun: "+name+" registering..."); + //System.out.println("OUT: sfRun: "+name+" registering..."); } public synchronized void sfTerminateWith(TerminationRecord tr) { @@ -79,29 +79,29 @@ boolean relevant; boolean enabled; boolean isEnabled=true; - System.out.println("Dependency Enablement check:"+ name); + //System.out.println("Dependency Enablement check:"+ name); try { relevant = sfResolve("relevant", true, false); if (relevant){ - System.out.println("I am relevant!"); + //System.out.println("I am relevant!"); boolean onEnabled; enabled = sfResolve("enabled", false, false); - System.out.println("I am enabled?"+enabled); + //System.out.println("I am enabled?"+enabled); if (on!=null) onEnabled = ((!(on instanceof DependencyValidation)) || ((DependencyValidation) on).isEnabled()); else onEnabled=true; - System.out.println("I am onEnabled?"+onEnabled); + //System.out.println("I am onEnabled?"+onEnabled); isEnabled = (enabled && onEnabled); } } catch (Exception e) {/*Elaborate*/ isEnabled=false;} - System.out.println("Enabled:"+isEnabled); + //System.out.println("Enabled:"+isEnabled); return isEnabled; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-02-16 11:37:27 UTC (rev 7394) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-02-16 14:29:21 UTC (rev 7395) @@ -1,18 +1,14 @@ package org.smartfrog.services.dependencies.statemodel.state; -import org.smartfrog.services.dependencies.threadpool.ThreadPool; -import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import java.rmi.RemoteException; +import java.util.Enumeration; + +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.compound.CompoundImpl; -import org.smartfrog.sfcore.compound.Compound; -import org.smartfrog.sfcore.common.Context; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogUpdateException; import org.smartfrog.sfcore.prim.Liveness; -import org.smartfrog.sfcore.reference.ApplyReference; +import org.smartfrog.sfcore.prim.Prim; -import java.rmi.RemoteException; -import java.util.Enumeration; - /** * */ @@ -30,7 +26,11 @@ //My name... Object name_o = sfContext().get("name"); if (name_o!=null && name_o instanceof String) name = (String) name_o; - else name = (String) sfParent().sfAttributeKeyFor(this); + else { + Prim p = sfParent(); + if (p!=null) name = (String) sfParent().sfAttributeKeyFor(this); + else name="sfConfig"; + } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-02-16 11:37:27 UTC (rev 7394) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-02-16 14:29:21 UTC (rev 7395) @@ -91,14 +91,14 @@ } private boolean checkRunning(){ - System.out.println("Am I running -IN-"+name+"?"+m_running); + //System.out.println("Am I running -IN-"+name+"?"+m_running); if (!m_running){ Boolean runValue = null; try { runValue = (Boolean) sfResolve(new Reference(ReferencePart.attrib("running"))); } catch (Exception e){/*System.out.println("Wee exception:"+e);*/} if (runValue!=null) m_running = runValue.booleanValue(); } - System.out.println("Am I running -OUT-"+name+"?"+m_running); + //System.out.println("Am I running -OUT-"+name+"?"+m_running); return m_running; } @@ -131,7 +131,7 @@ private void resetPossibleTransitions() throws StateComponentTransitionException { if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").resetPossibleTransitions()"); - System.out.println("IN: State("+name+").resetPossibleTransitions()"); + //System.out.println("IN: State("+name+").resetPossibleTransitions()"); enabled=null; @@ -140,7 +140,7 @@ enabled = (HashMap<String,ComponentDescription>) transitions.clone(); //Remove externally disabled transitions... - System.out.println("Going thru dependencies..."); + //System.out.println("Going thru dependencies..."); for (Iterator d = dependencies.iterator(); d.hasNext();) { DependencyValidation dv = (DependencyValidation) d.next(); String transition = dv.getTransition(); @@ -156,21 +156,21 @@ boolean go=false; - System.out.println("transition"+trans); + //System.out.println("transition"+trans); try { go = trans.sfResolve(ConstraintConstants.GUARD, false, true); } catch (Exception e){ enabled=null; /**Exception needs handling properly**/ - System.out.println("We have excepted!!!"); + //System.out.println("We have excepted!!!"); throw new StateComponentTransitionException(StateComponentTransitionException.g_DEPENDENCYVALUEUNRESOLVABLE); } - System.out.println("transitionresult"+go); + //System.out.println("transitionresult"+go); if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Key:"+key+":"+go); if (go) { - System.out.println("Component: "+name+", enabled transition: "+key); + //System.out.println("Component: "+name+", enabled transition: "+key); if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Dependency enabled."); } else { @@ -262,7 +262,7 @@ //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!! COMPONENT:"+name); if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleStateChange()"); - System.out.println("To run DPEs..."+dpes.size()); + //System.out.println("To run DPEs..."+dpes.size()); boolean progress=false; @@ -271,12 +271,12 @@ progress = runDPEs(); Constraint.applyUpdateContext(); } - System.out.println("^^^^^^^^^^^^^^^^^^^Progress"+progress);System.out.flush(); + //System.out.println("^^^^^^^^^^^^^^^^^^^Progress"+progress);System.out.flush(); if (progress) { - System.out.println("Progress made"); + //System.out.println("Progress made"); threadpool.runIdleAgain(); - System.out.println("Other side!");System.out.flush(); + //System.out.println("Other side!");System.out.flush(); return; //skip now, as this will come round... } @@ -287,7 +287,7 @@ } if (enabled==null) { - System.out.println("no enabled transitions..."); + //System.out.println("no enabled transitions..."); if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Nothing to do..."); return; //nothing to do... @@ -301,7 +301,7 @@ } public void register(DependencyValidation d) throws SmartFrogStateLifecycleException { - System.out.println("Dependency Registration. Component: "+name+", d: "+d.toString()); + //System.out.println("Dependency Registration. Component: "+name+", d: "+d.toString()); dependencies.add(d); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-02-16 11:37:27 UTC (rev 7394) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-02-16 14:29:21 UTC (rev 7395) @@ -21,8 +21,6 @@ package org.smartfrog.sfcore.languages.sf.functions; import java.util.Enumeration; -import java.util.Iterator; -import java.util.Vector; import org.smartfrog.services.dependencies.statemodel.state.SynchedComposite; import org.smartfrog.services.orchcomponent.model.OrchComponentModel; @@ -36,10 +34,9 @@ import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.languages.sf.constraints.ConstraintConstants; import org.smartfrog.sfcore.languages.sf.constraints.CoreSolver; -import org.smartfrog.sfcore.languages.sf.constraints.FreeVar; -import org.smartfrog.sfcore.languages.sf.functions.Constraint.ComponentResolution; import org.smartfrog.sfcore.languages.sf.sfreference.SFReference; import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; @@ -274,8 +271,14 @@ static private void replaceSingleValue(Object key, Object update, Object source){ String fullname=""; try { - if (source instanceof Prim) fullname = ((Prim)source).sfCompleteName().toString(); - else fullname = ((ComponentDescription)source).sfCompleteName().toString(); + if (source instanceof Prim) { + PrimImpl p = (PrimImpl) source; + fullname = p.sfCompleteName().toString(); + if (p.sfLog().isInfoEnabled()) p.sfLog().info("Replacing: "+key+" with: "+update+ " in: "+fullname); + } + else { + fullname = ((ComponentDescription)source).sfCompleteName().toString(); + } }catch(Exception e){} //System.out.println("Replacing: "+key+" with: "+update+ " in: "+fullname); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-05-05 13:21:48
|
Revision: 7571 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7571&view=rev Author: anfarr Date: 2009-05-05 13:21:37 +0000 (Tue, 05 May 2009) Log Message: ----------- SF-252 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/examples/TestBench.java trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/model/OrchComponentModel.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/CoreSolver.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/DynamicPolicyEvaluation.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java Removed Paths: ------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Model.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -3,6 +3,7 @@ import java.rmi.RemoteException; import java.util.Enumeration; +import org.smartfrog.services.dependencies.threadpool.ThreadPool; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.compound.CompoundImpl; @@ -15,7 +16,10 @@ public class Composite extends CompoundImpl implements Compound, StateChangeNotification, RunSynchronisation { private String name=""; - + + //Threads on tap... + private ThreadPool threadpool; + public Composite() throws RemoteException { super(); } @@ -31,11 +35,19 @@ if (p!=null) name = (String) sfParent().sfAttributeKeyFor(this); else name="sfConfig"; } - - } + + threadpool = (ThreadPool) sfResolve("threadpool", false); + } + + public synchronized void sfStart() throws RemoteException, SmartFrogException { + //System.out.println("&&&&& IN MODEL START &&&&&"); + super.sfStart(); + if (threadpool!=null) threadpool.setIdleRunnable(new Notifier()); + } + public synchronized void sfRun() throws SmartFrogException{ - System.out.println("IN: sfRun"+this); + //System.out.println("IN: sfRun"+this); for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { Object c = e.nextElement(); @@ -43,23 +55,46 @@ ((RunSynchronisation)c).sfRun(); } } - System.out.println("OUT: sfRun"+this); + //System.out.println("OUT: sfRun"+this); } public String getName(){ return name; } + public String getStatusAsString() throws RemoteException { + String status=""; + for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { + Object c = e.nextElement(); + if (c instanceof StateChangeNotification) { + status+=((StateChangeNotification)c).getStatusAsString(); + } + } + return status; + } + //child down to State, where it is handled - public void handleStateChange() { - //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!! COMPOSITE"); - //System.out.println("handling state change...COMPOSITE"); - for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { + public void handleStateChange() throws RemoteException { + if (sfLog().isDebugEnabled()) sfLog().debug("IN: Composite.hsc()"+name); + for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { Object c = e.nextElement(); if (c instanceof StateChangeNotification) { + //if (sfLog().isDebugEnabled()) sfLog().debug("GOING IN with:"+c); ((StateChangeNotification)c).handleStateChange(); } } + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: Composite.hsc()"+name); } + /* ************************************************* + * Update class + */ + protected class Notifier implements Runnable { + public void run() { + if (sfLog().isDebugEnabled()) sfLog().debug("IN: Composite.Notifier.run()"); + //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!!"); + try{handleStateChange();} catch (RemoteException re){throw new RuntimeException(re);} + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: Composite.Notifier.run()"); + } + } } Deleted: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Model.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Model.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Model.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -1,49 +0,0 @@ -package org.smartfrog.services.dependencies.statemodel.state; - -import java.rmi.RemoteException; - -import org.smartfrog.services.dependencies.threadpool.ThreadPool; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.compound.Compound; - -/** - - */ -public class Model extends SynchedComposite implements Compound { - - //Threads on tap... - private ThreadPool threadpool; - - public Model() throws RemoteException { - } - - public synchronized void sfDeploy() throws RemoteException, SmartFrogException { - //System.out.println("&&&&& IN MODEL DEPLOY &&&&&"); - super.sfDeploy(); - threadpool = (ThreadPool) sfResolve("threadpool", true); - } - - public synchronized void sfStart() throws RemoteException, SmartFrogException { - //System.out.println("&&&&& IN MODEL START &&&&&"); - super.sfStart(); - threadpool.setIdleRunnable(new Notifier()); - } - - public void runNotifier(){ - threadpool.runIdle(); - } - - - /* ************************************************* - * Update class - */ - protected class Notifier implements Runnable { - public void run() { - if (sfLog().isDebugEnabled()) sfLog().debug("IN: Model.Notifier.run()"); - //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!!"); - handleStateChange(); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: Model.Notifier.run()"); - } - } - - } \ No newline at end of file Added: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -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 + +*/ +package org.smartfrog.services.dependencies.statemodel.state; + +import java.rmi.RemoteException; + +import org.smartfrog.sfcore.prim.Prim; + +public class NilStateComponent extends StateComponent implements Prim { + + public NilStateComponent() throws RemoteException {super();} + + public boolean threadBody(){ + return true; + } +} Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -1,13 +1,12 @@ package org.smartfrog.services.dependencies.statemodel.state; -import org.smartfrog.sfcore.common.Context; - import java.rmi.Remote; import java.rmi.RemoteException; /** */ -public interface StateChangeNotification{ +public interface StateChangeNotification extends Remote { //child down to State, where it is handled - public void handleStateChange(); + public void handleStateChange() throws RemoteException; + public String getStatusAsString() throws RemoteException; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -6,7 +6,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Vector; -import java.util.concurrent.Future; import java.util.concurrent.locks.ReentrantLock; import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; @@ -21,6 +20,8 @@ import org.smartfrog.sfcore.languages.sf.functions.Constraint; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.reference.ApplyReference; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; @@ -42,7 +43,7 @@ private Vector<ApplyReference> dpes=new Vector<ApplyReference>(); private ThreadPool threadpool; - private Future<?> currentActionFuture = null; + private Object currentAction = null; protected boolean asyncResponse = false; private boolean m_running=false; private ReentrantLock transitionLock = new ReentrantLock(); @@ -57,7 +58,7 @@ threadpool = (ThreadPool) sfResolve("threadpool", false); Context cxt = sfContext(); - asAndConnector = sfResolve("asAndConnector", asAndConnector, true); + asAndConnector = sfResolve("asAndConnector", asAndConnector, false); //transitions, dpes, state reflection... Enumeration keys = cxt.keys(); @@ -117,13 +118,17 @@ } public void invokeAsynchronousStateChange(InvokeAsynchronousStateChange iasc) throws StateComponentTransitionException { + + if (currentAction!=null) return; //temporary NEED TO EXCEPT!!! + //System.out.println("Hoping to acquire the lock..."); - acquireLock(); + if (!acquireLock()) return; //temporary NEED TO EXCEPT!!! //System.out.println("Hoping to acquire the lock2..."); resetPossibleTransitions(); //System.out.println("Hoping to acquire the lock3..."); iasc.actOn(this); //System.out.println("Hoping to acquire the lock4..."); + handleDPEs(); clean(); //System.out.println("Hoping to acquire the lock5..."); } @@ -160,7 +165,7 @@ try { go = trans.sfResolve(ConstraintConstants.GUARD, false, true); } catch (Exception e){ enabled=null; /**Exception needs handling properly**/ - //System.out.println("We have excepted!!!"); + System.out.println("We have excepted!!!"); throw new StateComponentTransitionException(StateComponentTransitionException.g_DEPENDENCYVALUEUNRESOLVABLE); } @@ -184,11 +189,14 @@ if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").resetPossibleTransitions()"); } - protected void acquireLock(){ + protected boolean acquireLock(){ if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").acquireLock(...)"); + if (sfLog().isDebugEnabled()) sfLog().debug("is locked?"+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); + if ((currentAction!=null && currentAction!=Thread.currentThread()) || //Allow locking only by scheduled action... + (currentAction==null && transitionLock.isLocked() && !transitionLock.isHeldByCurrentThread())) return false; //or by current owner thread transitionLock.lock(); if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").acquireLock(...)"); - + return true; } protected void cleanLock(){ @@ -196,6 +204,7 @@ while (transitionLock.isHeldByCurrentThread()) { //CHECK! transitionLock.unlock(); } + if (sfLog().isDebugEnabled()) sfLog().debug("is locked?"+transitionLock.isHeldByCurrentThread()+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").cleanLock(...)"); } @@ -229,14 +238,26 @@ public void go(String transition) throws StateComponentTransitionException { if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").go()"); - ComponentDescription trans = (ComponentDescription) enabled.get(transition); try { + if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition"+transition); + ComponentDescription trans = null; + try{trans = (ComponentDescription) enabled.get(transition);} catch (Throwable e){sfLog().debug("WHAT THE JC? "+e.getMessage());} trans.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.EFFECTS))); - } catch (Exception e){throw new StateComponentTransitionException("Unable to apply effects in transition: "+trans, StateComponentTransitionException.g_UNABLETOAPPLYEFFECTS);} + } catch (Exception e){throw new StateComponentTransitionException("Unable to apply effects in transition: "+transition, StateComponentTransitionException.g_UNABLETOAPPLYEFFECTS);} if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").go()"); } + + + public void clean(){ + if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").clean(...)"); + currentAction=null; + cleanLock(); + asyncResponse=false; + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").clean(...)"); + } + boolean runDPEs(){ boolean ret=false; for (int i=0;i<dpes.size();i++){ @@ -248,38 +269,44 @@ } return ret; } - - public void clean(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").clean(...)"); - currentActionFuture=null; - cleanLock(); - asyncResponse=false; - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").clean(...)"); + + public boolean handleDPEs(){ + if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleDPEs()"); + boolean progress=false; + + //synchronized(CoreSolver.getInstance()){ + Constraint.lockUpdateContext(); + progress = runDPEs(); + Constraint.applyUpdateContext(); + //} + + if (sfLog().isDebugEnabled()) sfLog().debug("^^^^^^^^^^^^^^^^^^^Progress"+progress); + + if (progress) { + System.out.println("Progress made"); + threadpool.runIdleAgain(); + } + return progress; } - public void handleStateChange() { + public String getStatusAsString() throws RemoteException {return "";} + public void handleStateChange() throws RemoteException { - //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!! COMPONENT:"+name); + if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleStateChange()"); - //System.out.println("To run DPEs..."+dpes.size()); + if (sfLog().isDebugEnabled()) sfLog().debug("To run DPEs..."+dpes.size()+": currentAction: "+currentAction); + + if (currentAction!=null) return; //temporary - boolean progress=false; + if (!acquireLock()) return; //need to except... - synchronized(CoreSolver.getInstance()){ - Constraint.lockUpdateContext(); - progress = runDPEs(); - Constraint.applyUpdateContext(); + if (handleDPEs()){ + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange()"); + clean(); + return; } - //System.out.println("^^^^^^^^^^^^^^^^^^^Progress"+progress);System.out.flush(); - if (progress) { - //System.out.println("Progress made"); - threadpool.runIdleAgain(); - //System.out.println("Other side!");System.out.flush(); - return; //skip now, as this will come round... - } - try { resetPossibleTransitions(); } catch (Exception e){ @@ -287,13 +314,32 @@ } if (enabled==null) { - //System.out.println("no enabled transitions..."); + if (sfLog().isDebugEnabled()) sfLog().debug("no enabled transitions..."); if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Nothing to do..."); + clean(); return; //nothing to do... } + //Check if simple transition... try { + if (enabled.size()==1){ + String key = enabled.keySet().iterator().next(); + ComponentDescription transition = (ComponentDescription) enabled.get(key); + if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition"+key); + if (!transition.sfResolve("requiresThread", false, true)){ + if (sfLog().isDebugEnabled()) sfLog().debug("State("+name+").handleStateChange() -- Script call..."); + transition.sfResolve("deploy"); //Apply script... + go(key); + clean(); + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); + return; + } + } + } catch (SmartFrogException e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} + + + try { setState(); } catch (StateComponentTransitionException stce) {/*Hardly acceptable handling*/} @@ -332,29 +378,33 @@ public synchronized Object sfReplaceAttribute(Object name, Object value) throws SmartFrogRuntimeException, RemoteException { - //System.out.println("*****************************************************************************************Replacing Attribute..."+name+":"+value); - Object result = super.sfReplaceAttribute(name,value); if (!Constraint.isUpdateContextLocked() && threadpool!=null) threadpool.runIdle(); return result; } - private Future<?> clearCurrentAction(){ - if (currentActionFuture ==null) return null; - return (currentActionFuture = threadpool.removeFromQueue(currentActionFuture)); + private Object clearCurrentAction(){ + return currentAction; + //if (currentActionFuture ==null) return null; + //return (currentActionFuture = threadpool.removeFromQueue(currentActionFuture)); } public void setState() throws StateComponentTransitionException { if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateComponent.setState()"); - if (clearCurrentAction()!=null) return; //Not appropriate to allow further transition at this time... + //handled above: if (clearCurrentAction()!=null) return; //Not appropriate to allow further transition at this time... - //System.out.println("Adding to queue..."); + if (sfLog().isDebugEnabled()) sfLog().debug("Adding to queue..."); + - currentActionFuture= threadpool.addToQueue(new StateUpdateThread()); + //currentActionFuture= threadpool.addToQueue(new StateUpdateThread()); - //System.out.println("Adding to queue..."+currentActionFuture); + threadpool.addToQueue((StateUpdateThread)(currentAction=new StateUpdateThread())); + + cleanLock(); + + System.out.println("Adding to queue..."+currentAction); if (sfLog().isDebugEnabled()) sfLog().debug("OUT: StateComponent.setState()"); } @@ -369,11 +419,11 @@ public class StateUpdateThread implements Runnable { public void run() { if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateUpdateThread.run()"); - acquireLock(); try{ if (threadBody()) { StateComponent.this.clean(); } else { + //Should this clean now? StateComponent.this.cleanLock(); StateComponent.this.asyncResponse=true; } @@ -381,5 +431,4 @@ if (sfLog().isDebugEnabled()) sfLog().debug("OUT: StateUpdateThread.run()"); } } - } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -5,15 +5,21 @@ public class StateComponentTransitionException extends SmartFrogException { private int code; - StateComponentTransitionException(int code){ + public StateComponentTransitionException(int code){ this.code = code; } - StateComponentTransitionException(String msg, int code){ + public StateComponentTransitionException(String msg, int code){ super(msg); this.code = code; } + public StateComponentTransitionException(String msg){ + this(msg, g_NOCODEAVAILABLE); + } + + //These codes are in drastic need of an update... + public static final int g_NOCODEAVAILABLE=0xFFFF; public static final int g_NOTRANSITIONS=0x0; public static final int g_NOSUCHAVAILABLETRANSITION=0x1; public static final int g_NOTRANSITIONSELECTED=0x2; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -29,7 +29,7 @@ //System.out.println("In SynchedComposite..."); try { - System.out.println("Replacing attribute in: "+this.sfCompleteName+": name:"+name+" : "+value); + //System.out.println("Replacing attribute in: "+this.sfCompleteName+": name:"+name+" : "+value); if (name.equals("run") && (value instanceof Boolean) && ((Boolean)value).booleanValue()) { this.sfRun(); super.sfReplaceAttribute("running", new Boolean(true)); Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -1,19 +1,17 @@ package org.smartfrog.services.dependencies.threadpool; +import java.io.Serializable; import java.rmi.Remote; import java.rmi.RemoteException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.smartfrog.services.orchcomponent.model.OrchComponentModel; -import org.smartfrog.services.orchcomponent.model.OrchConstants; +import org.smartfrog.services.dependencies.statemodel.state.Notifier; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.reference.Reference; -import org.smartfrog.sfcore.reference.ReferencePart; /** * Implementation of the SmartFrog ThreadPool component @@ -21,12 +19,12 @@ * Implements the ThreadPool Interface, and provides methods for * controlling the execution of a set of jobs by a thread pool */ -public class SimpleThreadPoolImpl extends PrimImpl implements Remote, Prim, ThreadPool { +public class SimpleThreadPoolImpl extends PrimImpl implements Remote, Prim, Notifier, Serializable { private int numThreads=5; private int busyThreads=0; - private ExecutorService es; + private transient ExecutorService es; private boolean suspended=false; - private Runnable idleRunnable; + private transient Runnable idleRunnable; private boolean runAgain=false; public SimpleThreadPoolImpl() throws RemoteException { @@ -98,10 +96,12 @@ } public void runIdle(){ + if (sfLog().isDebugEnabled()) sfLog().debug("IN: threadPool: runIdle()"); if (busyThreads==0 && !suspended) { suspended=true; es.submit(idleRunnable); } + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: threadPool: runIdle()"); } public void setIdleRunnable(Runnable idleRunnable){ @@ -114,9 +114,11 @@ * */ public Future<?> addToQueue(Runnable run){ + if (sfLog().isDebugEnabled()) sfLog().debug("IN: threadPool: addToQueue()"); synchronized (this){ busyThreads++; //we should increase before it's run... } + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: threadPool: addToQueue()"); return es.submit(new Runnable_(run)); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -19,43 +19,6 @@ */ package org.smartfrog.services.display; -import org.smartfrog.SFSystem; -import org.smartfrog.sfcore.common.JarUtil; -import org.smartfrog.sfcore.common.Logger; -import org.smartfrog.sfcore.common.SmartFrogCoreKeys; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.TerminatorThread; -import org.smartfrog.sfcore.common.ExitCodes; -import org.smartfrog.sfcore.logging.LogFactory; -import org.smartfrog.sfcore.logging.LogSF; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.processcompound.SFProcess; -import org.smartfrog.sfcore.reference.Reference; - -import javax.swing.BorderFactory; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JToggleButton; -import javax.swing.JToolBar; -import javax.swing.JTree; -import javax.swing.KeyStroke; -import javax.swing.Timer; -import javax.swing.WindowConstants; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.Document; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -69,6 +32,7 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedReader; @@ -81,15 +45,70 @@ import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.io.PrintStream; +import java.io.StringReader; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.net.InetAddress; import java.rmi.RemoteException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Enumeration; +import java.util.List; import java.util.Properties; +import java.util.StringTokenizer; import java.util.Vector; +import javax.swing.BorderFactory; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JToggleButton; +import javax.swing.JToolBar; +import javax.swing.JTree; +import javax.swing.KeyStroke; +import javax.swing.Timer; +import javax.swing.WindowConstants; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +import javax.swing.text.Document; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathFactory; +import org.smartfrog.SFSystem; +import org.smartfrog.sfcore.common.ExitCodes; +import org.smartfrog.sfcore.common.JarUtil; +import org.smartfrog.sfcore.common.Logger; +import org.smartfrog.sfcore.common.SmartFrogCoreKeys; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.common.TerminatorThread; +import org.smartfrog.sfcore.logging.LogFactory; +import org.smartfrog.sfcore.logging.LogSF; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.processcompound.SFProcess; +import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.security.SFClassLoader; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + + /** * Multiuse Simple display object. It is possible to start / stop the data * producer. @@ -204,10 +223,10 @@ /** * Menu item - about. */ - JMenuItem jMenuItemAbout = new JMenuItem(); + JMenuItem jMenuItemAbout = new JMenuItem(); /** * File name. - */ + */ String currFileName = null; /** * File chooser. @@ -260,7 +279,13 @@ private Prim sfObj = null; private boolean systemExit = true; Display mngConsole = null; + /** + * + */ + private JMenu jMenuMngConsole = new JMenu(); private JMenuItem jMenuItemMngConsole = new JMenuItem(); + private JMenu[] jMenuItemCellVMs; + private int fontSize = 12; /** @@ -1123,7 +1148,6 @@ return; } //End option dialog - int port = 3800; String hostName = null; try { @@ -1142,6 +1166,11 @@ return; } + startMngConsole(hostName); + } + + void startMngConsole(String hostName) { + int port = 3800; try { java.net.InetAddress.getByName(hostName); SFProcess.getRootLocator() @@ -1159,7 +1188,7 @@ return; } catch (Exception e) { this.modalErrorDialog("startMngConsole", - "Couldn't start SFMngConsole for resource " + hostName); + "Couldn't start SFMngConsole for resource " + hostName + ". " + e); return; } @@ -1397,16 +1426,132 @@ void jMenuItemProcessComp_actionPerformed(ActionEvent e) { this.infoProcessCompound(); } - - + + private String cfcLocation = "org.smartfrog.services.display.supCfc1"; + + private String ipaddress; + private Class supWatcher; + private Class supHttp; + + private void loadSupWatcher(){ + try { + + Constructor con = supWatcher.getConstructor(String.class, int.class, String.class); + if (ipaddress==null) { + ipaddress = System.getProperty(cfcLocation); + if (ipaddress==null) ipaddress=java.net.InetAddress.getLocalHost().getHostAddress(); + } + + String path="/cfc/cell1"; + Object watcher = con.newInstance(ipaddress, 8100, path); + + //Get subcells... + Method scm = supWatcher.getMethod("getCfcSubcells"); + List<String> subcells = (List<String>) scm.invoke(watcher); + + + DocumentBuilderFactory domFactory = + DocumentBuilderFactory.newInstance(); + domFactory.setNamespaceAware(false); + DocumentBuilder builder = domFactory.newDocumentBuilder(); + + int numCells = subcells.size(); + jMenuItemCellVMs = new JMenu[numCells]; + + for (int i=0; i<subcells.size();i++){ + String cell = subcells.get(i); + try { + + Method cwm = supWatcher.getMethod("subcellWatcher", String.class); + Object cfcn_scwatcher = cwm.invoke(watcher, cell); + Method chm = supWatcher.getMethod("getCfcHttp"); + Object cfcn_schttp = chm.invoke(cfcn_scwatcher); + Method gmm = supHttp.getMethod("getModel", String.class); + String modelString = (String) gmm.invoke(cfcn_schttp, ""); + + org.w3c.dom.Document doc = builder.parse(new InputSource(new StringReader(modelString))); + XPath xpath = XPathFactory.newInstance().newXPath(); + XPathExpression expr = xpath.compile("//cellIndex/text()"); + Node cfcn_index = (Node) expr.evaluate(doc, XPathConstants.NODE); + String cfcn_path=("cell"+new StringTokenizer(cfcn_index.getNodeValue().toString()).nextToken()); + + JMenu cellMenu = new JMenu(); + cellMenu.setText(cfcn_path); + jMenuItemCellVMs[i]= cellMenu; + + xpath = XPathFactory.newInstance().newXPath(); + expr = xpath.compile("//vm[@def=\"vmcfc\"]/vif/IPAddress/text()"); + Node cfcn_ipa = (Node) expr.evaluate(doc, XPathConstants.NODE); + String cfcn_ipaddress = new StringTokenizer(cfcn_ipa.getNodeValue().toString()).nextToken(); + + Object cfcn_watcher = con.newInstance(cfcn_ipaddress, 8100, "/cfc/"+cfcn_path); + Object cfcn_http = chm.invoke(cfcn_watcher); + modelString = (String) gmm.invoke(cfcn_http, ""); + doc = builder.parse(new InputSource(new StringReader(modelString))); + + xpath = XPathFactory.newInstance().newXPath(); + expr = xpath.compile("//dnsName/text()"); + NodeList vms = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); + for (int j=0; j<vms.getLength();j++){ + final String vm = new StringTokenizer(vms.item(j).getNodeValue().toString()).nextToken(); + int idx = vm.indexOf(cfcn_path); + String vmPref = vm.substring(0,idx-1); + + JMenuItem vmItem = new JMenuItem(); + vmItem.setText(vmPref); + cellMenu.add(vmItem); + vmItem.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + startMngConsole(vm); + } + }); + } + } catch (Throwable t){System.out.println("Unable to get information for cell"+cell);} + } + } catch(Throwable t){jMenuItemCellVMs=null;} + } + + private boolean supAvailable(){ + try { + supWatcher = SFClassLoader.forName("com.hp.sup.http.CfcWatcher"); + supHttp = SFClassLoader.forName("com.hp.sup.http.CfcHttp"); + loadSupWatcher(); + } catch (Exception e){/*Intentionally do nothing*/} + return supWatcher!=null; + } + + private void updateMngConsoleMenuWkr(){ + if (supWatcher!=null && ipaddress!=null){ + removeVMMngConsoleMenuItems(); + loadSupWatcher(); + addVMMngConsoleMenuItems(); + } + } + + private void removeVMMngConsoleMenuItems(){ + if (jMenuItemCellVMs==null) return; + for (JMenu item : jMenuItemCellVMs){ + this.jMenuMngConsole.remove(item); + } + } + + private void addVMMngConsoleMenuItems(){ + if (jMenuItemCellVMs==null) return; + for (JMenu item : jMenuItemCellVMs){ + this.jMenuMngConsole.add(item); + } + } + + MouseListener ml; + boolean ignore=false; /** * Widjets initialization * * @throws Exception If unable to initialize */ private void jbInit() throws Exception { - - String imagesPath = Display.class.getPackage().getName() + "."; + String imagesPath = Display.class.getPackage().getName() + "."; imagesPath = imagesPath.replace('.', '/'); //imagesPath = imagesPath + "frog.gif"; imagesPath = imagesPath + "SplodgeGreen32.ico"; @@ -1492,14 +1637,35 @@ jCheckBoxMenuItemAskSaveChanges.setText("Ask Save Changes?"); jCheckBoxMenuItemAskSaveChanges.setSelected(true); - - jMenuItemMngConsole.setText("SF Management Console"); + + JMenuItem manMenuItem; + if (supAvailable()) { + jMenuMngConsole.setText("SF Management Console"); + jMenuItemMngConsole.setText("Enter SF hostname"); + jMenuMngConsole.add(jMenuItemMngConsole); + manMenuItem = jMenuMngConsole; + + if (jMenuItemCellVMs!=null){ + jMenuMngConsole.addSeparator(); + for (JMenu item : jMenuItemCellVMs) jMenuMngConsole.add(item); + } + + + + + } else { + jMenuItemMngConsole.setText("SF Management Console"); + manMenuItem = jMenuItemMngConsole; + } + jMenuItemMngConsole.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jMenuItemMngConsole_actionPerformed(e); } }); + + jMenuBarDisplay.add(jMenuDisplayOptions); jMenuBarDisplay.add(jMenuHelp); jMenuDisplayOptions.add(jCheckBoxMenuItemPause); @@ -1517,9 +1683,26 @@ jMenuHelp.add(jMenuItemInfoProp); jMenuHelp.addSeparator(); jMenuHelp.add(jMenuItemProcessComp); - jMenuHelp.add(jMenuItemMngConsole); + jMenuHelp.add(manMenuItem); jMenuHelp.addSeparator(); jMenuHelp.add(jMenuItemAbout); + + jMenuHelp.addMenuListener(new MenuListener(){ + public void menuSelected(MenuEvent e) { + //try{ + //Runtime.getRuntime().exec("echo \"COMPONENT SHOWN\" >> /tmp/menu"); + //} catch (Exception ex){} + //if (!ignore) { + updateMngConsoleMenuWkr(); + // ignore=true; + //} + } + public void menuDeselected(MenuEvent e) { + } + public void menuCanceled(MenuEvent e) { + } + }); + this.setJMenuBar(jMenuBarDisplay); //end Menus Modified: trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/examples/TestBench.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/examples/TestBench.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/examples/TestBench.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -100,7 +100,7 @@ private void updateModel(){ model.runPrims(); - model.runNotifier(); + //model.runNotifier(); FIX NOTIFIER!!! } public class TestBenchThread implements Runnable { Modified: trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/model/OrchComponentModel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/model/OrchComponentModel.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/services/orchcomponent/model/OrchComponentModel.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -5,7 +5,6 @@ import java.util.Vector; import org.smartfrog.services.dependencies.statemodel.state.Composite; -import org.smartfrog.services.dependencies.statemodel.state.Model; import org.smartfrog.services.orchcomponent.desiredstate.DesiredEvent; import org.smartfrog.services.orchcomponent.desiredstate.DesiredEventRecord; import org.smartfrog.services.orchcomponent.desiredstate.DesiredEventRegistration; @@ -16,7 +15,7 @@ import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; -public class OrchComponentModel extends Model { +public class OrchComponentModel extends Composite { DesiredEventRegistration der; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/CoreSolver.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/CoreSolver.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/CoreSolver.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -77,7 +77,7 @@ private static final String CONSTRAINT_FUNCTION = "org.smartfrog.sfcore.languages.sf.functions.Constraint"; private static final String ATTR_CONSTRAINT = "sfConstraint"; private static final String ENV_SOLVERCLASS = "SOLVERCLASS"; - private static final String ATTR_IS_GENERATOR = "sfIsArrayGenerator"; + private static final String ATTR_IS_GENERATOR = "sfIsGenerator"; public static final String ERROR = "ERROR: "; public static final String ERROR_COULD_NOT_INSTANTIATE_SOLVER = ERROR +"Could not instantiate solver "; public static final String ERROR_NO_CLASS = ERROR + "Class not found: "; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -53,9 +53,9 @@ * */ protected Object doFunction() throws SmartFrogFunctionResolutionException { Object retval=null; - synchronized(CoreSolver.getInstance()){ + //synchronized(CoreSolver.getInstance()){ retval=doFunctionWkr(); - } + //} return retval; } @@ -77,7 +77,7 @@ } public static void applyEffects(ComponentDescription effects) throws SmartFrogFunctionResolutionException { - //System.out.println("IN applyEffects"); + System.out.println("IN applyEffects"); //Array/path/pred? Reference array = null; @@ -86,43 +86,43 @@ ComponentDescription pcontext = null; try { array = (Reference) effects.sfContext().get(ConstraintConstants.ARRAY); } catch(Exception e){/**/} - //System.out.println("ARRAY: "+array); + System.out.println("ARRAY: "+array); if (array!=null){ try { prefix = (String) effects.sfContext().get(ConstraintConstants.PREFIX); } catch(Exception e){/**/} - //System.out.println("PREFIX: "+prefix); + System.out.println("PREFIX: "+prefix); try { pred = (Reference) effects.sfContext().get(ConstraintConstants.PRED); } catch(Exception e){/**/} - //System.out.println("PRED: "+pred); + System.out.println("PRED: "+pred); try { pcontext = (ComponentDescription) effects.sfContext().get(ConstraintConstants.CONTEXT); } catch(Exception e){/**/} - //System.out.println("PCONTEXT: "+pcontext); + System.out.println("PCONTEXT: "+pcontext); } Object key = effects.sfContext().get(ConstraintConstants.KEY); if (key==SFNull.get()) key=null; if (key!=null && key instanceof Reference) try { key=effects.sfResolve((Reference)key);}catch(Exception e){} - //System.out.println("KEY: "+key); + System.out.println("KEY: "+key); Object update = effects.sfContext().get(ConstraintConstants.UPDATE); if (update==SFNull.get()) update=null; if (update!=null && update instanceof Reference) try { update=effects.sfResolve((Reference)update);}catch(Exception e){} - //System.out.println("UPDATE: "+update); + System.out.println("UPDATE: "+update); ComponentDescription deploy = null; if (update==null){ try { deploy= (ComponentDescription) effects.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.DEPLOY)));}catch(Exception e){} } - //System.out.println("DEPLOY: "+deploy); + System.out.println("DEPLOY: "+deploy); if (deploy==null && update==null) return; Reference path = null; try { path = (Reference) effects.sfContext().get(ConstraintConstants.PATH); } catch(ClassCastException cce){ /*Take as null*/ } - //System.out.println("PATH: "+path); + System.out.println("PATH: "+path); Object source = null; if (array==null){ @@ -132,7 +132,7 @@ throw new SmartFrogFunctionResolutionException("path in effects will not resolve: "+effects); } } else { source = effects; - //System.out.println("Looking for..."+key+" to update with "+update); + System.out.println("Looking for..."+key+" to update with "+update); while (true){ source = Constraint.resolveParent(source); @@ -141,17 +141,18 @@ } } - //System.out.println("SOURCE: "+source.getClass()+source.hashCode()); + System.out.println("SOURCE: "+source.getClass()+source.hashCode()); } if (array==null && source==null) return; if (deploy!=null) { + System.out.println("DEPLOYING..."+key); if (source instanceof Compound) { Compound source_nd = (Compound) source; ComponentDescription deploy_cd = (ComponentDescription) deploy.copy(); try {source_nd.sfCreateNewChild(key, deploy_cd, null);} - catch(Exception e){/*Elaborate*/} + catch(Exception e){/*System.out.println("EXCEPTION1:"+e);*/} OrchComponentModel model = null; try { @@ -161,7 +162,7 @@ Prim added = null; try{ added = (Prim) source_nd.sfResolve(key.toString()); - } catch (Exception e){/**/} + } catch (Exception e){/*System.out.println("EXCEPTION2:"+e);*/} if (added!=null && added instanceof SynchedComposite) model.addToRun(added); } } @@ -171,13 +172,13 @@ //Replace in array? if (array!=null && prefix!=null){ - //System.out.println("We are replacing in an array"); + System.out.println("We are replacing in an array"); try { source=effects.sfResolve(array); } catch(Exception e){ throw new SmartFrogFunctionResolutionException("path in effects will not resolve: "+effects); } - //System.out.println("000"); + System.out.println("000"); Context src_context = null; try {src_context = (source instanceof Prim?((Prim)source).sfContext():((ComponentDescription)source).sfContext());} @@ -186,15 +187,15 @@ Enumeration en = src_context.keys(); while (en.hasMoreElements()){ - //System.out.println("222"); + System.out.println("222"); String akey = en.nextElement().toString(); if (akey.startsWith(prefix)){ - //System.out.println("In with the prefix..."+akey); + System.out.println("In with the prefix..."+akey); Object member = src_context.get(akey); - //System.out.println("333"); + System.out.println("333"); Prim p = (member instanceof Prim?(Prim)member:null); ComponentDescription c=(member instanceof ComponentDescription?(ComponentDescription)member:null); @@ -216,11 +217,11 @@ } if (pred!=null){ - //System.out.println("Pred not null..."+pred); + System.out.println("Pred not null..."+pred); try { if (pred instanceof SFReference) pred=((SFReference) pred).sfAsReference(); } catch (SmartFrogCompilationException sfce){ System.out.println(sfce); throw new SmartFrogFunctionResolutionException(sfce);} - //System.out.println("Really pred not null..."); + System.out.println("Really pred not null..."); Object eval_pred = null; try { @@ -236,13 +237,13 @@ } else if (eval_pred==null || !(eval_pred instanceof SFNull)) throw new SmartFrogFunctionResolutionException("In extracting values as per source, pred "+pred+" should yield Boolean from: "+source); } - //System.out.println("We have a match..."); + System.out.println("We have a match..."); try { if (path!=null) member = (p!=null? p.sfResolve(path) : c.sfResolve(path)); } catch (Exception e) { - System.out.println("FART::::"+e); + //System.out.println("FART::::"+e); /*Intentionally Leave*/ } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -259,7 +259,7 @@ } else generator_cd.sfContext().put(ConstraintConstants.INDEX, el_idx); generator_cd.sfContext().put(ConstraintConstants.TAG, el); - generator_cd.sfContext().remove("sfIsArrayGenerator"); + generator_cd.sfContext().remove("sfIsGenerator"); if (dest instanceof ComponentDescription){ generator_cd.setParent((ComponentDescription) dest); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Constraint.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -767,7 +767,7 @@ public Object getval(){return val;} ComponentResolution(){} - ComponentResolution(Object pc, Object key, Object val){ this.pc=pc; this.key=key; this.val=val;} + ComponentResolution(Object key, Object val,Object pc){ this.pc=pc; this.key=key; this.val=val;} } static public ComponentResolution getSourceKey(Reference ref, Object source) throws SmartFrogResolutionException { @@ -860,7 +860,8 @@ static void replaceAttribute(Object k, Object v, Object c){ try { if (v instanceof SFNull) v=null; - if (g_updateContext!=null) g_updateContext.add(new ComponentResolution(c,k,v)); + //System.out.println("UPDATE CONTEXT..."+g_updateContext); + if (g_updateContext!=null) g_updateContext.add(new ComponentResolution(k,v,c)); else replaceAttributeWkr(k, v, c); } catch (Exception e){/*Shouldn't happen*/} } @@ -872,14 +873,20 @@ static void replaceAttributeWkrPrim(Object k, Object v, Prim p){ try{ - if (v!=null) p.sfReplaceAttribute(k, v); + //System.out.println("About to replace..."+k+":"+v+" in "+p.sfContext()); + if (v!=null) { + Object oldValue = p.sfReplaceAttribute(k, v); + //System.out.println("OLD VALUE!!!"+oldValue); + } else p.sfRemoveAttribute(k); + //System.out.println("Have replaced..."+k+":"+v+" in "+p.sfContext()); + if (v instanceof ComponentDescription){ ((ComponentDescription)v).setPrimParent(p); } - }catch(Exception e){/**/} + }catch(Exception e){System.out.println("Failed to replace:"+k+" with "+v+" in "+p);} } static void replaceAttributeWkrComp(Object k, Object v, ComponentDescription c){ @@ -911,7 +918,7 @@ for (int i=0;i<g_updateContext.size();i++){ ComponentResolution cr = g_updateContext.get(i); - System.out.println("Replacing...1"+cr.key+":"+cr.val+":"+cr.pc); + //System.out.println("IN APPLYUPDATECONTEXT::: Replacing...1"+cr.key+":"+cr.val+":"+cr.pc); replaceAttributeWkr(cr.key, cr.val, cr.pc); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/DynamicPolicyEvaluation.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/DynamicPolicyEvaluation.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/DynamicPolicyEvaluation.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -50,9 +50,9 @@ * */ protected Object doFunction() throws SmartFrogFunctionResolutionException { Object retval=null; - synchronized(CoreSolver.getInstance()){ + //synchronized(CoreSolver.getInstance()){ retval=doFunctionWkr(); - } + //} return retval; } @@ -62,6 +62,8 @@ ComponentDescription comp = context.getOriginatingDescr(); context = comp.sfContext(); + //System.out.println("DPE: Checking guard/s"); + //Check the guards on the policy evaluation... //(1) Explicit guard Boolean guard = null; @@ -86,20 +88,28 @@ if (guard!=null && !guard.booleanValue()) return guard; } } + + //System.out.println("DPE: Past guard/s"); + //OK, so we are allowed to evaluate the DPE... try { Enumeration e = context.keys(); while (e.hasMoreElements()) { Object key = e.nextElement(); + //System.out.println("*********ATTRIBUTE********"+key); Object val = comp.sfResolve(key.toString()); - if (val!=null) context.put(key, val); + if (val!=null) { + context.put(key, val); + //System.out.println("DPE: Replacing: "+key+" with "+val); + } } } catch (SmartFrogException e){/*Shouldn't happen*/} //Let's finish with a few effects... + //System.out.println("DPE: Applying Effects"); try { comp.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.EFFECTS)));} catch (SmartFrogResolutionException sfre){/*Intentionally do nothing*/} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -139,7 +139,7 @@ comp.setParent(rrcd); //Am I an array generator?, if so quit... - try { if (comp.sfContext().get("sfIsArrayGenerator")!=null) return this; } catch (Exception e){/*Do nothing!*/} + try { if (comp.sfContext().get("sfIsGenerator")!=null) return this; } catch (Exception e){/*Do nothing!*/} String functionClassStatus = (String) comp.sfContext().get("sfFunctionClassStatus"); if (functionClassStatus!=null && functionClassStatus.equals("done")) return comp; //done already Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java 2009-05-05 11:33:55 UTC (rev 7570) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java 2009-05-05 13:21:37 UTC (rev 7571) @@ -20,22 +20,25 @@ package org.smartfrog.sfcore.utils; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + import org.smartfrog.sfcore.common.Context; +import org.smartfrog.sfcore.common.ContextImpl; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.ContextImpl; import org.smartfrog.sfcore.componentdescription.ComponentDescription; +import org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl; import org.smartfrog.sfcore.parser.Phases; import org.smartfrog.sfcore.parser.SFParser; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; import org.smartfrog.sfcore.security.SFClassLoader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.Enumeration; -import java.util.Iterator; - /** * This class provides a single static method - print - which takes a ComponentDescription * and iterates over it to generate an output string. It can be used, for example, to generate XML text. @@ -75,6 +78,7 @@ String CDPEnd = ""; String CDPSep = ""; + try { CDPStart = cd.sfResolve(new Reference(ReferencePart.here("CDPStart")), CDPStart, false); } catch (SmartFrogResolutionException e) { @@ -116,7 +120,22 @@ * @throws FileNotFoundException */ public static String printURL(String url, Context params) throws SmartFrogException, FileNotFoundException { + return printURLSorted(url, params, false); + } + + /** + * Method to take a URL, parse it, add the addtional k... [truncated message content] |
From: <st...@us...> - 2009-06-03 14:50:17
|
Revision: 7624 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7624&view=rev Author: steve_l Date: 2009-06-03 14:49:30 +0000 (Wed, 03 Jun 2009) Log Message: ----------- SFOS-1216 some code is using Log.error(Object) and passing in an exception, causing the stack trace to get lost Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/apache/ApacheImpl.java 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/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/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java trunk/core/smartfrog/src/org/smartfrog/services/trace/TraceTreePanel.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ActionDump.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogToStreamsImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFRMIClassLoaderSpi.java trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -394,7 +394,7 @@ } catch (Exception ex) { try { if (sfLog().isErrorEnabled()) { - sfLog().error(ex); + sfLog().error(ex, ex); } } catch (Throwable ex1) { ex.printStackTrace(); @@ -792,7 +792,7 @@ SFParser parser = new SFParser(language); return parser.sfParseAnyValue(textToParse); } catch (Throwable ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } return null; } Modified: trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/examples/arithnet/NetElemImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -126,7 +126,7 @@ } } } catch (Exception e) { - sfLog().error(e); + sfLog().error(e, e); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/apache/ApacheImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/apache/ApacheImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/examples/dynamicwebserver/apache/ApacheImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -166,7 +166,7 @@ if (manageDaemon) p = Runtime.getRuntime().exec(apachectlLocation + " start"); } catch (Exception e) { - if (sfLog().isErrorEnabled()) sfLog().error (e); + if (sfLog().isErrorEnabled()) sfLog().error (e, e); } if (sfLog().isInfoEnabled()) sfLog().info( "httpd started"); @@ -179,7 +179,7 @@ p = Runtime.getRuntime().exec(apachectlLocation + " start"); needRestart = false; } catch (IOException e) { - if (sfLog().isErrorEnabled()) sfLog().error (e); + if (sfLog().isErrorEnabled()) sfLog().error (e, e); } } //end if (needRestart) @@ -250,7 +250,7 @@ } } } catch (Exception e) { - if (sfLog().isErrorEnabled()) sfLog().error (e); + if (sfLog().isErrorEnabled()) sfLog().error (e, e); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -961,7 +961,7 @@ "User termination", null); sfObj.sfDetachAndTerminate(tr); } catch (Exception ex) { - sfLog().error(ex); + sfLog().error(ex, ex); } } } @@ -982,7 +982,7 @@ this.sfObj.sfDetachAndTerminate(tr); } catch (Exception ex) { if (sfLog().isErrorEnabled()) { - sfLog().error(ex); + sfLog().error(ex, ex); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/SFDisplay.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -394,7 +394,7 @@ try { printMsgImp.printMsg(msg + ""); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } else { //System.out.println("" + msg); @@ -422,7 +422,7 @@ try { printMsgImp.printMsg(msg + ""); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } else { //System.out.println("" + msg); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -199,7 +199,7 @@ //return entry; } catch (Exception ex) { //System.out.println(ex.toString()); - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } return null; @@ -260,7 +260,7 @@ //unexported if (sfLog().isIgnoreEnabled()) sfLog().ignore(nex); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } else if (entry instanceof ComponentDescription) { //System.out.println("EntryCD: getting name"); @@ -273,7 +273,7 @@ } } } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } //System.out.println("getDN(): "+name); @@ -299,7 +299,7 @@ //unexported if (sfLog().isIgnoreEnabled()) sfLog().ignore(nex); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } else if (entry instanceof ComponentDescription) { //System.out.println("EntryCD: getting name"); @@ -307,7 +307,7 @@ name = ((ComponentDescription) entry).sfCompleteName().toString(); // System.out.println("EntryCD: getting name - "+name); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } //System.out.println("getDN(): "+name); @@ -328,8 +328,7 @@ try { return ((getChildren())[index][1]); } catch (Exception ex) { - //System.out.println(ex.toString()); - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } @@ -421,7 +420,7 @@ index++; } } catch (Exception ex1) { - if (sfLog().isErrorEnabled()) sfLog().error(ex1); + if (sfLog().isErrorEnabled()) sfLog().error(ex1, ex1); } } @@ -479,7 +478,7 @@ index++; } } catch (Exception ex1) { - if (sfLog().isErrorEnabled()) sfLog().error(ex1); + if (sfLog().isErrorEnabled()) sfLog().error(ex1, ex1); data[index][0] = name; data[index][1] = "Error:"+ex1.toString(); index++; @@ -487,7 +486,7 @@ } return data; } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); return null; } } @@ -687,7 +686,7 @@ counter++; } } catch (Exception ex1) { - if (sfLog().isErrorEnabled()) sfLog().error(ex1); + if (sfLog().isErrorEnabled()) sfLog().error(ex1, ex1); } } return counter; @@ -788,7 +787,7 @@ } } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } return entryName; @@ -955,7 +954,7 @@ try { this.sfLog=LogFactory.getLog("sfManagementConsole"); } catch (Exception e) { - sfLog.error(e); + sfLog.error(e, e); } } private LogSF sfLog(){ Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntryCellRenderer.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -94,7 +94,7 @@ try { return new ImageIcon(org.smartfrog.SFSystem.getByteArrayForResource(path)); } catch (SmartFrogException ex) { - if (sfLogStatic.isErrorEnabled()) sfLogStatic.error(ex); + if (sfLogStatic.isErrorEnabled()) sfLogStatic.error(ex, ex); } return null; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreeModelSF.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -69,7 +69,7 @@ initLog(); //System.out.println("Model created"); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } @@ -225,7 +225,7 @@ this.sfLog=LogFactory.getLog((String)entry.getEntry()); } } catch (Exception e) { - sfLog.error(e); + sfLog.error(e, e); } } private LogSF sfLog(){ Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -94,7 +94,7 @@ treeInit(null,false , false,true); jbInit(); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); } } @@ -113,7 +113,7 @@ jbInit(); popupinit(); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); } } @@ -422,7 +422,7 @@ ex.printStackTrace(pw); stackTrace = ("\r\n"+sw.toString()+"\r\n"); } catch (Exception e2) { - if (sfLog().isErrorEnabled()) sfLog().error (e2); + if (sfLog().isErrorEnabled()) sfLog().error (e2, e2); } } String tempString = ""; Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -115,7 +115,7 @@ } } } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); } } @@ -208,7 +208,7 @@ attribute[2] = null; } } catch (Exception e1) { - if (sfLog().isErrorEnabled()) sfLog().error (e1); + if (sfLog().isErrorEnabled()) sfLog().error (e1, e1); WindowUtilities.showError(this,"Failed to modify attribute '"+attribute.toString()+"'. \n"+e1.toString()); } @@ -235,7 +235,7 @@ return top.sfAsComponentDescription(); } } catch (Throwable ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); } try { @@ -285,7 +285,7 @@ //3 Info } } catch (Throwable ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); } return null; @@ -323,7 +323,7 @@ attribute[1] = null; attribute[2] = null; } catch (Exception e1) { - if (sfLog().isErrorEnabled()) sfLog().error (e1); + if (sfLog().isErrorEnabled()) sfLog().error (e1, e1); } this.dispose(); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -262,7 +262,7 @@ try { ((Prim)node).sfParentageChanged(); } catch (RemoteException ex1) { - if (sfLog().isErrorEnabled()) sfLog().error (ex1); + if (sfLog().isErrorEnabled()) sfLog().error (ex1, ex1); } } else if (node instanceof ComponentDescription){ ((ComponentDescriptionImpl)node).sfParentageChanged(); @@ -313,7 +313,7 @@ Object obj = (parent.getParent()); SFDeployDisplay.addScriptingPanel(((JTabbedPane)(obj)) ,name ,node, hostname ,port ); } catch (Exception e1) { - if (sfLog().isErrorEnabled()) sfLog().error (e1); + if (sfLog().isErrorEnabled()) sfLog().error (e1, e1); WindowUtilities.showError(this,e1.toString()); } } @@ -377,7 +377,7 @@ message.append (dumper.toString()); name = (objPrim).sfCompleteName().toString(); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); StringWriter sw = new StringWriter(); PrintWriter pr = new PrintWriter(sw,true); ex.printStackTrace(pr); @@ -404,7 +404,7 @@ if (fileName == null) return; ((DumperCDImpl)dumper).getCDtoFile(fileName); } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); + if (sfLog().isErrorEnabled()) sfLog().error (ex, ex); WindowUtilities.showError(this,ex.toString()); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/SFDeployDisplay.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -190,7 +190,7 @@ newDisplay.cleanAddedPanels(); } catch (Throwable thr1) { if (LogFactory.getLog("SFManagementConsole").isErrorEnabled()){ - LogFactory.getLog("SFManagementConsole").error(thr1); + LogFactory.getLog("SFManagementConsole").error(thr1, thr1); } } try { @@ -200,7 +200,7 @@ if (scriptingTab!=null) newDisplay.tabPane.add(scriptingPanelName,scriptingTab); } catch (Throwable ex) { if (LogFactory.getLog("SFManagementConsole").isErrorEnabled()){ - LogFactory.getLog("SFManagementConsole").error(ex); + LogFactory.getLog("SFManagementConsole").error(ex, ex); } //exitWith("Error in SFDeployDisplay.refresh():" + ex, ExitCodes.EXIT_ERROR_CODE_GENERAL); } @@ -222,7 +222,7 @@ treePanel.refresh(); } catch (Throwable thr1) { if (LogFactory.getLog("SFManagementConsole").isErrorEnabled()){ - LogFactory.getLog("SFManagementConsole").error(thr1); + LogFactory.getLog("SFManagementConsole").error(thr1, thr1); } } } @@ -261,7 +261,7 @@ try { addScriptingPanel (newDisplay.tabPane, null,null,hostname,port ); } catch (Exception e1) { - if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(e1);} + if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(e1, e1);} WindowUtilities.showError(newDisplay,e1.toString()); } //refreshButtonPanes.doClick(); @@ -295,7 +295,7 @@ */ - public static Display starParserConsole(String nameDisplay, int height, int width, String positionDisplay, ComponentDescription cd, boolean shouldSystemExit) throws Exception { + public static Display startParserConsole(String nameDisplay, int height, int width, String positionDisplay, ComponentDescription cd, boolean shouldSystemExit) throws Exception { final JButton refreshButtonPanes; final JButton refreshButtonNode; JMenu jMenuMng; @@ -571,7 +571,7 @@ tabPane.setSelectedIndex(tabIndex); } } catch (Throwable thr){ - if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(thr);} + if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(thr, thr);} if (thr instanceof ClassNotFoundException) { WindowUtilities.showError(tabPane, "For the scripting panel to work BeanShell ('bsh-1.3.0.jar') \nneeds to be in the console's classpath or lib directory"); } else { @@ -625,7 +625,7 @@ createManagementPane(); } catch (Exception e) { if (sfLog().isErrorEnabled()) { - sfLog().error(e); + sfLog().error(e, e); } //if } //catch } //run @@ -711,7 +711,7 @@ try { addScriptingPanel (display.tabPane, "sfManagementConsole", this,"localhost",3800 ); } catch (Exception e1) { - if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(e1); } + if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(e1, e1); } WindowUtilities.showError(display,e1.toString()); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/os/runshell/RunShellImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -426,7 +426,7 @@ subProcess = null; } } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } super.sfTerminateWith(tr); @@ -447,7 +447,7 @@ try { Thread.sleep(delayBetweenCmds * 1000); } catch (InterruptedException iex) { - if (sfLog().isErrorEnabled()) sfLog().error(iex); + if (sfLog().isErrorEnabled()) sfLog().error(iex, iex); } } else { if (sfLog().isTraceEnabled()) sfLog().trace("No delay between two consecutive cmds."); @@ -460,7 +460,7 @@ dos.writeBytes(cmd); dos.flush(); } catch (IOException ex) { - sfLog().error(ex); + sfLog().error(ex, ex); } } else { sfLog().error("Error: Stream closed. Shell probably terminated."); @@ -593,7 +593,7 @@ } } } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/RunProcessImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -580,7 +580,7 @@ processDos.flush(); } catch (IOException ex) { if (sfLog.isErrorEnabled()) { - sfLog.error(ex); + sfLog.error(ex, ex); } } } else { Modified: trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/shellscript/ScriptExecutionImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -207,7 +207,7 @@ if (exception != null) cd.sfAddAttribute("exception", exception); } catch (SmartFrogRuntimeException ex) { - if (log.isErrorEnabled()) log.error(ex); + if (log.isErrorEnabled()) log.error(ex, ex); } return cd; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/trace/TraceTreePanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/trace/TraceTreePanel.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/services/trace/TraceTreePanel.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -70,7 +70,7 @@ try { jbInit(); } catch (Exception ex) { - sfLog().error(ex); + sfLog().error(ex, ex); } } @@ -85,7 +85,7 @@ try { jbInit(); } catch (Exception ex) { - sfLog().error(ex); + sfLog().error(ex, ex); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ActionDump.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ActionDump.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ActionDump.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -105,7 +105,7 @@ message.append("\n*************** End state for " + name + " *****************\n"); } catch (Exception ex) { if (SFSystem.sfLog().isErrorEnabled()) { - SFSystem.sfLog().error(ex); + SFSystem.sfLog().error(ex, ex); } StringWriter sw = new StringWriter(); PrintWriter pr = new PrintWriter(sw, true); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -691,7 +691,7 @@ if (SFSystem.sfLog().isTraceEnabled()) {SFSystem.sfLog().trace(" Extracted ["+field+"] from ["+tempURL+"]"); } setName(field); } catch (Exception ex) { - SFSystem.sfLog().error(ex); + SFSystem.sfLog().error(ex, ex); throw new SmartFrogInitException("Error parsing NAME in: "+ deploymentURL+"("+ex.getMessage()+")", ex); } if (SFSystem.sfLog().isDebugEnabled()){SFSystem.sfLog().debug("Parsing SFACT results: ["+this+"]");} @@ -760,21 +760,21 @@ try { setName(cd.sfResolve(ATR_NAME, "", false)); } catch (Exception ex) { - SFSystem.sfLog().error(ex); + SFSystem.sfLog().error(ex, ex); throw new SmartFrogInitException("Error parsing NAME in: "+ cd +"("+ex.getMessage()+")", ex); } try { setActionType(cd.sfResolve(ATR_ACTION, "", true)); } catch (Exception ex) { - SFSystem.sfLog().error(ex); + SFSystem.sfLog().error(ex, ex); throw new SmartFrogInitException("Error parsing ACTION_TYPE in: "+ cd +"("+ex.getMessage()+")", ex); } try { setUrl(cd.sfResolve(ATR_DESC_URL, "", false)); } catch (Exception ex) { - SFSystem.sfLog().error(ex); + SFSystem.sfLog().error(ex, ex); throw new SmartFrogInitException( "Error parsing DESCRIPION_URL in: "+ cd +"("+ex.getMessage()+")", ex); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -85,7 +85,7 @@ rootRef = from.sfCompleteName(); init(); } catch (RemoteException e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e, e); } } @@ -102,7 +102,7 @@ sfKeysToBeRemoved = configuration.sfResolve(ATR_SF_KEYS_TO_BE_REMOVED, sfKeysToBeRemoved ,false); } } catch (Exception ex){ - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } @@ -148,11 +148,11 @@ ComponentDescription child = createCDWithKeysRemoved(stateCopy,true); placeHolder.sfReplaceAttribute(name, child); } catch (SmartFrogException ex) { - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); } } catch (Exception e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e, e); throw e; } } @@ -367,7 +367,7 @@ String cdStr = toString(timeout); return cdStr; } catch (Exception ex){ - if (sfLog().isErrorEnabled()) sfLog().error(ex); + if (sfLog().isErrorEnabled()) sfLog().error(ex, ex); return (ex.toString()); } } @@ -386,14 +386,14 @@ out.write(e.getMessage()); } } catch (IOException e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e, e); } finally { try { if( out != null ) { out.close(); } } catch (IOException e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e, e); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -125,7 +125,7 @@ testJarRepeat = configuration.sfResolve(ATR_TEST_JAR_REPEAT,testJarRepeat,false); } } catch (Exception ex){ - if (SFSystem.sfLog().isErrorEnabled()) { SFSystem.sfLog().error(ex); } + if (SFSystem.sfLog().isErrorEnabled()) { SFSystem.sfLog().error(ex, ex); } } initialized = true; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/compound/CompoundImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -1147,7 +1147,7 @@ } sfLog().debug("update with done"); } catch (Exception e) { - sfLog().error(e); + sfLog().error(e, e); try { sfLog().debug("abandoning"); sfAbandonUpdate(); @@ -1172,7 +1172,7 @@ sfUpdateStart(); sfLog().debug("update start done"); } catch (Exception e) { - sfLog().error(e); + sfLog().error(e, e); try { sfTerminate(TerminationRecord.abnormal("fatal error in update - terminated comopnents", sfCompleteNameSafe(), e)); } catch (Exception e1) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogToStreamsImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogToStreamsImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogToStreamsImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -403,10 +403,12 @@ // Append stack trace if not null if (t != null) { buf.append(" <"); - if (t instanceof SmartFrogException) + if (t instanceof SmartFrogException) { buf.append(((SmartFrogException) t).toString("\n ")); - else + } + else { buf.append(t.toString()); + } buf.append(">\n "); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -792,7 +792,7 @@ } catch (Exception sfex) { if (sfLog().isErrorEnabled()) { - sfLog().error(sfex); + sfLog().error(sfex, sfex); } //Logger.log(sfex); new TerminatorThread(this, sfex, null).quietly().start(); @@ -1978,7 +1978,7 @@ } } catch (Exception e) { if (sfLog().isErrorEnabled()) { - sfLog().error(e); + sfLog().error(e,e); } try { if (sfLog().isTraceEnabled()) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/processcompound/ProcessCompoundImpl.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -1016,7 +1016,7 @@ ap, ap.getClass().getName(), "java.lang.Boolean"); - sfLog().error(srex); + sfLog().error(srex,srex); } } @@ -1072,8 +1072,7 @@ sfLog().debug("New ProcessCompound " + name + " created: " + newPc .sfCompleteName()); } catch (Throwable thr) { - sfLog().debug("New ProcessCompound " + name + " created."); - sfLog().error(thr); + sfLog().error("New ProcessCompound " + name + " create failed " +thr,thr); } } return newPc; @@ -1482,9 +1481,8 @@ } } } catch (Exception ex) { - //Logger.log(ex); if (sfLog().isErrorEnabled()) { - sfLog().error(ex); + sfLog().error(ex, ex); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFRMIClassLoaderSpi.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFRMIClassLoaderSpi.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/security/SFRMIClassLoaderSpi.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -84,10 +84,10 @@ * @throws ClassNotFoundException if a definition for the class could not * be found at the specified location */ - public Class loadClass(String codebase, String name, + public Class<?> loadClass(String codebase, String name, ClassLoader defaultLoader) throws MalformedURLException, ClassNotFoundException { - Class result = defaultProviderInstance.loadClass(codebase, name, + Class<?> result = defaultProviderInstance.loadClass(codebase, name, defaultLoader); if (debug != null) { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2009-06-03 11:55:05 UTC (rev 7623) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2009-06-03 14:49:30 UTC (rev 7624) @@ -163,7 +163,7 @@ try { s.event(messages.get(i)); } catch (Exception ex) { - sfLog().error(ex); + sfLog().error(ex, ex); } } synchronized (registrationMessages) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-03 14:58:47
|
Revision: 7626 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7626&view=rev Author: steve_l Date: 2009-06-03 14:58:45 +0000 (Wed, 03 Jun 2009) Log Message: ----------- SFOS-1215 Add new task ExpandFully, to expand the task; reworking SFParse first. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFParse.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ParseOptionSet.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFParse.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFParse.java 2009-06-03 14:50:53 UTC (rev 7625) +++ trunk/core/smartfrog/src/org/smartfrog/SFParse.java 2009-06-03 14:58:45 UTC (rev 7626) @@ -1,28 +1,30 @@ /** (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 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. + 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 + 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 + For more information: www.smartfrog.org -*/ + */ package org.smartfrog; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; +import java.io.PrintWriter; import java.util.Vector; import org.smartfrog.services.management.SFDeployDisplay; @@ -41,38 +43,30 @@ import org.smartfrog.sfcore.security.SFSecurity; /** - * SFParse provides the utility methods to parse file descriptions and generate - * the parsing report. The main function looks for a filename(s) on the argument - * line and parses locally. + * SFParse provides the utility methods to parse file descriptions and generate the parsing report. The main function + * looks for a filename(s) on the argument line and parses locally. * - * <P> - * The main loop of SFParse reads an optionset. It then parses the file(s) - * and/or prints the status report depending on the options. - * </P> - * - * <b>Warning</b> This class is not thread safe; the static methods used shared static data structures. - * It is intended to be executed in from Main() methods and not from Java code. + * <P> The main loop of SFParse reads an optionset. It then parses the file(s) and/or prints the status report depending + * on the options. </P> + * + * <b>Warning</b> This class is not thread safe; the static methods used shared static data structures. It is intended + * to be executed in from Main() methods and not from Java code. */ -public class SFParse implements MessageKeys { +public final class SFParse implements MessageKeys { -// static String usageString = "Usage: sfParse [-v][-d] filename"; private static ParseOptionSet opts = null; private static Vector<Vector<String>> errorReport = null; - - private static ComponentDescription cd = null; - - - private SFParse(){ + + + private SFParse() { } /** * Gets language from the URL * * @param url URL passed to application - * * @return Language string - * * @throws SmartFrogException In case any error while getting the language string */ private static String getLanguageFromUrl(String url) throws @@ -82,7 +76,7 @@ if (i <= 0) { // i.e. it cannot contain no "." or start with the only "." throw new SmartFrogException( - "unable to source locate language in URL '" + url+"'"); + "unable to source locate language in URL '" + url + "'"); } else { return url.substring(i + 1); } @@ -90,78 +84,132 @@ /** * Ascertains whether a file is parseable + * * @param fileUrl the fileurl to be parsed - * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, - * that is before any parsing phases are carried out, so we have the opportunity to modify it before the phases are carried out + * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, that + * is before any parsing phases are carried out, so we have the opportunity to modify it before the + * phases are carried out * @return success or not */ public static boolean fileParses(String fileUrl, RawParseModifier rpm) { - if (opts == null) { - opts = new ParseOptionSet(new String[]{"sfParse"}); + ParseResults results = parseFile(fileUrl, rpm, createOptions()); + return extractErrors(results); + } + + + /** + * Ascertains whether a file is parseable + * + * @param fileUrl the fileurl to be parsed + * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, that + * is before any parsing phases are carried out, so we have the opportunity to modify it before the + * phases are carried out + * @return true if the file contained no errors + */ + public static boolean parseSingleFile(String fileUrl, RawParseModifier rpm) { + ParseResults results = parseFile(fileUrl, rpm, createOptions()); + return extractErrors(results); + } + + /** + * Extract errors from the results, add it to the ongoing error report (which is created if needed) + * + * @param results parsing output + * @return true if the file contained no errors + */ + private static boolean extractErrors(ParseResults results) { + if (results.errors.isEmpty()) { + return true; } - createErrorReport(); - parseFile(fileUrl,rpm); - return !errorReport.isEmpty(); + if (errorReport == null) { + errorReport = new Vector<Vector<String>>(); + } + errorReport.addAll(results.errors); + return false; } private static void createErrorReport() { - errorReport= new Vector<Vector<String>>(); + errorReport = new Vector<Vector<String>>(); } /** * Attempts to parse given file, returning resultant component description + * * @param fileUrl the fileurl to be parsed * @return ComponentDescription resulting from parse, if file successfully parses, else null */ - public static ComponentDescription parseFileToDescription(String fileUrl) { - return parseFileToDescription(fileUrl, null); + public static ComponentDescription parseFileToDescription(String fileUrl) { + return parseFileToDescription(fileUrl, null); } - - + + /** - * Attempts to parse given file, returning resultant component description + * Attempts to parse given file, returning resultant component description. Saves errors to the static variable + * {@link #errorReport} + * * @param fileUrl the fileurl to be parsed - * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, - * that is before any parsing phases are carried out, so we have the opportunity to modify it before the phases are carried out + * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, that + * is before any parsing phases are carried out, so we have the opportunity to modify it before the + * phases are carried out * @return ComponentDescription resulting from parse, if file successfully parses, else null */ - public static ComponentDescription parseFileToDescription(String fileUrl, RawParseModifier rpm) { - boolean parses = fileParses(fileUrl, rpm); - return parses? cd: null; + public static ComponentDescription parseFileToDescription(String fileUrl, RawParseModifier rpm) { + ParseOptionSet options = createOptions(); + ParseResults results = parseFile(fileUrl, rpm, options); + return results.hasErrors() ? null : results.cd; } - + /** - * Parses a file. + * Create the options, using the static {@link # opts} variable if present. * + * @return an optionset + */ + private static ParseOptionSet createOptions() { + ParseOptionSet options = opts; + if (options == null) { + options = new ParseOptionSet(new String[]{"sfParse"}); + } + return options; + } + + /** + * Attempts to parse given file, returning resultant component description + * * @param fileUrl the fileurl to be parsed - * @return the parse report + * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, that + * is before any parsing phases are carried out, so we have the opportunity to modify it before the + * phases are carried out + * @param options the options for this parse + * @return the parse results */ - private static Vector<String> parseFile(String fileUrl) { - return parseFile(fileUrl, null); + public static ParseResults parseFileToResults(String fileUrl, RawParseModifier rpm, ParseOptionSet options) { + return parseFile(fileUrl, rpm, options); } - + /** * Parses a file. * * @param fileUrl the fileurl to be parsed - * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, - * that is before any parsing phases are carried out, so we have the opportunity to modify it before the phases are carried out - * @return the parse report + * @param rpm A RawParseModifier on which we call modify(...) passing the raw parsed ComponentDescription, that + * is before any parsing phases are carried out, so we have the opportunity to modify it before the + * phases are carried out + * @param options the options for this parse + * @return the parse results */ - private static Vector<String> parseFile(String fileUrl, RawParseModifier rpm) { + private static ParseResults parseFile(String fileUrl, RawParseModifier rpm, ParseOptionSet options) { //To calculate how long it takes to parse a description - Vector<String> report = new Vector<String>(); - report.add("File: "+fileUrl+"\n"); - long parseTime=System.currentTimeMillis(); + ParseResults results = new ParseResults(); + Vector<String> report = results.report; + report.add("File: " + fileUrl + "\n"); + long parseTime = System.currentTimeMillis(); try { String language = getLanguageFromUrl(fileUrl); - //report.add("language: "+language); - Vector phaseList; Phases top; - InputStream is=null; + InputStream is = null; + boolean printPhases = options.verbose && !options.quiet; try { is = SFClassLoader.getResourceAsStream(fileUrl); if (is == null) { @@ -170,12 +218,12 @@ throw new SmartFrogParseException(msg); } top = (new SFParser(language)).sfParse(is); - if (opts.verbose && !opts.quiet) { + if (printPhases) { printPhase("raw", top.toString()); } - report.add(" "+"raw phase: OK"); + report.add(" " + "raw phase: OK"); } catch (Exception ex) { - report.add(" "+ "raw" +" phase: FAILED!"); + report.add(" " + "raw" + " phase: FAILED!"); throw ex; } finally { if (is != null) { @@ -187,7 +235,7 @@ } if (rpm != null) { - rpm.modify((top)); + rpm.modify(top); } phaseList = top.sfGetPhases(); @@ -197,49 +245,67 @@ phase = (String) aPhaseList; try { top = top.sfResolvePhase(phase); - if (opts.verbose && !opts.quiet) { + if (printPhases) { printPhase(phase, top.toString()); } report.add(" " + phase + " phase: OK"); } catch (Exception ex) { - //report.add(" "+ phase +" phase: "+ex.getMessage()); report.add(" " + phase + " phase: FAILED!"); throw ex; } } - cd = top.sfAsComponentDescription(); + results.cd = top.sfAsComponentDescription(); - if ((opts.description) || (opts.verbose && !opts.quiet)) { - printPhase("sfAsComponentDescription", cd.toString()); + if (options.description || printPhases) { + printPhase("sfAsComponentDescription", results.cd.toString()); } - parseTime=System.currentTimeMillis()-parseTime; - report.add(", parsed in "+ (parseTime) + " millisecs."); + parseTime = System.currentTimeMillis() - parseTime; + report.add(", parsed in " + (parseTime) + " millisecs."); + results.parseDurationMillis = parseTime; - showConsole(cd); + showConsole(options, results.cd); } catch (Exception e) { - //report.add("Error: "+ e.getMessage()); - //report.add(" "+ phase +" phase: FAILED!"); - SFSystem.sfLog().err("'"+fileUrl+"': \n"+ e+"\n",e); + SFSystem.sfLog().err("'" + fileUrl + "': \n" + e + "\n", e); Vector<String> itemError = new Vector<String>(); itemError.add(fileUrl); + boolean printStack; if (e instanceof SmartFrogException) { - itemError.add(((SmartFrogException)e).toString("<BR><BR>")); - } - else { + itemError.add(((SmartFrogException) e).toString("<BR><BR>")); + printStack = options.verbose; + } else { + printStack = true; itemError.add(e.toString()); } - errorReport.add(itemError); + //print the stack if verbose is set, or it is a non-SF exception (i.e. internal problems) + if (printStack) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + pw.flush(); + pw.close(); + itemError.add(sw.toString()); + } + results.errors.add(itemError); } - return report; + return results; } - private static void showConsole(ComponentDescription componentDescription) throws Exception { - if (opts.showConsole) { - SFDeployDisplay.starParserConsole("ParseConsole", 440, 600, "N", componentDescription, true); + + /** + * Optionally show a console + * + * @param options options to look at + * @param componentDescription the CD to display + * @throws Exception + */ + private static void showConsole(ParseOptionSet options, ComponentDescription componentDescription) + throws Exception { + if (options.showConsole) { + SFDeployDisplay.startParserConsole("ParseConsole", 440, 600, "N", componentDescription, true); Thread.sleep(3600 * 100); } } @@ -247,13 +313,16 @@ /** * Parses a list of files. * - * @param list the list of files to be parsed + * @param filenames the list of files to be parsed + * @return the list of parse results */ - private static void parseFiles(Vector<String> list) { + private static Vector<ParseResults> parseFiles(Vector<String> filenames, ParseOptionSet options) { StringBuffer strb; Vector<Vector<String>> report = new Vector<Vector<String>>(); + Vector<ParseResults> parseResults = new Vector<ParseResults>(filenames.size()); + Vector<Vector<String>> errors = new Vector<Vector<String>>();; //Loop through the vector - for (String file : list) { + for (String file : filenames) { try { strb = new StringBuffer(); //If it's not an empty line @@ -263,8 +332,15 @@ .append(file) .append("\n") .append("-----------------------------------------------"); - if (!opts.quiet) SFSystem.sfLog().out(strb.toString()); - report.add(parseFile(file)); + if (!options.quiet) { + SFSystem.sfLog().out(strb.toString()); + } + ParseResults results = parseFile(file, null, options); + parseResults.add(results); + errors.addAll(results.errors); + errors = results.errors; + Vector<String> output = results.report; + report.add(output); } } catch (Throwable thr) { strb = new StringBuffer(); @@ -276,17 +352,20 @@ .append(thr.getMessage()) .append("\n") .append("-----------------------------------------------"); - if (!opts.quiet) SFSystem.sfLog().err(strb.toString(), thr); + if (!options.quiet) { + SFSystem.sfLog().err(strb.toString(), thr); + } } } - if (opts.statusReport) { + if (options.statusReport) { printTotalReport(report); } - if (opts.statusReportHTML) { + if (options.statusReportHTML) { printTotalReportHTML(report); FileWriter newFile = null; try { - newFile = new FileWriter(opts.fileName + "_report.html"); + String destFile = options.fileName + "_report.html"; + newFile = new FileWriter(destFile); newFile.write("<!doctype HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><html>"); newFile.write("<body>" + "\n"); newFile.write("<font color=\"BLUE\" size=\"5\">Status report<font/>" + "\n"); @@ -295,18 +374,18 @@ newFile.write("<table/>"); newFile.write("<font color=\"BLUE\" size=\"5\">Error report<font/>" + "\n"); newFile.write("<table border=\"1\">" + "\n"); - newFile.write(printTotalReportHTML(errorReport)); + newFile.write(printTotalReportHTML(errors)); newFile.write("<table/>"); newFile.write("<body/>" + "\n"); newFile.write("<html/>" + "\n"); newFile.flush(); newFile.close(); newFile = null; - SFSystem.sfLog().out("Report created: " + opts.fileName + "_report.html"); + SFSystem.sfLog().out("Report created: " + destFile); } catch (IOException e) { - SFSystem.sfLog().error(e); + SFSystem.sfLog().error(e, e); } finally { - if (newFile!=null) { + if (newFile != null) { try { newFile.close(); } catch (IOException ignored) { @@ -315,6 +394,8 @@ } } } + SFParse.errorReport = errors; + return parseResults; } /** @@ -340,58 +421,54 @@ showVersionInfo(); - opts = new ParseOptionSet(args); + ParseOptionSet optionSet = new ParseOptionSet(args); + //stack trace flag comes from the verbose option + org.smartfrog.sfcore.common.Logger.logStackTrace = optionSet.verbose; + + //reset the error report createErrorReport(); - showDiagnostics(opts); + showDiagnostics(optionSet); - if (opts.errorString != null) { - if (opts.help) { - SFSystem.sfLog().out("Help: \n" + opts.errorString); + if (optionSet.errorString != null) { + if (optionSet.help) { + SFSystem.sfLog().out("Help: \n" + optionSet.errorString); ExitCodes.exitWithError(ExitCodes.EXIT_CODE_SUCCESS); } else { - SFSystem.sfLog().out("Error: " + opts.errorString); - ExitCodes.exitWithError(ExitCodes.EXIT_CODE_SUCCESS); + SFSystem.sfLog().out("Error: " + optionSet.errorString); + ExitCodes.exitWithError(ExitCodes.EXIT_ERROR_CODE_BAD_ARGS); } - exit(); } - if (opts.loadDescriptionsFromFile) { - parseFiles(opts.filesList); + if (optionSet.loadDescriptionsFromFile) { + parseFiles(optionSet.filesList, optionSet); } else { - Vector<String> report = parseFile(opts.fileName); - if (opts.statusReport) { - printItemReport(report); + ParseResults results = parseFile(optionSet.fileName, null, optionSet); + extractErrors(results); + if (optionSet.statusReport) { + printItemReport(results.report); } } - //Added so that ant task detects error during build process. // If we found errors during parsing we force exit. if (!errorReport.isEmpty()) { SFSystem.sfLog().out("Error detected. Check report."); - exit(); + SFSystem.sfLog().out("SFParse: FAILED"); + ExitCodes.exitWithError(ExitCodes.EXIT_ERROR_CODE_GENERAL); } else { SFSystem.sfLog().out("SFParse: SUCCESSFUL"); ExitCodes.exitWithError(ExitCodes.EXIT_CODE_SUCCESS); } } catch (Throwable thr) { - SFSystem.sfLog().error(thr); + SFSystem.sfLog().error("Exception "+ thr, thr); } } /** - * Exits SFParse. - */ - private static void exit() { - SFSystem.sfLog().out( "SFParse: FAILED"); - ExitCodes.exitWithError(ExitCodes.EXIT_ERROR_CODE_GENERAL); - } - - /** * Shows the version info of the SmartFrog system. */ private static void showVersionInfo() { - SFSystem.sfLog().out("\nParser - " +Version.versionString()); + SFSystem.sfLog().out("\nParser - " + Version.versionString()); SFSystem.sfLog().out(Version.copyright()); SFSystem.sfLog().out(" "); } @@ -401,102 +478,96 @@ * Prints the phase. * * @param phaseName the phase name - * @param result the result to be printed + * @param result the result to be printed */ private static void printPhase(String phaseName, String result) { SFSystem.sfLog().out( - "******************** PHASE " + phaseName + - " *********************"); + "******************** PHASE " + phaseName + + " *********************"); SFSystem.sfLog().out(result); SFSystem.sfLog().out("\n\n\n\n\n"); } - /** - * Prints the total parsing report. - * - * @param report the report to be printed - */ - private static void printTotalReport(Vector<Vector<String>> report){ - for (Vector<String> entry : report) { - printItemReport(entry); - } + /** + * Prints the total parsing report. + * + * @param report the report to be printed + */ + private static void printTotalReport(Vector<Vector<String>> report) { + for (Vector<String> entry : report) { + printItemReport(entry); + } } - /** - * Print the parsing report for an item. - * - * @param report the report to be printed - */ + /** + * Print the parsing report for an item. + * + * @param report the report to be printed + */ private static void printItemReport(Vector<String> report) { - StringBuilder st = new StringBuilder("STATUS REPORT: "); - for (Object line : report) { - st.append(line.toString()).append("<td/>\n"); - } - SFSystem.sfLog().out(st.toString()); - } + StringBuilder st = new StringBuilder("STATUS REPORT: "); + for (String line : report) { + st.append(line); + } + SFSystem.sfLog().out(st.toString()); + } - /** - * Prints the total parsing report in html format. - * - * @param report the report to be printed - * @return the string form of the parse report - */ - private static String printTotalReportHTML(Vector<Vector<String>> report){ - //StringBuffer reportHTML = new StringBuffer("<!doctype HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><html>"); - StringBuilder reportHTML = new StringBuilder(); -// reportHTML.append("<body>"+"\n"); -// //Add table -// reportHTML.append("<table border=\"1\">"+"\n"); - for(Vector<String> entry:report) { - reportHTML.append(printItemReportHTML(entry)); - } -// reportHTML.append("<table/>"); -// reportHTML.append("<body/>"+"\n"); -// reportHTML.append("<html/>"+"\n"); - return reportHTML.toString(); + /** + * Prints the total parsing report in html format. + * + * @param reportList the report to be printed + * @return the string form of the parse report + */ + private static String printTotalReportHTML(Vector<Vector<String>> reportList) { + StringBuilder reportHTML = new StringBuilder(); + for (Vector<String> entry : reportList) { + reportHTML.append(printItemReportHTML(entry)); + } + return reportHTML.toString(); } - /** - * Print the parsing report for an item in html format. - * - * @param report the report to be printed - * @return the output as a table row - */ + /** + * Print the parsing report for an item in html format. + * + * @param report the report to be printed + * @return the output as a table row + */ private static String printItemReportHTML(Vector<String> report) { - //SFSystem.sfLog().out("STATUS REPORT:\n"); - StringBuilder st = new StringBuilder("<tr>" + "\n"); - for (String line : report) { - st.append("<td>").append(line).append("<td/>\n"); - } - st.append("<tr/>" + "\n"); - return st.toString(); - } + StringBuilder st = new StringBuilder("<tr>" + "\n"); + for (String line : report) { + st.append("<td>").append(line).append("<td/>\n"); + } + st.append("<tr/>\n"); + return st.toString(); + } /** * Shows diagnostics report + * * @param options OptionSet */ private static void showDiagnostics(ParseOptionSet options) { - if (options.diagnostics){ - StringBuffer report = new StringBuffer(); - Diagnostics.doReport(report); - SFSystem.sfLog().out(report.toString()); - } + if (options.diagnostics) { + StringBuffer report = new StringBuffer(); + Diagnostics.doReport(report); + SFSystem.sfLog().out(report.toString()); + } } - - public static boolean isVerboseOptSet(){ - return opts != null && opts.verbose; - } - + public interface RawParseModifier { - public void modify(ComponentDescription cd); + public void modify(ComponentDescription cd); } - private static class ParseResults { + /** + * This is the class to use + */ + public static class ParseResults { ComponentDescription cd; Vector<String> parsed; Vector<Vector<String>> errors = new Vector<Vector<String>>(); - + Vector<String> report = new Vector<String>(); + long parseDurationMillis; + public boolean hasErrors() { return !errors.isEmpty(); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ParseOptionSet.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ParseOptionSet.java 2009-06-03 14:50:53 UTC (rev 7625) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ParseOptionSet.java 2009-06-03 14:58:45 UTC (rev 7626) @@ -131,12 +131,15 @@ case 'd': description = true; break; + case 'r': statusReport = true; break; + case 'R': statusReportHTML = true; break; + case 'D': diagnostics = true; break; @@ -144,6 +147,7 @@ case 'f': loadDescriptionsFromFile = true; break; + case 'c': showConsole = true; break; @@ -162,10 +166,7 @@ } catch (Exception e) { errorString = "illegal format for options "; exitCode = ExitCodes.EXIT_ERROR_CODE_BAD_ARGS; - //Logger.log(ex); - if (SFSystem.sfLog().isErrorEnabled()) { - SFSystem.sfLog().error(e); - } + SFSystem.sfLog().error("Error " + e, e); } } @@ -174,16 +175,12 @@ filesList= loadListOfFiles(fileName); } - if ((errorString != null)||fileName==null) { - if ((fileName==null) &&(!help)) errorString="no file to parse"; - errorString += usage; - //System.exit(1); - } - } catch (Exception ex){ - //Logger.log(ex); - if (SFSystem.sfLog().isErrorEnabled()) { - SFSystem.sfLog().error(ex); + if ((errorString != null) || fileName == null) { + if ((fileName == null) && (!help)) errorString = "no file to parse"; + errorString += usage; } + } catch (Throwable t) { + SFSystem.sfLog().error(t, t); exitCode = ExitCodes.EXIT_ERROR_CODE_BAD_ARGS; } } @@ -212,16 +209,13 @@ } } catch (IOException ex) { errorString = ex.getMessage(); - //Logger.log(ex); - if (SFSystem.sfLog().isErrorEnabled()) { - SFSystem.sfLog().error(ex); - } + SFSystem.sfLog().error(errorString, ex); } finally { if(file!=null) { try { file.close(); } catch (IOException e) { - SFSystem.sfLog().error(e); + SFSystem.sfLog().error(e, e); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-11 16:29:05
|
Revision: 7647 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7647&view=rev Author: steve_l Date: 2009-06-11 16:28:14 +0000 (Thu, 11 Jun 2009) Log Message: ----------- SFOS-1228 print out the security manager classname on startup. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/security/DummySecurityManager.java trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingRealSecurityManager.java trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingSecurityManager.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2009-06-11 10:50:52 UTC (rev 7646) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2009-06-11 16:28:14 UTC (rev 7647) @@ -694,6 +694,11 @@ sfLog().warn(MessageUtil.formatMessage(WARN_SECURE_RESOURCES_OFF)); } } + SecurityManager manager = System.getSecurityManager(); + if (manager != null) { + sfLog().info("Security Manager is " + manager); + } + // if this property is set then a security manager is created, here we provide debug information about it. String secPro = System.getProperty("java.security.policy"); if (secPro != null) { @@ -701,6 +706,7 @@ } else { if (sfLog().isDebugEnabled()) sfLog().debug("No security manager loaded by SmartFrog"); } + } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/security/DummySecurityManager.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/security/DummySecurityManager.java 2009-06-11 10:50:52 UTC (rev 7646) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/security/DummySecurityManager.java 2009-06-11 16:28:14 UTC (rev 7647) @@ -101,4 +101,13 @@ } } } + + /** + * {@inheritDoc} + * @return a description of the security manager + */ + @Override + public String toString() { + return "DummySecurityManager:\n allows everything"; + } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingRealSecurityManager.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingRealSecurityManager.java 2009-06-11 10:50:52 UTC (rev 7646) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingRealSecurityManager.java 2009-06-11 16:28:14 UTC (rev 7647) @@ -61,7 +61,9 @@ */ @Override public String toString() { - return "ExitTrappingRealSecurityManager, systemExitPermitted=" + isSystemExitPermitted(); + return "ExitTrappingRealSecurityManager:\n" + + " security is checked;" + + " systemExitPermitted=" + isSystemExitPermitted(); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingSecurityManager.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingSecurityManager.java 2009-06-11 10:50:52 UTC (rev 7646) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/security/ExitTrappingSecurityManager.java 2009-06-11 16:28:14 UTC (rev 7647) @@ -72,7 +72,9 @@ */ @Override public String toString() { - return "ExitTrappingSecurityManager, systemExitPermitted=" + isSystemExitPermitted(); + return "ExitTrappingSecurityManager:" + + "\n no security checks; " + + "systemExitPermitted=" + isSystemExitPermitted(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-06-17 11:07:37
|
Revision: 7675 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7675&view=rev Author: anfarr Date: 2009-06-17 11:07:30 +0000 (Wed, 17 Jun 2009) Log Message: ----------- SFOS-1238: Update to orch/constraints-related in support of auto-deployment into cells task Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/components.sf trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/components.sf 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/components.sf 2009-06-17 11:07:30 UTC (rev 7675) @@ -49,17 +49,13 @@ enabled false; } -NilStateComponent extends StateComponent { +StateComponent extends Prim { sfClass "org.smartfrog.services.dependencies.statemodel.state.NilStateComponent"; -} - -StateComponent extends Prim { - sfClass "org.smartfrog.services.dependencies.statemodel.state.StateComponent"; - sfUpdatable true; + //sfUpdatable true; sfUniqueComponentID; [sfFinal] asAndConnector false; - - threadpool LAZY PARENT:ATTRIB threadpool; // default place for the threadpool + + threadpool LAZY PARENT:ATTRIB threadpool; } ThreadedCompositeBase extends { @@ -72,6 +68,7 @@ Composite extends Compound { sfClass "org.smartfrog.services.dependencies.statemodel.state.Composite"; sfUpdatable true; + sfSyncTerminate true; /*inputConnectors extends Compound { sfUpdatable true; @@ -99,6 +96,7 @@ Model extends CompositeWithSync { //phase.modelcheck "org.smartfrog.services.dependencies.modelcheck.ModelCheck"; running true; //note this has changed in meaning from legacy versions + sfIsOrchModel; } CompositeTerminator extends StateComponent { @@ -159,16 +157,34 @@ requiresThread true; } -SimpleTransition extends Transition { +SimpleTransitionNoScriptingAgent extends Transition { requiresThread false; + lag 0; } +SimpleTransition extends SimpleTransitionNoScriptingAgent { + scriptAttributes []; + doScript extends ScriptWrapper { + script LAZY PARENT:ATTRIB script; + scriptPrim LAZY PARENT:ATTRIB scriptingAgent; + scriptAttributes LAZY PARENT:scriptAttributes; + } +} + +PrepareTransition extends SimpleTransition { + sfIsStateComponentTransition "prepare"; +} + +FinalizeTransition extends SimpleTransition { + sfIsStateComponentTransition "finalize"; +} + ScriptWrapper extends Function { sfFunctionClass "org.smartfrog.services.dependencies.scripting.ScriptWrapper"; sfLazyFunction true; script TBD; scriptPrim TBD; - notifier LAZY PARENT:ATTRIB threadpool; + scriptAttributes []; } VerificationRecord extends { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -3,12 +3,12 @@ import java.rmi.RemoteException; import java.util.Enumeration; -import org.smartfrog.services.dependencies.threadpool.ThreadPool; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.compound.CompoundImpl; import org.smartfrog.sfcore.prim.Liveness; import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.TerminationRecord; /** * @@ -16,35 +16,37 @@ public class Composite extends CompoundImpl implements Compound, StateChangeNotification, RunSynchronisation { private String name=""; - - //Threads on tap... - private ThreadPool threadpool; + private boolean terminating=false; public Composite() throws RemoteException { super(); } - public synchronized void sfDeploy() throws RemoteException, SmartFrogException { - super.sfDeploy(); - - //My name... - Object name_o = sfContext().get("name"); - if (name_o!=null && name_o instanceof String) name = (String) name_o; - else { - Prim p = sfParent(); - if (p!=null) name = (String) sfParent().sfAttributeKeyFor(this); - else name="sfConfig"; - } + public synchronized void sfDeploy() throws RemoteException, SmartFrogException { + //My name... + Object name_o = sfContext().get("name"); + if (name_o!=null && name_o instanceof String) name = (String) name_o; + else { + Prim p = sfParent(); + if (p!=null) name = (String) sfParent().sfAttributeKeyFor(this); + else name="sfConfig"; + } - threadpool = (ThreadPool) sfResolve("threadpool", false); + super.sfDeploy(); } public synchronized void sfStart() throws RemoteException, SmartFrogException { - //System.out.println("&&&&& IN MODEL START &&&&&"); - super.sfStart(); - if (threadpool!=null) threadpool.setIdleRunnable(new Notifier()); + try { + sfResolve("sfIsOrchModel"); + new Thread(new Notifier()).start(); + } catch(Exception e){/*Intentionally ok!*/} + super.sfStart(); } + public synchronized void sfTerminateWith(TerminationRecord tr) { + terminating=true; + super.sfTerminateWith(tr); + } public synchronized void sfRun() throws SmartFrogException{ //System.out.println("IN: sfRun"+this); @@ -89,11 +91,13 @@ /* ************************************************* * Update class */ - protected class Notifier implements Runnable { + class Notifier implements Runnable { public void run() { if (sfLog().isDebugEnabled()) sfLog().debug("IN: Composite.Notifier.run()"); //System.out.println("++++++++++++++++++++HANDLE STATE CHANGE!!!"); - try{handleStateChange();} catch (RemoteException re){throw new RuntimeException(re);} + while (!Composite.this.terminating){ + try{handleStateChange();} catch (RemoteException re){throw new RuntimeException(re);} + } if (sfLog().isDebugEnabled()) sfLog().debug("OUT: Composite.Notifier.run()"); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -3,6 +3,8 @@ import java.rmi.Remote; import java.rmi.RemoteException; +import org.smartfrog.services.dependencies.statemodel.state.Composite.Notifier; + /** */ public interface StateChangeNotification extends Remote { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -1,5 +1,7 @@ package org.smartfrog.services.dependencies.statemodel.state; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.rmi.RemoteException; import java.util.Enumeration; import java.util.HashMap; @@ -8,10 +10,13 @@ import java.util.Vector; import java.util.concurrent.locks.ReentrantLock; +import javax.swing.Timer; + import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; import org.smartfrog.services.dependencies.threadpool.ThreadPool; import org.smartfrog.sfcore.common.Context; +import org.smartfrog.sfcore.common.SFNull; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.componentdescription.ComponentDescription; @@ -19,6 +24,7 @@ import org.smartfrog.sfcore.languages.sf.functions.Constraint; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.reference.ApplyReference; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; @@ -48,6 +54,20 @@ public StateComponent() throws RemoteException { } + public synchronized void sfTerminateWith(TerminationRecord t) { + if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: (IN) sfTerminateWith(t)"); + + ComponentDescription tTermination = transitions.get("tOnTermination"); + try{ + if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: Applying termination script"); + tTermination.sfResolve("doScript");} + catch(Exception e){/*Ok for now*/} + + super.sfTerminateWith(t); + if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: "+name+" terminated"); + if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: (OUT) sfTerminateWith(t)"); + } + public synchronized void sfDeploy() throws RemoteException, SmartFrogException { super.sfDeploy(); @@ -67,7 +87,7 @@ if (val instanceof ComponentDescription){ ComponentDescription cd = (ComponentDescription) val; - if (cd.sfContext().get("sfIsStateComponentTransition")!=null) transitions.put(key, cd); + if (cd.sfContext().get("sfIsStateComponentTransition")==SFNull.get()) transitions.put(key, cd); } else if (val instanceof ApplyReference){ ApplyReference ar = (ApplyReference) val; ComponentDescription cd = ar.getComponentDescription(); @@ -154,6 +174,11 @@ Iterator keys = ((HashMap<String,ComponentDescription>)enabled.clone()).keySet().iterator(); while (keys.hasNext()){ Object key = keys.next(); + if (key.toString().equals("tOnTermination")) { + enabled.remove(key); + continue; //ignore + } + ComponentDescription trans = (ComponentDescription) enabled.get(key); boolean go=false; @@ -232,6 +257,33 @@ return result; } + public void preparefinalize(boolean prepare, String transition) throws StateComponentTransitionException { + //Is there a prepare/finalizetransition script? + String actualName = (prepare?"tPrepare"+transition.substring(1):"tFinalize"+transition.substring(1)); + if (sfLog().isDebugEnabled()) sfLog().debug("Prepare transition..."+actualName); + ComponentDescription action = (ComponentDescription) sfContext().get(actualName); + if (action!=null) { + if (sfLog().isDebugEnabled()) sfLog().debug("Prepare/Finalize transition..."); + + Object qual = action.sfContext().get("sfIsStateComponentTransition"); + if (sfLog().isDebugEnabled()) sfLog().debug("Prepare/Finalize transition..."+qual.toString()); + + try{if (qual!=null && qual.toString().equals((prepare?"prepare":"finalize"))) action.sfResolve("doScript");} + catch(Exception e){/*Ok for now*/if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: Prepare/Finalize transition..."+e.getMessage()); + } + } + } + + public void doPrepare(String transition) throws StateComponentTransitionException { + if (sfLog().isDebugEnabled()) sfLog().debug("Prepare transition..."); + preparefinalize(true, transition); + } + + public void doFinalize(String transition) throws StateComponentTransitionException { + if (sfLog().isDebugEnabled()) sfLog().debug("Finalize transition..."); + preparefinalize(false, transition); + } + public void go(String transition) throws StateComponentTransitionException { if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").go()"); @@ -252,6 +304,7 @@ currentAction=null; cleanLock(); asyncResponse=false; + scriptTimer=null; if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").clean(...)"); } @@ -279,14 +332,12 @@ if (sfLog().isDebugEnabled()) sfLog().debug("^^^^^^^^^^^^^^^^^^^Progress"+progress); - if (progress) { - System.out.println("Progress made"); - threadpool.runIdleAgain(); - } return progress; } public String getStatusAsString() throws RemoteException {return "";} + + Timer scriptTimer; public void handleStateChange() throws RemoteException { @@ -294,7 +345,7 @@ if (sfLog().isDebugEnabled()) sfLog().debug("To run DPEs..."+dpes.size()+": currentAction: "+currentAction); - if (currentAction!=null) return; //temporary + if (currentAction!=null || scriptTimer!=null) return; //temporary if (!acquireLock()) return; //need to except... @@ -321,15 +372,27 @@ //Check if simple transition... try { if (enabled.size()==1){ - String key = enabled.keySet().iterator().next(); - ComponentDescription transition = (ComponentDescription) enabled.get(key); - if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition"+key); + final String key = enabled.keySet().iterator().next(); + final ComponentDescription transition = (ComponentDescription) enabled.get(key); + if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition: "+key); + if (!transition.sfResolve("requiresThread", false, true)){ - if (sfLog().isDebugEnabled()) sfLog().debug("State("+name+").handleStateChange() -- Script call..."); - transition.sfResolve("deploy"); //Apply script... - go(key); - clean(); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); + + if (sfLog().isDebugEnabled()) sfLog().debug("Does not require thread"); + + //Is there a preparetransition script? + doPrepare(key); + + int lag = transition.sfResolve("lag", 0, true); + if (lag>0) { + ActionListener taskPerformer = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + transitionScript(transition, key); + } + }; + (scriptTimer=new Timer(lag, taskPerformer)).start(); + + } else transitionScript(transition, key); return; } } @@ -343,6 +406,21 @@ if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange()"); } + void transitionScript(ComponentDescription transition, String key) { + //Need to handle properly... + try { + if (sfLog().isDebugEnabled()) sfLog().debug("State("+name+").handleStateChange() -- Script call..."); + try{transition.sfResolve("doScript");} catch (Exception e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple script "+e.getMessage());}//Apply script... + + //Is there a finalizetransition script? + doFinalize(key); + + go(key); + clean(); + if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); + } catch (SmartFrogException e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} + } + public void register(DependencyValidation d) throws SmartFrogStateLifecycleException { //System.out.println("Dependency Registration. Component: "+name+", d: "+d.toString()); dependencies.add(d); @@ -377,7 +455,6 @@ Object result = super.sfReplaceAttribute(name,value); - if (!Constraint.isUpdateContextLocked() && threadpool!=null) threadpool.runIdle(); return result; } @@ -399,6 +476,8 @@ threadpool.addToQueue((StateUpdateThread)(currentAction=new StateUpdateThread())); + if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateComponent.setState() Added to Queue"); + cleanLock(); System.out.println("Adding to queue..."+currentAction); @@ -417,8 +496,15 @@ public void run() { if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateUpdateThread.run()"); try{ + String key=null; + if (enabled.size()==1){ + key = enabled.keySet().iterator().next(); + doPrepare(key); + } + if (threadBody()) { StateComponent.this.clean(); + if (key!=null) doFinalize(key); } else { //Should this clean now? StateComponent.this.cleanLock(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -17,15 +17,13 @@ * <p/> * Implements the ThreadPool Interface, and provides methods for * controlling the execution of a set of jobs by a thread pool + * */ -public class SimpleThreadPoolImpl extends PrimImpl implements Remote, Prim, Serializable { +public class SimpleThreadPoolImpl extends PrimImpl implements ThreadPool, Remote, Prim, Serializable { private int numThreads=5; private int busyThreads=0; private transient ExecutorService es; - private boolean suspended=false; - private transient Runnable idleRunnable; - private boolean runAgain=false; - + public SimpleThreadPoolImpl() throws RemoteException { } @@ -35,10 +33,6 @@ es = Executors.newFixedThreadPool(numThreads); } - public synchronized void sfStart() throws RemoteException, SmartFrogException { - super.sfStart(); - } - public synchronized void sfTerminateWith(TerminationRecord tr) { es.shutdown(); super.sfTerminateWith(tr); @@ -50,65 +44,14 @@ toRun=run; } public void run(){ - synchronized (SimpleThreadPoolImpl.this) { - while (suspended) { - try {SimpleThreadPoolImpl.this.wait();} catch (InterruptedException ie){/**/} - } - } toRun.run(); synchronized(SimpleThreadPoolImpl.this){ busyThreads--; - runIdle(); } } } - private class IdleRunnable implements Runnable { - Runnable toRun; - IdleRunnable(Runnable run){ - toRun=run; - } - public void run(){ - runAgain=true; - while(runAgain){ - runAgain=false; - toRun.run(); - } - synchronized(SimpleThreadPoolImpl.this){ - suspended=false; - SimpleThreadPoolImpl.this.notifyAll(); - } - } - } - /** - * Remove a runnable from the registered Runnable jobs - */ - public Future<?> removeFromQueue(Future<?> task){ - boolean cancelled= task.cancel(false); - if (cancelled) synchronized(this) { busyThreads--; } - return (cancelled?null:task); - } - - public void runIdleAgain(){ - runAgain=true; - } - - public void runIdle(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: threadPool: runIdle()"); - if (busyThreads==0 && !suspended) { - suspended=true; - es.submit(idleRunnable); - } - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: threadPool: runIdle()"); - } - - public void setIdleRunnable(Runnable idleRunnable){ - this.idleRunnable=new IdleRunnable(idleRunnable); - runIdle(); - } - - /** * register a Runnable to be allocated a thread * */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -27,11 +27,6 @@ */ public Future<?> addToQueue(Runnable run); - public Future<?> removeFromQueue(Future<?> task); + //public Future<?> removeFromQueue(Future<?> task); - public void setIdleRunnable(Runnable idle); - - public void runIdle(); - - public void runIdleAgain(); } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -52,6 +52,7 @@ public static final String KEY_TAG="sfKey"; public final static String DEPLOY = "deployComponent"; + public final static String TERMINATE = "terminateComponent"; public static final String CONTEXT="context"; public static final String CONTEXT_TAG="sfContext"; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -33,10 +33,10 @@ import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.languages.sf.constraints.ConstraintConstants; -import org.smartfrog.sfcore.languages.sf.constraints.CoreSolver; import org.smartfrog.sfcore.languages.sf.sfreference.SFReference; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; @@ -77,13 +77,17 @@ } public static void applyEffects(ComponentDescription effects) throws SmartFrogFunctionResolutionException { - System.out.println("IN applyEffects"); + //NOTE: This code is lacking a jolly good tidy- ADHF + + System.out.println("IN applyEffects"); //Array/path/pred? Reference array = null; String prefix = null; Reference pred = null; ComponentDescription pcontext = null; + Object toTerminate=null; + try { array = (Reference) effects.sfContext().get(ConstraintConstants.ARRAY); } catch(Exception e){/**/} System.out.println("ARRAY: "+array); @@ -115,9 +119,12 @@ ComponentDescription deploy = null; if (update==null){ try { deploy= (ComponentDescription) effects.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.DEPLOY)));}catch(Exception e){} + if (deploy==null){ + try { toTerminate=effects.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.TERMINATE)));}catch(Exception e){} + } } System.out.println("DEPLOY: "+deploy); - if (deploy==null && update==null) return; + if (deploy==null && update==null && toTerminate==null) return; Reference path = null; try { path = (Reference) effects.sfContext().get(ConstraintConstants.PATH); } @@ -166,8 +173,17 @@ if (added!=null && added instanceof SynchedComposite) model.addToRun(added); } } - } - else { + } else if (toTerminate!=null){ + if (source instanceof Compound) { + Compound source_nd = (Compound) source; + try { + Prim primTerm = (Prim) source_nd.sfResolve(key.toString()); + primTerm.sfDetachAndTerminate(TerminationRecord.normal(null)); + } catch (Exception e){ + throw new SmartFrogFunctionResolutionException("Unable to terminate prim with key: "+key+" in: "+source_nd); + } + } + } else { //Replace in array? if (array!=null && prefix!=null){ @@ -178,7 +194,6 @@ catch(Exception e){ throw new SmartFrogFunctionResolutionException("path in effects will not resolve: "+effects); } - System.out.println("000"); Context src_context = null; try {src_context = (source instanceof Prim?((Prim)source).sfContext():((ComponentDescription)source).sfContext());} @@ -187,7 +202,6 @@ Enumeration en = src_context.keys(); while (en.hasMoreElements()){ - System.out.println("222"); String akey = en.nextElement().toString(); @@ -195,8 +209,7 @@ System.out.println("In with the prefix..."+akey); Object member = src_context.get(akey); - System.out.println("333"); - + Prim p = (member instanceof Prim?(Prim)member:null); ComponentDescription c=(member instanceof ComponentDescription?(ComponentDescription)member:null); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java 2009-06-16 16:19:12 UTC (rev 7674) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java 2009-06-17 11:07:30 UTC (rev 7675) @@ -24,6 +24,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Enumeration; +import java.util.Iterator; import java.util.Set; import java.util.Vector; @@ -57,6 +58,7 @@ import org.smartfrog.sfcore.parser.ReferencePhases; import org.smartfrog.sfcore.reference.HereReferencePart; import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.reference.ReferencePart; /** * Defines the context class used by Components. Context implementations @@ -810,6 +812,33 @@ } /** + * Link resolution is exclusively an SFComponentDescription phenomenon. But it is possible that we + * would like to do simple link resolution dynamically on deployed cds which at run-time are plain + * ComponentDescriptions. Hence this method which does a "simple" link resolution. + * @param comp input cd + * @return link resolved cd + * @throws SmartFrogException + */ + public static ComponentDescription simpleLinkResolve(ComponentDescription comp) throws SmartFrogException { + //Simple link resolve... + ComponentDescription newcomp = new SFComponentDescriptionImpl(); + newcomp.setParent(comp.sfParent()); + newcomp.setEager(comp.getEager()); + + for (Iterator v = comp.sfAttributes(); v.hasNext();) { + Object name = v.next(); + String nameS = name.toString(); + Reference ref = new Reference(ReferencePart.here(name)); + Object value=comp.sfResolve(ref); + if (value instanceof ComponentDescription) value=simpleLinkResolve((ComponentDescription)value); + + newcomp.sfAddAttribute(name, value); + newcomp.sfAddTags(name, comp.sfGetTags(name)); + } + return newcomp; + } + + /** * 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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2009-06-29 16:35:37
|
Revision: 7747 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7747&view=rev Author: julgui Date: 2009-06-29 16:35:30 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Testing sfDump with timeout to register timeout exception inside tests. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumpVisitorImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-06-29 13:26:30 UTC (rev 7746) +++ trunk/core/smartfrog/src/org/smartfrog/services/display/Display.java 2009-06-29 16:35:30 UTC (rev 7747) @@ -1440,10 +1440,10 @@ * @throws Exception If unable to initialize */ protected void jbInit() throws Exception { - String imagesPath = Display.class.getPackage().getName() + "."; + String imagesPath = Display.class.getPackage().getName() + "."; imagesPath = imagesPath.replace('.', '/'); //imagesPath = imagesPath + "frog.gif"; - imagesPath = imagesPath + "SplodgeGreen32.ico"; + imagesPath = imagesPath + "SplodgeGreen32.gif"; this.setIconImage(createImage(imagesPath)); documentScreen = screen.getDocument(); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumpVisitorImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumpVisitorImpl.java 2009-06-29 13:26:30 UTC (rev 7746) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumpVisitorImpl.java 2009-06-29 16:35:30 UTC (rev 7747) @@ -36,14 +36,14 @@ */ public class DumpVisitorImpl implements Dump, Serializable { - //static final long serialVersionUID = -812223322957783371L; + static final long serialVersionUID = -812223322957783371L; //Reference to the class collecting results from visits private transient Dumper dumper = null; public DumpVisitorImpl (Dumper dumper){ this.dumper = dumper; - System.out.println(" - Visitor ("+this+"): created"); + //System.out.println(" - Visitor ("+this+"): created"); } /** * Components use this method to dump their state to when requested (using @@ -67,21 +67,25 @@ numberOfChildren = new Integer (numberC); } - System.out.println(" - Visitor 1 ("+this+") ("+numberOfChildren+"): "+name); + //System.out.println(" - Visitor 1 ("+this+") ("+numberOfChildren+"): "+name); dumper.visiting(from.sfCompleteName().toString(),numberOfChildren); - System.out.println(" - Visitor 2 ("+this+") to clone context ("+numberOfChildren+"): "+name); + //System.out.println(" - Visitor 2 ("+this+") to clone context ("+numberOfChildren+"): "+name); //System.out.println(" - Visitor 3 ("+this+") context "+ state.toString()); Context stateCopy = (Context)((Context)state).clone(); try { - System.out.println(" - Visitor 4 ("+this+") to modifyCD ("+numberOfChildren+"): "+name); + //System.out.println(" - Visitor 4 ("+this+") to modifyCD ("+numberOfChildren+"): "+name); dumper.modifyCD(searchRef, stateCopy); - System.out.println(" - Visitor 5 ("+this+") modified CD ("+numberOfChildren+"): "+name); + //System.out.println(" - Visitor 5 ("+this+") modified CD ("+numberOfChildren+"): "+name); } catch (Exception e) { throw new RemoteException(" Visitor Failed to modifyCD from "+name,e); } - System.out.println(" - Visitor 6 ("+this+") visited: "+name); + //System.out.println(" - Visitor 6 ("+this+") visited: "+name); dumper.visited(name); } + public String toString(){ + return ("DumpVisitor reporting to Dumper: "+ dumper +", #"+ this.hashCode()); + } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java 2009-06-29 13:26:30 UTC (rev 7746) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/DumperCDImpl.java 2009-06-29 16:35:30 UTC (rev 7747) @@ -108,7 +108,7 @@ public Dump getDumpVisitor(){ Dump dumpVisitor = new DumpVisitorImpl(this); - if (sfLog().isInfoEnabled()) sfLog().info("Returning dumpVisitor: "+dumpVisitor); + if (sfLog().isDebugEnabled()) sfLog().debug("Returning dumpVisitor: "+ dumpVisitor); return dumpVisitor; } @@ -239,9 +239,9 @@ // not found, wait for leftover timeout long now = (new Date()).getTime(); if (now>=endTime) { - if (sfLog().isInfoEnabled()) sfLog().info("Timeout ("+completed+")"); + if (sfLog().isTraceEnabled()) sfLog().trace("Timeout ("+completed+")"); if (completed) { - if (sfLog().isWarnEnabled()) sfLog().warn("Description creation Timeout ("+ (timeout/1000) +" sec) and completed."); + if (sfLog().isDebugEnabled()) sfLog().debug("Description creation Timeout ("+ (timeout/1000) +" sec) and completed."); return cd; } else { StringBuffer message = new StringBuffer (); @@ -256,7 +256,7 @@ // message.append ("\n"); // Diagnostics.doReportThreadDump(message); message.append ("\n+-.End.-"); - if (sfLog().isWarnEnabled()) sfLog().warn(message); + if (sfLog().isDebugEnabled()) sfLog().debug(message); throw new SmartFrogException(message.toString()); } } @@ -280,11 +280,13 @@ */ public void visiting(String name, Integer numberOfChildren) throws RemoteException { // Notify any waiting threads that an attribute was added - if (sfLog().isInfoEnabled()) sfLog().info(" - Dumper: VisitING notitification received#"+visiting+ " from "+name +" lock:"+ visitingLock); + synchronized (visitingLock) { + if (sfLog().isDebugEnabled()) sfLog().debug(" - Dumper: VisitING notitification received#"+visiting+ " from "+name +" lock:"+ visitingLock); visiting = new Long (visiting.longValue() + numberOfChildren.longValue()); + if (sfLog().isDebugEnabled()) sfLog().debug(" - Dumper: VisitING notitification received and counted#"+visiting+ " from "+name); } - if (sfLog().isInfoEnabled()) sfLog().info(" - Dumper: VisitING notitification received and counted#"+visiting+ " from "+name); + } /** @@ -296,16 +298,18 @@ */ public void visited(String name) throws RemoteException { // Notify any waiting threads that an attribute was added - if (sfLog().isInfoEnabled()) sfLog().info(" - Dumper: VisitED notitification received#"+visiting+ " from "+name); + synchronized (visitingLock) { + if (sfLog().isDebugEnabled()) sfLog().debug(" - Dumper: VisitED notitification received#"+visiting+ " from "+name); visiting = new Long (visiting.longValue()-1); if (visiting.longValue()==0) { //done with all visits completed = true; visitingLock.notify(); } + if (sfLog().isDebugEnabled()) sfLog().debug(" - Dumper: VisitED notitification received and counted #"+visiting+ " from "+name); } - if (sfLog().isInfoEnabled()) sfLog().info(" - Dumper: VisitED notitification received and counted #"+visiting+ " from "+name); + } /** Get the resulting Component Description in a String format @@ -317,7 +321,7 @@ try { return "sfConfig extends {\n" + getComponentDescription(waitTimeout).toString() + "}"; } catch (Exception e) { - if (sfLog().isWarnEnabled()) sfLog().warn(e); + if (sfLog().isWarnEnabled()) sfLog().warn(e.getMessage(),e); return e.getMessage(); } } @@ -383,8 +387,8 @@ String cdStr = toString(timeout); return cdStr; } catch (Exception ex){ - if (sfLog().isErrorEnabled()) sfLog().error("",ex); - return (ex.toString()); + if (sfLog().isErrorEnabled()) sfLog().error(ex.getMessage(),ex); + return ( "NULL , error: " + ex.toString()); } } @@ -399,17 +403,17 @@ componentDescription.setEager(true); componentDescription.writeOn(out, 1); } catch (SmartFrogException e) { - out.write(e.getMessage()); + out.write(e.toString()); } } catch (IOException e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e.getMessage(),e); } finally { try { if( out != null ) { out.close(); } } catch (IOException e) { - if (sfLog().isErrorEnabled()) sfLog().error(e); + if (sfLog().isErrorEnabled()) sfLog().error(e.getMessage(),e); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2009-06-29 13:26:30 UTC (rev 7746) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2009-06-29 16:35:30 UTC (rev 7747) @@ -1156,10 +1156,11 @@ */ public void sfDumpState(Dump target) { try { + if (sfLog().isDebugEnabled()) { sfLog().debug("Dumping state to: " + target); }; target.dumpState(sfContext, this); } catch (Exception ex) { - if (sfLog().isIgnoreEnabled()) { - sfLog().ignore(ex); + if (sfLog().isErrorEnabled()) { + sfLog().error(ex.getMessage(),ex); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-07-29 16:30:41
|
Revision: 7792 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7792&view=rev Author: anfarr Date: 2009-07-29 16:30:34 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheck.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheckResults.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/NuSMVInterface.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/Resolver.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnectorExists.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/Connector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NXorConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NandConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NorConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnectorExists.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/DependencyValidation.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateException.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateLifecycleException.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/InvokeAsynchronousStateChange.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NWayComposite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/RunSynchronisation.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SimpleStateComponent.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateDependencies.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/termination/CompositeTermination.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/utils/CDUtil.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPoolTester.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/CDPrinter.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheck.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheck.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheck.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.modelcheck; import java.io.FileOutputStream; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheckResults.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheckResults.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/ModelCheckResults.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.modelcheck; import java.util.Vector; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/NuSMVInterface.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/NuSMVInterface.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/NuSMVInterface.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.modelcheck; import java.io.File; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/Resolver.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/Resolver.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/modelcheck/Resolver.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.modelcheck; import java.util.Enumeration; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; -import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; - import java.rmi.RemoteException; -import java.util.HashSet; import java.util.Iterator; +import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; + /** */ public class AndConnector extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnectorExists.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnectorExists.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnectorExists.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; -import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; - import java.rmi.RemoteException; -import java.util.HashSet; import java.util.Iterator; +import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; + /** */ public class AndConnectorExists extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/Connector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/Connector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/Connector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NXorConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NXorConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NXorConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NandConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NandConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NandConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; +import java.rmi.RemoteException; +import java.util.Iterator; + import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; -import java.util.HashSet; -import java.util.Iterator; -import java.rmi.RemoteException; - /** */ public class NandConnector extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NorConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NorConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/NorConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; +import java.rmi.RemoteException; +import java.util.Iterator; + import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; -import java.util.HashSet; -import java.util.Iterator; -import java.rmi.RemoteException; - /** */ public class NorConnector extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; +import java.rmi.RemoteException; +import java.util.Iterator; + import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; -import java.util.HashSet; -import java.util.Iterator; -import java.rmi.RemoteException; - /** */ public class OrConnector extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnectorExists.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnectorExists.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnectorExists.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,16 +1,30 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; +import java.rmi.RemoteException; +import java.util.Iterator; + import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; -import org.smartfrog.services.dependencies.statemodel.exceptions.SmartFrogStateLifecycleException; -import org.smartfrog.services.dependencies.statemodel.state.StateDependencies; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.common.SmartFrogException; -import java.util.HashSet; -import java.util.Iterator; -import java.rmi.RemoteException; - /** */ public class OrConnectorExists extends Connector { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.connector; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.dependency; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/DependencyValidation.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/DependencyValidation.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/DependencyValidation.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.dependency; public interface DependencyValidation { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateException.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateException.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.exceptions; import org.smartfrog.sfcore.common.SmartFrogException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateLifecycleException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateLifecycleException.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/exceptions/SmartFrogStateLifecycleException.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.exceptions; import org.smartfrog.sfcore.prim.Prim; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import java.rmi.RemoteException; @@ -15,7 +35,7 @@ import org.smartfrog.sfcore.prim.TerminationRecord; /** - * + * Composite pattern for orchestration components */ public class Composite extends CompoundImpl implements Compound, StateChangeNotification, RunSynchronisation, DeployingAgent { @@ -76,15 +96,12 @@ } public synchronized void sfRun() throws SmartFrogException{ - //System.out.println("IN: sfRun"+this); - for (Enumeration<Liveness> e = sfChildren(); e.hasMoreElements(); ) { Object c = e.nextElement(); if (c instanceof RunSynchronisation) { ((RunSynchronisation)c).sfRun(); } } - //System.out.println("OUT: sfRun"+this); } public String getName(){ Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/InvokeAsynchronousStateChange.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/InvokeAsynchronousStateChange.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/InvokeAsynchronousStateChange.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; public interface InvokeAsynchronousStateChange { Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NWayComposite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NWayComposite.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NWayComposite.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/NilStateComponent.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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 + +*/ + /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/RunSynchronisation.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/RunSynchronisation.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/RunSynchronisation.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import org.smartfrog.sfcore.common.SmartFrogException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SimpleStateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SimpleStateComponent.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SimpleStateComponent.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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 + +*/ + /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateChangeNotification.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import java.rmi.Remote; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import java.awt.event.ActionEvent; @@ -35,6 +55,9 @@ /** */ + +///TIME FOR A CODE REVIEW FOR THIS CLASS + public abstract class StateComponent extends PrimImpl implements Prim, StateDependencies, StateChangeNotification, DependencyValidation { private HashSet dependencies = new HashSet(); @@ -51,8 +74,7 @@ private boolean m_running=false; private ReentrantLock transitionLock = new ReentrantLock(); - public StateComponent() throws RemoteException { - } + public StateComponent() throws RemoteException {super();} public synchronized void sfTerminateWith(TerminationRecord t) { if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: (IN) sfTerminateWith(t)"); @@ -70,9 +92,7 @@ public synchronized void sfDeploy() throws RemoteException, SmartFrogException { super.sfDeploy(); - - //System.out.println("&&&&& IN STATECOMPONENT DEPLOY &&&&&"); - + threadpool = (ThreadPool) sfResolve("threadpool", false); Context cxt = sfContext(); asAndConnector = sfResolve("asAndConnector", asAndConnector, false); Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import org.smartfrog.sfcore.common.SmartFrogException; @@ -18,7 +38,6 @@ this(msg, g_NOCODEAVAILABLE); } - //These codes are in drastic need of an update... public static final int g_NOCODEAVAILABLE=0xFFFF; public static final int g_NOTRANSITIONS=0x0; public static final int g_NOSUCHAVAILABLETRANSITION=0x1; @@ -30,10 +49,10 @@ public static final int g_INVALIDSUPPLIEDVALUE=0x7; public static final int g_VALUESLEFTTOSET=0x8; public static final int g_VALUEALREADYSET=0x9; - public static final int g_NOTPERMITTED=0x10; - public static final int g_DEPENDENCYVALUEUNRESOLVABLE=0x4; - public static final int g_UNABLETOAPPLYEFFECTS=0x4; - public static final int g_COMPONENTNOTENABLED=0x10; + public static final int g_NOTPERMITTED=0xA; + public static final int g_DEPENDENCYVALUEUNRESOLVABLE=0xB; + public static final int g_UNABLETOAPPLYEFFECTS=0xC; + public static final int g_COMPONENTNOTENABLED=0xD; public int getExceptionCode(){ return code; } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateDependencies.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateDependencies.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateDependencies.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/SynchedComposite.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.state; import org.smartfrog.sfcore.compound.CompoundImpl; @@ -26,10 +46,7 @@ Object result = super.sfReplaceAttribute(name,value); - //System.out.println("In SynchedComposite..."); - try { - //System.out.println("Replacing attribute in: "+this.sfCompleteName+": name:"+name+" : "+value); if (name.equals("run") && (value instanceof Boolean) && ((Boolean)value).booleanValue()) { this.sfRun(); super.sfReplaceAttribute("running", new Boolean(true)); Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/termination/CompositeTermination.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/termination/CompositeTermination.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/termination/CompositeTermination.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.termination; import java.rmi.RemoteException; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/utils/CDUtil.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/utils/CDUtil.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/utils/CDUtil.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.statemodel.utils; import org.smartfrog.sfcore.componentdescription.ComponentDescription; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/SimpleThreadPoolImpl.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.threadpool; import java.io.Serializable; @@ -56,12 +76,14 @@ * */ public Future<?> addToQueue(Runnable run){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: threadPool: addToQueue()"); + if (sfLog().isInfoEnabled()) sfLog().info("IN: threadPool: addToQueue()"); synchronized (this){ busyThreads++; //we should increase before it's run... } - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: threadPool: addToQueue()"); - return es.submit(new Runnable_(run)); + if (sfLog().isInfoEnabled()) sfLog().info("threadPool: addToQueue() SUBMITTING"); + Future<?> future = es.submit(new Runnable_(run)); + if (sfLog().isInfoEnabled()) sfLog().info("OUT: threadPool: addToQueue()"); + return future; } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPool.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.threadpool; import java.util.concurrent.Future; Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPoolTester.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPoolTester.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/threadpool/ThreadPoolTester.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -1,3 +1,23 @@ +/** (C) Copyright 1998-2009 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.dependencies.threadpool; import org.smartfrog.sfcore.common.SmartFrogException; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java 2009-07-29 15:32:57 UTC (rev 7791) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfcomponentdescription/SFComponentDescriptionImpl.java 2009-07-29 16:30:34 UTC (rev 7792) @@ -19,6 +19,7 @@ */ package org.smartfrog.sfcore.languages.sf.sfcomponentdescription; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.Serializable; import java.io.StringWriter; @@ -56,9 +57,11 @@ import org.smartfrog.sfcore.languages.sf.functions.Constraint.SmartFrogConstraintBacktrackError; import org.smartfrog.sfcore.parser.Phases; import org.smartfrog.sfcore.parser.ReferencePhases; +import org.smartfrog.sfcore.parser.SFParser; import org.smartfrog.sfcore.reference.HereReferencePart; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.reference.ReferencePart; +import org.smartfrog.sfcore.security.SFClassLoader; /** * Defines the context class used by Components. Context implementations @@ -961,8 +964,35 @@ return res; } + + + /** + * Method to take a URL, parse it, add the addtional key-value parameters to the top level, and then resolve it. + * @param url the file to parse + * @param params a context containing the parameter key-value pairs + * @return the resultant component description + * @throws SmartFrogException + * @throws FileNotFoundException + */ + public static ComponentDescription getDescriptionURL(String url, Context params) throws SmartFrogException, FileNotFoundException { + System.out.println("SFCDImpl1:"+url); + + Phases p = new SFParser().sfParse(SFClassLoader.getResourceAsStream(url)); + + System.out.println("SFCDImpl2:"+p); + // add params + if (params != null) { + for (Enumeration keys = params.keys(); keys.hasMoreElements(); ) { + Object k = keys.nextElement(); + p.sfReplaceAttribute(k, params.get(k)); + } + } + + System.out.println("SFCDImpl3"+p); + + return p.sfResolvePhases().sfAsComponentDescription(); + } - protected Object copyValue(Object v) throws SmartFrogCompilationException { if (v instanceof Number) return v; if (v instanceof Boolean) return v; Modif... [truncated message content] |
From: <an...@us...> - 2009-11-14 23:06:43
|
Revision: 8042 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8042&view=rev Author: anfarr Date: 2009-11-14 23:06:35 +0000 (Sat, 14 Nov 2009) Log Message: ----------- SFOS-1264 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/LoadBalancerBindingImpl.java trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/ServerInstanceImpl.java trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/gui/progresspanel/ProgressBarsImpl.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java Modified: trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/LoadBalancerBindingImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/LoadBalancerBindingImpl.java 2009-11-14 20:33:08 UTC (rev 8041) +++ trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/LoadBalancerBindingImpl.java 2009-11-14 23:06:35 UTC (rev 8042) @@ -34,7 +34,7 @@ public class LoadBalancerBindingImpl extends StateComponent implements Prim, LoadBalancerBinding { - public LoadBalancerBindingImpl() throws RemoteException {super();} + public LoadBalancerBindingImpl() throws RemoteException {} private Balancer lb = null; private Integer sfIndex; Modified: trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/ServerInstanceImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/ServerInstanceImpl.java 2009-11-14 20:33:08 UTC (rev 8041) +++ trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/balancer/ServerInstanceImpl.java 2009-11-14 23:06:35 UTC (rev 8042) @@ -38,7 +38,7 @@ public class ServerInstanceImpl extends StateComponent implements Prim, ServerInstance { - public ServerInstanceImpl() throws RemoteException {super();} + public ServerInstanceImpl() throws RemoteException {} private Balancer lb = null; private ComponentDescription template = null; Modified: trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/gui/progresspanel/ProgressBarsImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/gui/progresspanel/ProgressBarsImpl.java 2009-11-14 20:33:08 UTC (rev 8041) +++ trunk/core/smartfrog/src/org/smartfrog/examples/orchdws/gui/progresspanel/ProgressBarsImpl.java 2009-11-14 23:06:35 UTC (rev 8042) @@ -70,9 +70,7 @@ * * @exception RemoteException In case of network/rmi error */ - public ProgressBarsImpl() throws RemoteException { - super(); - } + public ProgressBarsImpl() throws RemoteException {} /** * Print the receipt of any event for debugging Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-11-14 20:33:08 UTC (rev 8041) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2009-11-14 23:06:35 UTC (rev 8042) @@ -73,17 +73,17 @@ public StateComponent() throws RemoteException {} public synchronized void sfTerminateWith(TerminationRecord t) { - if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: (IN) sfTerminateWith(t)"); + sfLog().debug ("StateComponent: (IN) sfTerminateWith(t)"); ComponentDescription tTermination = transitions.get("tOnTermination"); try{ - if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: Applying termination script"); + sfLog().debug ("StateComponent: Applying termination script"); tTermination.sfResolve("doScript");} catch(Exception e){/*Ok for now*/} super.sfTerminateWith(t); - if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: "+name+" terminated"); - if (sfLog().isDebugEnabled()) sfLog().debug ("StateComponent: (OUT) sfTerminateWith(t)"); + sfLog().debug ("StateComponent: "+name+" terminated"); + sfLog().debug ("StateComponent: (OUT) sfTerminateWith(t)"); } public synchronized void sfDeploy() throws RemoteException, SmartFrogException { @@ -156,7 +156,7 @@ private void resetPossibleTransitions() throws StateComponentTransitionException { - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").resetPossibleTransitions()"); + sfLog().debug("IN: State("+name+").resetPossibleTransitions()"); enabled=null; if (!checkRunning() || !checkIsEnabled()) throw new StateComponentTransitionException(StateComponentTransitionException.g_COMPONENTNOTENABLED); @@ -188,50 +188,50 @@ throw new StateComponentTransitionException(StateComponentTransitionException.g_DEPENDENCYVALUEUNRESOLVABLE); } - if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Key:"+key+":"+go); + sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Key:"+key+":"+go); if (go) { - if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Dependency enabled."); + sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Dependency enabled."); } else { - if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Dependency not enabled."); + sfLog().debug("WITHIN: State("+name+").resetPossibleTransitions(). Dependency not enabled."); enabled.remove(key); } } if (enabled.isEmpty()) enabled=null; - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").resetPossibleTransitions()"); + sfLog().debug("OUT: State("+name+").resetPossibleTransitions()"); } protected boolean acquireLock(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").acquireLock(...)"); - if (sfLog().isDebugEnabled()) sfLog().debug("is locked?"+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); + sfLog().debug("IN: State("+name+").acquireLock(...)"); + sfLog().debug("is locked?"+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); if ((currentAction!=null && currentAction!=Thread.currentThread()) || //Allow locking only by scheduled action... (currentAction==null && transitionLock.isLocked() && !transitionLock.isHeldByCurrentThread())) return false; //or by current owner thread transitionLock.lock(); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").acquireLock(...)"); + sfLog().debug("OUT: State("+name+").acquireLock(...)"); return true; } protected void cleanLock(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").cleanLock(...)"); + sfLog().debug("IN: State("+name+").cleanLock(...)"); while (transitionLock.isHeldByCurrentThread()) { //CHECK! transitionLock.unlock(); } - if (sfLog().isDebugEnabled()) sfLog().debug("is locked?"+transitionLock.isHeldByCurrentThread()+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").cleanLock(...)"); + sfLog().debug("is locked?"+transitionLock.isHeldByCurrentThread()+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); + sfLog().debug("OUT: State("+name+").cleanLock(...)"); } public boolean selectSingleAndGo(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").selectSingleAndGo(...)"); + sfLog().debug("IN: State("+name+").selectSingleAndGo(...)"); boolean result=true; try { resetPossibleTransitions(); - if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").selectSingleAndGo(...). Number transitions..."+enabled.size()); + sfLog().debug("WITHIN: State("+name+").selectSingleAndGo(...). Number transitions..."+enabled.size()); if (enabled.size()==0 || enabled.size()>1) return false; - if (sfLog().isDebugEnabled()) sfLog().debug("WITHIN: State("+name+").selectSingleAndGo(...). Single transition..."); + sfLog().debug("WITHIN: State("+name+").selectSingleAndGo(...). Single transition..."); Iterator keys = enabled.keySet().iterator(); if (keys.hasNext()){ @@ -239,7 +239,7 @@ go(key); } } catch (StateComponentTransitionException e) {result=false;} - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").selectSingleAndGo(...)"); + sfLog().debug("OUT: State("+name+").selectSingleAndGo(...)"); return result; } @@ -247,52 +247,52 @@ public void preparefinalize(boolean prepare, String transition) throws StateComponentTransitionException { //Is there a prepare/finalizetransition script? String actualName = (prepare?"tPrepare"+transition.substring(1):"tFinalize"+transition.substring(1)); - if (sfLog().isDebugEnabled()) sfLog().debug("Prepare transition..."+actualName); + sfLog().debug("Prepare transition..."+actualName); ComponentDescription action = (ComponentDescription) sfContext().get(actualName); if (action!=null) { - if (sfLog().isDebugEnabled()) sfLog().debug("Prepare/Finalize transition..."); + sfLog().debug("Prepare/Finalize transition..."); Object qual = action.sfContext().get("sfIsStateComponentTransition"); - if (sfLog().isDebugEnabled()) sfLog().debug("Prepare/Finalize transition..."+qual.toString()); + sfLog().debug("Prepare/Finalize transition..."+qual.toString()); try{if (qual!=null && qual.toString().equals((prepare?"prepare":"finalize"))) action.sfResolve("doScript");} - catch(Exception e){/*Ok for now*/if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: Prepare/Finalize transition..."+e.getMessage()); + catch(Exception e){/*Ok for now*/ sfLog().debug("EXCEPTION: Prepare/Finalize transition..."+e.getMessage()); } } } public void doPrepare(String transition) throws StateComponentTransitionException { - if (sfLog().isDebugEnabled()) sfLog().debug("Prepare transition..."); + sfLog().debug("Prepare transition..."); preparefinalize(true, transition); } public void doFinalize(String transition) throws StateComponentTransitionException { - if (sfLog().isDebugEnabled()) sfLog().debug("Finalize transition..."); + sfLog().debug("Finalize transition..."); preparefinalize(false, transition); } public void go(String transition) throws StateComponentTransitionException { - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").go()"); + sfLog().debug("IN: State("+name+").go()"); try { - if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition"+transition); + sfLog().debug("Key in simple transition"+transition); ComponentDescription trans = null; try{trans = (ComponentDescription) enabled.get(transition);} catch (Throwable e){sfLog().debug("WHAT? "+e.getMessage());} trans.sfResolve(new Reference(ReferencePart.here(ConstraintConstants.EFFECTS))); } catch (Exception e){throw new StateComponentTransitionException("Unable to apply effects in transition: "+transition, StateComponentTransitionException.g_UNABLETOAPPLYEFFECTS);} - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").go()"); + sfLog().debug("OUT: State("+name+").go()"); } public void clean(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").clean(...)"); + sfLog().debug("IN: State("+name+").clean(...)"); currentAction=null; cleanLock(); asyncResponse=false; scriptTimer=null; - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").clean(...)"); + sfLog().debug("OUT: State("+name+").clean(...)"); } boolean runDPEs(){ @@ -308,7 +308,7 @@ } public boolean handleDPEs(){ - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleDPEs()"); + sfLog().debug("IN: State("+name+").handleDPEs()"); boolean progress=false; //synchronized(CoreSolver.getInstance()){ @@ -317,7 +317,7 @@ Constraint.applyUpdateContext(); //} - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleDPEs() Progress"+progress); + sfLog().debug("IN: State("+name+").handleDPEs() Progress"+progress); return progress; } @@ -327,17 +327,16 @@ Timer scriptTimer; public void handleStateChange() throws RemoteException { - - if (sfLog().isDebugEnabled()) sfLog().debug("IN: State("+name+").handleStateChange()"); + sfLog().debug("IN: State("+name+").handleStateChange()"); - if (sfLog().isDebugEnabled()) sfLog().debug("To run DPEs..."+dpes.size()+": currentAction: "+currentAction); + sfLog().debug("To run DPEs..."+dpes.size()+": currentAction: "+currentAction); if (currentAction!=null || scriptTimer!=null) return; //temporary if (!acquireLock()) return; //need to except... if (handleDPEs()){ - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange()"); + sfLog().debug("OUT: State("+name+").handleStateChange()"); clean(); return; } @@ -349,9 +348,9 @@ } if (enabled==null) { - if (sfLog().isDebugEnabled()) sfLog().debug("no enabled transitions..."); + sfLog().debug("no enabled transitions..."); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Nothing to do..."); + sfLog().debug("OUT: State("+name+").handleStateChange() -- Nothing to do..."); clean(); return; //nothing to do... } @@ -361,11 +360,11 @@ if (enabled.size()==1){ final String key = enabled.keySet().iterator().next(); final ComponentDescription transition = (ComponentDescription) enabled.get(key); - if (sfLog().isDebugEnabled()) sfLog().debug("Key in simple transition: "+key); + sfLog().debug("Key in simple transition: "+key); if (!transition.sfResolve("requiresThread", false, true)){ - if (sfLog().isDebugEnabled()) sfLog().debug("Does not require thread"); + sfLog().debug("Does not require thread"); //Is there a preparetransition script? doPrepare(key); @@ -383,29 +382,29 @@ return; } } - } catch (SmartFrogException e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} + } catch (SmartFrogException e){ sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} try { setState(); } catch (StateComponentTransitionException stce) {/*Hardly acceptable handling*/} - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange()"); + sfLog().debug("OUT: State("+name+").handleStateChange()"); } void transitionScript(ComponentDescription transition, String key) { //Need to handle properly... try { - if (sfLog().isDebugEnabled()) sfLog().debug("State("+name+").handleStateChange() -- Script call..."); - try{transition.sfResolve("doScript");} catch (Exception e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple script "+e.getMessage());}//Apply script... + sfLog().debug("State("+name+").handleStateChange() -- Script call..."); + try{transition.sfResolve("doScript");} catch (Exception e){ sfLog().debug("EXCEPTION: in applying simple script "+e.getMessage());}//Apply script... //Is there a finalizetransition script? doFinalize(key); go(key); clean(); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); - } catch (SmartFrogException e){if (sfLog().isDebugEnabled()) sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} + sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); + } catch (SmartFrogException e){ sfLog().debug("EXCEPTION: in applying simple transition"+e.getMessage());} } public void register(DependencyValidation d) throws SmartFrogStateLifecycleException { @@ -452,22 +451,22 @@ } public void setState() throws StateComponentTransitionException { - if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateComponent.setState()"); + sfLog().debug("IN: StateComponent.setState()"); //handled above: if (clearCurrentAction()!=null) return; //Not appropriate to allow further transition at this time... - if (sfLog().isDebugEnabled()) sfLog().debug("Adding to queue..."); + sfLog().debug("Adding to queue..."); //currentActionFuture= threadpool.addToQueue(new StateUpdateThread()); threadpool.addToQueue((StateUpdateThread)(currentAction=new StateUpdateThread())); - if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateComponent.setState() Added to Queue"); + sfLog().debug("IN: StateComponent.setState() Added to Queue"); cleanLock(); - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: StateComponent.setState()"); + sfLog().debug("OUT: StateComponent.setState()"); } protected abstract boolean threadBody() throws StateComponentTransitionException; @@ -479,7 +478,7 @@ */ public class StateUpdateThread implements Runnable { public void run() { - if (sfLog().isDebugEnabled()) sfLog().debug("IN: StateUpdateThread.run()"); + sfLog().debug("IN: StateUpdateThread.run()"); try{ String key=null; if (enabled.size()==1){ @@ -496,7 +495,7 @@ StateComponent.this.asyncResponse=true; } } catch (StateComponentTransitionException stce) {/*Hardly acceptable handling*/} - if (sfLog().isDebugEnabled()) sfLog().debug("OUT: StateUpdateThread.run()"); + sfLog().debug("OUT: StateUpdateThread.run()"); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-11-14 20:33:08 UTC (rev 8041) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-11-14 23:06:35 UTC (rev 8042) @@ -295,7 +295,7 @@ } public interface DeployingAgent extends Remote { - public void addToDeploy(String name, ComponentDescription cd) throws Exception; + public void addToDeploy(String name, ComponentDescription cd) throws SmartFrogException, RemoteException; public void addToTerminate(String name) throws RemoteException; public void waitOnQueuesCleared() throws RemoteException; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-12-24 13:33:20
|
Revision: 8117 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8117&view=rev Author: anfarr Date: 2009-12-24 13:33:13 +0000 (Thu, 24 Dec 2009) Log Message: ----------- SFOS-1402: Changed to throw InterruptedIOException. This is a temporary measure until possibly a subclass is introduced. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-12-23 18:04:28 UTC (rev 8116) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2009-12-24 13:33:13 UTC (rev 8117) @@ -20,6 +20,8 @@ package org.smartfrog.services.dependencies.statemodel.state; +import java.io.IOException; +import java.io.InterruptedIOException; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Enumeration; @@ -68,7 +70,7 @@ public Composite() throws RemoteException { } - public void waitOnQueuesCleared(){ + public void waitOnQueuesCleared() throws IOException { sfLog().debug("IN: Composite: waitOnQueuesCleared()"); CompositeQueueListener ccl = new CompositeQueueListener(); synchronized (listeners){ @@ -81,8 +83,11 @@ sfLog().debug("Sleeping..."); try { Thread.sleep(WAIT_A_REASONABLE_PERIOD); - } catch(InterruptedException ignored){ - sfLog().ignore(ignored); + } catch(InterruptedException e){ + sfLog().debug(e); + InterruptedIOException ie = new InterruptedIOException(e.getMessage()); + ie.setStackTrace(e.getStackTrace()); + throw ie; } } sfLog().debug("OUT: Composite: waitOnQueuesCleared()"); @@ -214,7 +219,6 @@ while (keys.hasNext()){ String key = keys.next(); sfLog().debug("Composite.hsc() "+name +"Deploying "+key); - //try { try { sfCreateNewChild(key, toDeploy.get(key), null); } catch (SmartFrogDeploymentException e) { @@ -253,7 +257,7 @@ */ class Notifier implements Runnable { public void run() { - sfLog().debug("IN: Composite.Notifier.run()"); + sfLog().debug("IN: Composite.Notifier.run()"); while (!Composite.this.terminating){ try{ handleStateChange(); @@ -264,7 +268,7 @@ sfLog().warn(ignored); //trying to be somewhat robust to the presence of these, just ignore and try again next time... } } - sfLog().debug("OUT: Composite.Notifier.run()"); + sfLog().debug("OUT: Composite.Notifier.run()"); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-12-23 18:04:28 UTC (rev 8116) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2009-12-24 13:33:13 UTC (rev 8117) @@ -20,6 +20,8 @@ package org.smartfrog.sfcore.languages.sf.functions; +import java.io.IOException; +import java.io.InterruptedIOException; import java.rmi.Remote; import java.rmi.RemoteException; import java.util.Enumeration; @@ -297,7 +299,7 @@ public interface DeployingAgent extends Remote { public void addToDeploy(String name, ComponentDescription cd) throws SmartFrogException, RemoteException; public void addToTerminate(String name) throws RemoteException; - public void waitOnQueuesCleared() throws RemoteException; + public void waitOnQueuesCleared() throws IOException; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2010-01-20 17:34:54
|
Revision: 8157 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8157&view=rev Author: anfarr Date: 2010-01-20 17:34:48 +0000 (Wed, 20 Jan 2010) Log Message: ----------- SFOS-1408 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/functions.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Function.java Modified: trunk/core/smartfrog/src/org/smartfrog/functions.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/functions.sf 2010-01-20 17:13:35 UTC (rev 8156) +++ trunk/core/smartfrog/src/org/smartfrog/functions.sf 2010-01-20 17:34:48 UTC (rev 8157) @@ -222,6 +222,7 @@ Aggregator extends Function, AggregateSpecifierArrayPath { sfFunctionClass "org.smartfrog.sfcore.languages.sf.functions.Aggregator"; + sfFunctionClassEvalEarly true; } PrettyPrint extends Function, AggregateSpecifierArrayPath { Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Function.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Function.java 2010-01-20 17:13:35 UTC (rev 8156) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Function.java 2010-01-20 17:34:48 UTC (rev 8157) @@ -3,6 +3,7 @@ import org.smartfrog.sfcore.common.Context; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogFunctionResolutionException; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.languages.sf.sfreference.SFApplyReference; /** @@ -41,5 +42,15 @@ public Object doit(Context c, Reference name, RemoteReferenceResolver container) throws SmartFrogException; public Object doit(Context ctx, Reference unused, RemoteReferenceResolver resolver, Reference ar, Object key) throws SmartFrogException; - + + public Object getReferenceObject(); + public Object getReferenceKey(); + + public void setReferenceContext(Context context); + public Context getReferenceContext(); + + public ComponentDescription getReferenceCD(); + public void setReferenceCD(ComponentDescription comp); + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2010-01-28 21:03:50
|
Revision: 8167 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8167&view=rev Author: anfarr Date: 2010-01-28 21:03:37 +0000 (Thu, 28 Jan 2010) Log Message: ----------- SFOS-1277: Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/functions.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java Modified: trunk/core/smartfrog/src/org/smartfrog/functions.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/functions.sf 2010-01-28 20:58:14 UTC (rev 8166) +++ trunk/core/smartfrog/src/org/smartfrog/functions.sf 2010-01-28 21:03:37 UTC (rev 8167) @@ -214,9 +214,11 @@ Array extends Function { sfFunctionClass "org.smartfrog.sfcore.languages.sf.functions.Array"; + sfFunctionClassEvalEarly true; + sfFunctionClassReturnEarly true; } -ArrayGenerator extends { +ArrayGenerator extends { //slated for removal in next round of constraints work sfIsGenerator; } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java 2010-01-28 20:58:14 UTC (rev 8166) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/constraints/ConstraintConstants.java 2010-01-28 21:03:37 UTC (rev 8167) @@ -18,6 +18,10 @@ */ package org.smartfrog.sfcore.languages.sf.constraints; + +import org.smartfrog.sfcore.common.SmartFrogFunctionResolutionException; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; + /** * Collection of constant literals used in * @author andrew @@ -59,9 +63,13 @@ public static final String EXTENT="extent"; public static final String EXTENT_TAG="sfExtent"; + + public static final String SIZE = "size"; public static final String GENERATOR="generator"; public static final String GENERATOR_TAG="sfGenerator"; + + public static final String TEMPLATE = "template"; public static final String EFFECTS="effects"; public static final String EFFECTS_TAG="sfEffects"; @@ -104,5 +112,19 @@ public static final String DEFVAR="default"; public static final String FunctionClassStatus="sfFunctionClassStatus"; + public static final String FunctionClassEvalEarly = "sfFunctionClassEvalEarly"; + public static final String FunctionClassReturnEarly = "sfFunctionClassReturnEarly"; public static final String FCS_DONE="done"; + + public static final String PREFIXMUSTBESTRING = " prefix must be a String..."; + public static final String CANNOTRESOLVEPATH = " can not resolve path:"; + public static final String VECTOREXTENTSTRING = " vector extent should be comprised of Strings"; + public static final String EXTENTTYPE = "extent in Array should be an Integer or a Vector"; + public static final String BADLYFORMEDEXTENT = "badly formed multi-dimensional extent"; + + public static SmartFrogFunctionResolutionException relay(Class cl, ComponentDescription comp, String msg){ + return new SmartFrogFunctionResolutionException("In "+cl.getSimpleName()+" with context: "+comp+", "+msg); + + } + } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2010-01-28 20:58:14 UTC (rev 8166) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/Array.java 2010-01-28 21:03:37 UTC (rev 8167) @@ -20,23 +20,18 @@ package org.smartfrog.sfcore.languages.sf.functions; -import java.util.Enumeration; -import java.util.Vector; - import org.smartfrog.sfcore.common.Context; import org.smartfrog.sfcore.common.MessageKeys; -import org.smartfrog.sfcore.common.SFNull; -import org.smartfrog.sfcore.common.SmartFrogContextException; import org.smartfrog.sfcore.common.SmartFrogFunctionResolutionException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.componentdescription.ComponentDescription; -import org.smartfrog.sfcore.languages.sf.constraints.ConstraintConstants; +import static org.smartfrog.sfcore.languages.sf.constraints.ConstraintConstants.*; import org.smartfrog.sfcore.languages.sf.constraints.CoreSolver; -import org.smartfrog.sfcore.languages.sf.functions.Constraint.ComponentResolution; import org.smartfrog.sfcore.languages.sf.sfreference.SFApplyReference; -import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; +import java.util.Vector; + /** * Defines the Constraint function. */ @@ -50,46 +45,53 @@ * @throws SmartFrogFunctionResolutionException if any of the parameters are not there or of the wrong type * */ protected Object doFunction() throws SmartFrogFunctionResolutionException { - Object result=null; - try {result=doFunctionWkr();} catch (SmartFrogContextException e){/*Shouldn't happen*/} - return result; - } - - /** - * Internal worker method for doFunction - * @return result of applying function - * @throws SmartFrogFunctionResolutionException - * @throws SmartFrogContextException - */ - private Object doFunctionWkr() throws SmartFrogFunctionResolutionException, SmartFrogContextException { - Object dest = comp; + ComponentDescription dest = comp; CoreSolver.getInstance().setShouldUndo(true); - - String path=null; + + String path=null; String prefix=null; - + //Get the prefix... - try { prefix = (String) orgContext.get(ConstraintConstants.PREFIX);} - catch (Exception e){throw new SmartFrogFunctionResolutionException("In Array: "+comp+", prefix must be a String...");} - + try { + prefix = (String) orgContext.get(PREFIX); + } catch (Exception e) { + //sfLog().debug(e); + throw relay(this.getClass(), comp, PREFIXMUSTBESTRING); + } + + if (prefix==null){ + prefix=arkey.toString(); + } + int cidx=prefix.lastIndexOf(":"); - if (cidx!=1){ + if (cidx!=-1){ path=prefix.substring(0,cidx); prefix=prefix.substring(cidx+1); } if (path!=null){ - try { dest = comp.sfResolve(Reference.fromString(path)); } - catch(Exception e){throw new SmartFrogFunctionResolutionException("In Array: "+comp+", can not resolve path: "+path);} + try { + dest = (ComponentDescription) comp.sfResolve(Reference.fromString(path)); + } catch (SmartFrogResolutionException e) { + //sfLog().debug(e); + throw relay(this.getClass(), comp, CANNOTRESOLVEPATH+path); + } } - - Object extent = orgContext.get(ConstraintConstants.EXTENT); - Object generator = orgContext.get(ConstraintConstants.GENERATOR); - + + Object extent = orgContext.get(EXTENT); + if (extent==null) extent = orgContext.get(SIZE); + + Object generator = orgContext.get(GENERATOR); + if (generator == null) generator = orgContext.get(TEMPLATE); + if (extent!=null){ + process_array_members(dest,prefix,extent,generator); - } else { + } /* + IN THE TIDY OF THIS FUNCTION, THIS ASPECT HAS BEEN DISABLED FOR TIME BEING... + + else { boolean first=true; //Now do the tagged versions... Enumeration key_enum = orgContext.keys(); @@ -98,12 +100,12 @@ while (key_enum.hasMoreElements()){ key = key_enum.nextElement(); //System.out.println("key:"+key); - if (!orgContext.sfContainsTag(key, ConstraintConstants.EXTENT_TAG)) continue; //around while... + if (!orgContext.sfContainsTag(key, EXTENT_TAG)) continue; //around while... extent = orgContext.get(key); if (key_enum.hasMoreElements()) { key = key_enum.nextElement(); //System.out.println("key:"+key); - if (!orgContext.sfContainsTag(key, ConstraintConstants.GENERATOR_TAG)) throw new SmartFrogFunctionResolutionException("In Array: "+comp+", generator must follow extent..."); + if (!orgContext.sfContainsTag(key, GENERATOR_TAG)) throw new SmartFrogFunctionResolutionException("In Array: "+comp+", generator must follow extent..."); generator = orgContext.get(key); boolean md = process_array_members(dest,prefix,extent,generator); if (md && !first) throw new SmartFrogFunctionResolutionException("In Array: "+comp+", multi-dimensional arrays can not define multiple extents..."); @@ -111,10 +113,15 @@ } } if (first) throw new SmartFrogFunctionResolutionException("In Array: "+comp+", extent & generator must follow prefix..."); - } + + }*/ //Set sfFunctionClass to "done" - orgContext.put("sfFunctionClassStatus", "done"); + orgContext.put(FunctionClassStatus, "done"); + orgContext.remove(GENERATOR); + orgContext.remove(TEMPLATE); //this is the future... + orgContext.remove(FunctionClassEvalEarly); + orgContext.remove(FunctionClassReturnEarly); CoreSolver.getInstance().setShouldUndo(false); return comp; @@ -132,8 +139,8 @@ private boolean process_array_members(Object dest, String prefix_s, Object extent, Object generator) throws SmartFrogFunctionResolutionException { boolean md=false; if (extent instanceof Integer){ - int ext_int = ((Integer)extent).intValue() + idx; - for (int i=idx; i<ext_int; i++) putArrayEntry(dest, prefix_s+i, generator, new Integer(i)); + int ext_int = (Integer) extent + idx; + for (int i=idx; i<ext_int; i++) putArrayEntry(dest, prefix_s+i, generator, i); idx=ext_int; } else if (extent instanceof Vector){ Vector ext_vec = (Vector)extent; @@ -141,10 +148,9 @@ //Is it a multi-dimensional array? if (ext_vec.get(0) instanceof String){ //no... - for (int i=0; i<ext_vec.size(); i++) { - Object suff = ext_vec.get(i); - if (!(suff instanceof String)) throw new SmartFrogFunctionResolutionException("Vector extent in Array: "+comp+" should be comprised of Strings"); - putArrayEntry(dest, prefix_s+suff, generator, (String) suff); + for (Object suff: ext_vec) { + if (!(suff instanceof String)) throw relay(this.getClass(), comp, VECTOREXTENTSTRING); + putArrayEntry(dest, prefix_s+suff, generator, suff); } } else { md=true; @@ -155,7 +161,7 @@ putArrayEntry(dest, prefix_s, generator, el_idx); } } - } else throw new SmartFrogFunctionResolutionException("Extent in Array: "+dest+" should be an Integer or a Vector"); + } else throw relay(this.getClass(), comp, EXTENTTYPE); return md; } @@ -165,15 +171,15 @@ * @return first index * @throws SmartFrogFunctionResolutionException */ + @SuppressWarnings("unchecked") private Vector get_first_el_idx(Vector ref_vec) throws SmartFrogFunctionResolutionException{ Vector el_idx = new Vector(); - for (int i=0; i<ref_vec.size(); i++){ - Object ref = ref_vec.get(i); + for (Object ref : ref_vec){ if (ref instanceof Integer){ - el_idx.add(new Integer(0)); + el_idx.add(0); } else if (ref instanceof Vector){ el_idx.add(((Vector)ref).get(0)); - } else throw new SmartFrogFunctionResolutionException("In Array: "+comp+" badly formed multi-dimensional extent"); + } else throw relay(this.getClass(), comp, BADLYFORMEDEXTENT); } return el_idx; } @@ -185,7 +191,7 @@ * @return next index * @throws SmartFrogFunctionResolutionException */ - + @SuppressWarnings("unchecked") private Vector next_el_idx(Vector el_idx, Vector ref_vec) throws SmartFrogFunctionResolutionException { if (el_idx==null) return get_first_el_idx(ref_vec); @@ -199,14 +205,14 @@ next_idx.add(el); } else { if (ref instanceof Integer){ - int ref_int = ((Integer)ref).intValue(); - int next_int = ((Integer)el_idx.get(idx)).intValue() + 1; + int ref_int = (Integer)ref; + int next_int = (Integer)el_idx.get(idx) + 1; if (ref_int>next_int) { next=true; //found... - next_idx.add(new Integer(next_int)); + next_idx.add(next_int); } else { - next_idx.add(new Integer(0)); + next_idx.add(0); } } else if (ref instanceof Vector){ Vector ref_v = (Vector) ref; @@ -222,7 +228,7 @@ } - } else throw new SmartFrogFunctionResolutionException("In Array: "+comp+" badly formed multi-dimensional extent"); + } else throw relay(this.getClass(), comp, BADLYFORMEDEXTENT); } } if (next) return next_idx; @@ -238,9 +244,8 @@ */ private void putArrayEntry(Object dest, String el, Object generator, Object el_idx) { ComponentDescription generator_cd=null; - Object generator_copy=null; + Object generator_copy=null; - if (generator instanceof ComponentDescription) { generator_copy = generator_cd = (ComponentDescription) ((ComponentDescription) generator).copy(); } else if (generator instanceof SFApplyReference) { @@ -248,18 +253,18 @@ generator_cd = ((SFApplyReference)generator_copy).getComponentDescription(); } - + Context generator_context = generator_cd.sfContext(); + if (el_idx instanceof Vector) { //Multi-dimensional... Vector el_vec = (Vector) el_idx; for (int i=0; i<el_vec.size(); i++) { Object suff = el_vec.get(i); el+="_"+suff; - generator_cd.sfContext().put(ConstraintConstants.INDEX+i, suff); + generator_context.put(INDEX+i, suff); } - } else generator_cd.sfContext().put(ConstraintConstants.INDEX, el_idx); + } else generator_context.put(INDEX, el_idx); - generator_cd.sfContext().put(ConstraintConstants.TAG, el); - generator_cd.sfContext().remove("sfIsGenerator"); + generator_context.put(TAG, el); if (dest instanceof ComponentDescription){ generator_cd.setParent((ComponentDescription) dest); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2010-01-28 20:58:14 UTC (rev 8166) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/sfreference/SFApplyReference.java 2010-01-28 21:03:37 UTC (rev 8167) @@ -122,7 +122,7 @@ ComponentDescription rrcd = (ComponentDescription) rr; comp.setParent(rrcd); - //***CONSTRAINTS stuff + //***CONSTRAINTS stuff. THIS CHECK IS SLATED FOR REMOVAL. //Am I an array generator?, if so quit... try { if (comp.sfContext().get("sfIsGenerator")!=null) return this; } catch (Exception e){/*Do nothing!*/} //***end: CONSTRAINTS stuff This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2010-02-24 11:14:20
|
Revision: 8235 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8235&view=rev Author: steve_l Date: 2010-02-24 11:14:14 +0000 (Wed, 24 Feb 2010) Log Message: ----------- SFOS-1457 Enhancements to Spinner class Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/ports/PortUtils.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/Spinner.java Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/TimedOutIOException.java Removed Paths: ------------- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SmartFrogOperationTimedOutException.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/ports/PortUtils.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/ports/PortUtils.java 2010-02-23 17:04:45 UTC (rev 8234) +++ trunk/core/smartfrog/src/org/smartfrog/services/ports/PortUtils.java 2010-02-24 11:14:14 UTC (rev 8235) @@ -21,7 +21,7 @@ import org.smartfrog.services.filesystem.FileSystem; import org.smartfrog.sfcore.utils.Spinner; -import org.smartfrog.sfcore.utils.SmartFrogOperationTimedOutException; +import org.smartfrog.sfcore.utils.TimedOutIOException; import java.io.IOException; import java.net.InetSocketAddress; @@ -96,11 +96,7 @@ try { //check for and handle a repeat cycle if(!firstRun) { - try { - spinner.sleep(); - } catch (SmartFrogOperationTimedOutException e) { - throw new IOException(e); - } + spinner.sleep(); } else { firstRun = false; } Deleted: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SmartFrogOperationTimedOutException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SmartFrogOperationTimedOutException.java 2010-02-23 17:04:45 UTC (rev 8234) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SmartFrogOperationTimedOutException.java 2010-02-24 11:14:14 UTC (rev 8235) @@ -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 - - */ -package org.smartfrog.sfcore.utils; - -import org.smartfrog.sfcore.common.SmartFrogRuntimeException; - -/** - * created 23-Feb-2010 11:35:23 - */ - -public class SmartFrogOperationTimedOutException extends SmartFrogRuntimeException { - - public SmartFrogOperationTimedOutException(String msg) { - super(msg); - } - - public SmartFrogOperationTimedOutException(Throwable cause) { - super(cause); - } - - public SmartFrogOperationTimedOutException(String message, Throwable cause) { - super(message, cause); - } -} Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/Spinner.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/Spinner.java 2010-02-23 17:04:45 UTC (rev 8234) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/Spinner.java 2010-02-24 11:14:14 UTC (rev 8235) @@ -19,9 +19,12 @@ */ package org.smartfrog.sfcore.utils; +import java.io.IOException; +import java.io.InterruptedIOException; + /** * Utility class to spin and timeout. It can sleep for a predefined wait interval, and will, if interrupted, - * throw a {@link SmartFrogOperationTimedOutException} in such a situation. + * throw a {@link TimedOutIOException} in such a situation. * </p> * After timeout, any exception set with {@link #setLastThrown(Throwable)} will be included * as a nested exception, for more meaningful stack traces @@ -51,16 +54,20 @@ /** * Sleep for a defined period of time - * @throws SmartFrogOperationTimedOutException if we have already timed out. This check occurs before any sleep + * @throws TimedOutIOException if we have already timed out. This check occurs before any sleep + * @throws InterruptedIOException if the operation was interrupted + * @throws IOException as the signature */ - public void sleep() throws SmartFrogOperationTimedOutException { + public void sleep() throws IOException { if (isTimedOut()) { - throw new SmartFrogOperationTimedOutException(operation + TIMED_OUT, lastThrown); + throw new TimedOutIOException(operation + TIMED_OUT, lastThrown); } try { Thread.sleep(waitInterval); } catch (InterruptedException e) { - throw new SmartFrogOperationTimedOutException(operation + WAS_INTERRUPTED, lastThrown); + //the nested exception is the one last thrown, if non-null + throw (InterruptedIOException) new InterruptedIOException(operation + WAS_INTERRUPTED).initCause( + lastThrown != null ? lastThrown : e); } } Copied: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/TimedOutIOException.java (from rev 8234, trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SmartFrogOperationTimedOutException.java) =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/TimedOutIOException.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/TimedOutIOException.java 2010-02-24 11:14:14 UTC (rev 8235) @@ -0,0 +1,42 @@ +/** (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.sfcore.utils; + + +import java.io.IOException; + +/** + * An exception for an IO operation that timed out + */ + +public class TimedOutIOException extends IOException { + + public TimedOutIOException(String msg) { + super(msg); + } + + public TimedOutIOException(Throwable cause) { + super(cause); + } + + public TimedOutIOException(String message, Throwable cause) { + super(message, cause); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2010-05-26 20:58:39
|
Revision: 8301 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8301&view=rev Author: anfarr Date: 2010-05-26 20:58:33 +0000 (Wed, 26 May 2010) Log Message: ----------- SDEP-1 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2010-05-26 16:28:05 UTC (rev 8300) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponentTransitionException.java 2010-05-26 20:58:33 UTC (rev 8301) @@ -27,13 +27,13 @@ public enum StateComponentExceptionCode { GENERIC, COMPONENT_NOTRUNNING, - CURRENTACTION_ONGOING, + //CURRENTACTION_ONGOING, FAILEDTO_ACQUIRELOCK, FAILEDTO_EXECUTETRANSITIONSCRIPT, FAILEDTO_FINDSINGLEDEPENDENCYENABLED, FAILEDTO_GETNAMEDENABLEDTRANSITION, - FAILEDTO_HANDLEDPES, + //FAILEDTO_HANDLEDPES, FAILEDTO_RESOLVETRANSITIONEFFECTS, FAILEDTO_WRITEEVENTLOGBUTISPRESENT Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2010-05-26 16:28:05 UTC (rev 8300) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2010-05-26 20:58:33 UTC (rev 8301) @@ -96,8 +96,10 @@ } Object key = effects.sfContext().get(KEY); + if (key==SFNull.get()) key=null; - if (key!=null && key instanceof Reference) { + if (key==null) return; //nothing here... + if (key instanceof Reference) { try { key=effects.sfResolve((Reference)key); } catch (SmartFrogResolutionException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2010-05-27 13:33:11
|
Revision: 8307 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8307&view=rev Author: anfarr Date: 2010-05-27 13:33:05 +0000 (Thu, 27 May 2010) Log Message: ----------- SDEP-18 -> Mature orch implementation Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/AndConnector.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -21,6 +21,8 @@ package org.smartfrog.services.dependencies.statemodel.connector; import java.rmi.RemoteException; + +import org.smartfrog.SFSystem; import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; @@ -31,6 +33,8 @@ public AndConnector() throws RemoteException {} public boolean isEnabled() throws RemoteException, SmartFrogRuntimeException { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); boolean existsCheck = false; boolean result=true; for (DependencyValidation dep : dependencies){ @@ -46,6 +50,9 @@ result = existsCheck; } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); + //Either way, subsequently toggle result based on not return (not? !result: result); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/OrConnector.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -21,6 +21,8 @@ package org.smartfrog.services.dependencies.statemodel.connector; import java.rmi.RemoteException; + +import org.smartfrog.SFSystem; import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; @@ -30,6 +32,8 @@ public OrConnector() throws RemoteException {} public boolean isEnabled() throws RemoteException, SmartFrogRuntimeException { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); boolean existsCheck = false; boolean result = false; for (DependencyValidation dep : dependencies) { @@ -45,6 +49,9 @@ result = !existsCheck; } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); + //Either way, subsequently toggle result based on not return (not ? !result : result); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/connector/XorConnector.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -21,6 +21,8 @@ package org.smartfrog.services.dependencies.statemodel.connector; import java.rmi.RemoteException; + +import org.smartfrog.SFSystem; import org.smartfrog.services.dependencies.statemodel.dependency.DependencyValidation; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; @@ -28,6 +30,8 @@ public XorConnector() throws RemoteException {} public boolean isEnabled() throws RemoteException, SmartFrogRuntimeException { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); boolean existsCheck = false; boolean result = false; for (DependencyValidation dep : dependencies) { @@ -45,6 +49,9 @@ result = !existsCheck; } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); + //Either way, subsequently toggle result based on not return (not ? !result : result); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/dependency/Dependency.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -57,6 +57,8 @@ super.sfDeploy(); //transition = sfResolve(TRANSITION, (String) null, false); name = this.sfParent().sfAttributeKeyFor(this).toString(); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public synchronized void sfStart() throws SmartFrogException, RemoteException { @@ -72,6 +74,8 @@ } if (running!=null && running) sfRun(); //set it up now ("run" it)... + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public synchronized void sfRun() throws SmartFrogException, RemoteException { @@ -122,9 +126,13 @@ } sfLog().debug("ON: " + on); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public synchronized void sfTerminateWith(TerminationRecord tr) { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); try { by.deregister(this); } catch (RemoteException e) { @@ -132,6 +140,8 @@ throw new RuntimeException(e); //force a hard reset, which should follow... } super.sfTerminateWith(tr); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public String toString(){ @@ -164,7 +174,9 @@ isEnabled = (enabled && (on == null || on.isEnabled())); } sfLog().debug("ISENABLED: " + isEnabled); - + + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return isEnabled; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/Composite.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -88,6 +88,8 @@ } super.sfDeploy(); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void sfStart() throws RemoteException, SmartFrogException { @@ -103,6 +105,8 @@ } catch (SmartFrogResolutionException ignored) { sfLog().ignore(ignored); //intentionally ok } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void sfTerminateWith(TerminationRecord tr) { @@ -110,6 +114,8 @@ terminating = true; super.sfTerminateWith(tr); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void sfRun() throws SmartFrogException, RemoteException { @@ -121,6 +127,8 @@ ((RunSynchronisation) c).sfRun(); } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void waitOnQueuesCleared() throws IOException { @@ -144,6 +152,8 @@ throw ie; } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void addToDeploy(String name, ComponentDescription cd) throws SmartFrogException { @@ -169,6 +179,8 @@ if (added!=null && added instanceof SynchedComposite) model.addToRun(added); }*/ } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void addToTerminate(String name){ @@ -176,6 +188,8 @@ synchronized (toTerminate){ toTerminate.add(name); } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } @@ -193,6 +207,8 @@ status += ((StateChangeNotification) c).getDesiredStatusAsString(); } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return status; } @@ -205,6 +221,8 @@ status += ((StateChangeNotification) c).getServiceStateDetails(); } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return status; } @@ -291,6 +309,8 @@ listeners.clear(); }}} + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/services/dependencies/statemodel/state/StateComponent.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -75,7 +75,8 @@ @Override public synchronized void sfTerminateWith(TerminationRecord t) { - sfLog().debug ("StateComponent: (IN) sfTerminateWith(t)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); ComponentDescription tTermination = transitions.get(T_ONTERMINATION); @@ -89,12 +90,15 @@ super.sfTerminateWith(t); sfLog().debug ("StateComponent: "+name+" terminated"); - sfLog().debug ("StateComponent: (OUT) sfTerminateWith(t)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } @Override public synchronized void sfDeploy() throws RemoteException, SmartFrogException { - super.sfDeploy(); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); + super.sfDeploy(); Context cxt = sfContext(); @@ -134,6 +138,8 @@ fullNamePath = SERVICERESOURCE.substring(1).replaceAll(PATHDELIM, SFDELIM)+fullName; sfReplaceAttribute(FULLNAMEPATH, fullNamePath = SERVICERESOURCE.substring(1).replaceAll(PATHDELIM, SFDELIM) + fullName); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } @@ -142,18 +148,23 @@ } private boolean checkRunning(){ + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); if (!amRunning){ Boolean runValue = null; try { runValue = (Boolean) sfResolve(new Reference(ReferencePart.attrib(RUNNING))); } catch (Exception e){/*System.out.println("Wee exception:"+e);*/} if (runValue!=null) amRunning = runValue; } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return amRunning; } @SuppressWarnings("unchecked") private void resetPossibleTransitions() throws StateComponentTransitionException, RemoteException, SmartFrogRuntimeException { - sfLog().debug("IN: State("+name+").resetPossibleTransitions()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); enabled=null; if (!checkRunning()){ @@ -202,10 +213,13 @@ if (enabled.isEmpty()) enabled=null; - sfLog().debug("OUT: State("+name+").resetPossibleTransitions()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void acquireLock() throws StateComponentTransitionException { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); sfLog().debug("IN: State("+name+").acquireLock(...)"); sfLog().debug("is locked?"+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); if ((currentAction!=null && currentAction!=Thread.currentThread()) || //Allow locking only by scheduled action... @@ -213,20 +227,25 @@ throw new StateComponentTransitionException(StateComponentTransitionException.StateComponentExceptionCode.FAILEDTO_ACQUIRELOCK); } transitionLock.lock(); - sfLog().debug("OUT: State("+name+").acquireLock(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void cleanLock(){ - sfLog().debug("IN: State("+name+").cleanLock(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); while (transitionLock.isHeldByCurrentThread()) { //CHECK! transitionLock.unlock(); } sfLog().debug("is locked?"+transitionLock.isHeldByCurrentThread()+transitionLock.isLocked()+transitionLock.getHoldCount()+transitionLock.getQueueLength()); - sfLog().debug("OUT: State("+name+").cleanLock(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void preparefinalize(boolean prepare, String transition) throws StateComponentTransitionException { - //Is there a prepare/finalizetransition script? + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); + //Is there a prepare/finalizetransition script? String actualName = (prepare?T_PREPARE+transition.substring(1):T_FINALIZE+transition.substring(1)); sfLog().debug("Prepare transition..."+actualName); ComponentDescription action = (ComponentDescription) sfContext().get(actualName); @@ -245,25 +264,35 @@ } } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void doPrepare(String transition) throws StateComponentTransitionException { - sfLog().debug("Prepare transition..."); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); preparefinalize(true, transition); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void doFinalize(String transition) throws StateComponentTransitionException { - sfLog().debug("Finalize transition..."); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); preparefinalize(false, transition); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private void clean(){ - sfLog().debug("IN: State("+name+").clean(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); currentAction=null; cleanLock(); //asyncResponse=false; //LOG ISSUE AND REMOVE... scriptTimer=null; - sfLog().debug("OUT: State("+name+").clean(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } //See handleDPEs() @@ -279,7 +308,8 @@ }*/ private void transitionScript(ComponentDescription transition, String key) throws StateComponentTransitionException { - sfLog().debug("State("+name+").handleStateChange() -- Script call..."); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); try { transition.sfResolve(DO_SCRIPT); @@ -293,19 +323,25 @@ go(key); clean(); - sfLog().debug("OUT: State("+name+").handleStateChange() -- Script call..."); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } private boolean checkIsEnabled() throws RemoteException, SmartFrogRuntimeException { //and connector on the dependencies + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); for (DependencyValidation dv : dependencies) { if (dv.getTransition() != null) continue; if (!dv.isEnabled()) return false; } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return true; } private void setState() throws StateComponentTransitionException { - sfLog().debug("IN: StateComponent.setState()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); sfLog().debug("Adding to queue..."); try { @@ -315,7 +351,8 @@ cleanLock(); - sfLog().debug("OUT: StateComponent.setState()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } protected abstract boolean threadBody() throws StateComponentTransitionException, RemoteException; @@ -379,7 +416,8 @@ }*/ public void selectSingleAndGo() throws RemoteException, StateComponentTransitionException, SmartFrogRuntimeException { - sfLog().debug("IN: State(" + name + ").selectSingleAndGo(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); resetPossibleTransitions(); sfLog().debug("WITHIN: State(" + name + ").selectSingleAndGo(...). Number transitions..." + enabled.size()); @@ -392,11 +430,13 @@ String key = (String) keys.next(); go(key); - sfLog().debug("OUT: State(" + name + ").selectSingleAndGo(...)"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void go(String transition) throws StateComponentTransitionException { - sfLog().debug("IN: State(" + name + ").go()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); sfLog().debug("Key in simple transition" + transition); ComponentDescription trans = null; //try{ @@ -421,11 +461,14 @@ throw new StateComponentTransitionException(StateComponentTransitionException.StateComponentExceptionCode.FAILEDTO_WRITEEVENTLOGBUTISPRESENT); } - sfLog().debug("OUT: State(" + name + ").go()"); + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } ////////////////////////////////////////////////////////////////////// //StateChangeNotification + + //The following aren't really "StateComponent" methods and should be removed at some stage public String getModelInfoAsString(String refresh) throws RemoteException, SmartFrogResolutionException { if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); @@ -465,15 +508,18 @@ } } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return result.toString(); } public String getTransitionLogAsString() throws RemoteException, SmartFrogResolutionException { + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1]); + StringBuilder result = new StringBuilder(); - - if (eventLog != null) { int count = eventLog.sfResolve(COUNT, 0, true); for (int i = 0; i < count; i++) { @@ -485,11 +531,16 @@ append(SCRIPTHEADERCLOSE); } } + if (sfLog().isDebugEnabled()) + sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return result.toString(); } + /* + *DEPRECATED! + public String getDesiredStatusAsString() throws RemoteException, SmartFrogResolutionException { //Look for link meta-data... @@ -541,7 +592,7 @@ } */ - + /* StringBuilder result = new StringBuilder(); ComponentDescription metaData = sfResolve(INFORMMETADATA, (ComponentDescription) null, false); @@ -563,11 +614,11 @@ append("' style=\"display:").append(show?"block":"none").append(";\">"); - /* - <a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a> - <div id="foo" style="display:none;">This is foo</div> - */ + //<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a> + //<div id="foo" style="display:none;">This is foo</div> + + //result.append("<DIV) @@ -621,7 +672,7 @@ return result.toString(); - } + } */ void observed(ComponentDescription entry, StringBuilder result, int indent) throws SmartFrogResolutionException, RemoteException { if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); @@ -686,9 +737,11 @@ append(value).append(annotate?POBSERVED:"").append(SCRIPTHEADERCLOSE); } } + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]+":LEAVING"); } void desired(ComponentDescription entry, StringBuilder result, int indent) throws SmartFrogResolutionException { + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); ComponentDescription desired = (ComponentDescription) entry.sfContext().get(DESIRED); boolean cont = true; if (desired != null) { @@ -795,10 +848,12 @@ sfLog().debug("DESIREDSTATESET! "); } } + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]+":LEAVING"); } void links(ComponentDescription entry, StringBuilder result, int indent){ + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); ComponentDescription links = null; try { links = (ComponentDescription) entry.sfResolve(LINKS); @@ -841,9 +896,12 @@ } } + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]+":LEAVING"); } + /*DEPRECATED - to be removed void stdout(StringBuilder result){ + String stdout = null; String stderr = null; @@ -865,7 +923,7 @@ } sfLog().debug("STDOUT/ERR! "); - } + }*/ public String getServiceStateDetails() throws RemoteException, SmartFrogResolutionException { if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); @@ -972,6 +1030,7 @@ if (extra.toString().length()==0) return ""; else status.append(extra); } + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]+":LEAVING"); return status.toString(); } @@ -994,6 +1053,7 @@ //ANY LINKS? links(entry, result, indent); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return result.toString(); } @@ -1011,7 +1071,7 @@ desired(entry, result, indent); sfLog().debug("DESIRED! " + key); - + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return result.toString(); } @@ -1019,29 +1079,9 @@ if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); StringBuilder result = new StringBuilder(); - // - /* - ComponentDescription metaData = sfResolve(INFORMMETADATA, (ComponentDescription) null, false); + //This should be removed but it requires changing the index.html implementation to not ask for a "container!"... - if (metaData != null) { - - boolean show = sfResolve(SHOW, false, false); - String cdescription = sfResolve(DESCRIPTION, (String) null, false); - - result.append(SMALLHEADER).append("<A HREF=\"#\" ONCLICK=\"toggle_visibility('").append(fullName).append("');\">"); - if (cdescription != null) { - result.append(cdescription).append("</A> -- "); - } - result.append(fullName); - if (cdescription == null) { - result.append("</A>"); - } - result.append("<DIV id='").append(fullName). - append("' style=\"display:").append(show ? "block" : "none").append(";\">"); - - stdout(result); - - }*/ + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return result.toString(); } @@ -1053,6 +1093,7 @@ Timer scriptTimer; public void handleStateChange() throws RemoteException, SmartFrogException { + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); if (this.sfIsTerminating || this.sfIsTerminated || !(this.sfIsStarted)) return; @@ -1118,28 +1159,34 @@ } setState(); - sfLog().debug("OUT: State(" + name + ").handleStateChange()"); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]+":LEAVING"); } ////////////////////////////////////////////////////////////////////// //StateDependencies public void register(DependencyValidation d) { + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); dependencies.add(d); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } public void deregister(DependencyValidation d) { + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); dependencies.remove(d); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } ///////////////////////////////////////////////////////// //DependencyValidation public boolean isEnabled() throws RemoteException, SmartFrogRuntimeException { + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); return (!asAndConnector) || checkIsEnabled(); } public String getTransition(){ + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); return null; } @@ -1150,7 +1197,7 @@ */ public class StateUpdateThread implements Runnable { public void run() { - sfLog().debug("IN: StateUpdateThread.run()"); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1]); try{ String key=null; if (enabled.size()==1){ @@ -1172,7 +1219,7 @@ } catch (RemoteException ignored) { sfLog().warn(ignored); //appropriate action will have already been taken } - sfLog().debug("OUT: StateUpdateThread.run()"); + if (sfLog().isDebugEnabled()) sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2010-05-27 12:06:04 UTC (rev 8306) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/languages/sf/functions/ApplyEffects.java 2010-05-27 13:33:05 UTC (rev 8307) @@ -48,6 +48,8 @@ * */ protected Object doFunction() throws SmartFrogFunctionResolutionException { //First try me... + if (SFSystem.sfLog().isDebugEnabled()) + SFSystem.sfLog().debug(Thread.currentThread().getStackTrace()[1]); applyEffects(comp); //Then any nested effects... @@ -57,13 +59,16 @@ Object effects = context.get(key); if (!(effects instanceof ComponentDescription)) continue; applyEffects((ComponentDescription)effects); - } - + } + if (SFSystem.sfLog().isDebugEnabled()) + SFSystem.sfLog().debug(Thread.currentThread().getStackTrace()[1] + ":LEAVING"); + return true; } public static void applyEffects(ComponentDescription effects) throws SmartFrogFunctionResolutionException { - SFSystem.sfLog().debug("IN applyEffects"); + if (SFSystem.sfLog().isDebugEnabled()) + SFSystem.sfLog().debug(Thread.currentThread().getStackTrace()[1]); Reference array = null; try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2010-12-03 15:18:51
|
Revision: 8437 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8437&view=rev Author: steve_l Date: 2010-12-03 15:18:44 +0000 (Fri, 03 Dec 2010) Log Message: ----------- SFOS-1541 delete files on startup, workflow enabled Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/DeleteFilesImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/components.sf trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/DeleteFilesImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/DeleteFilesImpl.java 2010-12-03 15:02:53 UTC (rev 8436) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/DeleteFilesImpl.java 2010-12-03 15:18:44 UTC (rev 8437) @@ -20,8 +20,9 @@ package org.smartfrog.services.filesystem.files; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.utils.ComponentHelper; import java.io.File; import java.rmi.RemoteException; @@ -30,9 +31,8 @@ /** * Delete a set of files */ -public class DeleteFilesImpl extends FilesCompoundImpl implements Files { +public final class DeleteFilesImpl extends FilesCompoundImpl implements Files { - public static final String ATTR_CONTINUE_AFTER_DELETE_FAILURES = "continueAfterDeleteFailures"; public DeleteFilesImpl() throws RemoteException { } @@ -42,25 +42,43 @@ super.sfStart(); //now delete the files Set<File> files = getFileset(); - execute(files, sfResolve(ATTR_CONTINUE_AFTER_DELETE_FAILURES, true, true)); + int count = execute(files); + TerminationRecord tr = TerminationRecord.normal("Deleted " + count + " files", sfCompleteName); + new ComponentHelper(this).targetForWorkflowTermination(tr); } - private void execute(Set<File> files, boolean continueAfterFailures) + /** + * run through the set of files + * @param files the files to work with + * @return the number of files processed + * @throws SmartFrogException SmartFrog problems (or wrapped issues) + * @throws RemoteException Networking problems. + */ + private int execute(final Set<File> files) throws SmartFrogException, RemoteException { + int count = 0; for (File file : files) { - executeSingleFile(file, continueAfterFailures); + if (executeSingleFile(file)) { + count++; + } } + return count; } - private void executeSingleFile(final File file, final boolean continueAfterFailures) + /** + * Process a single file + * @param file filename + * @return true if it was deleted + * @throws SmartFrogException SmartFrog problems (or wrapped issues) + * @throws RemoteException Networking problems. + */ + private boolean executeSingleFile(final File file) throws SmartFrogException, RemoteException { if (!file.delete()) { String message = "Failed to delete " + file; - if (continueAfterFailures) { - sfLog().info(message); - } else { - throw new SmartFrogDeploymentException(message); - } + sfLog().info(message); + return false; } + return true; } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/components.sf =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/components.sf 2010-12-03 15:02:53 UTC (rev 8436) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/components.sf 2010-12-03 15:18:44 UTC (rev 8437) @@ -18,6 +18,7 @@ */ #include "/org/smartfrog/services/filesystem/components.sf" +#include "/org/smartfrog/sfcore/workflow/eventbus/eventbus.sf" /** * This component provides a list of files that match a pattern. @@ -88,17 +89,24 @@ * 3. Any child component with an absolutePath attribute that resolves to a string. * All of these are merged, duplicate file path references removed, and the final files[] attribute returned. */ -FilesCompound extends Compound { +FilesCompound extends EventCompound { sfClass "org.smartfrog.services.filesystem.files.FilesCompoundImpl"; } /** * This class deletes files when deployed. - * Any file in the list that is missing is skipped, any + * Any file in the list that is missing is skipped, this component will never fail just because + * it cannot delete a file. + * + * It is a workflow component */ DeleteFiles extends FilesCompound { sfClass "org.smartfrog.services.filesystem.files.DeleteFilesImpl"; //set this flag to false and the run will stop after the first failure continueAfterDeleteFailures true; +} + +DeleteFilesWorkflow extends DeleteFiles { + sfTerminate true; } \ No newline at end of file Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2010-12-03 15:02:53 UTC (rev 8436) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/workflow/components/EventQueue.java 2010-12-03 15:18:44 UTC (rev 8437) @@ -23,10 +23,8 @@ package org.smartfrog.sfcore.workflow.components; import java.rmi.RemoteException; -import java.util.Enumeration; import java.util.Vector; import java.util.Hashtable; -import java.util.Iterator; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.workflow.eventbus.EventPrimImpl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-02-15 14:01:41
|
Revision: 8488 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8488&view=rev Author: steve_l Date: 2011-02-15 14:01:35 +0000 (Tue, 15 Feb 2011) Log Message: ----------- javadocs and suppress some warnings Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/WrappedInstance.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2011-02-15 14:00:56 UTC (rev 8487) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2011-02-15 14:01:35 UTC (rev 8488) @@ -75,11 +75,13 @@ /** * A flag that ensures only one system initialisation. */ + @SuppressWarnings({"StaticNonFinalField"}) private static boolean alreadySystemInit = false; /** * Core Log */ + @SuppressWarnings({"StaticNonFinalField"}) private static LogSF sflog = null; @@ -206,8 +208,8 @@ * @throws SmartFrogException failed to create or set output/error streams */ public static void setOutputStreams() throws SmartFrogException { - String outClass = SFSystem.getProperty(SmartFrogCoreProperty.propOutStreamClass); - String errClass = SFSystem.getProperty(SmartFrogCoreProperty.propErrStreamClass); + String outClass = getProperty(SmartFrogCoreProperty.propOutStreamClass); + String errClass = getProperty(SmartFrogCoreProperty.propErrStreamClass); try { if (errClass != null) { @@ -385,8 +387,8 @@ * * @param args execution arguments */ - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) - public void execute(String args[]) { + @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "CallToPrintStackTrace"}) + public void execute(String[] args) { //First things first: system gets initialized try { @@ -396,7 +398,7 @@ if (sfLog().isErrorEnabled()) { sfLog().error(ex, ex); } - } catch (Throwable ex1) { + } catch (Throwable ignored) { ex.printStackTrace(); } exitWith("Failed to initialize SmartFrog", ExitCodes.EXIT_ERROR_CODE_GENERAL); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/WrappedInstance.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/WrappedInstance.java 2011-02-15 14:00:56 UTC (rev 8487) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/WrappedInstance.java 2011-02-15 14:01:35 UTC (rev 8488) @@ -112,7 +112,7 @@ /** * Return the description and whether or not the instance is defined. - * @return + * @return the description and whether it is defined or not, but not the instance value */ @Override public String toString() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-29 13:32:37
|
Revision: 8555 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8555&view=rev Author: steve_l Date: 2011-03-29 13:32:30 +0000 (Tue, 29 Mar 2011) Log Message: ----------- SFOS-1578 replace uses of *copy* with a constant 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 2011-03-28 15:14:43 UTC (rev 8554) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2011-03-29 13:32:30 UTC (rev 8555) @@ -519,7 +519,7 @@ void remove() { Object obj = getNode(); //we need to check is the parent is a copy - if (isParentNodeACopy() || getRDNNode().endsWith("*copy*") ) { + if (isParentNodeACopy() || getRDNNode().endsWith(ComponentDescriptionImpl.COPY_MARKER) ) { 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 2011-03-28 15:14:43 UTC (rev 8554) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2011-03-29 13:32:30 UTC (rev 8555) @@ -70,6 +70,7 @@ ComponentDescription, MessageKeys, PrettyPrinting { + public static final String COPY_MARKER = "*copy*"; /** Context of attributes (key value pairs). */ public Context sfContext; @@ -172,7 +173,7 @@ } 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*")); + sfCompleteName.addElement(new HereReferencePart(name+ COPY_MARKER)); 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. |