public class DescriptorImpl extends Object implements Descriptor, Externalizable
Constructor and Description |
---|
DescriptorImpl()
For serialization
|
DescriptorImpl(Descriptor copyMe)
Does a deep copy of the incoming descriptor
|
DescriptorImpl(Set<String> contracts,
String name,
String scope,
String implementation,
Map<String,List<String>> metadatas,
Set<String> qualifiers,
DescriptorType descriptorType,
DescriptorVisibility descriptorVisibility,
HK2Loader loader,
int rank,
Boolean proxiable,
Boolean proxyForSameScope,
String analysisName,
Long id,
Long locatorId)
This creates this descriptor impl, taking all of the fields
as given
|
Modifier and Type | Method and Description |
---|---|
void |
addAdvertisedContract(String addMe)
Adds an advertised contract to the set of contracts advertised by this descriptor
|
void |
addMetadata(Map<String,List<String>> metadata)
Adds all of the entries from this map to the existing descriptor's
metadata.
|
void |
addMetadata(String key,
String value)
Adds a value to the list of values associated with this key
|
void |
addQualifier(String addMe)
Adds the given string to the list of qualifiers
|
void |
clearMetadata()
Removes all metadata values
|
static boolean |
descriptorEquals(Descriptor a,
Descriptor 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
|
boolean |
equals(Object a)
This equals matches only if the following fields of the descriptor match:
implementation
contracts
name
scope
qualifiers
descriptorType
descriptorVisibility
metadata
proxiable
proxyForSameScope
analysisName
|
Set<String> |
getAdvertisedContracts()
Returns the base class name of the contracts that
this service describes.
|
String |
getClassAnalysisName()
Returns the name of the
ClassAnalyzer service that
should be used to discover the constructors, initialization methods,
field and postConstruct and preDestory methods. |
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
|
DescriptorVisibility |
getDescriptorVisibility()
Returns the visibility of this descriptor.
|
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 |
hashCode() |
Boolean |
isProxiable()
If this returns true then the system will create a proxy for
instances of this descriptor.
|
Boolean |
isProxyForSameScope()
This value determines whether or not this service should be
proxied when being injected into other services of the same
scope.
|
static void |
pretty(StringBuffer sb,
Descriptor d)
Will pretty print a descriptor
|
void |
readExternal(ObjectInput in) |
boolean |
readObject(BufferedReader in)
This can be used to read in instances of this object that were previously written out with
writeObject.
|
boolean |
removeAdvertisedContract(String removeMe)
Removes an advertised contract from the set of contracts advertised by this descriptor
|
boolean |
removeAllMetadata(String key)
Removes all the metadata values associated with key
|
boolean |
removeMetadata(String key,
String value)
Removes the given value from the given key
|
boolean |
removeQualifier(String removeMe)
Removes the given qualifier from the list of qualifiers
|
void |
setClassAnalysisName(String name)
Sets the name of the service that will be used
to analyze this class
|
void |
setDescriptorType(DescriptorType descriptorType)
Sets the descriptor type
|
void |
setDescriptorVisibility(DescriptorVisibility descriptorVisibility)
Sets the descriptor visilibity
|
void |
setImplementation(String implementation)
Sets the implementation
|
void |
setLoader(HK2Loader loader)
Sets the loader to use with this descriptor
|
void |
setLocatorId(Long locatorId)
Sets the locator id for this descriptor
|
void |
setMetadata(Map<String,List<String>> metadata)
Sets the metadata of this DescriptorImpl to exactly the set
of metadata in the incoming map.
|
void |
setName(String name)
Sets the name this descriptor should have
|
void |
setProxiable(Boolean proxiable)
Sets whether or not this descriptor should be proxied
|
void |
setProxyForSameScope(Boolean proxyForSameScope)
Sets whether or not to proxy this descriptor for other
services in the same scope
|
int |
setRanking(int ranking)
Returns the ranking of this descriptor.
|
void |
setScope(String scope)
Sets the scope this descriptor should have
|
void |
setServiceId(Long id)
Sets the service id for this descriptor
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
void |
writeObject(PrintWriter out)
This writes this object to the data output stream in a human-readable
format, excellent for writing out data files
|
public DescriptorImpl()
public DescriptorImpl(Descriptor copyMe)
copyMe
- The descriptor to copypublic DescriptorImpl(Set<String> contracts, String name, String scope, String implementation, Map<String,List<String>> metadatas, Set<String> qualifiers, DescriptorType descriptorType, DescriptorVisibility descriptorVisibility, HK2Loader loader, int rank, Boolean proxiable, Boolean proxyForSameScope, String analysisName, Long id, Long locatorId)
contracts
- The set of contracts this descriptor impl should advertise (should not be null)name
- The name of this descriptor (may be null)scope
- The scope of this descriptor. If null PerLookup is assumedimplementation
- The name of the implementation class (should not be null)metadatas
- The metadata associated with this descriptor (should not be null)qualifiers
- The set of qualifiers associated with this descriptor (should not be null)descriptorType
- The type of this descriptor (should not be null)descriptorVisibility
- The visibility this descriptor should haveloader
- The HK2Loader to associated with this descriptor (may be null)rank
- The rank to initially associate with this descriptorproxiable
- The proxiable value to associate with this descriptor (may be null)proxyForSameScope
- The proxyForSameScope value to associate with this descriptor (may be null)analysisName
- The name of the ClassAnalysis service to useid
- The ID this descriptor should take (may be null)locatorId
- The locator ID this descriptor should take (may be null)public Set<String> getAdvertisedContracts()
Descriptor
getAdvertisedContracts
in interface Descriptor
public void addAdvertisedContract(String addMe)
addMe
- The contract to add. May not be nullpublic boolean removeAdvertisedContract(String removeMe)
removeMe
- The contract to remove. May not be nullpublic String getImplementation()
Descriptor
getImplementation
in interface Descriptor
public void setImplementation(String implementation)
implementation
- The implementation this descriptor should havepublic String getScope()
Descriptor
getScope
in interface Descriptor
public void setScope(String scope)
scope
- The scope of this descriptorpublic String getName()
Descriptor
getName
in interface Descriptor
public void setName(String name)
name
- The name for this descriptorpublic Set<String> getQualifiers()
Descriptor
getQualifiers
in interface Descriptor
public void addQualifier(String addMe)
addMe
- The fully qualified class name of the qualifier to add. May not be nullpublic boolean removeQualifier(String removeMe)
removeMe
- The fully qualifier class name of the qualifier to remove. May not be nullpublic DescriptorType getDescriptorType()
Descriptor
getDescriptorType
in interface Descriptor
public void setDescriptorType(DescriptorType descriptorType)
descriptorType
- The descriptor type. May not be nullpublic DescriptorVisibility getDescriptorVisibility()
Descriptor
If the visibility is NORMAL then this descriptor may be seen by all children locators of the locator in which this descriptor is bound
If the visibility is LOCAL then this descriptor may only be seen by the servcie locator in which it is bound, and in none of the children of that locator
getDescriptorVisibility
in interface Descriptor
public void setDescriptorVisibility(DescriptorVisibility descriptorVisibility)
descriptorVisibility
- The visibility this descriptor should havepublic Map<String,List<String>> getMetadata()
Descriptor
getMetadata
in interface Descriptor
public void setMetadata(Map<String,List<String>> metadata)
metadata
- The non-null metadata that this descriptor
should havepublic void addMetadata(Map<String,List<String>> metadata)
metadata
- The non-null but possibly empty list of fields
to add to the metadata mappublic void addMetadata(String key, String value)
key
- The key to which to add the value. May not be null. May
not contain the character '='value
- The value to add. May not be nullpublic boolean removeMetadata(String key, String value)
key
- The key of the value to remove. May not be null, and
may not contain the character '='value
- The value to remove. May not be nullpublic boolean removeAllMetadata(String key)
key
- The key of the metadata values to removepublic void clearMetadata()
public HK2Loader getLoader()
Descriptor
getLoader
in interface Descriptor
public void setLoader(HK2Loader loader)
loader
- The loader to use with this descriptorpublic int getRanking()
Descriptor
getRanking
in interface Descriptor
public int setRanking(int ranking)
Descriptor
The ranking of a service may change at any time during the life of the descriptor
setRanking
in interface Descriptor
ranking
- The new ranking this descriptor should havepublic Long getServiceId()
Descriptor
getServiceId
in interface Descriptor
public void setServiceId(Long id)
id
- the service id for this descriptorpublic Boolean isProxiable()
Descriptor
ProxyCtl
interface
It is an error for this method to return true if the scope that
this descriptor is in is Unproxiable
(such as PerLookup).
isProxiable
in interface Descriptor
Proxiable
)public void setProxiable(Boolean proxiable)
proxiable
- 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 inpublic Boolean isProxyForSameScope()
Descriptor
isProxyForSameScope
in interface Descriptor
public void setProxyForSameScope(Boolean proxyForSameScope)
proxyForSameScope
- 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 inpublic String getClassAnalysisName()
Descriptor
ClassAnalyzer
service that
should be used to discover the constructors, initialization methods,
field and postConstruct and preDestory methods. If null the default
implementation will be used. Will be ignored for descriptors that
are not automatically analyzed by hk2getClassAnalysisName
in interface Descriptor
public void setClassAnalysisName(String name)
name
- The name of the ClassAnalyzer
service that should be used to analyze this
descriptorpublic Long getLocatorId()
Descriptor
getLocatorId
in interface Descriptor
public void setLocatorId(Long locatorId)
locatorId
- the locator id for this descriptorpublic static boolean descriptorEquals(Descriptor a, Descriptor b)
a
- The possibly null descriptor to compareb
- The possibly null descriptor to comparepublic boolean equals(Object a)
public static void pretty(StringBuffer sb, Descriptor d)
sb
- The string buffer put the pretty print intod
- The descriptor to writepublic void writeObject(PrintWriter out) throws IOException
out
- The output stream to write this object out toIOException
- on failurepublic boolean readObject(BufferedReader in) throws IOException
in
- The reader to read fromIOException
- on failurepublic void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Copyright © 2009-2017, Oracle and/or its affiliates. All Rights Reserved.