A plugin is a way for a third party to extend the functionality of an application. A plugin implements extension points
A plugin is a way for a third party to extend the functionality of an application. A plugin implements extension points
declared by application or other plugins. Also a plugin can define extension points.
declared by application or other plugins. Also, a plugin can define extension points.
**NOTE:** Starting with version 0.9 you can define an extension directly in the application jar (you're not obligated to put the extension in a plugin - you can see this extension as a default/system extension). See [WhazzupGreeting](https://github.com/pf4j/pf4j/blob/master/demo/app/src/main/java/org/pf4j/demo/WhazzupGreeting.java) for a real example.
**NOTE:** Starting with version 0.9 you can define an extension directly in the application jar (you're not obligated to put the extension in a plugin - you can see this extension as a default/system extension). See [WhazzupGreeting](https://github.com/pf4j/pf4j/blob/master/demo/app/src/main/java/org/pf4j/demo/WhazzupGreeting.java) for a real example.
@ -17,7 +17,7 @@ Features/Benefits
With PF4J you can easily transform a monolithic java application in a modular application.
With PF4J you can easily transform a monolithic java application in a modular application.
PF4J is an open source (Apache license) lightweight (around __100 KB__) plugin framework for java, with minimal dependencies (only slf4j-api) and very extensible (see `PluginDescriptorFinder` and `ExtensionFinder`).
PF4J is an open source (Apache license) lightweight (around __100 KB__) plugin framework for java, with minimal dependencies (only slf4j-api) and very extensible (see `PluginDescriptorFinder` and `ExtensionFinder`).
Practically PF4J is a microframework and the aim is to keep the core simple but extensible. I try to create a little ecosystem (extensions) based on this core with the help of the comunity.
Practically PF4J is a microframework and the aim is to keep the core simple but extensible. I try to create a little ecosystem (extensions) based on this core with the help of the community.
For now are available these extensions:
For now are available these extensions:
- [pf4j-update](https://github.com/pf4j/pf4j-update) (update mechanism for PF4J)
- [pf4j-update](https://github.com/pf4j/pf4j-update) (update mechanism for PF4J)
- [pf4j-spring](https://github.com/pf4j/pf4j-spring) (PF4J - Spring Framework integration)
- [pf4j-spring](https://github.com/pf4j/pf4j-spring) (PF4J - Spring Framework integration)
@ -70,17 +70,11 @@ public class WelcomeGreeting implements Greeting {
}
}
```
```
Create (it's __optional__) a `Plugin` class if you are interested for plugin's lifecycle events (start, stop, ...):
Create (it's __optional__) a `Plugin` class if you are interested in plugin's lifecycle events (start, stop, ...):
```java
```java
public class WelcomePlugin extends Plugin {
public class WelcomePlugin extends Plugin {
public WelcomePlugin(PluginWrapper wrapper) {
super(wrapper);
// you can use "wrapper" to have access to the plugin context (plugin manager, descriptor, ...)
}
@Override
@Override
public void start() {
public void start() {
System.out.println("WelcomePlugin.start()");
System.out.println("WelcomePlugin.start()");
@ -101,7 +95,7 @@ public class WelcomePlugin extends Plugin {
In above code I created a plugin (welcome) that comes with one extension for the `Greeting` extension point.
In above code I created a plugin (welcome) that comes with one extension for the `Greeting` extension point.
You can distribute you plugin as a jar file (the simple solution). In this case add the plugin's metadata in `MANIFEST.MF` file of jar:
You can distribute your plugin as a jar file (the simple solution). In this case add the plugin's metadata in `MANIFEST.MF` file of jar: