Core: redesign server-side hook mechanism (#261).

Plugins implement listener interfaces instead of overriding hook methods.

IMPORTANT: developers must adapt their plugins.

The required changes are quite minor. For each used hook a dedicated listener interface must be imported and implemented. The existing hook method can still act as the listener implementation. Only the method name changes slightly (the "Hook" wording is obsolete). The registration of the listeners is performed automatically by the framework by reflecting the implemented interfaces.

See the postCreateHook() of the Workspaces plugin as an example:

Old code:

    public class WorkspacesPlugin extends Plugin implements WorkspacesService {

        @Override
        public void postCreateHook(Topic topic, ClientState clientState, Directives directives) {
            ...
        }
    }

New code:

    import de.deepamehta.core.service.listeners.PostCreateTopicListener;

    public class WorkspacesPlugin extends Plugin implements WorkspacesService, PostCreateTopicListener {

        @Override
        public void postCreateTopic(Topic topic, ClientState clientState, Directives directives) {
            ...
        }
    }

The core service API has 2 new methods:
    List<Object> fireEvent(CoreEvent event, Object... params);
    void addListener(CoreEvent event, Listener listener);

These are usually not to be called by the plugin developer.

For the moment only the postCreateHook() is transformed.
The other hooks will follow.

See ticket 261.
Core: transform 7 more hooks to listeners (#261).

Old Hook Method           New Listener Method        Listener Interface
----------------------------------------------------------------------------------
preCreateHook             -> preCreateTopic          PreCreateTopicListener

preUpdateHook             -> preUpdateTopic          PreUpdateTopicListener
postUpdateHook            -> postUpdateTopic         PostUpdateTopicListener

preDeleteAssociationHook  -> preDeleteAssociation    PreDeleteAssociationListener
postDeleteAssociationHook -> postDeleteAssociation   PostDeleteAssociationListener

preSendTopicHook          -> preSendTopic            PreSendTopicListener
preSendTopicTypeHook      -> preSendTopicType        PreSendTopicTypeListener
----------------------------------------------------------------------------------

2 hooks from DM3 are removed:
    providePropertiesHook(Topic topic)
    providePropertiesHook(Association assoc)

7 more hooks are pending.

See ticket 261.
Core: internal events (#261).

A plugin can send an event to itself.
This is needed for the events (hook formerly) that are bound to a particular plugin (instead of fired globally):
    - postInstallPluginHook
    - modifyTopicTypeHook
    - serviceArrived
    - serviceGone

Transformed 1 more hook into a listener:

Old Hook Method           New Listener Method        Listener Interface
----------------------------------------------------------------------------------
postInstallPluginHook     -> postInstallPlugin       PostInstallPluginListener
----------------------------------------------------------------------------------

Package renamed to ...service.listener (instead ...service.listeners)

6 more hooks are pending.

See ticket 261.
Core: all hooks transformed into listeners (#261).

Transformed 5 hooks:

Old Hook Method           New Listener Method        Listener Interface
----------------------------------------------------------------------------------
postRetypeAssociationHook -> postRetypeAssociation   PostRetypeAssociationListener
allPluginsReadyHook       -> allPluginsReady         AllPluginsReadyListener
modifyTopicTypeHook       -> introduceTopicType      IntroduceTopicTypeListener
serviceArrived            -> serviceArrived          ServiceArrivedListener
serviceGone               -> serviceGone             ServiceGoneListener
----------------------------------------------------------------------------------

Removed 1 hook:
    executeCommandHook()

Plugin hot deployment doesn't work yet.

Removed 1 core service call:
    executeCommand()
The "Commands" concept is obsolete and will be dropped.

Note: the Commands related code is not yet dropped as it still provides a working file uplaod implementation. See:
    de.deepamehta.plugins.webservice.WebservicePlugin#executeCommand()
    de.deepamehta.plugins.webservice.provider.CommandParamsProvider
    de.deepamehta.core.util.UploadedFile

See ticket 261.
Core: fix closing service trackers (#261).

We close the service trackers in reverse creation order.
Consider this case: when a consumed plugin service goes away the core service is still needed to deliver the SERVICE_GONE event.

Plugin redeployment still doesn't work properly.

See ticket 261.
Core: unregister event listeners (#261).

When a plugin is stopped it unregisters its event listeners.

Plugin hot redeployment works.

Technically the listeners are fully functional.
The old hook concept and code is now obsolete.

Removal of unused code and code cleanup is pending.

See ticket 261.
Core: remove unused code and cleanup (#261).

See ticket 261.
Core: fix plugin and service tracking (#261).

Plugin redeployment and container shutdown works properly.

Two groups of services are distinguished: a) the 3 "core services" (dms, web publishing, and event admin), and b) the "plugin services" as provided by plugins.
Once the dms is removed from a plugin the trackers of the consumed plugin services are closed. This is necessary because the dms is still needed to deliver the respective SERVICE_GONE events. Once the dms arrives the trackers are opened.

Simplification of plugin dependency tracking: plugin concept of being "ready" is now equivalent with being "registered" (at the core). No separate semantic anymore. No double bookkeeping.

See ticket 261.
Core: rename some events (#261).

3 core events are renamed:
    SERVICE_ARRIVED   -> PLUGIN_SERVICE_ARRIVED
    SERVICE_GONE      -> PLUGIN_SERVICE_GONE
    ALL_PLUGINS_READY -> ALL_PLUGINS_ACTIVE
The listener interfaces and and handler methods are renamed accordingly.

1 internal OSGi event is renamed:
    PLUGIN_READY      -> PLUGIN_ACTIVATED

See ticket 261.