public final class AdapterFabric extends java.lang.Object
An adapter object inherits from a parent class or java.lang.Object
, implements a set of specified
interfaces, and provides method implementation / overrides defined by Golo closures.
Adapter instance makers are created based on a configuration that is defined by a simple collections-based
representation where the root is a java.util.Map
instance with keys:
extends
: a string for the parent class, java.lang.Object
if not specified,interfaces
: a java.lang.Iterable
of strings specifying which interfaces to implement,implements
: points to a map where keys are strings of method names to implement, and values are the
implementation closures, overrides
: same as a implements
to provides overrides.The signature for closures is as follows:
|receiver, argument1, argument2|
(and so on),|handle_in_superclass, receiver, argument1, argument2|
(and so on).Star implementations or overrides can also be provided, in which case any unimplemented or not overridden method is dispatched to the provided closure. Note that both a star implementation and a star override cannot be defined. The signatures are as follows.
|method_name, arguments_array|
,|handle_in_superclass, method_name, arguments_array|
.It is important to note that adapters are useful for interoperability with 3rd-party Java code, as that allow passing adequate objects from Golo to such libraries. Their usage for pure Golo code is discouraged.
Modifier and Type | Class and Description |
---|---|
static class |
AdapterFabric.Maker
An adapter maker can produce instances of Golo adapter objects.
|
Constructor and Description |
---|
AdapterFabric()
Makes an adapter fabric whose parent is the current thread context classloader.
|
AdapterFabric(java.lang.ClassLoader classLoader)
Makes an adapter fabric using a classloader.
|
Modifier and Type | Method and Description |
---|---|
AdapterFabric.Maker |
maker(java.util.Map<java.lang.String,java.lang.Object> configuration)
Provides an instance maker based on an adapter definition.
|
static AdapterFabric |
withParentClassLoader(java.lang.ClassLoader parentClassLoader)
Makes an adapter fabric whose parent classloader is provided.
|
public AdapterFabric(java.lang.ClassLoader classLoader)
classLoader
- the classloader to use.public AdapterFabric()
public static AdapterFabric withParentClassLoader(java.lang.ClassLoader parentClassLoader)
parentClassLoader
- the parent classloader.public AdapterFabric.Maker maker(java.util.Map<java.lang.String,java.lang.Object> configuration)
configuration
- the adapter configuration.