diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2012-10-11 13:29:43 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2012-10-11 13:29:43 +0300 |
commit | 2aeb77b8c8e6023651d1fc7b9ef31736b855cafa (patch) | |
tree | 00b9bf8944c517fe991dbf83da672c002f9f12f0 /demo | |
download | pf4j-2aeb77b8c8e6023651d1fc7b9ef31736b855cafa.tar.gz pf4j-2aeb77b8c8e6023651d1fc7b9ef31736b855cafa.zip |
first commit
Diffstat (limited to 'demo')
-rw-r--r-- | demo/api/pom.xml | 44 | ||||
-rw-r--r-- | demo/api/src/main/java/org/pf4j/demo/api/Greeting.java | 24 | ||||
-rw-r--r-- | demo/app/pom.xml | 89 | ||||
-rw-r--r-- | demo/app/src/main/assembly/assembly.xml | 32 | ||||
-rw-r--r-- | demo/app/src/main/java/org/pf4j/demo/Boot.java | 63 | ||||
-rw-r--r-- | demo/app/src/main/resources/log4j.properties | 10 | ||||
-rw-r--r-- | demo/app/src/main/resources/logging.properties | 8 | ||||
-rw-r--r-- | demo/plugin1/plugin.properties | 5 | ||||
-rw-r--r-- | demo/plugin1/pom.xml | 127 | ||||
-rw-r--r-- | demo/plugin1/src/main/assembly/assembly.xml | 37 | ||||
-rw-r--r-- | demo/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java | 46 | ||||
-rw-r--r-- | demo/plugin2/plugin.properties | 5 | ||||
-rw-r--r-- | demo/plugin2/pom.xml | 136 | ||||
-rw-r--r-- | demo/plugin2/src/main/assembly/assembly.xml | 37 | ||||
-rw-r--r-- | demo/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java | 48 | ||||
-rw-r--r-- | demo/pom.xml | 60 |
16 files changed, 771 insertions, 0 deletions
diff --git a/demo/api/pom.xml b/demo/api/pom.xml new file mode 100644 index 0000000..1514476 --- /dev/null +++ b/demo/api/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.pf4j.demo</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>pf4j-demo-api</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Demo Api</name> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.pf4j</groupId> + <artifactId>pf4j</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + +</project> diff --git a/demo/api/src/main/java/org/pf4j/demo/api/Greeting.java b/demo/api/src/main/java/org/pf4j/demo/api/Greeting.java new file mode 100644 index 0000000..b21f80c --- /dev/null +++ b/demo/api/src/main/java/org/pf4j/demo/api/Greeting.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012 Decebal Suiu + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with + * the License. You may obtain a copy of the License in the LICENSE file, or at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.pf4j.demo.api; + +import org.pf4j.ExtensionPoint; + +/** + * @author Decebal Suiu + */ +public interface Greeting extends ExtensionPoint { + + public String getGreeting(); + +} diff --git a/demo/app/pom.xml b/demo/app/pom.xml new file mode 100644 index 0000000..d9084b1 --- /dev/null +++ b/demo/app/pom.xml @@ -0,0 +1,89 @@ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.pf4j.demo</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>pf4j-demo-app</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Demo App</name> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <properties> + <main.class>org.pf4j.demo.Boot</main.class> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.3</version> + <configuration> + <descriptors> + <descriptor> + src/main/assembly/assembly.xml + </descriptor> + </descriptors> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.3.1</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + <mainClass>${main.class}</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.pf4j</groupId> + <artifactId>pf4j</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.pf4j.demo</groupId> + <artifactId>pf4j-demo-api</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + +</project> diff --git a/demo/app/src/main/assembly/assembly.xml b/demo/app/src/main/assembly/assembly.xml new file mode 100644 index 0000000..1d9e8e4 --- /dev/null +++ b/demo/app/src/main/assembly/assembly.xml @@ -0,0 +1,32 @@ +<!-- + Describes the dist + + @author Decebal Suiu + @version 1.0 +--> +<assembly> + <id>plugin</id> + <formats> + <format>dir</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <useProjectArtifact>false</useProjectArtifact> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*:jar:*</include> + </includes> + </dependencySet> + </dependencySets> + <fileSets> + <fileSet> + <directory>${project.build.directory}</directory> + <outputDirectory></outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + </fileSets> +</assembly> + diff --git a/demo/app/src/main/java/org/pf4j/demo/Boot.java b/demo/app/src/main/java/org/pf4j/demo/Boot.java new file mode 100644 index 0000000..b34af53 --- /dev/null +++ b/demo/app/src/main/java/org/pf4j/demo/Boot.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012 Decebal Suiu + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with + * the License. You may obtain a copy of the License in the LICENSE file, or at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.pf4j.demo; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.pf4j.DefaultPluginManager; +import org.pf4j.ExtensionWrapper; +import org.pf4j.PluginManager; +import org.pf4j.demo.api.Greeting; + +/** + * A boot class that start the demo. + * + * @author Decebal Suiu + */ +public class Boot { + + public static void main(String[] args) { + // print logo + printLogo(); + + // load and start (active/resolved) plugins + final PluginManager pluginManager = new DefaultPluginManager(); + pluginManager.loadPlugins(); + pluginManager.startPlugins(); + + List<ExtensionWrapper<Greeting>> greetings = pluginManager.getExtensions(Greeting.class); + for (ExtensionWrapper<Greeting> greeting : greetings) { + System.out.println(">>> " + greeting.getInstance().getGreeting()); + } + + pluginManager.stopPlugins(); + /* + Runtime.getRuntime().addShutdownHook(new Thread() { + + @Override + public void run() { + pluginManager.stopPlugins(); + } + + }); + */ + } + + private static void printLogo() { + System.out.println(StringUtils.repeat("#", 40)); + System.out.println(StringUtils.center("PF4J-DEMO", 40)); + System.out.println(StringUtils.repeat("#", 40)); + } + +} diff --git a/demo/app/src/main/resources/log4j.properties b/demo/app/src/main/resources/log4j.properties new file mode 100644 index 0000000..b3e5aa8 --- /dev/null +++ b/demo/app/src/main/resources/log4j.properties @@ -0,0 +1,10 @@ +log4j.rootLogger=DEBUG,Console + +log4j.appender.Console=org.apache.log4j.ConsoleAppender +log4j.appender.Console.layout=org.apache.log4j.PatternLayout +log4j.appender.Console.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n + +log4j.logger.org.apache.wicket=INFO +log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO +log4j.logger.org.apache.wicket.version=INFO +log4j.logger.org.apache.wicket.RequestCycle=INFO diff --git a/demo/app/src/main/resources/logging.properties b/demo/app/src/main/resources/logging.properties new file mode 100644 index 0000000..6fe7cef --- /dev/null +++ b/demo/app/src/main/resources/logging.properties @@ -0,0 +1,8 @@ +#handlers = java.util.logging.ConsoleHandler +handlers = org.slf4j.bridge.SLF4JBridgeHandler + +# Set the default logging level for the root logger +.level = ALL + +# Set the default formatter for new ConsoleHandler instances +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter diff --git a/demo/plugin1/plugin.properties b/demo/plugin1/plugin.properties new file mode 100644 index 0000000..9da9bcc --- /dev/null +++ b/demo/plugin1/plugin.properties @@ -0,0 +1,5 @@ +plugin.id=welcome-plugin +plugin.class=org.pf4j.demo.welcome.WelcomePlugin +plugin.version=0.0.1 +plugin.provider=Decebal Suiu +plugin.dependencies= diff --git a/demo/plugin1/pom.xml b/demo/plugin1/pom.xml new file mode 100644 index 0000000..10c1163 --- /dev/null +++ b/demo/plugin1/pom.xml @@ -0,0 +1,127 @@ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.pf4j.demo</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>pf4j-demo-plugin1</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Demo Plugin #1</name> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <version>1.0-alpha-2</version> + <executions> + <execution> + <phase>initialize</phase> + <goals> + <goal>read-project-properties</goal> + </goals> + <configuration> + <files> + <file>plugin.properties</file> + </files> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.6</version> + <executions> + <execution> + <id>unzip jar file</id> + <phase>package</phase> + <configuration> + <target> + <unzip src="target/${artifactId}-${version}.${packaging}" dest="target/plugin-classes" /> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.3</version> + <configuration> + <descriptors> + <descriptor> + src/main/assembly/assembly.xml + </descriptor> + </descriptors> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestEntries> + <Plugin-Id>${plugin.id}</Plugin-Id> + <Plugin-Class>${plugin.class}</Plugin-Class> + <Plugin-Version>${plugin.version}</Plugin-Version> + <Plugin-Provider>${plugin.provider}</Plugin-Provider> + <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.pf4j</groupId> + <artifactId>pf4j</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.pf4j.demo</groupId> + <artifactId>pf4j-demo-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + +</project> diff --git a/demo/plugin1/src/main/assembly/assembly.xml b/demo/plugin1/src/main/assembly/assembly.xml new file mode 100644 index 0000000..3fdc464 --- /dev/null +++ b/demo/plugin1/src/main/assembly/assembly.xml @@ -0,0 +1,37 @@ +<!-- + Describes the plugin archive + + @author Decebal Suiu + @version 1.0 +--> +<assembly> + <id>plugin</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <useProjectArtifact>false</useProjectArtifact> + <scope>runtime</scope> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*:jar:*</include> + </includes> + </dependencySet> + </dependencySets> + <!-- + <fileSets> + <fileSet> + <directory>target/classes</directory> + <outputDirectory>classes</outputDirectory> + </fileSet> + </fileSets> + --> + <fileSets> + <fileSet> + <directory>target/plugin-classes</directory> + <outputDirectory>classes</outputDirectory> + </fileSet> + </fileSets> +</assembly> diff --git a/demo/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java b/demo/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java new file mode 100644 index 0000000..22ebf7d --- /dev/null +++ b/demo/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012 Decebal Suiu + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with + * the License. You may obtain a copy of the License in the LICENSE file, or at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.pf4j.demo.welcome; + +import org.pf4j.Extension; +import org.pf4j.Plugin; +import org.pf4j.PluginWrapper; +import org.pf4j.demo.api.Greeting; + +/** + * @author Decebal Suiu + */ +public class WelcomePlugin extends Plugin { + + public WelcomePlugin(PluginWrapper wrapper) { + super(wrapper); + } + + public void start() { + System.out.println("WelcomePlugin.start()"); + } + + public void stop() { + System.out.println("WelcomePlugin.stop()"); + } + + @Extension + public static class WelcomeGreeting implements Greeting { + + public String getGreeting() { + return "Welcome"; + } + + } + +} diff --git a/demo/plugin2/plugin.properties b/demo/plugin2/plugin.properties new file mode 100644 index 0000000..60b6f33 --- /dev/null +++ b/demo/plugin2/plugin.properties @@ -0,0 +1,5 @@ +plugin.id=hello-plugin +plugin.class=org.pf4j.demo.hello.HelloPlugin +plugin.version=0.0.1 +plugin.provider=Decebal Suiu +plugin.dependencies= diff --git a/demo/plugin2/pom.xml b/demo/plugin2/pom.xml new file mode 100644 index 0000000..7f4f617 --- /dev/null +++ b/demo/plugin2/pom.xml @@ -0,0 +1,136 @@ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.pf4j.demo</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>pf4j-demo-plugin2</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Demo Plugin #2</name> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <version>1.0-alpha-2</version> + <executions> + <execution> + <phase>initialize</phase> + <goals> + <goal>read-project-properties</goal> + </goals> + <configuration> + <files> + <file>plugin.properties</file> + </files> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.6</version> + <executions> + <execution> + <id>unzip jar file</id> + <phase>package</phase> + <configuration> + <target> + <unzip src="target/${artifactId}-${version}.${packaging}" dest="target/plugin-classes" /> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.3</version> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor> + src/main/assembly/assembly.xml + </descriptor> + </descriptors> + <archive> + <manifestEntries> + <Plugin-Id>${plugin.id}</Plugin-Id> + <Plugin-Class>${plugin.class}</Plugin-Class> + <Plugin-Version>${plugin.version}</Plugin-Version> + <Plugin-Provider>${plugin.provider}</Plugin-Provider> + <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> + </manifestEntries> + </archive> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestEntries> + <Plugin-Id>${plugin.id}</Plugin-Id> + <Plugin-Class>${plugin.class}</Plugin-Class> + <Plugin-Version>${plugin.version}</Plugin-Version> + <Plugin-Provider>${plugin.provider}</Plugin-Provider> + <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.pf4j</groupId> + <artifactId>pf4j</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.pf4j.demo</groupId> + <artifactId>pf4j-demo-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + +</project> diff --git a/demo/plugin2/src/main/assembly/assembly.xml b/demo/plugin2/src/main/assembly/assembly.xml new file mode 100644 index 0000000..5cefe0d --- /dev/null +++ b/demo/plugin2/src/main/assembly/assembly.xml @@ -0,0 +1,37 @@ +<!-- + Describes the plugin archive + + @author Decebal Suiu + @version 1.0 +--> +<assembly> + <id>plugin</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <useProjectArtifact>false</useProjectArtifact> + <scope>runtime</scope> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*:jar:*</include> + </includes> + </dependencySet> + </dependencySets> + <!-- + <fileSets> + <fileSet> + <directory>target/classes</directory> + <outputDirectory>classes</outputDirectory> + </fileSet> + </fileSets> + --> + <fileSets> + <fileSet> + <directory>target/plugin-classes</directory> + <outputDirectory>classes</outputDirectory> + </fileSet> + </fileSets> +</assembly> diff --git a/demo/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java b/demo/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java new file mode 100644 index 0000000..ad7fd0c --- /dev/null +++ b/demo/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Decebal Suiu + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with + * the License. You may obtain a copy of the License in the LICENSE file, or at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.pf4j.demo.hello; + +import org.pf4j.Extension; +import org.pf4j.Plugin; +import org.pf4j.PluginWrapper; +import org.pf4j.demo.api.Greeting; + +/** + * A very simple plugin. + * + * @author Decebal Suiu + */ +public class HelloPlugin extends Plugin { + + public HelloPlugin(PluginWrapper wrapper) { + super(wrapper); + } + + public void start() { + System.out.println("HelloPlugin.start()"); + } + + public void stop() { + System.out.println("HelloPlugin.stop()"); + } + + @Extension + public static class HelloGreeting implements Greeting { + + public String getGreeting() { + return "Hello"; + } + + } + +} diff --git a/demo/pom.xml b/demo/pom.xml new file mode 100644 index 0000000..dbb029a --- /dev/null +++ b/demo/pom.xml @@ -0,0 +1,60 @@ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.pf4j</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.pf4j.demo</groupId> + <artifactId>pom</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>pom</packaging> + <name>PF4J Demo</name> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <build> + <resources> + <resource> + <filtering>false</filtering> + <directory>src/main/java</directory> + <excludes> + <exclude>**/*.java</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.6</source> + <target>1.6</target> + <optimize>true</optimize> + </configuration> + </plugin> + </plugins> + </build> + + <modules> + <module>app</module> + <module>api</module> + <module>plugin1</module> + <module>plugin2</module> + </modules> + +</project> |