Suche

This notation, along with the one, described in this chapter can be used to define commands in PAK.

1. Basics

Services are often implemented by simple command implementations. The commands only inject the respective service and execute a method on it. This behaviour
is very repetitive and can be automized by using the following command notation.

The main difference between this notation and the other is that this notation turns the methods within a class
into commands and is an effective way to turn already existing legacy code into commands.

To be more specific: It turns them into CommandMetas (json-files, containing all command-specific information), while the other notation
processes a whole class and produces one command per class.

In order to process methods as commands, the class containing the methods must be marked with @JavaCommandService.
  • If all methods inside the given class need to be processed, then only use @JavaCommandService on class-level.

  • If only certain methods inside the class need to be processed. It’s required to additionally use @JavaCommand. It must be used to annotate the specific methods and mark them as a command.
    Only these methods will then be recognized as commands by the corresponding annotation processor.

Furthermore, it’s possible to inject services into the commands by using @LiteService above the attributes.
Allowing the class to be constructed as if it were in its original context.

1.1. Prerequisites

In order to use the new command notation. Make sure that the following dependencies are used within your build.gradle file:

Listing 1. build.gradle
pakVersion = '1.9.10'

dependencies {
[...]
    annotationProcessor "de.asap.pak.jlcint:jlcint-processor:${pakVersion}"
    provided "de.asap.pak.jlcint:jlcint-commandapi"
}

[...]

task metaJar(type: Jar) {
    archiveClassifier = 'pakmeta'
    from sourceSets.main.output
    include 'meta/**'
    include 'entities/**'
    from sourceSets.main.java
    include 'icon/**'
}

2. Usage

The following two listings show how to correctly define methods in order to be converted into commands.

2.1. Processing of All Methods within the Class

If all methods within a class should be processed, the class only has to be annotated with @JavaCommandService.

Listing 2. Processing of multiple commands within one class
@JavaCommandService (1)
public class CommandClass {

	@Service (2)
	private ICredentialRequester credentialRequester;


	public CommandClass(final ICredentialRequester credentialRequester) {
		this.credentialRequester = credentialRequester;
	}


	public void myCommand1(String str1, String str2) { (3)
	    int strLength = str1.length() + str2.length();
	}

    @Deprecated (4)
	public int myCommand2(String myReadVariable) { (5)

		return 42;
	}
}
1 Usage of @JavaCommandService: @JavaCommandService on class-level, all methods inside the class-scope are turned into a command.
2 Service injection: The service ICredentialRequester is injected into the class, holding the means to the call the method. The injected service must not be in
the same package as the class using this service. Otherwise, GUICE can’t find the respective, and the injection fails.
3 Declaration of method: Methods must be declared as public, otherwise they will not be recognized as commands.
4 Deprecation of commands: Commands can be deprecated by annotating the corresponding method with @Deprecated.
5 Marking of read/ write-variables: In contrast to myCommand1, this method/ command (myCommand2) has a return-type,
meaning it has a WRITE variable and one READ variable (myReadVariable). While myCommand1 has two variables: str1(scope: READ) and str2
(scope: READ). It’s important to keep in mind, that if a method has the return-type void,
the command must not have any WRITE variables.

Listing 2 produces two commands (myCommand1, myCommand2).

2.2. Processing of certain Methods within the Class

If only a certain selection of methods needs to be processed or if the user wishes to further configure his/her command, it’s required to mark those methods with @JavaCommand.

Listing 3. Processing of only one command within one class
@JavaCommandService (1)
public class CommandClass {

	@LiteService (2)
	private ICommandRestService restService;

	public CommandClass(final ICommandRestService restService) {
		this.restService = restService;
	}


	/**
    * This is the workflowDocumentation for my command
    *
    * @param myReadVariable Actual docu of my variable (3)
    * @param noReadVariable This is the documentation for noReadVariable
    * @return This is the workflowDocumentation for my write-Variable (myCommandResult)
    */ (4)
	@Persistent(mandatory = false) (5)
	@JavaCommand
    @CommandGroup("myCommandGroup") (6)
	public String myCommand(@Persistent(mandatory = false) String myReadVariable, String noReadVariable) {

		return "hello";
	}

    /**
    * Simple dummy method, not a command
    *
    * @param number some dummy parameter
    */
	public int retNum(int number) {
	    return number;
	}
}
1 Usage of @JavaCommandService: @JavaCommandService on class-level, in contrast to Listing 2 only the methods, which will be turned into commands are marked with @JavaCommand.
2 Service injection: The lite-service ICommandRestService is injected into the class, holding the means to call the method. The injected service must not be in
the same package as the class using this service. Otherwise, GUICE can’t find the respective service, and the injection fails.
3 Variable documentation: The text after the @param tag in the JavaDoc-block represents the documentation for the corresponding variable.
4 Workflow documentation: The workflow documentation for the command and/or variables can be fetched from the JavaDoc-block. The method-documentation
is the workflowDocumentation for the whole command, while @param describes the docu for the READ variables and @return for the WRITE variables.
5 Marking of read/ write-variables: If @Persistent is above the method-body, variables with the scope WRITE are defined. @Persistent must be used within the
method parameters (only when @JavaCommand is used) in order to mark variables with scope READ(myReadVariable). Both READ and WRITE variables can also be not mandatory (as shown above). Method-parameters, which are not annotated with @Persistent will not be
recognized as any command-relevant variables and do not have a scope (only when @JavaCommand is used). Furthermore, it does not matter if the parameters/ methods are declared as final or not. They will be recognized as READ or WRITE variables either way.
6 Grouping of Commands: It’s possible to group those commands, by using @CommandGroup. If @CommandGroup is missing, the name of the package is chosen as the command-group.

Listing 3 produces only one command (myCommand).

The command-notation from above corresponds to the following CommandMeta:

Listing 4. CommandMeta corresponding to previously defined command
{
    "deprecated": false,
    "group": "myCommandGroup",
    "id": "stimuli.pkg5.CommandClass#myCommandByStringAndString",
    "increment": 0,
    "interpreter": "de.asap.pak.jlcint.pakbridge.JavaServiceInterpreter",
    "liteServices": [
        {
            "id": "de.asap.pak.core.services.api.ICommandRestServices",
            "key": "restService",
            "name": "ICommandRestService"
        }
    ],
    "major": 2,
    "mappings": [
        {
            "documentation": "Actual docu of my variable",
            "isAllowedValuesSuggestion": false,
            "key": "myReadVariable",
            "mandatory": false,
            "scope": "READ",
            "type": "STRING"
        },
        {
            "documentation": "This is the workflowDocumentation for my write-Variable (myCommandResult)",
            "isAllowedValuesSuggestion": false,
            "key": "myCommandResult", (1)
            "mandatory": false,
            "scope": "WRITE",
            "type": "STRING"
        }
    ],
    "minor": 1,
    "name": "myCommand",
    "properties": {
        "methodParameters": [
            {
                "dataType": "java.lang.String",
                "mandatory": false,
                "order": 0,
                "parameterName": "myReadVariable",
                "persistent": true
            },
            {
                "dataType": "java.lang.String",
                "mandatory": true,
                "order": 1,
                "parameterName": "noReadVariable",
                "persistent": false
            }
        ],
        "methodName": "editDescription"
    },
[...]
}
1 The name of the WRITE Variable gets constructed by taking the name of the method and adding the string Result.

2.3. Overloading of Methods

It’s also possible to overload methods (commands). These commands can be distinguished
by the names as well as the types of the READ parameters of the command. The id of those commands
gets constructed by concatenating the READ parameter-types with the name of the method. While the name gets
constructed by concatenating the READ parameter-names with the name of the method. In order for the concatenation to look
prettier the keywords And and By are used between the different parameter-types.

Listing 5. Overloading of command
@JavaCommandService
public class CommandClass {

    [...]

	public String myCommand(int myIntReadVariable, String myStringReadVariable) { (1)

		return "hello";
	}

	public int myCommand(String myReadVariable) { (2)

		return 42;
	}
}
1 The name of this command: myCommandByIntAndString. The id of this command: CommandClass#myCommandByIntAndString.
2 The name of this command: myCommandByString. The id of this command: CommandClass#myCommandByString.

Sonatype Nexus

PAK features connectors and commands for Sonatype Nexus. This means the software can directly interact with Nexus repositories for storing and managing artifacts. Through these connectors, PAK can automate tasks like uploading binaries or retrieving dependencies, ensuring efficient artifact management within Nexus.

Jenkins

PAK has connectors and commands for Jenkins. This allows the software to directly communicate with Jenkins servers, enabling the automation of CI/CD (Continuous Integration/Continuous Deployment) tasks. Through these connectors, PAK can trigger builds, fetch build statuses, or manage job configurations, streamlining the CI/CD processes within Jenkins.

Git Hub

PAK possesses connectors and commands for GitHub. This means the software can interface directly with GitHub repositories, facilitating actions like code pushes, pull requests, or issue tracking. Through these connectors, PAK can automate various GitHub operations, enhancing code collaboration and repository management.

Atlassian Confluence

PAK is equipped with connectors and commands for Atlassian Confluence. This enables the software to directly interact with Confluence spaces and pages. Through these connectors, PAK can automate actions such as creating, updating, or retrieving documentation, ensuring efficient content management and collaboration within Confluence.

Codebeamer

PAK features connectors and commands for Codebeamer. This allows the software to seamlessly integrate with Codebeamer’s ALM (Application Lifecycle Management) platform. Through these connectors, PAK can automate tasks like issue tracking, test management, or requirements tracing, enhancing the coordination and management of software development processes.

JFrog Artifactory

PAK has connectors and commands for JFrog Artifactory. This means the software can directly interface with Artifactory repositories, enabling actions like artifact storage, retrieval, and management. Through these connectors, PAK can automate tasks such as deploying artifacts or managing repository configurations, streamlining the integration and management of binary artifacts within Artifactory.

Amazon Web Services (AWS)

PAK has connectors and commands for Amazon Web Services (AWS). This means the software possesses specialized interfaces to directly interact with AWS services and execute actions on the AWS platform. Through these connectors, PAK can automate AWS-specific commands, such as launching EC2 instances, managing S3 buckets, or configuring Lambda functions. This allows for efficient integration, management, and automation of AWS resources and services directly from PAK.

Atlassian Jira

PAK features integration tools and capabilities for Atlassian Jira. These tools allow for a direct connection to Jira and the execution of specific actions. Using these integration tools, PAK can automate Jira actions such as adding comments or changing ticket priorities, ensuring seamless handling and coordination of Jira processes.

Git

PAK has connectors and commands for Git. This means it has interfaces to directly communicate with Git and execute actions. Through these connectors, the software can automate Git commands such as retrieving changes or creating branches, enabling efficient integration and management of Git tasks.

Generic Human Tasks

PAK offers you a standard set of commands which require creative input from the user. Enables you to start with automating your workflows, that still need abit of human input.

Generic Commands

PAK offers a standard set of commands giving you the first steps to automate your workflows.

Nexus Maven Command Pool

Nexus is an artifact repository manager for storing binaries, libraries, and artifacts, supporting formats like Maven. Maven, a software project management tool, is based on the Project Object Model (POM) and allows developers to consistently define projects and dependencies. Our Command Pool offers commands for interactions between Maven and Nexus, such as artifact uploads or dependency retrieval.

Artifactory Maven Command Pool

Artifactory allows developers to store, retrieve, and manage binary files and artifacts, providing a
central source for all binaries used in a development process. Apache Maven is a software project
management and comprehension tool that enables developers to consistently describe a project and
its dependencies. Our Command Pool offers a collection of commands used to facilitate interactions
between Maven and Artifactory, such as uploading artifacts or retrieving dependencies.

Open API Command Interpreter

The OpenApi Command Interpreter allows you the automatic parsing of commands from an OpenApi defintion. No additional code needs to be written anymore, just add the address to the definition and our framework does the rest!

Kotlin Command Interpreter

The Kotlin Command Interpreter allows you the parsing and execution of commands within a Kotlin environment to automate various tasks or processes.

Bpmn Interpreter

Workflows come in many shapes and forms. The BPMN (Business Process Model and Notation) Interpreter enables the parsing of worklows defined in the BPMN format into the PAK intern model.

Human Task Interpreter

The Human Task Interpreter allows you the parsing and running of commands within a HTML and Javascript environment. Use this to build commands which need the creative input of a workflow user!

Java Command Interpreter

The Java Command Interpreter allows you the parsing and execution of commands within a Java
environment to automate various tasks or processes.

Core

The heart of the PAK-Framework. Contains the means to run workflows with the PAK engine, but also the possibility to enrich the frameworks interfaces with your own implementations and solutions.

RocksDB Persistence

Data that is generated by a workflow run needs to be saved for short or longer terms. Our solution to the Persistence Interface of the PAK-Framework is to use the high-performance, key-value based RocksDB developed by Facebook.

PAK online

PAK Online is a web based application and provides an Open API based REST API. It enables you to upload workflows and run them periodically or on REST demand.

Command Line App

Run tasks and workflows on the console or as part of a CI/CD Pipeline with our Command Line Interface.

Workflow Editor

With our specially developed editor, a wide variety of workflows can be easily modeled in the wide known BPMN process format.

Workflow Executor

The Workflow Executor is the application to run your workflows. It features a multilingual UI and easy managment of your favorite workflows.

Support

We offer a community website where you can exchange ideas and support each other. For our Pro packages we also offer full support via email.