Class IOExtensionPoint
- All Implemented Interfaces:
Proxy
GIOExtensionPoint provides a mechanism for modules to extend the
functionality of the library or application that loaded it in an
organized fashion.
An extension point is identified by a name, and it may optionally
require that any implementation must be of a certain type (or derived
thereof). Use register(java.lang.String) to register an
extension point, and setRequiredType(org.gnome.glib.Type) to
set a required type.
A module can implement an extension point by specifying the
GObject.Type that implements the functionality. Additionally, each
implementation of an extension point has a name, and a priority. Use
implement(java.lang.String, org.gnome.glib.Type, java.lang.String, int) to implement an extension point.
GIOExtensionPoint *ep;
// Register an extension point
ep = g_io_extension_point_register ("my-extension-point");
g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
// Implement an extension point
G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE)
g_io_extension_point_implement ("my-extension-point",
my_example_impl_get_type (),
"my-example",
10);
It is up to the code that registered the extension point how it uses the implementations that have been associated with it. Depending on the use case, it may use all implementations, or only the one with the highest priority, or pick a specific one by name.
To avoid opening all modules just to find out what extension points they implement, GIO makes use of a caching mechanism, see gio-querymodules. You are expected to run this command after installing a GIO module.
The GIO_EXTRA_MODULES environment variable can be used to
specify additional directories to automatically load modules
from. This environment variable has the same syntax as the
PATH. If two modules have the same base name in different
directories, then the latter one will be ignored. If additional
directories are specified GIO will load modules from the built-in
directory last.
-
Constructor Summary
ConstructorsConstructorDescriptionIOExtensionPoint(MemorySegment address) Create a IOExtensionPoint proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptiongetExtensionByName(String name) Finds aGIOExtensionfor an extension point by name.Gets a list of all extensions that implement this extension point.Gets the required type forextensionPoint.static IOExtensionRegisterstypeas extension for the extension point with nameextensionPointName.static IOExtensionPointLooks up an existing extension point.static IOExtensionPointRegisters an extension point.voidsetRequiredType(Type type) Sets the required type for this IOExtensionPoint totype.All implementations must henceforth have this type.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
IOExtensionPoint
Create a IOExtensionPoint proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
implement
public static IOExtension implement(String extensionPointName, Type type, String extensionName, int priority) Registerstypeas extension for the extension point with nameextensionPointName.If
typehas already been registered as an extension for this extension point, the existingGIOExtensionobject is returned.- Parameters:
extensionPointName- the name of the extension pointtype- theGTypeto register as extensionextensionName- the name for the extensionpriority- the priority for the extension- Returns:
- a
GIOExtensionobject forGType
-
lookup
Looks up an existing extension point.- Parameters:
name- the name of the extension point- Returns:
- the
GIOExtensionPoint, ornullif there is no registered extension point with the given name.
-
register
Registers an extension point.- Parameters:
name- The name of the extension point- Returns:
- the new
GIOExtensionPoint. This object is owned by GIO and should not be freed.
-
getExtensionByName
Finds aGIOExtensionfor an extension point by name.- Parameters:
name- the name of the extension to get- Returns:
- the
GIOExtensionfor this IOExtensionPoint that has the given name, ornullif there is no extension with that name
-
getExtensions
Gets a list of all extensions that implement this extension point. The list is sorted by priority, beginning with the highest priority.- Returns:
- a
GListofGIOExtensions. The list is owned by GIO and should not be modified.
-
getRequiredType
Gets the required type forextensionPoint.- Returns:
- the
GTypethat all implementations must have, orG_TYPE_INVALIDif the extension point has no required type
-
setRequiredType
Sets the required type for this IOExtensionPoint totype.All implementations must henceforth have this type.- Parameters:
type- theGTypeto require
-