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
7373Then, the WAR file (which can be found in the folder 'target' generated after a successful build) can be deployed on an
7474Apache Tomcat server.
7575
76- Required VM options while running
76+ VM options while running
7777
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.
7980
8081## Plugin management
8182
Original file line number Diff line number Diff line change 5050 </dependencyManagement >
5151
5252 <dependencies >
53+ <dependency >
54+ <groupId >org.glassfish</groupId >
55+ <artifactId >javax.json</artifactId >
56+ <version >1.0.4</version >
57+ </dependency >
5358 <dependency >
5459 <groupId >org.glassfish.jersey.containers</groupId >
5560 <artifactId >jersey-container-servlet-core</artifactId >
Original file line number Diff line number Diff line change 1616
1717import com .fasterxml .jackson .databind .ObjectMapper ;
1818import 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 ;
2030
2131import java .nio .file .Path ;
2232import java .util .List ;
2333
2434public class BlockchainPluginManager {
2535
36+ private static final Logger log = LoggerFactory .getLogger (BlockchainPluginManager .class );
37+
2638 private PluginManager pluginManager = null ;
2739 private static BlockchainPluginManager instance = null ;
2840
@@ -41,8 +53,12 @@ protected PluginDescriptorFinder createPluginDescriptorFinder() {
4153 return new ManifestPluginDescriptorFinder ();
4254 }
4355 };
56+
4457 pluginManager .loadPlugins ();
4558
59+ if (Boolean .getBoolean ("enablePluginsAtStart" )) {
60+ pluginManager .startPlugins ();
61+ }
4662 }
4763
4864 public static BlockchainPluginManager getInstance () {
Original file line number Diff line number Diff line change 66import com .fasterxml .jackson .databind .node .ObjectNode ;
77import org .glassfish .jersey .media .multipart .FormDataContentDisposition ;
88import org .glassfish .jersey .media .multipart .FormDataParam ;
9+ import org .pf4j .DependencyResolver .DependenciesNotFoundException ;
910import org .pf4j .PluginWrapper ;
1011import org .slf4j .Logger ;
1112import org .slf4j .LoggerFactory ;
@@ -47,10 +48,12 @@ public Response uploadJar(@FormDataParam("file") InputStream uploadedInputStream
4748 return Response .status (Response .Status .BAD_REQUEST ).entity ("File already exists with same name." ).build ();
4849 }
4950 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+ }
5457 }
5558
5659 @ POST
You can’t perform that action at this time.
0 commit comments