public interface Inventory extends AutoCloseable
The resources are organized by tenant (your company) and environments (i.e. testing, development, staging, production, ...).
Despite their name, tenants are not completely separated and one can easily create relationships between them or
between entities underneath different tenants. This is because there are situations where such relationships might
make sense but more importantly because at the API level, inventory does not mandate any security model. It is
assumed that the true multi-tenancy in the common sense of the word is implemented by a layer on top of the inventory
API that also understands some security model to separate the tenants. To help with multi-tenancy support, the API
provides "mixins" to modify the default behavior of the inventory, see the
Inventory.Mixin class and the augment(Inventory) method.
Resources are hierarchical - meaning that one can be a parent of others, recursively. One can also say that a resource can contain other resources. Resources can have other kinds of relationships that are not necessarily tree-like.
Resources can have a "resource type" (but they don't have to) which prescribes what kind of data a resource contains. Most prominently a resource can have a list of metrics and a resource type can define what those metrics should be by specifying the set of "metric types".
This interface offers a fluent API to compose a "traversal" over the graph of entities stored in the inventory in a strongly typed fashion.
The inventory implementations are not required to be thread-safe. Instances should therefore be accessed only by a single thread or serially.
Note to implementers:
The interfaces composing the inventory API are of 2 kinds:
Read, ReadWrite or ReadRelate interfaces, e.g.
Environments.ReadWrite),
Single interfaces that provide methods for navigating from a single entity.
These interfaces generally contain methods that enable modification of the entity or its relationships.
See Environments.Single for an example.
Multiple interfaces that provide methods for navigating from multiple entities at once.
These interfaces strictly offer only read-only access to the entities, because the semantics of what should
be done when modifying or relating multiple entities at once is not uniformly defined on all types of
entities and therefore would make the API more confusing than necessary. See
Environments.Multiple for example.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Inventory.Mixin
A class for producing mixins of inventory and the
Inventory.Mixin.Observable or Inventory.Mixin.AutoTenant
interfaces. |
| Modifier and Type | Method and Description |
|---|---|
static Inventory.Mixin.AutoTenantMixin |
augment(Inventory.Mixin.AutoTenant inventory) |
static Inventory.Mixin.ObservableMixin |
augment(Inventory.Mixin.Observable inventory) |
static Inventory.Mixin |
augment(Inventory inventory)
Returns an object with which one can modify the behavior of or add features to the provided inventory.
|
void |
initialize(Configuration configuration)
Initializes the inventory from the provided configuration object.
|
default <E extends Entity<?,?>,Single extends ResolvableToSingle<E>> |
inspect(E entity,
Class<Single> accessInterface)
A generic version of the
inspect methods that accepts an entity and returns the access interface to it. |
default Environments.Single |
inspect(Environment environment)
Provides an access interface for inspecting given environment.
|
default Feeds.Single |
inspect(Feed feed)
Provides an access interface for inspecting given feed.
|
default Metrics.Single |
inspect(Metric metric)
Provides an access interface for inspecting given metric.
|
default MetricTypes.Single |
inspect(MetricType metricType)
Provides an access interface for inspecting given metric type.
|
default Resources.Single |
inspect(Resource resource)
Provides an access interface for inspecting given resource.
|
default ResourceTypes.Single |
inspect(ResourceType resourceType)
Provides an access interface for inspecting given resource type.
|
default Tenants.Single |
inspect(Tenant tenant)
Provides an access interface for inspecting given tenant.
|
Tenants.ReadWrite |
tenants()
Entry point into the inventory.
|
closestatic Inventory.Mixin augment(Inventory inventory)
inventory - the inventory to augmentstatic Inventory.Mixin.ObservableMixin augment(Inventory.Mixin.Observable inventory)
static Inventory.Mixin.AutoTenantMixin augment(Inventory.Mixin.AutoTenant inventory)
void initialize(Configuration configuration)
configuration - the configuration to use.Tenants.ReadWrite tenants()
ResolvingToSingle.get(String)) or
more (ResolvingToMultiple.getAll(org.hawkular.inventory.api.filters.Filter...))
tenants and navigate further to the entities of interest.default Tenants.Single inspect(Tenant tenant) throws EntityNotFoundException
tenant - the tenant to steer to.EntityNotFoundExceptiondefault Environments.Single inspect(Environment environment) throws EntityNotFoundException
environment - the environment to steer to.EntityNotFoundExceptiondefault Feeds.Single inspect(Feed feed) throws EntityNotFoundException
feed - the feed to steer to.EntityNotFoundExceptiondefault Metrics.Single inspect(Metric metric) throws EntityNotFoundException
metric - the metric to steer to.EntityNotFoundExceptiondefault MetricTypes.Single inspect(MetricType metricType) throws EntityNotFoundException
metricType - the metric type to steer to.EntityNotFoundExceptiondefault Resources.Single inspect(Resource resource) throws EntityNotFoundException
resource - the resource to steer to.EntityNotFoundExceptiondefault ResourceTypes.Single inspect(ResourceType resourceType) throws EntityNotFoundException
resourceType - the resource type to steer to.EntityNotFoundExceptiondefault <E extends Entity<?,?>,Single extends ResolvableToSingle<E>> Single inspect(E entity, Class<Single> accessInterface)
inspect methods that accepts an entity and returns the access interface to it.
If you don't know the type of entity (and therefore cannot deduce access interface type) you can always use
ResolvableToSingle type which is guaranteed to be the super interface of
all access interfaces returned from this method (which makes it almost useless but at least you can get the
instance of it).
E - the type of the entitySingle - the type of the access interfaceentity - the entity to inspectaccessInterface - the expected access interfaceClassCastException - if the provided access interface doesn't match the entityCopyright © 2015 Red Hat, Inc.. All rights reserved.