Class PluginActivator

java.lang.Object
de.elo.ix.client.plugin.PluginActivator
All Implemented Interfaces:
VersionHistory, org.osgi.framework.BundleActivator

public abstract class PluginActivator extends Object implements org.osgi.framework.BundleActivator, VersionHistory
This class can be used as base class for a custom plugin. A custom plugin Activator class can look like this e.g.:

 
 public class MyActivator extends PluginActivator {
   public void start(BundleContext context) throws Exception {
     // Always call start() of super class.
     super.start(context);
     // Register IXServerEvents implementation class:
     registerService(IXServerEvents.class, new IXServerEventsImpl(this));
   }   
 }   
 
 
  • Field Details

    • serviceRegistrations

      protected final List<de.elo.ix.client.plugin.PluginActivator.ClassAndServiceRegistration> serviceRegistrations
      Registration of interface implementations provided by this plugin. Invoke function registerService(Class, Object) in order to register a service with OGSi.
    • hostServiceTracker

      protected volatile org.osgi.util.tracker.ServiceTracker<HostService,HostService> hostServiceTracker
      Tracker to receive the HostService interface provided by Indexserver.
    • context

      protected volatile org.osgi.framework.BundleContext context
      OSGi bundle context.
  • Constructor Details

    • PluginActivator

      public PluginActivator()
  • Method Details

    • start

      public void start(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      start in interface org.osgi.framework.BundleActivator
      Throws:
      Exception
    • registerService

      public void registerService(Class<?> interfaceClass, Object interfaceImplementation)
      Register a service implementation.
      Parameters:
      interfaceClass - Class object of service interface, e.g. IXServerEvents.class.
      interfaceImplementation - Service object that implements interfaceClass.
    • unregisterService

      public void unregisterService(Class<?> interfaceClass)
      Unregister the service with the given interface.
      Parameters:
      interfaceClass - Service interface.
    • stop

      public void stop(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      stop in interface org.osgi.framework.BundleActivator
      Throws:
      Exception
    • getHostService

      public HostService getHostService()
      Get Indexserver's HostService interface.
      Returns:
      HostService interface.
    • getScriptObjectFactory

      public ScriptObjectFactory getScriptObjectFactory(IXServerEventsContext ec)
      Get Indexserver's ScriptObjectFactory interface. This function internally calls getHostService() and HostService.getScriptObjectFactory(IXServerEventsContext).
      Parameters:
      ec - Execution context.
      Returns:
      ScriptObjectFactory interface. Must be closed after use.
    • getScriptObjectFactoryAdmin

      public ScriptObjectFactory getScriptObjectFactoryAdmin()
      Get Indexserver's ScriptObjectFactory interface. This function internally calls getScriptObjectFactory(IXServerEventsContext) passing IXServerEventsContext.ADMIN_CONTEXT.
      Returns:
      ScriptObjectFactory interface. Must be closed after use.
    • getScriptObjectFactoryFromClientInfo

      public ScriptObjectFactory getScriptObjectFactoryFromClientInfo(ClientInfo ci)
      Get Indexserver's ScriptObjectFactory interface based on the given ClientInfo.
      Parameters:
      ci - ClientInfo, at least member ticket should be valid.
      Returns:
      ScriptObjectFactory interface. Must be closed after use.
    • getIxConnect

      public IXConnection getIxConnect(IXServerEventsContext ec)
      Get connection object for user attached to the given execution context. This function internally calls ScriptObjectFactory.getIxConnect().
      Parameters:
      ec - Execution context.
      Returns:
      IXConnection object.
      Throws:
      UncheckedRemoteException
    • getIxConnectAdmin

      public IXConnection getIxConnectAdmin()
      Get connection object with administrator permissions. This function internally calls ScriptObjectFactory.getIxConnectAdmin().
      Returns:
      IXConnection object.
      Throws:
      UncheckedRemoteException
    • getIxConnect

      public IXConnection getIxConnect(ClientInfo ci)
      Get connection object initialized with the given ClientInfo.
      Parameters:
      ci - ClientInfo, at least member ticket should be valid.
      Returns:
      IXConnection object.
      Throws:
      UncheckedRemoteException
    • getDBConnection

      public DBConnection getDBConnection(IXServerEventsContext ec)
      Get DB connection for the current archive database. This function internally calls ScriptObjectFactory.getDBConnection().
      Parameters:
      ec - Execution context.
      Returns:
      DBConnection object.
      Throws:
      UncheckedRemoteException
    • getDBConnectionForDataSource

      public DBConnection getDBConnectionForDataSource(IXServerEventsContext ec, String dataSource)
      Get DB connection for the given data source. The data source has to be declared in Tomcat's context.xml file. More information can be found at DBConnection This function internally calls ScriptObjectFactory.getDBConnectionForDataSource(String).
      Parameters:
      ec - Execution context.
      Returns:
      DBConnection object.
      Throws:
      UncheckedRemoteException
    • throwException

      public void throwException(String s) throws byps.RemoteException
      Throws an exception with given message. Throws an exception with code IXExceptionC.SCRIPT_ERROR.
      Parameters:
      s -
      Throws:
      byps.RemoteException
    • throwException

      public void throwException(int code, String s) throws byps.RemoteException
      Throws an exception with the given code and message.
      Parameters:
      code - Exception code, one of the constants in IXExceptionC.
      s - Message
      Throws:
      byps.RemoteException
    • throwException

      public void throwException(int code, String s, Throwable e) throws byps.RemoteException
      Throws an exception with the given code, message and cause.
      Parameters:
      code - Exception code, one of the constants in IXExceptionC.
      s - Message
      e - Cause
      Throws:
      byps.RemoteException
    • getIxConnect

      public IXConnection getIxConnect(jakarta.servlet.http.HttpServletRequest request)
      Get the IXConnection object provided by Indexserver in a HTTP request. This function can be used by the plugin's implementation of a jakarta.servlet.Servlet to receive an IXConnection object e.g. created by authentication via SSO.

      If the request URI addresses /ix-archive/plugin-auth, a SSO authentication is performed and the returned connection represents a session for the authenticated user. The returned IXConnection object should be closed before the HTTP session expires in order to save resources.

      If the request URL is /ix-archive/manager/plugin, the user is authenticated against Tomcat Manager role and an administrative connection is returned. The returned IXConnection object should be closed before the HTTP session expires in order to save resources.

      If the request URL is /ix-archive/plugin and a cookie or parameter named "ticket" is supplied, a connection is created for this ticket. If neither matches the three cases, the function returns null. Closing this connection has no effect.

      Parameters:
      request -
      Returns:
      IXConnection or null.
    • getResourceBundle

      public ResourceBundle getResourceBundle(IXServerEventsContext ec)
      Get internal text resources.
      Parameters:
      ec - Execution context.
      Returns:
      ResourceBundle object.
    • getSymbolicName

      public String getSymbolicName()
      Get plugin ID, Bundle-SymbolicName from manifest.
      Returns:
      ID
    • getPluginName

      public String getPluginName()
      Get plugin name, Bundle-Name from manifest.
      Returns:
      Plugin name
    • getPluginVersion

      public String getPluginVersion()
      Get Bundle-Version from manifest.
      Returns:
      Version
    • getBundleProperty

      public String getBundleProperty(String key)
      Get a property from the bundle's manifest.
      Parameters:
      key - Property key.
      Returns:
      Property value.
    • getHistory

      public PluginHistory getHistory() throws IOException
      Description copied from interface: VersionHistory
      Read version history in given format.
      Specified by:
      getHistory in interface VersionHistory
      Returns:
      Version history in text format. This text is rendered as pre-formatted text in a HTML page.
      Throws:
      IOException
    • getHistoryName

      public String getHistoryName()
    • setHistoryName

      public void setHistoryName(String historyName)