Interface IPluginContext

All Superinterfaces:
org.apache.wicket.util.io.IClusterable, Serializable
All Known Implementing Classes:
ServiceContext

public interface IPluginContext extends org.apache.wicket.util.io.IClusterable
The main interface for a plugin to communicate with other plugins. It can be used to register, retrieve and track services. Furthermore, it gives plugins the possibility to start clusters of new plugins.

In general, services may come and go at any time. It is therefore not allowed to hold on to references to services, unless a IServiceTracker is used to clean up when the service disappears.

There are some exceptions to the above rule; some services are provided by the framework and may therefore be assumed to always exist. These are

  • a IDialogService with name service.dialog
  • an observable registry that tracks IObserver services that register under the name org.hippoecm.frontend.model.event.IObserver
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends org.apache.wicket.util.io.IClusterable>
    IServiceReference<T>
    getReference(T service)
    Retrieve a reference that can be stored in a page that is different from the one that contains the plugin.
    <T extends org.apache.wicket.util.io.IClusterable>
    T
    getService(String name, Class<T> clazz)
    Retrieve a service.
    <T extends org.apache.wicket.util.io.IClusterable>
    List<T>
    getServices(String name, Class<T> clazz)
    Retrieve the full list of services that registered under the service name and that are instances of the class.
    newCluster(IClusterConfig template, IPluginConfig parameters)
    Create a new cluster of plugins.
    void
    registerService(org.apache.wicket.util.io.IClusterable service, String name)
    Registers a service with the given name.
    void
    registerTracker(IServiceTracker<? extends org.apache.wicket.util.io.IClusterable> listener, String name)
    Registers a service tracker with the given name.
    void
    unregisterService(org.apache.wicket.util.io.IClusterable service, String name)
    Unregisters a service from the given name.
    void
    unregisterTracker(IServiceTracker<? extends org.apache.wicket.util.io.IClusterable> listener, String name)
    Unregisters a service tracker with the given name.
  • Method Details

    • newCluster

      IClusterControl newCluster(IClusterConfig template, IPluginConfig parameters)
      Create a new cluster of plugins. The template specifies what services are provided, what services are used and what additional properties can be set for the cluster. The parameters specify the values that are required to create a cluster from the template.

      Note that clusters that are started during the construction phase will not be able to reference services that have been created in the same phase.

      Parameters:
      template - A cluster template, i.e. a configuration hierarchy whose variables have not yet been expanded. The template contains values such as "${myparam}" that will be expanded.
      parameters - The values for the variables in the template.
    • getService

      <T extends org.apache.wicket.util.io.IClusterable> T getService(String name, Class<T> clazz)
      Retrieve a service. The first service that registered under the service name and that is an instance of the class, is returned. Always use an interface for the class name.
    • getServices

      <T extends org.apache.wicket.util.io.IClusterable> List<T> getServices(String name, Class<T> clazz)
      Retrieve the full list of services that registered under the service name and that are instances of the class. The list is immutable and will not be updated by the system. To receive notifications when services (un)register, use an IServiceTracker.
    • getReference

      <T extends org.apache.wicket.util.io.IClusterable> IServiceReference<T> getReference(T service)
      Retrieve a reference that can be stored in a page that is different from the one that contains the plugin. It is necessary to use these when communicating across pages, e.g. as in the case of a non-ajax modal window.

      Since the service reference contains a unique id for the service, it can also be used to construct unique service names.

    • registerService

      void registerService(org.apache.wicket.util.io.IClusterable service, String name)
      Registers a service with the given name. A service can be registered under multiple names.
    • unregisterService

      void unregisterService(org.apache.wicket.util.io.IClusterable service, String name)
      Unregisters a service from the given name. If the service has been registered under other names as well, it will still be available under those.
    • registerTracker

      void registerTracker(IServiceTracker<? extends org.apache.wicket.util.io.IClusterable> listener, String name)
      Registers a service tracker with the given name.
    • unregisterTracker

      void unregisterTracker(IServiceTracker<? extends org.apache.wicket.util.io.IClusterable> listener, String name)
      Unregisters a service tracker with the given name.