From: Julio G. <ju...@us...> - 2004-05-26 23:14:18
|
Hi Qinyi, You are making a correct use of EvenSent. Your problem is that you are = sending an event to a component that does not exist yet. e1 and comp1 = are in a Sequence and therefore comp1 won't be deployed until e1 has = terminated. If you replace Sequence with Parallel your example will work. Parallel will deploy all its children and it will terminate when all its = children have terminated. There is another example in examples/workflow that you can use. We are planning make some changes in the workflow components and that is = why you haven't seen any documentation for the workflow yet.=20 Some info about those components: DoNothing DoNothing extends EventPrim { sfClass "com.hp.sfServices.workflow.Components.DoNothing"; time 10000000; // time in milliseconds to wait terminationType "normal"; // termination record type printEvents false; // message "a message to print on the console prefixed by full name" } The do-nothing construct does nothing for a time, then terminates as = required. Its purpose is primarily to act as a stub for bits of workflow = yet to be written during testing. If terminationType is set to "none", = it waits for ever. The component prints the message to stdout and starts the timer during = its start phase and terminates when the timer has fired. If the time is = 0, the component will terminate immediately - though a thread is started = to do this so some asynchrony occurs. If no message is provided, no = message is printed. If the attribute printEvents is set to true, any events that it receives = will be printed on the console. If printEvents is false, it does nothing = internal with events, merely forwarding them as required. EventSend EventSend extends EventPrim { sfClass "com.hp.sfServices.workflow.Components.EventSend"; // event "the string to send as an event";=20 } An event sender contains an event to send, and it forwards the event to = any registered components as defined in the event framework. The component sends its event during the start phase, and then = terminates asynchronously. It does nothing internal with received = events. EventCounter EventCounter extends EventPrim { sfClass "com.hp.sfServices.workflow.Components.EventCounter"; count 1; allDifferent "true"; } Event counter waist for events, when they arrive it decrements its = counter (default 1). When the counter reaches 0, the component = terminates. If the attribute allDifferent is set to true, the counter is = not decremented if the event it receives is an identical string. OnEvent OnEvent extends EventCompound { sfClass "com.hp.sfServices.workflow.Components.OnEvent"; //event1 extends LAZY ... { ... } //event2 extends LAZY ... { ... } //otherwise extends LAZY ... { ... } } The OnEvent event dispatcher = provides a number of named event handlers as attributes - defined as = LAZY components. When an event arrives, it is compared to the names of = the attributes using Java string equality, and if a matching attribute = is found the component description is taken and deployed. If no match is found, the otherwise template is taken. If that is not = present, the component terminates with an error. Once a handler has been started, it runs as the newly created = sub-component as a child using the name running. When that child = terminates, so does the OnEvent, with the same termination type. Regards,=20 Julio Guijarro > -----Original Message----- > From: sma...@li...=20 > [mailto:smartfrog- dev...@li...] On Behalf Of = > qx...@cc... > Sent: 26 May 2004 19:56 > To: sma...@li... > Subject: [Smartfrog-developer] Question for EventSend and OnEvent=20 > components >=20 > Hi, > I want to use the Events mechanism in SF to exchange message between=20 > different components. Two insteresting components are EventSend and=20 > OnEvent. But I cannot find an example of how to use them. The only=20 > place I could get some hints for EventSend is in=20 > genericInstallScript.sf in dynamicWebserver example. However, when I = wrote a component like: > ------------------------------------------------------------ > #include "org/smartfrog/sfcore/workflow/components.sf"; > #include "org/smartfrog/components.sf" >=20 >=20 > event1 extends Sequence { > name "test"; >=20 > actions extends LAZY { > e1 extends EventSend { > sendTo:a LAZY ATTRIB comp1; > event (name); > } > comp1 extends DoNothing { > time 2000; > message "here"; > } >=20 > } > } >=20 > sfConfig extends event1; > ------------------------------------------------------------ >=20 > It can be parsed successful. But when I used sfStart to deploy it, the = > following error message was thrown: >=20 > $ sfStart localhost e event.sf > SmartFrog 3.02.002_beta > (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP > Warning: SmartFrog security is NOT active > - FAILED when trying DEPLOY of 'e', [event.sf], host:localhost > Error: > SmartFrogLifecycleException:: sfStart: > cause: SmartFrogResolutionException:: Reference not found,=20 > Unresolved > Reference: LAZY comp1, source: HOST > athena.cc.gatech.edu:rootProcess:e, path(83) > Command line SFACT: 'e:DEPLOY:event.sf::localhost:' > To String: ' name:e, type:DEPLOY, url:event.sf, host:localhost,=20 > resultType:FAILED, resultExceptionMessage:sfStart: ' >=20 > Is there anyone who can show me an example how to use these two=20 > components? >=20 > Thanks > Qinyi >=20 >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g Get certified on the=20 > hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick > _______________________________________________ > Smartfrog-developer mailing list > Sma...@li... > https://lists.sourceforge.net/lists/listinfo/smartfrog-developer |