Package org.glassfish.hk2.utilities
Class DescriptorImpl
- java.lang.Object
-
- org.glassfish.hk2.utilities.DescriptorImpl
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,Descriptor
- Direct Known Subclasses:
AbstractActiveDescriptor
public class DescriptorImpl extends java.lang.Object implements Descriptor, java.io.Externalizable
The implementation of the descriptor itself, with the bonus of being externalizable, and having writeable fields- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringANALYSIS_KEYprivate java.lang.StringanalysisNameprivate static java.lang.StringCONTRACT_KEYprivate java.util.Set<java.lang.String>contractsprivate DescriptorTypedescriptorTypeprivate DescriptorVisibilitydescriptorVisibilityprivate static java.util.Set<java.lang.String>EMPTY_CONTRACTS_SETprivate static java.util.Map<java.lang.String,java.util.List<java.lang.String>>EMPTY_METADATAS_MAPprivate static java.util.Set<java.lang.String>EMPTY_QUALIFIER_SETprivate static java.lang.StringEND_STARTprivate static charEND_START_CHARprivate java.lang.Longidprivate java.lang.Stringimplementationprivate HK2Loaderloaderprivate static java.lang.StringLOCAL_DTprivate java.lang.LonglocatorIdprivate static java.lang.StringMETADATA_KEYprivate java.util.Map<java.lang.String,java.util.List<java.lang.String>>metadatasprivate java.lang.Stringnameprivate static java.lang.StringNAME_KEYprivate static java.lang.StringNOT_IN_CONTRACTS_DIRECTIVEprivate static charNOT_IN_CONTRACTS_DIRECTIVE_CHARprivate static java.lang.StringPROVIDE_METHOD_DTprivate java.lang.Booleanproxiableprivate static java.lang.StringPROXIABLE_KEYprivate static java.lang.StringPROXY_FOR_SAME_SCOPE_KEYprivate java.lang.BooleanproxyForSameScopeprivate static java.lang.StringQUALIFIER_KEYprivate java.util.Set<java.lang.String>qualifiersprivate intrankprivate static java.lang.StringRANKING_KEYprivate java.lang.Stringscopeprivate static java.lang.StringSCOPE_KEYprivate static longserialVersionUIDFor serializationprivate static java.lang.StringSINGLETON_DIRECTIVEprivate static charSINGLETON_DIRECTIVE_CHARprivate static java.lang.StringSTART_STARTprivate static java.lang.StringTYPE_KEYprivate static java.lang.StringVISIBILITY_KEY
-
Constructor Summary
Constructors Constructor Description DescriptorImpl()For serializationDescriptorImpl(java.util.Set<java.lang.String> contracts, java.lang.String name, java.lang.String scope, java.lang.String implementation, java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadatas, java.util.Set<java.lang.String> qualifiers, DescriptorType descriptorType, DescriptorVisibility descriptorVisibility, HK2Loader loader, int rank, java.lang.Boolean proxiable, java.lang.Boolean proxyForSameScope, java.lang.String analysisName, java.lang.Long id, java.lang.Long locatorId)This creates this descriptor impl, taking all of the fields as givenDescriptorImpl(Descriptor copyMe)Does a deep copy of the incoming descriptor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdvertisedContract(java.lang.String addMe)Adds an advertised contract to the set of contracts advertised by this descriptorvoidaddMetadata(java.lang.String key, java.lang.String value)Adds a value to the list of values associated with this keyvoidaddMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)Adds all of the entries from this map to the existing descriptor's metadata.voidaddQualifier(java.lang.String addMe)Adds the given string to the list of qualifiersvoidclearMetadata()Removes all metadata valuesstatic booleandescriptorEquals(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 analysisNameprivate static <T> booleanequalMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> a, java.util.Map<java.lang.String,java.util.List<java.lang.String>> b)private static <T> booleanequalOrderedCollection(java.util.Collection<T> a, java.util.Collection<T> b)booleanequals(java.lang.Object a)This equals matches only if the following fields of the descriptor match: implementation contracts name scope qualifiers descriptorType descriptorVisibility metadata proxiable proxyForSameScope analysisNamejava.util.Set<java.lang.String>getAdvertisedContracts()Returns the base class name of the contracts that this service describes.java.lang.StringgetClassAnalysisName()Returns the name of theClassAnalyzerservice that should be used to discover the constructors, initialization methods, field and postConstruct and preDestory methods.DescriptorTypegetDescriptorType()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 factoryDescriptorVisibilitygetDescriptorVisibility()Returns the visibility of this descriptor.java.lang.StringgetImplementation()Returns the fully qualified class name of the implementation class.HK2LoadergetLoader()This returns the loader that should be used when classloading this descriptor.java.lang.LonggetLocatorId()This returns the id of the ServiceLocator which this descriptor is registered with.java.util.Map<java.lang.String,java.util.List<java.lang.String>>getMetadata()Returns all of the metadata associated that this object should be registered with or looked up byjava.lang.StringgetName()The name of this descriptor.java.util.Set<java.lang.String>getQualifiers()Returns all of the annotation classes that this object should be registered with or looked up byintgetRanking()Returns the ranking of this descriptor.java.lang.StringgetScope()Returns the fully qualified class name of the scope annotation that should be associated with this descriptor.java.lang.LonggetServiceId()This returns the unique identifier for this descriptor.inthashCode()java.lang.BooleanisProxiable()If this returns true then the system will create a proxy for instances of this descriptor.java.lang.BooleanisProxyForSameScope()This value determines whether or not this service should be proxied when being injected into other services of the same scope.static voidpretty(java.lang.StringBuffer sb, Descriptor d)Will pretty print a descriptorvoidreadExternal(java.io.ObjectInput in)booleanreadObject(java.io.BufferedReader in)This can be used to read in instances of this object that were previously written out with writeObject.private voidreinitialize()booleanremoveAdvertisedContract(java.lang.String removeMe)Removes an advertised contract from the set of contracts advertised by this descriptorbooleanremoveAllMetadata(java.lang.String key)Removes all the metadata values associated with keybooleanremoveMetadata(java.lang.String key, java.lang.String value)Removes the given value from the given keybooleanremoveQualifier(java.lang.String removeMe)Removes the given qualifier from the list of qualifiersvoidsetClassAnalysisName(java.lang.String name)Sets the name of the service that will be used to analyze this classvoidsetDescriptorType(DescriptorType descriptorType)Sets the descriptor typevoidsetDescriptorVisibility(DescriptorVisibility descriptorVisibility)Sets the descriptor visilibityvoidsetImplementation(java.lang.String implementation)Sets the implementationvoidsetLoader(HK2Loader loader)Sets the loader to use with this descriptorvoidsetLocatorId(java.lang.Long locatorId)Sets the locator id for this descriptorvoidsetMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)Sets the metadata of this DescriptorImpl to exactly the set of metadata in the incoming map.voidsetName(java.lang.String name)Sets the name this descriptor should havevoidsetProxiable(java.lang.Boolean proxiable)Sets whether or not this descriptor should be proxiedvoidsetProxyForSameScope(java.lang.Boolean proxyForSameScope)Sets whether or not to proxy this descriptor for other services in the same scopeintsetRanking(int ranking)Returns the ranking of this descriptor.voidsetScope(java.lang.String scope)Sets the scope this descriptor should havevoidsetServiceId(java.lang.Long id)Sets the service id for this descriptorjava.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)voidwriteObject(java.io.PrintWriter out)This writes this object to the data output stream in a human-readable format, excellent for writing out data files
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization- See Also:
- Constant Field Values
-
CONTRACT_KEY
private static final java.lang.String CONTRACT_KEY
- See Also:
- Constant Field Values
-
NAME_KEY
private static final java.lang.String NAME_KEY
- See Also:
- Constant Field Values
-
SCOPE_KEY
private static final java.lang.String SCOPE_KEY
- See Also:
- Constant Field Values
-
QUALIFIER_KEY
private static final java.lang.String QUALIFIER_KEY
- See Also:
- Constant Field Values
-
TYPE_KEY
private static final java.lang.String TYPE_KEY
- See Also:
- Constant Field Values
-
VISIBILITY_KEY
private static final java.lang.String VISIBILITY_KEY
- See Also:
- Constant Field Values
-
METADATA_KEY
private static final java.lang.String METADATA_KEY
- See Also:
- Constant Field Values
-
RANKING_KEY
private static final java.lang.String RANKING_KEY
- See Also:
- Constant Field Values
-
PROXIABLE_KEY
private static final java.lang.String PROXIABLE_KEY
- See Also:
- Constant Field Values
-
PROXY_FOR_SAME_SCOPE_KEY
private static final java.lang.String PROXY_FOR_SAME_SCOPE_KEY
- See Also:
- Constant Field Values
-
ANALYSIS_KEY
private static final java.lang.String ANALYSIS_KEY
- See Also:
- Constant Field Values
-
PROVIDE_METHOD_DT
private static final java.lang.String PROVIDE_METHOD_DT
- See Also:
- Constant Field Values
-
LOCAL_DT
private static final java.lang.String LOCAL_DT
- See Also:
- Constant Field Values
-
START_START
private static final java.lang.String START_START
- See Also:
- Constant Field Values
-
END_START
private static final java.lang.String END_START
- See Also:
- Constant Field Values
-
END_START_CHAR
private static final char END_START_CHAR
- See Also:
- Constant Field Values
-
SINGLETON_DIRECTIVE
private static final java.lang.String SINGLETON_DIRECTIVE
- See Also:
- Constant Field Values
-
NOT_IN_CONTRACTS_DIRECTIVE
private static final java.lang.String NOT_IN_CONTRACTS_DIRECTIVE
- See Also:
- Constant Field Values
-
SINGLETON_DIRECTIVE_CHAR
private static final char SINGLETON_DIRECTIVE_CHAR
- See Also:
- Constant Field Values
-
NOT_IN_CONTRACTS_DIRECTIVE_CHAR
private static final char NOT_IN_CONTRACTS_DIRECTIVE_CHAR
- See Also:
- Constant Field Values
-
EMPTY_CONTRACTS_SET
private static final java.util.Set<java.lang.String> EMPTY_CONTRACTS_SET
-
EMPTY_QUALIFIER_SET
private static final java.util.Set<java.lang.String> EMPTY_QUALIFIER_SET
-
EMPTY_METADATAS_MAP
private static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> EMPTY_METADATAS_MAP
-
contracts
private java.util.Set<java.lang.String> contracts
-
implementation
private java.lang.String implementation
-
name
private java.lang.String name
-
scope
private java.lang.String scope
-
metadatas
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadatas
-
qualifiers
private java.util.Set<java.lang.String> qualifiers
-
descriptorType
private DescriptorType descriptorType
-
descriptorVisibility
private DescriptorVisibility descriptorVisibility
-
loader
private transient HK2Loader loader
-
rank
private int rank
-
proxiable
private java.lang.Boolean proxiable
-
proxyForSameScope
private java.lang.Boolean proxyForSameScope
-
analysisName
private java.lang.String analysisName
-
id
private java.lang.Long id
-
locatorId
private java.lang.Long locatorId
-
-
Constructor Detail
-
DescriptorImpl
public DescriptorImpl()
For serialization
-
DescriptorImpl
public DescriptorImpl(Descriptor copyMe)
Does a deep copy of the incoming descriptor- Parameters:
copyMe- The descriptor to copy
-
DescriptorImpl
public DescriptorImpl(java.util.Set<java.lang.String> contracts, java.lang.String name, java.lang.String scope, java.lang.String implementation, java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadatas, java.util.Set<java.lang.String> qualifiers, DescriptorType descriptorType, DescriptorVisibility descriptorVisibility, HK2Loader loader, int rank, java.lang.Boolean proxiable, java.lang.Boolean proxyForSameScope, java.lang.String analysisName, java.lang.Long id, java.lang.Long locatorId)This creates this descriptor impl, taking all of the fields as given- Parameters:
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)
-
-
Method Detail
-
getAdvertisedContracts
public java.util.Set<java.lang.String> getAdvertisedContracts()
Description copied from interface:DescriptorReturns 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- Specified by:
getAdvertisedContractsin interfaceDescriptor- 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
-
addAdvertisedContract
public void addAdvertisedContract(java.lang.String addMe)
Adds an advertised contract to the set of contracts advertised by this descriptor- Parameters:
addMe- The contract to add. May not be null
-
removeAdvertisedContract
public boolean removeAdvertisedContract(java.lang.String removeMe)
Removes an advertised contract from the set of contracts advertised by this descriptor- Parameters:
removeMe- The contract to remove. May not be null- Returns:
- true if removeMe was removed from the set
-
getImplementation
public java.lang.String getImplementation()
Description copied from interface:DescriptorReturns 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.- Specified by:
getImplementationin interfaceDescriptor- 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
-
setImplementation
public void setImplementation(java.lang.String implementation)
Sets the implementation- Parameters:
implementation- The implementation this descriptor should have
-
getScope
public java.lang.String getScope()
Description copied from interface:DescriptorReturns the fully qualified class name of the scope annotation that should be associated with this descriptor.- Specified by:
getScopein interfaceDescriptor- Returns:
- If this returns null then this descriptor is assumed to be in the default scope, which is PerLookup
-
setScope
public void setScope(java.lang.String scope)
Sets the scope this descriptor should have- Parameters:
scope- The scope of this descriptor
-
getName
public java.lang.String getName()
Description copied from interface:DescriptorThe 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- Specified by:
getNamein interfaceDescriptor- Returns:
- The name of this descriptor, or null if there is no name associated with this qualifier
-
setName
public void setName(java.lang.String name)
Sets the name this descriptor should have- Parameters:
name- The name for this descriptor
-
getQualifiers
public java.util.Set<java.lang.String> getQualifiers()
Description copied from interface:DescriptorReturns all of the annotation classes that this object should be registered with or looked up by- Specified by:
getQualifiersin interfaceDescriptor- 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
-
addQualifier
public void addQualifier(java.lang.String addMe)
Adds the given string to the list of qualifiers- Parameters:
addMe- The fully qualified class name of the qualifier to add. May not be null
-
removeQualifier
public boolean removeQualifier(java.lang.String removeMe)
Removes the given qualifier from the list of qualifiers- Parameters:
removeMe- The fully qualifier class name of the qualifier to remove. May not be null- Returns:
- true if the given qualifier was removed
-
getDescriptorType
public DescriptorType getDescriptorType()
Description copied from interface:DescriptorReturns 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- Specified by:
getDescriptorTypein interfaceDescriptor- Returns:
- Either CLASS or PROVIDE_METHOD
-
setDescriptorType
public void setDescriptorType(DescriptorType descriptorType)
Sets the descriptor type- Parameters:
descriptorType- The descriptor type. May not be null
-
getDescriptorVisibility
public DescriptorVisibility getDescriptorVisibility()
Description copied from interface:DescriptorReturns the visibility of this 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
- Specified by:
getDescriptorVisibilityin interfaceDescriptor- Returns:
- Either NORMAL or LOCAL
-
setDescriptorVisibility
public void setDescriptorVisibility(DescriptorVisibility descriptorVisibility)
Sets the descriptor visilibity- Parameters:
descriptorVisibility- The visibility this descriptor should have
-
getMetadata
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMetadata()
Description copied from interface:DescriptorReturns all of the metadata associated that this object should be registered with or looked up by- Specified by:
getMetadatain interfaceDescriptor- 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
-
setMetadata
public void setMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)
Sets the metadata of this DescriptorImpl to exactly the set of metadata in the incoming map. Any previous metadata values will be removed. A deep copy of the incoming map will be made, so it is safe to use the input map after use of this API- Parameters:
metadata- The non-null metadata that this descriptor should have
-
addMetadata
public void addMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)
Adds all of the entries from this map to the existing descriptor's metadata. None of the keys in the map may have the '=' character- Parameters:
metadata- The non-null but possibly empty list of fields to add to the metadata map
-
addMetadata
public void addMetadata(java.lang.String key, java.lang.String value)Adds a value to the list of values associated with this key- Parameters:
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 null
-
removeMetadata
public boolean removeMetadata(java.lang.String key, java.lang.String value)Removes the given value from the given key- Parameters:
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 null- Returns:
- true if the value was removed
-
removeAllMetadata
public boolean removeAllMetadata(java.lang.String key)
Removes all the metadata values associated with key- Parameters:
key- The key of the metadata values to remove- Returns:
- true if any value was removed
-
clearMetadata
public void clearMetadata()
Removes all metadata values
-
getLoader
public HK2Loader getLoader()
Description copied from interface:DescriptorThis returns the loader that should be used when classloading this descriptor. If this method returns null then the class will be loaded with the classloader of the Injectee if there is one, or with the classloader that loaded HK2 itself; failing that the context class loader on the thread will be tried.- Specified by:
getLoaderin interfaceDescriptor- Returns:
- An HK2Loader that can be used to load this descriptor, or null if the default classloading algorithm should be used
-
setLoader
public void setLoader(HK2Loader loader)
Sets the loader to use with this descriptor- Parameters:
loader- The loader to use with this descriptor
-
getRanking
public int getRanking()
Description copied from interface:DescriptorReturns 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).- Specified by:
getRankingin interfaceDescriptor- Returns:
- the ranking that should be associated with this descriptor
-
setRanking
public int setRanking(int ranking)
Description copied from interface:DescriptorReturns 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
- Specified by:
setRankingin interfaceDescriptor- Parameters:
ranking- The new ranking this descriptor should have- Returns:
- the previous ranking that this descriptor had
-
getServiceId
public java.lang.Long getServiceId()
Description copied from interface:DescriptorThis 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.- Specified by:
getServiceIdin interfaceDescriptor- 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
-
setServiceId
public void setServiceId(java.lang.Long id)
Sets the service id for this descriptor- Parameters:
id- the service id for this descriptor
-
isProxiable
public java.lang.Boolean isProxiable()
Description copied from interface:DescriptorIf this returns true then the system will create a proxy for instances of this descriptor. As with all proxies, the proxy created will also implement theProxyCtlinterfaceIt is an error for this method to return true if the scope that this descriptor is in is
Unproxiable(such as PerLookup).- Specified by:
isProxiablein interfaceDescriptor- Returns:
- true if this descriptor must be proxied, false if this
descriptor must NOT be proxied (even if it is in an Unproxiable scope)
and null if this descriptor should take its proxiable status from
the scope it is in (i.e., it will only be proxied if the scope is
marked
Proxiable)
-
setProxiable
public void setProxiable(java.lang.Boolean proxiable)
Sets whether or not this descriptor should be proxied- Parameters:
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 in
-
isProxyForSameScope
public java.lang.Boolean isProxyForSameScope()
Description copied from interface:DescriptorThis value determines whether or not this service should be proxied when being injected into other services of the same scope. If a scope is proxiable then it will have a default setting for whether or not its services should be proxied when being injected into the same scope. If this method returns null then the default setting for the scope will be used. Otherwise the value returned will determine whether or not this service will be proxied when being injected into a service of the same scope.- Specified by:
isProxyForSameScopein interfaceDescriptor- Returns:
- null if this descriptor should use the default ProxyForSameScope value for the scope. If it returns true then this service will be proxied even when being injected into the same scope. If it returns false then this service will NOT be proxied when being injected into the same scope (i.e., it cannot be used for lazy initialization of the service when injected into the same scope)
-
setProxyForSameScope
public void setProxyForSameScope(java.lang.Boolean proxyForSameScope)
Sets whether or not to proxy this descriptor for other services in the same scope- Parameters:
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 in
-
getClassAnalysisName
public java.lang.String getClassAnalysisName()
Description copied from interface:DescriptorReturns the name of theClassAnalyzerservice 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 hk2- Specified by:
getClassAnalysisNamein interfaceDescriptor- Returns:
- the possibly null name of the ClassAnalysis service that should be used to analyze the class represented by this descriptor. If null then the HK2 default analysis will be performed
-
setClassAnalysisName
public void setClassAnalysisName(java.lang.String name)
Sets the name of the service that will be used to analyze this class- Parameters:
name- The name of theClassAnalyzerservice that should be used to analyze this descriptor
-
getLocatorId
public java.lang.Long getLocatorId()
Description copied from interface:DescriptorThis returns the id of the ServiceLocator which this descriptor is registered with. Returns null if this descriptor is not yet registered with a ServiceLocator- Specified by:
getLocatorIdin interfaceDescriptor- Returns:
- The id of the ServiceLocator this Descriptor is registered with, or null if this Descriptor is not registered with a ServiceLocator
-
setLocatorId
public void setLocatorId(java.lang.Long locatorId)
Sets the locator id for this descriptor- Parameters:
locatorId- the locator id for this descriptor
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equalOrderedCollection
private static <T> boolean equalOrderedCollection(java.util.Collection<T> a, java.util.Collection<T> b)
-
equalMetadata
private static <T> boolean equalMetadata(java.util.Map<java.lang.String,java.util.List<java.lang.String>> a, java.util.Map<java.lang.String,java.util.List<java.lang.String>> b)
-
descriptorEquals
public 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
- Parameters:
a- The possibly null descriptor to compareb- The possibly null descriptor to compare- Returns:
- true if they are the same, false otherwise
-
equals
public boolean equals(java.lang.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
- Overrides:
equalsin classjava.lang.Object- Parameters:
a- The object to compare to this one. May be null (which will result in a false)- Returns:
- true if the descriptors are equal
-
pretty
public static void pretty(java.lang.StringBuffer sb, Descriptor d)Will pretty print a descriptor- Parameters:
sb- The string buffer put the pretty print intod- The descriptor to write
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
writeObject
public void writeObject(java.io.PrintWriter out) throws java.io.IOExceptionThis writes this object to the data output stream in a human-readable format, excellent for writing out data files- Parameters:
out- The output stream to write this object out to- Throws:
java.io.IOException- on failure
-
reinitialize
private void reinitialize()
-
readObject
public boolean readObject(java.io.BufferedReader in) throws java.io.IOExceptionThis can be used to read in instances of this object that were previously written out with writeObject. Useful for reading from external data files- Parameters:
in- The reader to read from- Returns:
- true if a descriptor was read, false otherwise. This is useful if reading a file that might have comments at the end
- Throws:
java.io.IOException- on failure
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-