Changes between Version 16 and Version 17 of PluginDevelopmentGuide


Ignore:
Timestamp:
15.04.2013 00:17:34 (12 years ago)
Author:
jri
Comment:

The plugin main file

Legend:

Unmodified
Added
Removed
Modified
  • PluginDevelopmentGuide

    v16 v17  
    583583 
    584584Weather a DeepaMehta plugin has a server side part at all depends on the nature of the plugin. Plugins without a server side part include those which e.g. just define a data model or just provide a custom (JavaScript) renderer. 
     585 
     586=== The plugin main file === 
     587 
     588You must write a //plugin main file// if your plugin needs to a) listen to DeepaMehta Core events and/or b) provide a service. The plugin main file contains the event handling code resp. the implementation of the service methods then. A plugin main file is a Java class that is derived from `de.deepamehta.core.osgi.PluginActivator`. 
     589 
     590The plugin main file must be located directly in the plugin's `src/main/java/<your plugin package>/` directory. By convention the plugin main class ends with `Plugin`. 
     591 
     592Example: 
     593 
     594{{{ 
     595#!txt 
     596dm4-mycoolplugin/ 
     597    src/ 
     598        main/ 
     599            java/ 
     600                org/ 
     601                    mydomain/ 
     602                        deepamehta4/ 
     603                            mycoolplugin/ 
     604                                MyCoolPlugin.java 
     605}}} 
     606 
     607Here the plugin package is `org.mydomain.deepamehta4.mycoolplugin` and the plugin main class is `MyCoolPlugin`. 
     608 
     609Furthermore you must add 2 entries in the plugin's **`pom.xml`**: 
     610    1. A <dependencies> element to include the `deepamehta-core` dependency. This is needed as your plugin main file requires the `PluginActivator` class. 
     611    2. a <build> element to configure the Maven Bundle Plugin. It needs to know what your plugin's main class is. You must specify its fully-qualified class name. 
     612 
     613{{{ 
     614#!xml 
     615<project> 
     616    <modelVersion>4.0.0</modelVersion> 
     617 
     618    <name>My Cool Plugin</name> 
     619    <groupId>org.mydomain.dm4</groupId> 
     620    <artifactId>my-cool-plugin</artifactId> 
     621    <version>0.1-SNAPSHOT</version> 
     622    <packaging>bundle</packaging> 
     623 
     624    <parent> 
     625        <groupId>de.deepamehta</groupId> 
     626        <artifactId>deepamehta-plugin-parent</artifactId> 
     627        <version>4.1.1-SNAPSHOT</version> 
     628    </parent> 
     629 
     630    <dependencies> 
     631        <dependency> 
     632            <groupId>de.deepamehta</groupId> 
     633            <artifactId>deepamehta-core</artifactId> 
     634            <version>4.1.1-SNAPSHOT</version> 
     635        </dependency> 
     636    </dependencies> 
     637 
     638    <build> 
     639        <plugins> 
     640            <plugin> 
     641                <groupId>org.apache.felix</groupId> 
     642                <artifactId>maven-bundle-plugin</artifactId> 
     643                <configuration> 
     644                    <instructions> 
     645                        <Bundle-Activator> 
     646                            org.mydomain.deepamehta4.mycoolplugin.MyCoolPlugin 
     647                        </Bundle-Activator> 
     648                    </instructions> 
     649                </configuration> 
     650            </plugin> 
     651        </plugins> 
     652    </build> 
     653</project> 
     654}}}