'Static data model implementation in Worklet

Change-Id: Ic5eeb26eaea547523befd509f9f48281cb4c2031
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/DefaultWorkletDescription.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/DefaultWorkletDescription.java
new file mode 100644
index 0000000..82bb3f8
--- /dev/null
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/DefaultWorkletDescription.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.workflow.api;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.MoreObjects;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Class for default worklet description.
+ */
+public final class DefaultWorkletDescription implements WorkletDescription {
+
+    protected static final Logger log = getLogger(DefaultWorkletDescription.class);
+
+    /**
+     * worklet Name.
+     */
+    private String tag;
+
+    /**
+     * worklet data model.
+     */
+    private JsonDataModelTree data;
+
+    /**
+     * Constructor of worklet description.
+     *
+     * @param builder worklet description builder
+     */
+    public DefaultWorkletDescription(DefaultWorkletDescription.Builder builder) {
+        this.tag = builder.tag;
+        this.data = builder.data;
+    }
+
+    public DefaultWorkletDescription(String tag) {
+        this.tag = tag;
+    }
+
+    @Override
+    public String tag() {
+        return this.tag;
+    }
+
+    @Override
+    public JsonDataModelTree data() {
+        return this.data;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("tag", tag())
+                .add("data", data())
+                .toString();
+    }
+
+    /**
+     * Gets builder instance.
+     *
+     * @return builder instance
+     */
+    public static DefaultWorkletDescription.Builder builder() {
+        return new DefaultWorkletDescription.Builder();
+    }
+
+    /**
+     * Builder for worklet description.
+     */
+    public static class Builder {
+
+        /**
+         * worklet name.
+         */
+        private String tag;
+
+        /**
+         * static data model tree.
+         */
+        JsonDataModelTree data = new JsonDataModelTree();
+
+        /**
+         * Sets worklet name.
+         *
+         * @param tag worklet name
+         * @return builder
+         */
+        public DefaultWorkletDescription.Builder name(String tag) {
+            this.tag = tag;
+            return this;
+        }
+
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, String value) throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, Integer value) throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, Boolean value) throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, JsonNode value) throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, ArrayNode value)
+                throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+        public DefaultWorkletDescription.Builder staticDataModel(String path, ObjectNode value)
+                throws WorkflowException {
+
+            data.setAt(path, value);
+
+            return this;
+        }
+
+
+        /**
+         * Builds worklet description from builder.
+         *
+         * @return instance of worklet description
+         * @throws WorkflowException workflow exception
+         */
+        public DefaultWorkletDescription build() {
+
+            return new DefaultWorkletDescription(this);
+        }
+
+
+    }
+}
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/ImmutableListWorkflow.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/ImmutableListWorkflow.java
index 3e54c94..f4d9470 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/ImmutableListWorkflow.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/ImmutableListWorkflow.java
@@ -27,6 +27,7 @@
 import java.net.URI;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 
 import static org.onosproject.workflow.api.CheckCondition.check;
@@ -42,9 +43,9 @@
     private String initWorkletType;
 
     /**
-     * List of worklet.
+     * List of worklet  description.
      */
-    private List<String> workletTypeList;
+    private List<WorkletDescription> workletDescList;
 
     /**
      * Set of workflow attributes.
@@ -52,6 +53,7 @@
     private Set<WorkflowAttribute> attributes;
 
     private static JsonDataModelInjector dataModelInjector = new JsonDataModelInjector();
+    private static StaticDataModelInjector staticDataModelInjector = new StaticDataModelInjector();
 
     /**
      * Constructor of ImmutableListWorkflow.
@@ -61,7 +63,7 @@
     private ImmutableListWorkflow(Builder builder) {
         super(builder.id);
         this.initWorkletType = builder.initWorkletType;
-        workletTypeList = ImmutableList.copyOf(builder.workletTypeList);
+        workletDescList = ImmutableList.copyOf(builder.workletDescList);
         attributes = ImmutableSet.copyOf(builder.attributes);
     }
 
@@ -84,12 +86,11 @@
 
         ProgramCounter pc = current.clone();
 
-        for (int i = current.workletIndex(); i < workletTypeList.size(); pc = increased(pc), i++) {
+        for (int i = current.workletIndex(); i < workletDescList.size(); pc = increased(pc), i++) {
 
             if (cnt++ > Worklet.MAX_WORKS) {
                 throw new WorkflowException("Maximum worklet execution exceeded");
             }
-
             if (pc.isCompleted()) {
                 return pc;
             }
@@ -119,6 +120,12 @@
             } else {
                 // isNext is read only. It does not perform 'inhale'.
                 dataModelInjector.inject(worklet, context);
+                WorkletDescription workletDesc = getWorkletDesc(pc);
+                if (Objects.nonNull(workletDesc)) {
+                    if (!(workletDesc.tag().equals("INIT") || workletDesc.tag().equals("COMPLETED"))) {
+                        staticDataModelInjector.inject(worklet, workletDesc);
+                    }
+                }
                 if (worklet.isNext(context)) {
                     return pc;
                 }
@@ -132,18 +139,18 @@
     public ProgramCounter increased(ProgramCounter pc) throws WorkflowException {
 
         int increaedIndex = pc.workletIndex() + 1;
-        if (increaedIndex >= workletTypeList.size()) {
+        if (increaedIndex >= workletDescList.size()) {
             throw new WorkflowException("Out of bound in program counter(" + pc + ")");
         }
 
-        String workletType = workletTypeList.get(increaedIndex);
-        return ProgramCounter.valueOf(workletType, increaedIndex);
+        WorkletDescription workletDesc = workletDescList.get(increaedIndex);
+        return ProgramCounter.valueOf(workletDesc.tag(), increaedIndex);
     }
 
     @Override
     public Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException {
 
-        return getWorkletInstance(workletTypeList.get(pc.workletIndex()));
+        return getWorkletInstance(workletDescList.get(pc.workletIndex()).tag());
     }
 
     @Override
@@ -191,10 +198,21 @@
     }
 
     @Override
-    public List<String> getWorkletTypeList() {
-        return ImmutableList.copyOf(workletTypeList);
+    public List<WorkletDescription> getWorkletDescList() {
+        return ImmutableList.copyOf(workletDescList);
     }
 
+    @Override
+    public WorkletDescription getWorkletDesc(ProgramCounter pc) {
+        Optional<WorkletDescription> workletDescription = workletDescList.stream().filter(a -> Objects.equals(a.tag(),
+                workletDescList.get(pc.workletIndex()).tag())).findAny();
+        if (workletDescription.isPresent()) {
+            return workletDescription.get();
+        }
+        return null;
+    }
+
+
     /**
      * Gets index of class in worklet type list.
      *
@@ -202,8 +220,8 @@
      * @return index of class in worklet type list
      */
     private int getClassIndex(Class aClass) {
-        for (int i = 0; i < workletTypeList.size(); i++) {
-            if (Objects.equals(aClass.getName(), workletTypeList.get(i))) {
+        for (int i = 0; i < workletDescList.size(); i++) {
+            if (Objects.equals(aClass.getName(), workletDescList.get(i))) {
                 return i;
             }
         }
@@ -247,7 +265,7 @@
         }
         return Objects.equals(this.id(), ((ImmutableListWorkflow) obj).id())
                 && Objects.equals(this.initWorkletType, ((ImmutableListWorkflow) obj).initWorkletType)
-                && Objects.equals(this.workletTypeList, ((ImmutableListWorkflow) obj).workletTypeList)
+                && Objects.equals(this.workletDescList, ((ImmutableListWorkflow) obj).workletDescList)
                 && Objects.equals(this.attributes, ((ImmutableListWorkflow) obj).attributes);
     }
 
@@ -256,7 +274,7 @@
         return MoreObjects.toStringHelper(getClass())
                 .add("id", id())
                 .add("initWorklet", initWorkletType)
-                .add("workList", workletTypeList)
+                .add("workList", workletDescList)
                 .add("attributes", attributes)
                 .toString();
     }
@@ -277,7 +295,7 @@
 
         private URI id;
         private String initWorkletType;
-        private final List<String> workletTypeList = Lists.newArrayList();
+        private final List<WorkletDescription> workletDescList = Lists.newArrayList();
         private final Set<WorkflowAttribute> attributes = Sets.newHashSet();
 
         /**
@@ -288,7 +306,7 @@
          */
         public Builder id(URI uri) {
             this.id = uri;
-            workletTypeList.add(Worklet.Common.INIT.tag());
+            workletDescList.add(new DefaultWorkletDescription(Worklet.Common.INIT.tag()));
             return this;
         }
 
@@ -310,7 +328,7 @@
          * @return builder
          */
         public Builder chain(String workletClassName) {
-            workletTypeList.add(workletClassName);
+            workletDescList.add(new DefaultWorkletDescription(workletClassName));
             return this;
         }
 
@@ -331,8 +349,13 @@
          * @return instance of ImmutableListWorkflow
          */
         public ImmutableListWorkflow build() {
-            workletTypeList.add(Worklet.Common.COMPLETED.tag());
+            workletDescList.add(new DefaultWorkletDescription(Worklet.Common.COMPLETED.tag()));
             return new ImmutableListWorkflow(this);
         }
+
+        public Builder chain(DefaultWorkletDescription workletDesc) {
+            workletDescList.add(workletDesc);
+            return this;
+        }
     }
 }
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelTree.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelTree.java
index 7ee1be7..aec19ae 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelTree.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelTree.java
@@ -56,6 +56,7 @@
 
     /**
      * Constructor of JsonDataModelTree.
+     *
      * @param root root node of json data model tree
      */
     public JsonDataModelTree(JsonNode root) {
@@ -169,7 +170,8 @@
 
     /**
      * Allocates json data model tree on json pointer path with specific leaf type.
-     * @param ptr json pointer to allocate
+     *
+     * @param ptr      json pointer to allocate
      * @param leaftype type of leaf node
      * @return json data model tree
      * @throws WorkflowException workflow exception
@@ -194,6 +196,7 @@
 
     /**
      * Gets root json node.
+     *
      * @return root json node
      * @throws WorkflowException workflow exception
      */
@@ -203,6 +206,7 @@
 
     /**
      * Gets root json node as ObjectNode (MAP type).
+     *
      * @return root json node as ObjectNode
      * @throws WorkflowException workflow exception
      */
@@ -212,6 +216,7 @@
 
     /**
      * Gets root json node as ArrayNode (Array type).
+     *
      * @return root json node as ArrayNode
      * @throws WorkflowException workflow exception
      */
@@ -221,6 +226,7 @@
 
     /**
      * Gets json node on specific path.
+     *
      * @param path path of json node
      * @return json node on specific path
      * @throws WorkflowException workflow exception
@@ -232,6 +238,7 @@
 
     /**
      * Gets json node on specific json pointer.
+     *
      * @param ptr json pointer
      * @return json node on specific json pointer.
      * @throws WorkflowException workflow exception
@@ -246,6 +253,7 @@
 
     /**
      * Gets json node on specific path as ObjectNode.
+     *
      * @param path path of json node
      * @return ObjectNode type json node on specific path
      * @throws WorkflowException workflow exception
@@ -257,6 +265,7 @@
 
     /**
      * Gets json node on specific json pointer as ObjectNode.
+     *
      * @param ptr json pointer
      * @return ObjectNode type json node on specific json pointer.
      * @throws WorkflowException workflow exception
@@ -277,6 +286,7 @@
 
     /**
      * Gets json node on specific path as ArrayNode.
+     *
      * @param path path of json node
      * @return ArrayNode type json node on specific path
      * @throws WorkflowException workflow exception
@@ -288,6 +298,7 @@
 
     /**
      * Gets json node on specific json pointer as ArrayNode.
+     *
      * @param ptr json pointer
      * @return ArrayNode type json node on specific json pointer.
      * @throws WorkflowException workflow exception
@@ -308,6 +319,7 @@
 
     /**
      * Gets text node on specific path.
+     *
      * @param path path of json node
      * @return text on specific path
      * @throws WorkflowException workflow exception
@@ -319,6 +331,7 @@
 
     /**
      * Gets text on specific json pointer.
+     *
      * @param ptr json pointer
      * @return text on specific json pointer
      * @throws WorkflowException workflow exception
@@ -339,6 +352,7 @@
 
     /**
      * Gets integer node on specific path.
+     *
      * @param path path of json node
      * @return integer on specific path
      * @throws WorkflowException workflow exception
@@ -350,6 +364,7 @@
 
     /**
      * Gets integer on specific json pointer.
+     *
      * @param ptr json pointer
      * @return integer on specific json pointer
      * @throws WorkflowException workflow exception
@@ -370,6 +385,7 @@
 
     /**
      * Gets boolean on specific path.
+     *
      * @param path path of json node
      * @return boolean on specific path
      * @throws WorkflowException workflow exception
@@ -381,6 +397,7 @@
 
     /**
      * Gets boolean on specific json pointer.
+     *
      * @param ptr json pointer
      * @return boolean on specific json pointer
      * @throws WorkflowException workflow exception
@@ -401,6 +418,7 @@
 
     /**
      * Sets text on specific json path.
+     *
      * @param path json path
      * @param text text to set
      * @throws WorkflowException workflow exception
@@ -412,18 +430,21 @@
 
     /**
      * Sets text on the specific json pointer.
-     * @param ptr json pointer
+     *
+     * @param ptr  json pointer
      * @param text text to set
      * @throws WorkflowException workflow exception
      */
     public void setAt(JsonPointer ptr, String text) throws WorkflowException {
         TextNode textNode = TextNode.valueOf(text);
+
         attach(ptr, textNode);
     }
 
     /**
      * Sets boolean on specific json path.
-     * @param path json path
+     *
+     * @param path   json path
      * @param isTrue boolean to set
      * @throws WorkflowException workflow exception
      */
@@ -433,8 +454,83 @@
     }
 
     /**
+     * Sets text on the specific json pointer.
+     *
+     * @param ptr      json pointer
+     * @param jsonNode jsonNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(JsonPointer ptr, JsonNode jsonNode) throws WorkflowException {
+        JsonNode node = jsonNode;
+        attach(ptr, node);
+    }
+
+    /**
+     * Sets boolean on specific json path.
+     *
+     * @param path     json path
+     * @param jsonNode jsonNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(String path, JsonNode jsonNode) throws WorkflowException {
+        JsonPointer ptr = JsonPointer.compile(path);
+        setAt(ptr, jsonNode);
+    }
+
+
+    /**
+     * Sets text on the specific json pointer.
+     *
+     * @param ptr       json pointer
+     * @param arrayNode arrayNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(JsonPointer ptr, ArrayNode arrayNode) throws WorkflowException {
+        ArrayNode node = arrayNode;
+        attach(ptr, node);
+    }
+
+    /**
+     * Sets boolean on specific json path.
+     *
+     * @param path      json path
+     * @param arrayNode arrayNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(String path, ArrayNode arrayNode) throws WorkflowException {
+        JsonPointer ptr = JsonPointer.compile(path);
+        setAt(ptr, arrayNode);
+    }
+
+    /**
+     * Sets text on the specific json pointer.
+     *
+     * @param ptr        json pointer
+     * @param objectNode objectNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(JsonPointer ptr, ObjectNode objectNode) throws WorkflowException {
+        ObjectNode node = objectNode;
+        attach(ptr, node);
+    }
+
+    /**
+     * Sets boolean on specific json path.
+     *
+     * @param path       json path
+     * @param objectNode objectNode to set
+     * @throws WorkflowException workflow exception
+     */
+    public void setAt(String path, ObjectNode objectNode) throws WorkflowException {
+        JsonPointer ptr = JsonPointer.compile(path);
+        setAt(ptr, objectNode);
+    }
+
+
+    /**
      * Sets boolean on the specific json pointer.
-     * @param ptr json pointer
+     *
+     * @param ptr    json pointer
      * @param isTrue boolean to set
      * @throws WorkflowException workflow exception
      */
@@ -445,7 +541,8 @@
 
     /**
      * Sets integer on specific json path.
-     * @param path json path
+     *
+     * @param path   json path
      * @param number number to set
      * @throws WorkflowException workflow exception
      */
@@ -456,7 +553,8 @@
 
     /**
      * Sets integer on the specific json pointer.
-     * @param ptr json pointer
+     *
+     * @param ptr    json pointer
      * @param number number to set
      * @throws WorkflowException workflow exception
      */
@@ -467,8 +565,9 @@
 
     /**
      * Allocates json data model tree on json pointer path with specific leaf type.
-     * @param node current json node in the json tree path
-     * @param ptr json pointer
+     *
+     * @param node     current json node in the json tree path
+     * @param ptr      json pointer
      * @param leaftype leaf type to be allocated
      * @return allocated json node
      * @throws WorkflowException workflow exception
@@ -510,6 +609,7 @@
 
     /**
      * Creating empty json node.
+     *
      * @param type json node type to create
      * @return created json node
      * @throws WorkflowException workflow exception
@@ -528,6 +628,7 @@
 
     /**
      * Gets the pretty json formatted string of this json data model tree.
+     *
      * @return pretty json formatted string of this json data model tree
      */
     public String formattedRootString() {
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModel.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModel.java
new file mode 100644
index 0000000..91e8382
--- /dev/null
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModel.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.workflow.api;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+
+/**
+ * Annotation for injecting static data model on work-let execution context.
+ */
+public @interface StaticDataModel {
+
+    /**
+     * Path of data model.
+     *
+     * @return path of data model
+     */
+    String path() default "/";
+
+    /**
+     * Representing whether this data model is optional or not.
+     *
+     * @return optional or not
+     */
+    boolean optional() default false;
+}
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModelInjector.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModelInjector.java
new file mode 100644
index 0000000..92d3664
--- /dev/null
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/StaticDataModelInjector.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.workflow.api;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.List;
+import java.util.Objects;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class StaticDataModelInjector {
+
+    private static final Logger log = LoggerFactory.getLogger(StaticDataModelInjector.class);
+
+    /**
+     * Injects data model to work-let.
+     *
+     * @param worklet            work-let to be injected
+     * @param workletDescription worklet description
+     * @throws WorkflowException workflow exception
+     */
+    public void inject(Worklet worklet, WorkletDescription workletDescription) throws WorkflowException {
+
+        handle(worklet, workletDescription, this::injectModel);
+    }
+
+    private void handle(Worklet worklet, WorkletDescription workletDescription, DataModelFieldBehavior func)
+            throws WorkflowException {
+        Class cl = worklet.getClass();
+        List<Field> fields = getInheritedFields(cl);
+        if (Objects.isNull(fields)) {
+            log.error("Invalid fields on {}", cl);
+            return;
+        }
+
+        for (Field field : fields) {
+            Annotation[] annotations = field.getAnnotations();
+            if (Objects.isNull(annotations)) {
+                continue;
+            }
+            for (Annotation annotation : annotations) {
+                if (!(annotation instanceof StaticDataModel)) {
+                    continue;
+                }
+                StaticDataModel model = (StaticDataModel) annotation;
+                func.apply(worklet, workletDescription, field, model);
+            }
+        }
+    }
+
+    private static List<Field> getInheritedFields(Class<?> type) {
+        List<Field> fields = new ArrayList<Field>();
+
+        Class<?> cl = type;
+        while (cl != null && cl != Object.class) {
+            for (Field field : cl.getDeclaredFields()) {
+                if (!field.isSynthetic()) {
+                    fields.add(field);
+                }
+            }
+            cl = cl.getSuperclass();
+        }
+        return fields;
+    }
+
+    /**
+     * Functional interface for json data model annotated field behavior.
+     */
+    @FunctionalInterface
+    public interface DataModelFieldBehavior {
+        void apply(Worklet worklet, WorkletDescription workletDescription, Field field, StaticDataModel model)
+                throws WorkflowException;
+    }
+
+    private static Map<Class, DataModelFieldBehavior> injectTypeMap = new HashMap<>();
+
+    static {
+        injectTypeMap.put(String.class, StaticDataModelInjector::injectText);
+        injectTypeMap.put(Integer.class, StaticDataModelInjector::injectInteger);
+        injectTypeMap.put(Boolean.class, StaticDataModelInjector::injectBoolean);
+        injectTypeMap.put(JsonNode.class, StaticDataModelInjector::injectJsonNode);
+        injectTypeMap.put(ArrayNode.class, StaticDataModelInjector::injectArrayNode);
+        injectTypeMap.put(ObjectNode.class, StaticDataModelInjector::injectObjectNode);
+    }
+
+    /**
+     * Injects data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private void injectModel(Worklet worklet, WorkletDescription workletDescription, Field field, StaticDataModel model)
+            throws WorkflowException {
+
+        DataModelFieldBehavior behavior = injectTypeMap.get(field.getType());
+        if (Objects.isNull(behavior)) {
+            throw new WorkflowException("Not supported type(" + field.getType() + ")");
+        }
+        behavior.apply(worklet, workletDescription, field, model);
+    }
+
+    /**
+     * Injects text data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              text data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectText(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                   StaticDataModel model) throws WorkflowException {
+
+        String text = ((JsonDataModelTree) workletDescription.data()).textAt(model.path());
+        if (Objects.isNull(text)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid array node data model on (" + model.path() + ")");
+        }
+
+
+        if (!(Objects.equals(field.getType(), String.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not String");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, text);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+
+    /**
+     * Injects integer data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              integer data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectInteger(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                      StaticDataModel model) throws WorkflowException {
+
+        Integer number = ((JsonDataModelTree) workletDescription.data()).intAt(model.path());
+        if (Objects.isNull(number)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid array node data model on (" + model.path() + ")");
+        }
+        if (!(Objects.equals(field.getType(), Integer.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not Integer");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, number);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+
+
+    /**
+     * Injects boolean data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              boolean data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectBoolean(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                      StaticDataModel model) throws WorkflowException {
+
+        Boolean bool = ((JsonDataModelTree) workletDescription.data()).booleanAt(model.path());
+        if (Objects.isNull(bool)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid boolean data model on (" + model.path() + ")");
+        }
+
+        if (!(Objects.equals(field.getType(), Boolean.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not Boolean");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, bool);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+
+    /**
+     * Injects json node data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              json node data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectJsonNode(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                       StaticDataModel model) throws WorkflowException {
+
+        JsonNode jsonNode = ((JsonDataModelTree) workletDescription.data()).nodeAt(model.path());
+        if (Objects.isNull(jsonNode)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid json node data model on (" + model.path() + ")");
+        }
+
+        if (!(Objects.equals(field.getType(), JsonNode.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not JsonNode");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, jsonNode);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+
+    /**
+     * Injects json array node data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              json array node data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectArrayNode(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                        StaticDataModel model) throws WorkflowException {
+
+        ArrayNode arrayNode = ((JsonDataModelTree) workletDescription.data()).arrayAt(model.path());
+        if (Objects.isNull(arrayNode)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid array node data model on (" + model.path() + ")");
+        }
+
+        if (!(Objects.equals(field.getType(), ArrayNode.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not ArrayNode");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, arrayNode);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+
+    /**
+     * Injects json object node data model on the filed of work-let.
+     *
+     * @param worklet            work-let
+     * @param workletDescription worklet description
+     * @param field              the field of work-let
+     * @param model              json object node data model for the field
+     * @throws WorkflowException workflow exception
+     */
+    private static void injectObjectNode(Worklet worklet, WorkletDescription workletDescription, Field field,
+                                         StaticDataModel model) throws WorkflowException {
+
+        ObjectNode objNode = ((JsonDataModelTree) workletDescription.data()).objectAt(model.path());
+        if (Objects.isNull(objNode)) {
+            if (model.optional()) {
+                return;
+            }
+            throw new WorkflowException("Invalid object node data model on (" + model.path() + ")");
+        }
+
+        if (!(Objects.equals(field.getType(), ObjectNode.class))) {
+            throw new WorkflowException("Target field (" + field + ") is not ObjectNode");
+        }
+
+        try {
+            field.setAccessible(true);
+            field.set(worklet, objNode);
+        } catch (IllegalAccessException e) {
+            throw new WorkflowException(e);
+        }
+    }
+}
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/Workflow.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/Workflow.java
index 1404f9b..5073105 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/Workflow.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/Workflow.java
@@ -26,12 +26,14 @@
 
     /**
      * Id of workflow.
+     *
      * @return id
      */
     URI id();
 
     /**
      * Returns init worklet.
+     *
      * @param context workflow context
      * @return init worklet
      * @throws WorkflowException workflow exception
@@ -40,6 +42,7 @@
 
     /**
      * Returns next program counter.
+     *
      * @param context workflow context
      * @return next program counter
      * @throws WorkflowException workflow exception
@@ -48,6 +51,7 @@
 
     /**
      * Gets increased program coounter.
+     *
      * @param pc program counter
      * @return increased program counter
      * @throws WorkflowException workflow exception
@@ -56,6 +60,7 @@
 
     /**
      * Returns instance of worklet.
+     *
      * @param pc program counter
      * @return instance of worklet
      * @throws WorkflowException workflow exception
@@ -64,6 +69,7 @@
 
     /**
      * Returns instance of worklet.
+     *
      * @param workletType class name of worklet
      * @return instance of worklet
      * @throws WorkflowException workflow exception
@@ -72,8 +78,9 @@
 
     /**
      * Builds workflow context.
+     *
      * @param workplace workplace of system workflow
-     * @param data data model of system workflow context
+     * @param data      data model of system workflow context
      * @return workflow context
      * @throws WorkflowException workflow exception
      */
@@ -81,8 +88,9 @@
 
     /**
      * Builds system workflow context.
+     *
      * @param workplace workplace of system workflow
-     * @param data data model of system workflow context
+     * @param data      data model of system workflow context
      * @return system workflow context
      * @throws WorkflowException workflow exception
      */
@@ -90,13 +98,23 @@
 
     /**
      * Returns workflow attributes.
+     *
      * @return attributes
      */
     Set<WorkflowAttribute> attributes();
 
     /**
-     * Returns worklet type list.
-     * @return worklet type
+     * Returns worklet desc list.
+     *
+     * @return worklet description list
      */
-    List<String> getWorkletTypeList();
+    List<WorkletDescription> getWorkletDescList();
+
+    /**
+     * Returns worklet description.
+     * @param pc program counter
+     * @return worklet description list
+     */
+    WorkletDescription getWorkletDesc(ProgramCounter pc);
+
 }
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkflowStore.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkflowStore.java
index ac0de4d..a4274935 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkflowStore.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkflowStore.java
@@ -25,18 +25,21 @@
 
     /**
      * Registers workflow.
+     *
      * @param workflow registering workflow
      */
     void register(Workflow workflow);
 
     /**
      * Unregisters workflow.
+     *
      * @param id id of workflow
      */
     void unregister(URI id);
 
     /**
      * Gets workflow.
+     *
      * @param id id of workflow
      * @return workflow
      */
@@ -44,27 +47,32 @@
 
     /**
      * Gets all workflow.
+     *
      * @return collection of workflow
      */
     Collection<Workflow> getAll();
 
     /**
      * Registers local class loader.
+     *
      * @param loader class loader
      */
     void registerLocal(ClassLoader loader);
 
     /**
      * Unregisters local class loader.
+     *
      * @param loader class loader
      */
     void unregisterLocal(ClassLoader loader);
 
     /**
      * Gets class from registered class loaders.
+     *
      * @param name name of class
      * @return class
      * @throws ClassNotFoundException class not found exception
      */
     Class getClass(String name) throws ClassNotFoundException;
+
 }
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkletDescription.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkletDescription.java
new file mode 100644
index 0000000..71ddbe5
--- /dev/null
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/WorkletDescription.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.workflow.api;
+
+
+public interface WorkletDescription {
+
+    /**
+     * Gets worklet name.
+     *
+     * @return worklet name
+     */
+    String tag();
+
+    /**
+     * Gets worklet data model.
+     *
+     * @return worklet data model
+     */
+    JsonDataModelTree data();
+
+
+}