Skip to content

Developing Plugins#

Getting Started#

Concourse plugins must be implemented as Java classes that extend com.cinchapi.concourse.server.plugin.Plugin. To get started, create a Java project that depends on the concourse-plugin-core framework.

Create a build.gradle file#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
plugins {
    id "com.cinchapi.concourse-plugin" version "1.0.14"
    id 'java'
    id 'eclipse'
    id 'maven'
}

group = 'com.cinchapi'
version  = getVersion()

// Set the version for all Concourse dependencies
ext.concourseVersion = '0.7.0'

// Configure Concourse plugin
bundle {
    bundleName project.name
}

task wrapper(type: Wrapper) {
    gradleVersion = '3.0'
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.cinchapi', name: 'concourse-plugin-core',
      version: concourseVersion

    testCompile 'junit:junit:4.11'
    testCompile group: 'com.cinchapi', name: 'concourse-ete-test-core',
      version: concourseVersion
}

Download dependencies and generate IDE metadata#

1
./gradlew clean eclipse

Implement the plugin#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
package com.company.concourse.plugin.sample;

import com.cinchapi.concourse.server.plugin.Plugin;

/**
 * Sample Plugin Boilerplate
 */
public class SamplePlugin extends Plugin {

    /**
     * Construct a new instance.
     *
     * @param fromServer
     * @param fromPlugin
     */
    public Sample(String fromServer, String fromPlugin) {
        super(fromServer, fromPlugin);
    }

}

Any instance methods that are added to the plugin class will be dynamically added to the Concourse API.

Create the plugin package#

1
./gradlew bundleZip

Check the build/distributions directory to see the generated .zip plugin package.

Accessing Concourse within a Plugin#

Concourse plugins have privileged access to the database using a special API. To interact with Concourse, use the runtime method inside the plugin class.

1
2
3
4
5
6
7
public void sampleWriteMethod(String key, Object value) {
  runtime.addKeyValue(key, value);
}

public Object sampleReadMethod(String key) {
  //TODO: fixme
}

If you need to access Concourse from a class that does not extend Plugin (i.e. a utility class) you can interact with the runtime by calling PluginRuntime.getRuntime().

Background Requests#

Each Plugin has access to the host Concourse instance