Above answer gave me a hint but didn't solve the problem completely so here is my code which is serving the purpose.
My usertask in .bpmn file looks like:
<bpmn:userTask id="Task_063x95d" name="Tech Task">
<bpmn:documentation>SUCCESS,FAIL</bpmn:documentation>
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="language">Java</camunda:inputParameter>
<camunda:outputParameter name="Platform">Linux</camunda:outputParameter>
</camunda:inputOutput>
<camunda:properties>
<camunda:property name="user" value="Test_User" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1xjoyjq</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_028pkxo</bpmn:outgoing>
</bpmn:userTask>
I have analysed the .bpmn file and then just rendered its elements with help of below code
// Active tasks for currently running instanceId(input to below code)
List<Task> tasks = this.taskService.createTaskQuery().processInstanceId(instanceId).list();
String documentation= null;
for (Task task : tasks)
{
//This gives [documentation][1] field.
documentation = task.getDescription();
UserTaskImpl modelElementById = (UserTaskImpl) bpmnModelInstance.getModelElementById(tasks.get(0)
.getTaskDefinitionKey());
ExtensionElements childElementsByType2 = modelElementById.getExtensionElements();
Collection<ModelElementInstance> elements = childElementsByType2.getElements();
for (ModelElementInstance elem : elements)
{
//To access all properties.
if (elem instanceof CamundaPropertiesImpl)
{
CamundaPropertiesImpl camundaPropertiesImpl = (CamundaPropertiesImpl) elem;
Collection<CamundaProperty> camundaProperties = camundaPropertiesImpl.getCamundaProperties();
for (CamundaProperty test : camundaProperties)
{
System.out.println("camunda property name :" + test.getCamundaName() + " $ " + test.getCamundaValue());
}
}
else if (elem instanceof CamundaInputOutputImpl)
{
// To access input/output param
CamundaInputOutputImpl camundaInputOutputImpl = (CamundaInputOutputImpl) elem;
for (CamundaInputParameter test : camundaInputOutputImpl.getCamundaInputParameters())
{
log.info("camunda input params name :" + test.getCamundaName() + " $ " + test.getTextContent());
}
for (CamundaOutputParameter test : camundaInputOutputImpl.getCamundaOutputParameters())
{
log.info("camunda output params name :" + test.getCamundaName() + " $ " + test.getTextContent());
}
}
}
}