Simplify creation of extension activity for Assemble flow

From feedback from the users , Michael, Dave and team, the proposal is as following to simplify creation of the Activity for Assemble flow.

1. Change the event name convention of activity to make it more clear

The original event name convention of activity is "_[Activity Type]", e.g. we have the helloWorld activity, its event name will be "_helloWorld"

We will change it to [Activity Type]Activity, e.g. helloWorldActivity. Which is more clear to identify it is an Activity.

2. GC path changes for the Activity inputs to make it more understandable

access input list from /event/content to /event/inputs

access input map from /event/contentMap to /event/inputMap

Samples in groovy

event.inputs[0] will return the first input

event.inputMap["attachment"] will return the input named "attachment"

3. Simplify the way to return result of the activity

Sample in Groovy
def onHelloWorldActivity() {
   def input= event.inputs[0]
   event.result = "Hello, " + input
}
in Java
void onHelloWorldActivity() {
   String input = zget("/event/inputs#0");
   zput("/event/result", "Hello, " + input);
}

Note: Return the result by just setting it to event.result ("/event/result")

4. Using the convention to define the extension activity

In /app/assemble/activities directory, the developer can create the extension activity with Groovy in helloWorld.groovy

def onHelloWorldActivity() {
   def input= event.inputs[0]
   event.result = "Hello, " + input
}

metadata = [
   "inputOccurrence" : 1
]
Note: 1. No need to add config in the zero.config 2. We provide the ActvityResolver, which will resolve the Activity on demand in the runtime 3. The metadata will be used to validate the activity by parser and tooling. And it is written in Groovy syntax. 4. The original way to create the extension activity is also supported without any changes.

-- yili - 23 Feb 2008

r2 - 25 Feb 2008 - 15:03:46 - yili
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site