Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.util
Class Extensions

java.lang.Object
  extended by ch.elexis.util.Extensions

public class Extensions
extends java.lang.Object

Vereinfachung der Handhabung von Extensions. Verschidene statische Methoden zum Auflisten von Extensionpoint.-clients 2008: Implementation eines Service-Providers

Author:
gerry

Constructor Summary
Extensions()
           
 
Method Summary
static java.lang.Object executeService(java.lang.Object service, java.lang.String method, java.lang.Class[] types, java.lang.Object[] params)
          Execute a method of the service actor, that is known by name and signature
static java.lang.Object findBestService(java.lang.String name)
          Shortcut for findBestService(name,null)
static java.lang.Object findBestService(java.lang.String name, java.lang.String variant)
          We sort of replicate the OSGi Service Registry, but place it on top of the Extension point system.
static java.util.List getClasses(java.util.List<IConfigurationElement> list, java.lang.String points)
          Deprecated. Use #getClasses(List,String,boolean) instead
static java.util.List getClasses(java.util.List<IConfigurationElement> list, java.lang.String points, boolean bMandatory)
          Eine Liste von bereits initialisierten Klassen liefern, die an einem bestimmten parameter eines bestimmten Extensionpoints hängen
static java.util.List getClasses(java.lang.String extension, java.lang.String points)
          Shortcut für getClasses(getExtensions(extension),points);
static java.util.List<IConfigurationElement> getExtensions(java.lang.String ext)
          EIne Liste von IConfigurationElements (=komplette Definition) liefern, die an einem bestimmten Extensionpoint hängen
static java.util.List<java.lang.Object> getServices(java.lang.String name, java.lang.String variant)
           
static java.util.List<java.lang.String> getStrings(java.util.List<IConfigurationElement> list, java.lang.String attr)
          Eine Liste von Werten liefern, die ein bestimmtest Attribut hat
static java.util.List<java.lang.String> getStrings(java.lang.String ext, java.lang.String attr)
           
static boolean isServiceAvailable(java.lang.String name)
          Ask whether a service is available.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extensions

public Extensions()
Method Detail

getExtensions

public static java.util.List<IConfigurationElement> getExtensions(java.lang.String ext)
EIne Liste von IConfigurationElements (=komplette Definition) liefern, die an einem bestimmten Extensionpoint hängen

Parameters:
ext - Name des Extensionpoints

getClasses

public static java.util.List getClasses(java.util.List<IConfigurationElement> list,
                                        java.lang.String points)
Deprecated. Use #getClasses(List,String,boolean) instead

Eine Liste von bereits initialisierten Klassen liefern, die an einem bestimmten parameter eines bestimmten Extensionpoints hängen

Parameters:
list - eine Liste, wie von getExtension geliefert
points - Name der Klasse
Returns:
eine Liste der konstruierten Klassen

getClasses

public static java.util.List getClasses(java.util.List<IConfigurationElement> list,
                                        java.lang.String points,
                                        boolean bMandatory)
Eine Liste von bereits initialisierten Klassen liefern, die an einem bestimmten parameter eines bestimmten Extensionpoints hängen

Parameters:
list - eine Liste, wie von getExtension geliefert
points - Name der Klasse
bMandatory - false: do not handle exceptions
Returns:
eine Liste der konstruierten Klassen

getClasses

public static java.util.List getClasses(java.lang.String extension,
                                        java.lang.String points)
Shortcut für getClasses(getExtensions(extension),points);


getStrings

public static java.util.List<java.lang.String> getStrings(java.util.List<IConfigurationElement> list,
                                                          java.lang.String attr)
Eine Liste von Werten liefern, die ein bestimmtest Attribut hat

Parameters:
list -
attr -
Returns:

getStrings

public static java.util.List<java.lang.String> getStrings(java.lang.String ext,
                                                          java.lang.String attr)

findBestService

public static java.lang.Object findBestService(java.lang.String name,
                                               java.lang.String variant)
We sort of replicate the OSGi Service Registry, but place it on top of the Extension point system. A Plugin can publish a service by accessing the ExtensionPoint ch.elexis.ServiceRegistry and defining a service with an arbitrary name. It must offer an Object declared as "actor" that performs the service. The Methods to use must be documented. (@see executeService) A different plugin can implement the same Service "better" by using the same name but declaring a higher "value" A Client can retrieve and use Services through isServiceAvailable() and findBestService()

Parameters:
name - name of the service to load
variant - the variant wanted. Can be null to indicate don't mind
Returns:
the actor-Object that the "best" Service with this name offers or null if no service with the given name could be loaded.

getServices

public static java.util.List<java.lang.Object> getServices(java.lang.String name,
                                                           java.lang.String variant)

findBestService

public static java.lang.Object findBestService(java.lang.String name)
Shortcut for findBestService(name,null)


executeService

public static java.lang.Object executeService(java.lang.Object service,
                                              java.lang.String method,
                                              java.lang.Class[] types,
                                              java.lang.Object[] params)
Execute a method of the service actor, that is known by name and signature

Parameters:
service - The service actor as returned by findBestService()
method - the name of the method to be called
types - the parameter types
params - the parameters
Returns:
an Object that ist implementation dependent or null if the method call failed. It is recommended that an actor returns a ch.elexis.Result to allow error handling.

isServiceAvailable

public static boolean isServiceAvailable(java.lang.String name)
Ask whether a service is available. The call is cheap because no Object will be instantaniated. Note: If this call returns true, a call to findBestService() might still return null, because a Service might have gone unavailable in the meantime.

Parameters:
name - the name of the service to find.
Returns:
true if at least one implementation of a service with the given name is registered

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis