File tree Expand file tree Collapse file tree 4 files changed +32
-7
lines changed
src/main/java/blockchains/iaas/uni/stuttgart/de Expand file tree Collapse file tree 4 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,10 @@ mvn install
73
73
Then, the WAR file (which can be found in the folder 'target' generated after a successful build) can be deployed on an
74
74
Apache Tomcat server.
75
75
76
- Required VM options while running
76
+ VM options while running
77
77
78
- - ` pf4j.pluginsDir ` path where the plugins will be stored
78
+ - ` pf4j.pluginsDir ` path where the plugins will be stored. This property is mandatory.
79
+ - ` enablePluginsAtStart ` boolean flag to enable plugins during startup (default false). This property is optional.
79
80
80
81
## Plugin management
81
82
Original file line number Diff line number Diff line change 50
50
</dependencyManagement >
51
51
52
52
<dependencies >
53
+ <dependency >
54
+ <groupId >org.glassfish</groupId >
55
+ <artifactId >javax.json</artifactId >
56
+ <version >1.0.4</version >
57
+ </dependency >
53
58
<dependency >
54
59
<groupId >org.glassfish.jersey.containers</groupId >
55
60
<artifactId >jersey-container-servlet-core</artifactId >
Original file line number Diff line number Diff line change 16
16
17
17
import com .fasterxml .jackson .databind .ObjectMapper ;
18
18
import com .fasterxml .jackson .databind .jsontype .NamedType ;
19
- import org .pf4j .*;
19
+ import org .pf4j .DefaultPluginManager ;
20
+ import org .pf4j .PluginManager ;
21
+ import org .pf4j .PluginState ;
22
+ import org .pf4j .PluginWrapper ;
23
+ import org .pf4j .ManifestPluginDescriptorFinder ;
24
+ import org .pf4j .DependencyResolver .DependenciesNotFoundException ;
25
+ import org .pf4j .JarPluginLoader ;
26
+ import org .pf4j .PluginDescriptorFinder ;
27
+ import org .pf4j .PluginLoader ;
28
+ import org .slf4j .Logger ;
29
+ import org .slf4j .LoggerFactory ;
20
30
21
31
import java .nio .file .Path ;
22
32
import java .util .List ;
23
33
24
34
public class BlockchainPluginManager {
25
35
36
+ private static final Logger log = LoggerFactory .getLogger (BlockchainPluginManager .class );
37
+
26
38
private PluginManager pluginManager = null ;
27
39
private static BlockchainPluginManager instance = null ;
28
40
@@ -41,8 +53,12 @@ protected PluginDescriptorFinder createPluginDescriptorFinder() {
41
53
return new ManifestPluginDescriptorFinder ();
42
54
}
43
55
};
56
+
44
57
pluginManager .loadPlugins ();
45
58
59
+ if (Boolean .getBoolean ("enablePluginsAtStart" )) {
60
+ pluginManager .startPlugins ();
61
+ }
46
62
}
47
63
48
64
public static BlockchainPluginManager getInstance () {
Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .databind .node .ObjectNode ;
7
7
import org .glassfish .jersey .media .multipart .FormDataContentDisposition ;
8
8
import org .glassfish .jersey .media .multipart .FormDataParam ;
9
+ import org .pf4j .DependencyResolver .DependenciesNotFoundException ;
9
10
import org .pf4j .PluginWrapper ;
10
11
import org .slf4j .Logger ;
11
12
import org .slf4j .LoggerFactory ;
@@ -47,10 +48,12 @@ public Response uploadJar(@FormDataParam("file") InputStream uploadedInputStream
47
48
return Response .status (Response .Status .BAD_REQUEST ).entity ("File already exists with same name." ).build ();
48
49
}
49
50
writeToFile (uploadedInputStream , uploadedFileLocation );
50
-
51
- blockchainPluginManager .loadJar (filePath );
52
-
53
- return Response .ok ().build ();
51
+ try {
52
+ blockchainPluginManager .loadJar (filePath );
53
+ return Response .ok ().build ();
54
+ } catch (DependenciesNotFoundException e ) {
55
+ return Response .status (400 ).entity (e .getMessage ()).type ("text/plain" ).build ();
56
+ }
54
57
}
55
58
56
59
@ POST
You can’t perform that action at this time.
0 commit comments