Top Description Fields Constructors Methods
org.glassfish.hk2.utilities

public Class DescriptorImpl

extends Object
implements Descriptor, Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable, org.glassfish.hk2.api.Descriptor
Known Direct Subclasses
org.glassfish.hk2.utilities.AbstractActiveDescriptor
Imports
java.io.BufferedReader, .Externalizable, .IOException, .ObjectInput, .ObjectOutput, .PrintWriter, .StringReader, .StringWriter, java.util.Collection, .Collections, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Set, java.util.concurrent.locks.ReentrantLock, jakarta.inject.Singleton, org.glassfish.hk2.api.ClassAnalyzer, .Descriptor, .DescriptorType, .DescriptorVisibility, .HK2Loader, .PerLookup, org.glassfish.hk2.utilities.general.GeneralUtilities, org.glassfish.hk2.utilities.reflection.ReflectionHelper

The implementation of the descriptor itself, with the bonus of being externalizable, and having writeable fields
Author
jwells

Field Summary

Modifier and TypeField and Description
private static final String
private String
private static final String
private Set<String>
private DescriptorType
private DescriptorVisibility
private static final Set<String>
private static final Map<String, List<String>>
private static final Set<String>
private static final String
private static final char
private Long
private String
private transient HK2Loader
private static final String
private Long
private final ReentrantLock
private static final String
private Map<String, List<String>>
private String
private static final String
private static final String
private static final char
private static final String
private Boolean
private static final String
private static final String
private Boolean
private static final String
private Set<String>
private int
private static final String
private String
private static final String
private static final long
serialVersionUID

For serialization

private static final String
private static final char
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
DescriptorImpl()

For serialization

public
DescriptorImpl(Descriptor
The descriptor to copy
copyMe
)

Does a deep copy of the incoming descriptor

public
DescriptorImpl(Set<String>
The set of contracts this descriptor impl should advertise (should not be null)
contracts
,
String
The name of this descriptor (may be null)
name
,
String
The scope of this descriptor. If null PerLookup is assumed
scope
,
String
The name of the implementation class (should not be null)
implementation
,
Map<String, List<String>>
The metadata associated with this descriptor (should not be null)
metadatas
,
Set<String>
The set of qualifiers associated with this descriptor (should not be null)
qualifiers
,
DescriptorType
The type of this descriptor (should not be null)
descriptorType
,
DescriptorVisibility
The visibility this descriptor should have
descriptorVisibility
,
HK2Loader
The HK2Loader to associated with this descriptor (may be null)
loader
,
int
The rank to initially associate with this descriptor
rank
,
Boolean
The proxiable value to associate with this descriptor (may be null)
proxiable
,
Boolean
The proxyForSameScope value to associate with this descriptor (may be null)
proxyForSameScope
,
String
The name of the ClassAnalysis service to use
analysisName
,
Long
The ID this descriptor should take (may be null)
id
,
Long
The locator ID this descriptor should take (may be null)
locatorId
)

This creates this descriptor impl, taking all of the fields as given

Method Summary

Modifier and TypeMethod and Description
public void
addAdvertisedContract(String
The contract to add. May not be null
addMe
)

Adds an advertised contract to the set of contracts advertised by this descriptor

public void
addMetadata(Map<String, List<String>>
The non-null but possibly empty list of fields to add to the metadata map
metadata
)

Adds all of the entries from this map to the existing descriptor's metadata.

public void
addMetadata(String
The key to which to add the value. May not be null. May not contain the character '='
key
,
String
The value to add. May not be null
value
)

Adds a value to the list of values associated with this key

public void
addQualifier(String
The fully qualified class name of the qualifier to add. May not be null
addMe
)

Adds the given string to the list of qualifiers

public void
clearMetadata()

Removes all metadata values

public static boolean

Returns:

true if they are the same, false otherwise
descriptorEquals
(Descriptor
The possibly null descriptor to compare
a
,
Descriptor
The possibly null descriptor to compare
b
)

Tests if two descriptors are equal not taking into account the locator-id and server-id by comparing the following fields:

  • implementation
  • contracts
  • name
  • scope
  • qualifiers
  • descriptorType
  • descriptorVisibility
  • metadata
  • proxiable
  • proxyForSameScope
  • analysisName
private static <T> boolean
private static <T> boolean
public boolean

Returns:

true if the descriptors are equal
equals
(Object
The object to compare to this one. May be null (which will result in a false)
a
)

Overrides java.lang.Object.equals.

This equals matches only if the following fields of the descriptor match:

  • implementation
  • contracts
  • name
  • scope
  • qualifiers
  • descriptorType
  • descriptorVisibility
  • metadata
  • proxiable
  • proxyForSameScope
  • analysisName
public Set<String>
getAdvertisedContracts()

Implements org.glassfish.hk2.api.Descriptor.getAdvertisedContracts.

Returns the base class name of the contracts that this service describes.

public String
getClassAnalysisName()

Implements org.glassfish.hk2.api.Descriptor.getClassAnalysisName.

Returns the name of the ClassAnalyzer service that should be used to discover the constructors, initialization methods, field and postConstruct and preDestory methods.

public DescriptorType
getDescriptorType()

Implements org.glassfish.hk2.api.Descriptor.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

public DescriptorVisibility
getDescriptorVisibility()

Implements org.glassfish.hk2.api.Descriptor.getDescriptorVisibility.

Returns the visibility of this descriptor.

public String
getImplementation()

Implements org.glassfish.hk2.api.Descriptor.getImplementation.

Returns the fully qualified class name of the implementation class.

public HK2Loader
getLoader()

Implements org.glassfish.hk2.api.Descriptor.getLoader.

This returns the loader that should be used when classloading this descriptor.

public Long
getLocatorId()

Implements org.glassfish.hk2.api.Descriptor.getLocatorId.

This returns the id of the ServiceLocator which this descriptor is registered with.

public Map<String, List<String>>
getMetadata()

Implements org.glassfish.hk2.api.Descriptor.getMetadata.

Returns all of the metadata associated that this object should be registered with or looked up by

public String
getName()

Implements org.glassfish.hk2.api.Descriptor.getName.

The name of this descriptor.

public Set<String>
getQualifiers()

Implements org.glassfish.hk2.api.Descriptor.getQualifiers.

Returns all of the annotation classes that this object should be registered with or looked up by

public int
getRanking()

Implements org.glassfish.hk2.api.Descriptor.getRanking.

Returns the ranking of this descriptor.

public String
getScope()

Implements org.glassfish.hk2.api.Descriptor.getScope.

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

public Long
getServiceId()

Implements org.glassfish.hk2.api.Descriptor.getServiceId.

This returns the unique identifier for this descriptor.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public Boolean
isProxiable()

Implements org.glassfish.hk2.api.Descriptor.isProxiable.

If this returns true then the system will create a proxy for instances of this descriptor.

public Boolean
isProxyForSameScope()

Implements org.glassfish.hk2.api.Descriptor.isProxyForSameScope.

This value determines whether or not this service should be proxied when being injected into other services of the same scope.

public static void
pretty(StringBuffer
The string buffer put the pretty print into
sb
,
Descriptor
The descriptor to write
d
)

Will pretty print a descriptor

public void
readExternal(ObjectInput in)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

public boolean

Returns:

true if a descriptor was read, false otherwise. This is useful if reading a file that might have comments at the end
readObject
(BufferedReader
The reader to read from
in
)

This can be used to read in instances of this object that were previously written out with writeObject.

private void
public boolean

Returns:

true if removeMe was removed from the set
removeAdvertisedContract
(String
The contract to remove. May not be null
removeMe
)

Removes an advertised contract from the set of contracts advertised by this descriptor

public boolean

Returns:

true if any value was removed
removeAllMetadata
(String
The key of the metadata values to remove
key
)

Removes all the metadata values associated with key

public boolean

Returns:

true if the value was removed
removeMetadata
(String
The key of the value to remove. May not be null, and may not contain the character '='
key
,
String
The value to remove. May not be null
value
)

Removes the given value from the given key

public boolean

Returns:

true if the given qualifier was removed
removeQualifier
(String
The fully qualifier class name of the qualifier to remove. May not be null
removeMe
)

Removes the given qualifier from the list of qualifiers

public void
setClassAnalysisName(String
The name of the ClassAnalyzer service that should be used to analyze this descriptor
name
)

Sets the name of the service that will be used to analyze this class

public void
setDescriptorType(DescriptorType
The descriptor type. May not be null
descriptorType
)

Sets the descriptor type

public void
setDescriptorVisibility(DescriptorVisibility
The visibility this descriptor should have
descriptorVisibility
)

Sets the descriptor visilibity

public void
setImplementation(String
The implementation this descriptor should have
implementation
)

Sets the implementation

public void
setLoader(HK2Loader
The loader to use with this descriptor
loader
)

Sets the loader to use with this descriptor

public void
setLocatorId(Long
the locator id for this descriptor
locatorId
)

Sets the locator id for this descriptor

public void
setMetadata(Map<String, List<String>>
The non-null metadata that this descriptor should have
metadata
)

Sets the metadata of this DescriptorImpl to exactly the set of metadata in the incoming map.

public void
setName(String
The name for this descriptor
name
)

Sets the name this descriptor should have

public void
setProxiable(Boolean
if true then this descriptor will be proxied. If false then this descriptor will not be proxied. If null this descriptor will follow the rules of the scope it is in
proxiable
)

Sets whether or not this descriptor should be proxied

public void
setProxyForSameScope(Boolean
if true then this descriptor will be proxied for services in the same scope. If false then this descriptor will not be proxied for services in the same scope. If null this descriptor will follow the rules of the scope it is in
proxyForSameScope
)

Sets whether or not to proxy this descriptor for other services in the same scope

public int
setRanking(int ranking)

Implements org.glassfish.hk2.api.Descriptor.setRanking.

Returns the ranking of this descriptor.

public void
setScope(String
The scope of this descriptor
scope
)

Sets the scope this descriptor should have

public void
setServiceId(Long
the service id for this descriptor
id
)

Sets the service id for this descriptor

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
writeExternal(ObjectOutput out)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

public void
writeObject(PrintWriter
The output stream to write this object out to
out
)

This writes this object to the data output stream in a human-readable format, excellent for writing out data files

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait