public final class Extension
extends java.lang.Object
Represents an XMPP protocol extension (XEP).
An extension usually consists of:
"urn:xmpp:receipts"
Manager
class, which is associated with the extension and manages its business logic.An extension could have an XML schema implementation, but no business logic and therefore no manager class, like XEP-0203: Delayed Delivery.
The namespace is optional as well: If an extension has no namespace, it won’t be advertised in Service Discovery.
Extensions which have business logic (and hence a manager class), can be enabled or disabled.
In order to create an extension, use one of its static factory methods.
This class overrides equals(Object)
and hashCode()
, so that two extensions are considered equal if either their namespace are equal or their manager classes. This allows to disable certain extensions or managers by default.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
java.util.Collection<java.lang.Class<?>> |
getClasses()
Gets the collection of classes, which represent the extension’s XML schema implementation.
|
java.util.Collection<java.lang.String> |
getFeatures()
Gets the collection of “sub” features, which are associated with the extension.
|
java.lang.Class<? extends Manager> |
getManager()
Gets the manager class.
|
java.lang.String |
getNamespace()
Gets the protocol namespace.
|
int |
hashCode() |
boolean |
isEnabled()
Indicates whether the extension is enabled or not.
|
static Extension |
of(java.lang.Class<?>... classes)
Creates an extension with a set of classes (XML schema implementations) used by this extension.
|
static Extension |
of(java.lang.Class<? extends Manager> manager,
boolean enabled)
Creates an extension, which won’t get advertised during service discovery and only has a manager class.
|
static Extension |
of(java.lang.String namespace,
boolean enabled,
java.lang.Class<?>... classes)
Creates an extension without business logic, but an XML schema class.
|
static Extension |
of(java.lang.String namespace,
java.lang.Class<? extends Manager> manager,
boolean notify,
boolean enabled,
java.lang.Class<?>... classes)
Creates an PEP (Personal Eventing Protocol) extension with a namespace, business logic and XML schema classes.
|
static Extension |
of(java.lang.String namespace,
java.lang.Class<? extends Manager> manager,
boolean enabled,
java.lang.Class<?>... classes)
Creates an extension with a namespace, business logic and XML schema classes.
|
static Extension |
of(java.lang.String namespace,
java.lang.Class<? extends Manager> manager,
java.util.Set<java.lang.String> features,
boolean enabled,
java.lang.Class<?>... classes)
Creates an extension which can advertise additional features, such as XEP-0300.
|
public static Extension of(java.lang.Class<?>... classes)
Creates an extension with a set of classes (XML schema implementations) used by this extension.
Use it for extensions without business logic and no namespace which needs to be advertised, e.g. for Delayed Delivery.
classes
- The classes.public static Extension of(java.lang.Class<? extends Manager> manager, boolean enabled)
Creates an extension, which won’t get advertised during service discovery and only has a manager class.
manager
- The manager class.enabled
- If this manager is enabled.public static Extension of(java.lang.String namespace, boolean enabled, java.lang.Class<?>... classes)
Creates an extension without business logic, but an XML schema class. If enabled, it will be advertised as a feature in service discovery. Examples are XEP-0020, XEP-0122 or XEP-0141.
namespace
- The protocol namespace.enabled
- If this extension is enabled, i.e. whether it’s advertised in service discovery.classes
- The XML schema classes.public static Extension of(java.lang.String namespace, java.lang.Class<? extends Manager> manager, boolean enabled, java.lang.Class<?>... classes)
Creates an extension with a namespace, business logic and XML schema classes.
This is the most common extension characteristic.
namespace
- The protocol namespace.manager
- The manager class, which covers the business logic.enabled
- If this extension is enabled, i.e. whether its manager class is enabled and whether it’s advertised in service discovery.classes
- The XML schema classes.public static Extension of(java.lang.String namespace, java.lang.Class<? extends Manager> manager, boolean notify, boolean enabled, java.lang.Class<?>... classes)
Creates an PEP (Personal Eventing Protocol) extension with a namespace, business logic and XML schema classes.
namespace
- The protocol namespace.manager
- The manager class, which covers the business logic.notify
- True, if this feature should be advertised along with a “filtered notification”, i.e. as “namespace+notify”.enabled
- If this extension is enabled, i.e. whether its manager class is enabled and whether it’s advertised in service discovery.classes
- The XML schema classes.public static Extension of(java.lang.String namespace, java.lang.Class<? extends Manager> manager, java.util.Set<java.lang.String> features, boolean enabled, java.lang.Class<?>... classes)
Creates an extension which can advertise additional features, such as XEP-0300.
namespace
- The protocol namespace.manager
- The manager class, which covers the business logic.features
- The features, which are advertised in service discovery.enabled
- If this extension is enabled, i.e. whether its manager class is enabled and whether it’s advertised in service discovery.classes
- The XML schema classes.public final java.lang.String getNamespace()
Gets the protocol namespace.
public final java.lang.Class<? extends Manager> getManager()
Gets the manager class.
public final java.util.Collection<java.lang.Class<?>> getClasses()
Gets the collection of classes, which represent the extension’s XML schema implementation.
public final java.util.Collection<java.lang.String> getFeatures()
Gets the collection of “sub” features, which are associated with the extension.
public final boolean isEnabled()
Indicates whether the extension is enabled or not.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2014–2019 XMPP.rocks. All rights reserved.