Changes between Version 20 and Version 21 of PluginDevelopmentGuide
- Timestamp:
- 20.04.2013 18:17:53 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PluginDevelopmentGuide
v20 v21 733 733 ==== The service interface ==== 734 734 735 For a plugin to provide a service you must define a //service interface//. The service interface contains all the method signatures that make up the service. When other plugins consume your plugin's service they do so via itsservice interface.735 For a plugin to provide a service you must define a //service interface//. The service interface contains all the method signatures that make up the service. When other plugins consume your plugin's service they do so via the service interface. 736 736 737 737 The service interface //must// be located in the plugin's `src/main/java/<your plugin package>/service/` directory. By convention the name of the service interface ends with `...Service`. The service interface must be declared `public`. … … 739 739 The service interface is a regular Java interface that extends `de.deepamehta.core.service.PluginService`. PluginService is a common base interface for all plugin services. It's just a marker interface. 740 740 741 As an example look at the //Topicmaps// plugin (part of the DeepaMehta Standard Distribution): 741 A DeepaMehta plugin can define //one// service interface at most. More than one service interface is not supported. 742 743 As an example see the //Topicmaps// plugin (part of the DeepaMehta Standard Distribution): 742 744 743 745 {{{ … … 805 807 806 808 You see the Topicmaps service consist of methods to create topicmaps, retrieve topicmaps, and manipulate topicmaps. As any plugin service the Topicmaps service must be derived from `PluginService`. 809 810 ==== Implementing the service ==== 811 812 After defining the plugin's service interface you must implement the actual service methods. Implementation takes place in the plugin main file. 813 814 The plugin main class must declare that it implements the plugin's service interface. (So you need to import the service interface.) Each service method implementation must be `public`. Annotate each service method implementation with `@Override`. 815 816 As an example see the implementation of the //Topicmaps// service: 817 818 {{{ 819 #!java 820 package de.deepamehta.plugins.topicmaps; 821 822 import de.deepamehta.plugins.topicmaps.model.Topicmap; 823 import de.deepamehta.plugins.topicmaps.service.TopicmapsService; 824 825 import de.deepamehta.core.Topic; 826 import de.deepamehta.core.osgi.PluginActivator; 827 import de.deepamehta.core.service.ClientState; 828 829 830 831 public class TopicmapsPlugin extends PluginActivator implements TopicmapsService { 832 833 // *** TopicmapsService Implementation *** 834 835 @Override 836 public Topic createTopicmap(String name, String topicmapRendererUri, ClientState clientState) { 837 ... 838 } 839 840 @Override 841 public Topic createTopicmap(String name, String uri, String topicmapRendererUri, ClientState clientState) { 842 ... 843 } 844 845 // --- 846 847 @Override 848 public Topicmap getTopicmap(long topicmapId, ClientState clientState) { 849 ... 850 } 851 852 // --- 853 854 @Override 855 public void addTopicToTopicmap(long topicmapId, long topicId, int x, int y) { 856 ... 857 } 858 859 ... 860 }}} 861 862 You see, the plugin main class `TopicmapsPlugin` implements the plugin's service interface `TopicmapsService`.