Skip to content

Commit 05356f8

Browse files
committed
Initial commit.
1 parent 9e6d56f commit 05356f8

10 files changed

+712
-0
lines changed

‎.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
/bin/
2+
/target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/build/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
128
# Compiled class file
229
*.class
330

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# lowcoder-plugin-api
2+
3+
Lowcoder plugin APIs

‎pom.xml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.lowcoder.plugin</groupId>
7+
<artifactId>lowcoder-plugin-api</artifactId>
8+
<version>2.1.0</version>
9+
10+
<name>lowcoder-plugin-api</name>
11+
<description>Lowcoder shared plugin interfaces</description>
12+
<url>https://lowcoder.cloud</url>
13+
14+
<properties>
15+
<java.version>17</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>17</maven.compiler.source>
18+
<maven.compiler.target>17</maven.compiler.target>
19+
</properties>
20+
21+
<scm>
22+
<connection>scm:git:git@github.com:lowcoder-org/lowcoder-plugin-api.git</connection>
23+
<developerConnection>scm:git:ssh://github.com:lowcoder-org/lowcoder-plugin-api.git</developerConnection>
24+
<url>https://github.com/lowcoder-org/lowcoder-plugin-api/tree/main</url>
25+
</scm>
26+
27+
<licenses>
28+
<license>
29+
<name>The Apache License, Version 2.0</name>
30+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
31+
</license>
32+
</licenses>
33+
34+
<developers>
35+
<developer>
36+
<name>Lowcoder Dev Team</name>
37+
<email>service@lowcoder.cloud</email>
38+
<organization>Lowcoder Software Ltd</organization>
39+
<organizationUrl>https://lowcoder.cloud</organizationUrl>
40+
</developer>
41+
</developers>
42+
43+
<dependencies>
44+
</dependencies>
45+
46+
<distributionManagement>
47+
<snapshotRepository>
48+
<id>ossrh</id>
49+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
50+
</snapshotRepository>
51+
<repository>
52+
<id>ossrh</id>
53+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
54+
</repository>
55+
</distributionManagement>
56+
57+
<build>
58+
<pluginManagement>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.sonatype.plugins</groupId>
62+
<artifactId>nexus-staging-maven-plugin</artifactId>
63+
<version>1.6.13</version>
64+
<extensions>true</extensions>
65+
<configuration>
66+
<serverId>ossrh</serverId>
67+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
68+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
69+
</configuration>
70+
</plugin>
71+
</plugins>
72+
</pluginManagement>
73+
</build>
74+
75+
<profiles>
76+
<profile>
77+
<id>release</id>
78+
<activation>
79+
<property>
80+
<name>performRelease</name>
81+
<value>true</value>
82+
</property>
83+
</activation>
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-gpg-plugin</artifactId>
89+
<version>3.1.0</version>
90+
<executions>
91+
<execution>
92+
<id>sign-artifacts</id>
93+
<phase>verify</phase>
94+
<goals>
95+
<goal>sign</goal>
96+
</goals>
97+
<configuration>
98+
<keyname>${gpg.keyname}</keyname>
99+
<passphraseServerId>${gpg.keyname}</passphraseServerId>
100+
</configuration>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-javadoc-plugin</artifactId>
107+
<version>3.6.2</version>
108+
<executions>
109+
<execution>
110+
<id>attach-javadocs</id>
111+
<goals>
112+
<goal>jar</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
<configuration>
117+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
118+
</configuration>
119+
</plugin>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-source-plugin</artifactId>
123+
<version>3.3.0</version>
124+
<executions>
125+
<execution>
126+
<id>attach-sources</id>
127+
<goals>
128+
<goal>jar-no-fork</goal>
129+
</goals>
130+
</execution>
131+
</executions>
132+
</plugin>
133+
</plugins>
134+
</build>
135+
</profile>
136+
</profiles>
137+
138+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.lowcoder.plugin.api;
2+
3+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
4+
5+
import java.lang.annotation.Documented;
6+
import java.lang.annotation.ElementType;
7+
import java.lang.annotation.Inherited;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.Target;
10+
11+
import org.lowcoder.plugin.api.PluginEndpoint.Method;
12+
13+
14+
/**
15+
* Annotation used for marking Lowcoder endpoints.<br>
16+
* Provides basic information required for registering an endpoint in Lowcoder.
17+
*
18+
* @author ludomikula
19+
*/
20+
@Documented
21+
@Inherited
22+
@Retention(RUNTIME)
23+
@Target(ElementType.METHOD)
24+
public @interface EndpointExtension
25+
{
26+
/**
27+
* @return URI to which to bind annotated method to
28+
*/
29+
String uri();
30+
31+
/**
32+
* @return HTTP method for this annotated endpoint
33+
*/
34+
Method method() default Method.GET;
35+
36+
/**
37+
* @return True if this endpoint should be secured
38+
*/
39+
boolean authenticated() default false;
40+
41+
/**
42+
* @return Security SPeL expression (in case authenticated is set to true)
43+
*/
44+
String expression() default "";
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.lowcoder.plugin.api;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
/**
7+
* Interface to be implemented by all Lowcoder plugins.
8+
*
9+
* @author ludomikula
10+
*
11+
*/
12+
public interface LowcoderPlugin
13+
{
14+
/**
15+
* Load the plugin.
16+
*
17+
* @param environment Environment properties propagated from Lowcoder
18+
* @param lowcoderServices services shared from Lowcoder main application
19+
* @return true if we successfully loaded the plugin, false otherwise
20+
*/
21+
boolean load(Map<String, Object> environment, LowcoderServices lowcoderServices);
22+
23+
/**
24+
* Unload the plugin - this method is called on API server shutdown.
25+
* Free all resources, close all files etc in this method.
26+
*/
27+
void unload();
28+
29+
/**
30+
* Plugin Id must match following regex: {@code ^[a-zA-Z0-9-_]{5+}$ }.
31+
*
32+
* @return Unique plugin ID
33+
*/
34+
String pluginId();
35+
36+
/**
37+
* @return Plugin information serialized as part of /plugins listing.
38+
*/
39+
Object pluginInfo();
40+
41+
/**
42+
* @return Plugin description
43+
*/
44+
String description();
45+
46+
/**
47+
* @return Order in which to load the plugin. Lower number gets loaded first.
48+
*/
49+
int loadOrder();
50+
51+
/**
52+
* @return All endpoints defined by this plugin.
53+
*/
54+
List<PluginEndpoint> endpoints();
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.lowcoder.plugin.api;
2+
3+
import java.util.List;
4+
import java.util.function.Consumer;
5+
6+
import org.lowcoder.plugin.api.event.LowcoderEvent;
7+
8+
/**
9+
* Shared context which allows plugins to access services from Lowcoder main application
10+
*
11+
* @author ludomikula
12+
*
13+
*/
14+
public interface LowcoderServices
15+
{
16+
/**
17+
* Registers a listener method for events emitted by Lowcoder.
18+
*
19+
* @param listener Listener method consuming events
20+
*/
21+
void registerEventListener(Consumer<LowcoderEvent> listener);
22+
23+
/**
24+
* Registers endpoints defined by plugins in Lowcoder.
25+
*
26+
* @param urlPrefix Prefix used for endpoints (usually plugin Id)
27+
* @param endpoints Collection of endpoints to register
28+
*/
29+
void registerEndpoints(String urlPrefix, List<PluginEndpoint> endpoints);
30+
31+
/**
32+
* Sets a configuration key/value pair in Lowcoder.
33+
*
34+
* @param key Configuration key
35+
* @param value Configuration value
36+
*/
37+
void setConfig(String key, Object value);
38+
39+
/**
40+
* Reads the value of a configuration property.
41+
*
42+
* @param key Configuration key to read value for
43+
* @return Configuration value or null if it does not exist
44+
*/
45+
Object getConfig(String key);
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.lowcoder.plugin.api;
2+
3+
/**
4+
* All classes implementing an endpoint for Lowcoder need to implement this interface.
5+
*
6+
* @author ludomikula
7+
*/
8+
public interface PluginEndpoint
9+
{
10+
/**
11+
* Method used in {@link EndpointExtension} for specifying endpoint method.<br>
12+
* For example:<br>
13+
* {@code @EndpointExtension(uri = "/navigation", method = Method.GET) }
14+
*/
15+
enum Method
16+
{
17+
GET,
18+
PUT,
19+
POST,
20+
PATCH,
21+
DELETE,
22+
OPTIONS
23+
}
24+
}

0 commit comments

Comments
 (0)