org.glassfish.hk2.api
Interface Descriptor

All Known Subinterfaces:
ActiveDescriptor<T>, Creator<T>, Inhabitant<T>
All Known Implementing Classes:
AbstractActiveDescriptor, AbstractCreatorImpl, AbstractCreatorInhabitantImpl, AbstractInhabitantImpl, AliasDescriptor, AutoActiveDescriptor, ConfigBean, ConstantActiveDescriptor, ConstantActiveDescriptor, ConstructorCreator, CreatorImpl, DescriptorImpl, Dom, DomDescriptor, EventPublishingInhabitant, ExistingSingletonInhabitant, InhabitantImpl, LazyInhabitant, ScopedInhabitant, SystemDescriptor

public interface Descriptor

A Descriptor is a bean-like structure that describes a service declaration in HK2.

Services have a number of optional attributes such as name and scope. A service is required to minimally have a type name representing the concrete (i.e., byType) definition.

Author:
Jerome Dochez, Jeff Trent, Mason Taube

Method Summary
 Set<String> getAdvertisedContracts()
          Returns the base class name of the contracts that this service describes.
 Descriptor getBaseDescriptor()
          If this descriptor is based on another descriptor (for example via the Configuration bind call) then this method will return the original basis for this descriptor.
 DescriptorType getDescriptorType()
          Returns CLASS if this is a class descriptor and FACTORY if this is a descriptor describing a factory for a type, in which case the implClass should point to the implementation class of the factory
 String getImplementation()
          Returns the fully qualified class name of the implementation class.
 HK2Loader getLoader()
          This returns the loader that should be used when classloading this descriptor.
 Long getLocatorId()
          This returns the id of the ServiceLocator which this descriptor is registered with.
 Map<String,List<String>> getMetadata()
          Returns all of the metadata associated that this object should be registered with or looked up by
 String getName()
          The name of this descriptor.
 Set<String> getQualifiers()
          Returns all of the annotation classes that this object should be registered with or looked up by
 int getRanking()
          Returns the ranking of this descriptor.
 String getScope()
          Returns the fully qualified class name of the scope annotation that should be associated with this descriptor.
 Long getServiceId()
          This returns the unique identifier for this descriptor.
 int setRanking(int ranking)
          Returns the ranking of this descriptor.
 

Method Detail

getImplementation

String getImplementation()
Returns the fully qualified class name of the implementation class. If this is a factory descriptor then this will return the fully qualified name of the class implementing the factory interface.

Returns:
Might return null in some cases, but will usually return the fully qualified class name of the implementation class or of the factory class for this descriptor

getAdvertisedContracts

Set<String> getAdvertisedContracts()
Returns the base class name of the contracts that this service describes. If the contract is a paramterized type this will return the raw class. If this service can be looked up by its implementation class then the name of the implementation class must also be found in this list

Returns:
Will never return null, but may return an empty set. The returned strings are the fully qualified class names of contracts the predicate describes

getScope

String getScope()
Returns the fully qualified class name of the scope annotation that should be associated with this descriptor.

Returns:
If this returns null then this descriptor is assumed to be in the default scope, which is PerLookup

getName

String getName()
The name of this descriptor. Note that if this returns not null then there must also be the Named qualifier in the set of qualifiers with the same value

Returns:
The name of this descriptor, or null if there is no name associated with this qualifier

getQualifiers

Set<String> getQualifiers()
Returns all of the annotation classes that this object should be registered with or looked up by

Returns:
Never returns null, but may return an empty set. The set of fully qualified class names that are annotations that this object must have

getDescriptorType

DescriptorType getDescriptorType()
Returns CLASS if this is a class descriptor and FACTORY if this is a descriptor describing a factory for a type, in which case the implClass should point to the implementation class of the factory

Returns:
Either CLASS or FACTORY

getMetadata

Map<String,List<String>> getMetadata()
Returns all of the metadata associated that this object should be registered with or looked up by

Returns:
Never returns null, but may return an empty set. The set of metadata associated with the object. The values in the returned map will never be null, and will always have at least one member

getLoader

HK2Loader getLoader()
This returns the loader that should be used when classloading this descriptor. If this returns null then class will either be loaded with the classloader of the Injectee if there is one, or with the classloader that loaded HK2 itself.

Returns:
An HK2Loader that can be used to load this descriptor, or null if the default classloading algorithm should be used

getRanking

int getRanking()
Returns the ranking of this descriptor. Rankings with higher value will be considered "better" than rankings of lower value. Descriptors with the same ranking will be returned in the reverse ServiceID order (in other words, the least service ID is considered "better" than any higher service ID).

Returns:
the ranking that should be associated with this descriptor

setRanking

int setRanking(int ranking)
Returns the ranking of this descriptor. Rankings with higher value will be considered "better" than rankings of lower value. Descriptors with the same ranking will be returned in the reverse ServiceID order (in other words, the least service ID is considered "better" than any higher service ID).

The ranking of a service may change at any time during the life of the descriptor

Parameters:
ranking - The new ranking this descriptor should have
Returns:
the previous ranking that this descriptor had

getBaseDescriptor

Descriptor getBaseDescriptor()
If this descriptor is based on another descriptor (for example via the Configuration bind call) then this method will return the original basis for this descriptor.

On bind calls the value of this parameter will be ignored, and will be filled in by the system.

Note that even if the values in the returned descriptor are modified it will not affect the values in the parent descriptor (the fields must have been copied out of the base descriptor, not referenced)

Returns:
The original descriptor upon which this descriptor is based, or null if there is no known base descriptor. This field is filled in by the system at bind time

getServiceId

Long getServiceId()
This returns the unique identifier for this descriptor. This field will be ignored upon binding, and will then be assigned by the system. However, this field can be set on search operations, in which case this search will match exactly one Provider in the system.

Returns:
The service id for this object. Note that this field may return null if this is an initial bind, as it is not the responsibility of the binder to set this value. If this returns non-null on a bind operation the return value will be ignored

getLocatorId

Long getLocatorId()
This returns the id of the ServiceLocator which this descriptor is registered with. Returns null if this descriptor is not yet registered with a ServiceLocator

Returns:
The id of the ServiceLocator this Descriptor is registered with, or null if this Descriptor is not registered with a ServiceLocator


Copyright © 2013 Oracle Corporation. All Rights Reserved.