Changes between Version 6 and Version 7 of AnotherPluginDevelopmentGuide


Ignore:
Timestamp:
09.07.2012 17:01:53 (12 years ago)
Author:
dgf
Comment:

adapt API changes and link javadoc

Legend:

Unmodified
Added
Removed
Modified
  • AnotherPluginDevelopmentGuide

    v6 v7  
    88DeepaMehta provides a framework for the plugin developer which has: 
    99 
    10  * Access to the DeepaMehta Core service. 
     10 * Access to the [http://www.deepamehta.de/apidocs/deepamehta/4.0.12/de/deepamehta/core/service/DeepaMehtaService.html DeepaMehtaService]. 
    1111 * OSGi handling. 
    1212 * Migration management. 
     
    266266 
    267267Real migrations of existing data can be written in Java, you have fully access 
    268 to the DeepaMehtaService. 
     268to the [http://www.deepamehta.de/apidocs/deepamehta/4.0.12/de/deepamehta/core/service/DeepaMehtaService.html DeepaMehtaService]. 
    269269 
    270270Programmatic plugin migration example: 
     
    342342        var name = prompt('Example name', 'Another Example') 
    343343            topic = dm4c.restc.request('POST', '/example/create', { name: name }) 
    344         dm4c.canvas.add_topic(topic, true) 
    345         dm4c.do_select_topic(topic.id) 
     344        dm4c.show_topic(topic, 'show', null, true) 
    346345    } 
    347346 
     
    350349        var url = '/example/increase/' + dm4c.selected_object.id, 
    351350            topic = dm4c.restc.request('GET', url) 
    352         dm4c.canvas.update_topic(topic, true) 
    353         dm4c.do_select_topic(topic.id) 
     351        dm4c.show_topic(topic, 'show', null, true) 
    354352    } 
    355353 
    356354    // define type specific commands and register them  
    357     dm4c.register_listener('topic_commands', function (topic) { 
     355    dm4c.add_listener('topic_commands', function (topic) { 
    358356        return topic.type_uri !== 'dm4.example.type' ? [] : [{ 
    359357            context: ['context-menu', 'detail-panel-show'], 
     
    362360    }) 
    363361 
    364     // register a additional create command 
    365     dm4c.register_listener("post_refresh_create_menu", function(type_menu) { 
     362    // register an additional create command 
     363    dm4c.add_listener("post_refresh_create_menu", function(type_menu) { 
    366364        type_menu.add_separator() 
    367365        type_menu.add_item({ label: "New Example", handler: createAnotherExample }) 
     
    575573== Plugin == #plugin 
    576574 
    577 A Java plugin can interact with predefined hook overwrites and export  a OSGi service 
    578 with optional REST exposure. 
    579  
    580 All public methods of the plugin must be described in a service interface: 
     575A Java plugin can interact by implementing of listener and export a OSGi service 
     576with optional REST exposure. The listener contain topic CRUD (create, retype, update, delete)  
     577interaction and plugin lifecycle management, see package 
     578[http://www.deepamehta.de/apidocs/deepamehta/4.0.12/de/deepamehta/core/service/listener/package-summary.html de.deepamehta.core.service.listener]. 
     579 
     580All public methods of your plugin service must be described in a service interface that extends 
     581[http://www.deepamehta.de/apidocs/deepamehta/4.0.12/de/deepamehta/core/service/PluginService.html PluginService]: 
    581582{{{#!java 
    582583package de.deepamehta.plugins.example.service; 
     
    596597}}} 
    597598 
    598 '''TBD''' rewrite hook calls in favour of listener interface per event 
    599  
    600 The plugin itself can expose methods with  
    601 [http://jersey.java.net/nonav/documentation/latest/jax-rs.html JAX-RS] annotations: 
     599 
     600Implementing a plugin requires a derivation of 
     601[http://www.deepamehta.de/apidocs/deepamehta/4.0.12/de/deepamehta/core/osgi/PluginActivator.html PluginActivator], 
     602the plugin itself can expose methods with [http://jersey.java.net/nonav/documentation/latest/jax-rs.html JAX-RS] annotations: 
    602603{{{#!java 
    603604package de.deepamehta.plugins.example; 
    604605 
    605606import java.util.logging.Logger; 
    606 import javax.ws.rs.*; 
     607 
     608import javax.ws.rs.GET; 
     609import javax.ws.rs.HeaderParam; 
     610import javax.ws.rs.POST; 
     611import javax.ws.rs.Path; 
     612import javax.ws.rs.PathParam; 
     613import javax.ws.rs.Produces; 
     614import javax.ws.rs.WebApplicationException; 
    607615 
    608616import de.deepamehta.core.model.TopicModel; 
     617import de.deepamehta.core.osgi.PluginActivator; 
    609618import de.deepamehta.core.service.ClientState; 
    610 import de.deepamehta.core.service.Plugin; 
     619import de.deepamehta.core.service.listener.PreCreateTopicListener; 
    611620import de.deepamehta.plugins.example.model.Example; 
    612621import de.deepamehta.plugins.example.model.ExampleTopic; 
     
    615624@Path("/example") 
    616625@Produces("application/json") 
    617 public class ExamplePlugin extends Plugin implements ExampleService { 
     626public class ExamplePlugin extends PluginActivator implements ExampleService, 
     627        PreCreateTopicListener { 
    618628 
    619629    private Logger log = Logger.getLogger(getClass().getName()); 
     
    624634     */ 
    625635    @Override 
    626     public void preCreateHook(TopicModel model, ClientState clientState) { 
    627         if (model.getTypeUri().equals(ExampleTopic.TYPE)) { 
    628             log.info("init Example count of " 
    629                     + model.getCompositeValue().getString(ExampleTopic.NAME)); 
    630             model.getCompositeValue().put(ExampleTopic.COUNT, 0); 
     636    public void preCreateTopic(TopicModel model, ClientState clientState) { 
     637        if (model.getTypeUri().equals(ExampleTopic.COUNT)) { 
     638            log.info("init Example count"); 
     639            model.setSimpleValue(0); 
    631640        } 
    632641    } 
    633642 
    634643    /** 
    635      * Creates a new <code>Example</code> instance based on 
    636      * <code>ExampleTopic</code> model. 
     644     * Creates a new <code>Example</code> instance based on the domain specific 
     645     * REST call with a alternate JSON topic representation. 
    637646     */ 
    638647    @POST 
     
    649658 
    650659    /** 
    651      * Increase the count of a attached <code>Example</code> topic. 
     660     * Increase the count of an attached <code>Example</code> topic. 
    652661     */ 
    653662    @GET