Developing Template Projects - Xyna-Factory/xyna GitHub Wiki
The Xyna Factory can generate template projects for service groups or data types, triggers and filters. The templates are designed to quickly develop coded services, triggers or filters as a java library. A template project can be imported in an IDE like Eclipse and contains empty classes and methods that have to be implemented.
Templates for service groups or data types enable the implementation of coded services in a library. The templates contain function bodies with the appropriate signature for each coded service of the service group or data type. Xyna supports coded services implemented in Java or Python. If the goal is that your implemented services become part of an application that is included in the official Xyna release bundle, please choose Java templates. If you just want to develop your own project, feel free to also use Python templates.
Open the data type or service group in the Xyna Process Modeller for which you want to download a template. Make sure that each service you want to implement is set up correctly:
- Set the implementation type to "Coded Service Java" or "Coded Service Python".
- Check the correct signature of the service: input and output variables and exceptions.
- Replace the existing code snippet with a template call by clicking on the button "Template Call" (see image below).
After that, click on the upper or lower template symbol in the left hand side panel to download a Java or Python template. The downloaded ZIP file contains a project that can be imported into an IDE like Eclipse.
Templates can also be downloaded via cli:
./xynafactory.sh buildserviceprojectjava -fqDatatypeName <arg> -targetDirectory <arg> [-workspaceName <arg>]
The command buildserviceprojectpython
works in the same way.
The downloaded Template has the following structure and files (among others):
<projectroot>/common/src
<projectroot>/common/lib/xyna
<projectroot>/mdmimpl/<servicegroupname>Impl/src/<xynapath>/impl/<servicegroupname>InstanceOperationImpl.java
<projectroot>/mdmimpl/<servicegroupname>Impl/src/<xynapath>/impl/<servicegroupname>ServiceOperationImpl.java
<projectroot>/mdmimpl/<servicegroupname>Impl/lib/xyna/serviceDefinition-javadoc.jar
<projectroot>/mdmimpl/<servicegroupname>Impl/lib/xyna/serviceDefinition.jar
<projectroot>/mdmimpl/<servicegroupname>Impl/lib/xyna/mdm.jar
<projectroot>/mdmimpl/<servicegroupname>Impl/xmldefinition/<servicegroupname>.xml
<projectroot>/mdmimpl/<servicegroupname>Impl/build.xml
<projectroot>/mdmimpl/<servicegroupname>Impl/buildService.xml
<projectroot>/mdmimpl/<servicegroupname>Impl/Exceptions.xml
<projectroot>/server
<projectroot>/server.properties
- The two java files contain the methods for the coded services to be implemented. Instance services of data types are in
...InstanceOperationImpl.java
and the services of a service group are in...ServiceOperationImpl.java
. The later file also contains methods to which code can be added that will be executed each time the data type or service group is deployed or undeployed. -
build.xml
andbuildService.xml
provide Ant targets to support the development and deployment process (see next section). - The following JAR files might be used by templates.
- libraries in the directory
<projectroot>/common/lib/xyna
like thexynafactory.jar
, which contains the classes of the xyna factory itself, and other libraries used by xyna. -
mdm.jar
: contains classes of all the modeled data types and exception types. -
servicedefinition.jar
: contains interfaces/adapter classes for the implementation of services.
- libraries in the directory
The Ant buildfiles build.xml
and buildService.xml
in the template project provide Ant targets to support the development and deployment process.
Execute
ant -p
to get a list of available targets.
Always use the build.xml
file (the default), not buildService.xml
to execute Ant targets.
The file server.properties
has to be configured correctly for the Ant targets that interact with the Xyna Factory.
Check and modify the file if necessary.
An example configuration for the case that the Xyna Factory runs in a container is shown here.
Some changes occurring in the Xyna Factory, such as changes to the signature of coded services or changes of used XMOM objects make it necessary to update the used JAR files of the template. The Ant target
ant updateMDMandXynaFactoryJar
updates mdm.jar
and xynafactory.jar
. This is typically necessary when changes occurred in used data types.
An update of the he servicedefinition.jar
can be done in a similar way with the Ant target
ant updateServiceDefinition
which is required after changes to the signatures of the services in the service group or data type.
To build the project execute:
ant build
This will create a JAR file in the the directory <projectroot>/mdmimpl/<servicegroupname>Impl/deploy
.
Executing
ant deploy
builds and then deploys the JAR file on the server.
Alternatively, the new library can be deployed via the Xyna Process Modeller by opening the service group or data type associated with the library. Click the "plus" button inside the libraries section, then click deploy for the changes to take effect as shown in the image below.
The following options are available in order to use additional libraries:
- Simply add the libraries to the template project.
- Upload a Shared Library that can be used by all service groups, data types, trigger and filter within the same workspace or application. When JAR files have been added as a shared library they become available for selection in the "Java Shared Libraries" section of service groups and data types in the Xyna Process Modeller.
- Add the libraries to the global classpath
$XYNA_HOME/server/lib
and restart the server.