Template is one of the new feature that Oracle has introduced in SOA 12c. Earlier in 11g version we end up writing same functionality/code more than once when there is requirement to implement same functionality in multiple composites/components. To avoid/improve that, template has been introduced in 12c version, where we can create template out of that functionality, that needs to be implement at multiple places.
Templates provide following two major benefits.
2. Improve developer productivity
We have following templates in SOA 12c.
As name suggest, Project template comprises of full project along with all the references and artefacts as part of that project. We use these templates when we need to re-use whole project or we need to use template project as base code. E.g. We create project template with basic structure like common service call, error handling etc. and that basic structure needs to be there in all the projects. We use that project template to create new projects and that new project will have all the basic structure that is define in project template and then we can enhance new project it as per our requirement.
We can create project template just by right clicking on the project and click on “Create SOA Template”. We can also import external project template to our JDeveloper.
As name suggest, component template comprises of SOA Suite component i.e. service components along with all the references and artifacts. We use these templates when we need to re-use services component functionality more than once. E.g. BPEL process contain operation to update the flag in database once process complete the processing. To create this template, simply right click on service component and choose “Create Component Template” option.
Note: It is not necessary that service component is complete and complied before we create component template, we can generate component template from service components that are not complete and not complied.
Custom Activity Template
As name suggest, this template comprises of BPEL scope activity. That scope activity can have any type of activities like Assign, Transform, Invoke, Recieve etc. i.e. We use this template when we need to re-use bunch of activities at multiple places, we can generate this template by right click on scope activity and choose “Create Custom Activity Template” option.
Sub Process is also a new feature of SOA 12c, this feature is also used for re-usability of BPEL processes. This act like a bundle which contain a piece of BPEL code which we can re-use inside same BPEL or different BPEL in same composite. Note that we can’t use this sub processes across composites, this can be only used within composite only.
There are two types of Sub Processes available.
Inline Sub Processes
As name suggest, these sub process are used inside BPEL only, we can’t use these across BPEL process. We use Inline sub processes when we need to re-use group of activities in same BPEL process at multiple places. E.g. We need to update the flag in table two times in one BPEL process, so we create inline sub process that comprises of all the activities required to update the flag and we call this sub process at two places in one BPEL process. This sub process is not visible in composite view as this is part of parent BPEL.
Standalone Sub Processes
As name suggest, these sub processes are standalone and can be used across BPEL process in one composite but can’t be used across composites. We use this sub process when we need to re-use the whole component multiple times in one composite. we create this sub process by right click on composite and choose “Subprocess” option and it shows in Subprocess section of component palette. We can call this subprocess from another component by just dragging standalone subprocess from component palette and this adds one Call activity to that component.