Class ComponentMetadata
- java.lang.Object
-
- org.apache.felix.scr.impl.metadata.ComponentMetadata
-
public class ComponentMetadata extends java.lang.ObjectThis class holds the information associated to a component in the descriptor
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIGURATION_POLICY_IGNOREstatic java.lang.StringCONFIGURATION_POLICY_OPTIONALstatic java.lang.StringCONFIGURATION_POLICY_REQUIREprivate static java.util.Set<java.lang.String>CONFIGURATION_POLICY_VALIDprivate static java.lang.StringIMPLEMENTATION_CLASS_DUPLICATEprivate java.lang.Stringm_activateprivate booleanm_activateDeclaredprivate java.util.List<java.lang.String>m_activationFieldsprivate booleanm_configurableServicePropertiesprivate java.util.List<java.lang.String>m_configurationPidprivate java.lang.Stringm_configurationPolicyprivate booleanm_configureWithInterfacesprivate java.lang.Stringm_deactivateprivate booleanm_deactivateDeclaredprivate booleanm_delayedKeepInstancesprivate booleanm_deleteCallsModifyprivate DSVersionm_dsVersionprivate booleanm_enabledprivate java.lang.Stringm_factoryprivate java.util.Map<java.lang.String,java.lang.Object>m_factoryPropertiesprivate java.util.List<PropertyMetadata>m_factoryPropertyMetaDataprivate java.lang.Booleanm_immediateprivate java.lang.Stringm_implementationClassNameprivate java.lang.Stringm_initprivate java.lang.Stringm_modifiedprivate java.lang.Stringm_nameprivate java.lang.Booleanm_obsoleteFactoryComponentFactoryprivate booleanm_persistentFactoryComponentprivate java.util.Map<java.lang.String,java.lang.Object>m_propertiesprivate java.util.List<PropertyMetadata>m_propertyMetaDataprivate java.util.List<ReferenceMetadata>m_referencesprivate ServiceMetadatam_serviceprivate booleanm_validatedprivate static ServiceMetadataSERVICE_DUPLICATEprivate static byteTypeBooleanprivate static byteTypeByteprivate static byteTypeCharprivate static byteTypeDoubleprivate static byteTypeFloatprivate static byteTypeIntegerprivate static byteTypeLongprivate static byteTypeShortprivate static byteTypeString
-
Constructor Summary
Constructors Constructor Description ComponentMetadata(DSVersion dsVersion)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDependency(ReferenceMetadata newReference)Used to add a reference metadata to the componentvoidaddFactoryProperty(PropertyMetadata newProperty)Used to add a factory property to the instancevoidaddProperty(PropertyMetadata newProperty)Used to add a property to the instanceprivate voidcollectStrings(java.util.Map.Entry<java.lang.String,java.lang.Object> entry, java.util.Set<java.lang.String> strings)voidcollectStrings(java.util.Set<java.lang.String> strings)java.lang.StringgetActivate()Returns the name of the activate methodjava.util.List<java.lang.String>getActivationFields()Returns the names of the activation fieldsjava.util.List<java.lang.String>getConfigurationPid()Returns the configuration pid for the component.java.lang.StringgetConfigurationPolicy()Returns the configuration Policyjava.lang.StringgetDeactivate()Returns the name of the deactivate methodjava.util.List<ReferenceMetadata>getDependencies()Returns the dependency descriptorsDSVersiongetDSVersion()Returns the namespace code of the namespace of the component element declaring this component.java.lang.StringgetFactoryIdentifier()Returns the factory identifierjava.util.Map<java.lang.String,java.lang.Object>getFactoryProperties()Returns the factory properties.(package private) java.util.List<PropertyMetadata>getFactoryPropertyMetaData()Returns the list of factory property meta data.java.lang.StringgetImplementationClassName()Returns the name of the implementation classjava.lang.StringgetModified()Returns the name of the modified methodjava.lang.StringgetName()Returns the name of the componentintgetNumberOfConstructorParameters()Returns the number of constructor parameters (0 is default)intgetPidIndex(TargetedPID pid)java.util.Map<java.lang.String,java.lang.Object>getProperties()Returns the properties.(package private) java.util.List<PropertyMetadata>getPropertyMetaData()Returns the list of property meta data.ServiceMetadatagetServiceMetadata()Returns the associated ServiceMetadataServiceMetadata.ScopegetServiceScope()private bytegetType(java.lang.Class<?> typeClass)booleanisActivateDeclared()Returns whether the activate method has been declared in the descriptor or not.booleanisConfigurableServiceProperties()booleanisConfigurationIgnored()Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_IGNORE.booleanisConfigurationOptional()Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_OPTIONAL.booleanisConfigurationPidDeclared()Returns whether the configuration-pid has been declared in the descriptor or not.booleanisConfigurationRequired()Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_REQUIRE.booleanisConfigureWithInterfaces()booleanisDeactivateDeclared()Returns whether the deactivate method has been declared in the descriptor or not.booleanisDelayedKeepInstances()booleanisDeleteCallsModify()booleanisEnabled()Returns the value of the enabled flagbooleanisFactory()Test to see if this service is a factorybooleanisImmediate()Returns the flag that defines the activation policy for the component.booleanisObsoleteFactoryComponentFactory()booleanisPersistentFactoryComponent()static ComponentMetadataload(java.io.DataInputStream in, MetadataStoreHelper.MetaDataReader metaDataReader)(package private) static java.lang.ObjectloadPropertyValue(java.io.DataInputStream in, MetadataStoreHelper.MetaDataReader metaDataReader)voidsetActivate(java.lang.String activate)Sets the name of the activate methodvoidsetActivationFields(java.lang.String[] fields)voidsetConfigurableServiceProperties(boolean configurableServiceProperties)voidsetConfigurationPid(java.lang.String[] configurationPid)Setter for the configuration-pid component (since DS 1.2)voidsetConfigurationPolicy(java.lang.String configurationPolicy)Sets the configuration policyvoidsetConfigureWithInterfaces(boolean configureWithInterfaces)voidsetDeactivate(java.lang.String deactivate)Sets the name of the deactivate methodvoidsetDelayedKeepInstances(boolean delayedKeepInstances)voidsetDeleteCallsModify(boolean deleteCallsModify)voidsetEnabled(boolean enabled)Setter for the enabled propertyvoidsetFactoryIdentifier(java.lang.String factoryIdentifier)voidsetImmediate(boolean immediate)Setter for the immediate propertyvoidsetImplementationClassName(java.lang.String implementationClassName)Sets the name of the implementation classvoidsetInit(java.lang.String value)voidsetModified(java.lang.String modified)Sets the name of the modified methodvoidsetName(java.lang.String name)Setter for the namevoidsetObsoleteFactoryComponentFactory(boolean obsoleteFactoryComponentFactory)voidsetPersistentFactoryComponent(boolean persistentFactoryComponent)voidsetService(ServiceMetadata service)Used to set a ServiceMetadata object.voidstore(java.io.DataOutputStream out, MetadataStoreHelper.MetaDataWriter metaDataWriter)(package private) voidstorePropertyValue(java.lang.Object value, java.io.DataOutputStream out, MetadataStoreHelper.MetaDataWriter metaDataWriter)voidvalidate()Method used to verify if the semantics of this metadata are correct(package private) org.osgi.service.component.ComponentExceptionvalidationFailure(java.lang.String reason)Returns aComponentExceptionfor this component with the given explanation for failure.
-
-
-
Field Detail
-
CONFIGURATION_POLICY_REQUIRE
public static final java.lang.String CONFIGURATION_POLICY_REQUIRE
- See Also:
- Constant Field Values
-
CONFIGURATION_POLICY_IGNORE
public static final java.lang.String CONFIGURATION_POLICY_IGNORE
- See Also:
- Constant Field Values
-
CONFIGURATION_POLICY_OPTIONAL
public static final java.lang.String CONFIGURATION_POLICY_OPTIONAL
- See Also:
- Constant Field Values
-
CONFIGURATION_POLICY_VALID
private static final java.util.Set<java.lang.String> CONFIGURATION_POLICY_VALID
-
IMPLEMENTATION_CLASS_DUPLICATE
private static final java.lang.String IMPLEMENTATION_CLASS_DUPLICATE
- See Also:
- Constant Field Values
-
SERVICE_DUPLICATE
private static final ServiceMetadata SERVICE_DUPLICATE
-
m_dsVersion
private final DSVersion m_dsVersion
-
m_name
private java.lang.String m_name
-
m_enabled
private boolean m_enabled
-
m_factory
private java.lang.String m_factory
-
m_immediate
private java.lang.Boolean m_immediate
-
m_implementationClassName
private java.lang.String m_implementationClassName
-
m_activate
private java.lang.String m_activate
-
m_activateDeclared
private boolean m_activateDeclared
-
m_deactivate
private java.lang.String m_deactivate
-
m_deactivateDeclared
private boolean m_deactivateDeclared
-
m_modified
private java.lang.String m_modified
-
m_configurationPolicy
private java.lang.String m_configurationPolicy
-
m_configurationPid
private java.util.List<java.lang.String> m_configurationPid
-
m_activationFields
private java.util.List<java.lang.String> m_activationFields
-
m_properties
private final java.util.Map<java.lang.String,java.lang.Object> m_properties
-
m_factoryProperties
private final java.util.Map<java.lang.String,java.lang.Object> m_factoryProperties
-
m_propertyMetaData
private final java.util.List<PropertyMetadata> m_propertyMetaData
-
m_factoryPropertyMetaData
private final java.util.List<PropertyMetadata> m_factoryPropertyMetaData
-
m_service
private ServiceMetadata m_service
-
m_references
private final java.util.List<ReferenceMetadata> m_references
-
m_configurableServiceProperties
private boolean m_configurableServiceProperties
-
m_persistentFactoryComponent
private boolean m_persistentFactoryComponent
-
m_deleteCallsModify
private boolean m_deleteCallsModify
-
m_obsoleteFactoryComponentFactory
private java.lang.Boolean m_obsoleteFactoryComponentFactory
-
m_configureWithInterfaces
private boolean m_configureWithInterfaces
-
m_delayedKeepInstances
private boolean m_delayedKeepInstances
-
m_init
private java.lang.String m_init
-
m_validated
private boolean m_validated
-
TypeString
private static final byte TypeString
- See Also:
- Constant Field Values
-
TypeLong
private static final byte TypeLong
- See Also:
- Constant Field Values
-
TypeDouble
private static final byte TypeDouble
- See Also:
- Constant Field Values
-
TypeFloat
private static final byte TypeFloat
- See Also:
- Constant Field Values
-
TypeInteger
private static final byte TypeInteger
- See Also:
- Constant Field Values
-
TypeByte
private static final byte TypeByte
- See Also:
- Constant Field Values
-
TypeChar
private static final byte TypeChar
- See Also:
- Constant Field Values
-
TypeBoolean
private static final byte TypeBoolean
- See Also:
- Constant Field Values
-
TypeShort
private static final byte TypeShort
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ComponentMetadata
public ComponentMetadata(DSVersion dsVersion)
-
-
Method Detail
-
setConfigurationPid
public void setConfigurationPid(java.lang.String[] configurationPid)
Setter for the configuration-pid component (since DS 1.2)- Parameters:
configurationPid-
-
setName
public void setName(java.lang.String name)
Setter for the name- Parameters:
name-
-
setEnabled
public void setEnabled(boolean enabled)
Setter for the enabled property- Parameters:
enabled-
-
setFactoryIdentifier
public void setFactoryIdentifier(java.lang.String factoryIdentifier)
- Parameters:
factoryIdentifier-
-
setImmediate
public void setImmediate(boolean immediate)
Setter for the immediate property- Parameters:
immediate-
-
setImplementationClassName
public void setImplementationClassName(java.lang.String implementationClassName)
Sets the name of the implementation class- Parameters:
implementationClassName- a class name
-
setConfigurationPolicy
public void setConfigurationPolicy(java.lang.String configurationPolicy)
Sets the configuration policy- Parameters:
configurationPolicy- configuration policy- Since:
- 1.2.0 (DS 1.1)
-
setActivate
public void setActivate(java.lang.String activate)
Sets the name of the activate method- Parameters:
activate- a method name- Since:
- 1.2.0 (DS 1.1)
-
setDeactivate
public void setDeactivate(java.lang.String deactivate)
Sets the name of the deactivate method- Parameters:
deactivate- a method name- Since:
- 1.2.0 (DS 1.1)
-
setModified
public void setModified(java.lang.String modified)
Sets the name of the modified method- Parameters:
modified- a method name- Since:
- 1.2.0 (DS 1.1)
-
addProperty
public void addProperty(PropertyMetadata newProperty)
Used to add a property to the instance- Parameters:
newProperty- a property metadata object
-
addFactoryProperty
public void addFactoryProperty(PropertyMetadata newProperty)
Used to add a factory property to the instance- Parameters:
newProperty- a property metadata object
-
setService
public void setService(ServiceMetadata service)
Used to set a ServiceMetadata object.- Parameters:
service- a ServiceMetadata
-
addDependency
public void addDependency(ReferenceMetadata newReference)
Used to add a reference metadata to the component- Parameters:
newReference- a new ReferenceMetadata to be added
-
setConfigurableServiceProperties
public void setConfigurableServiceProperties(boolean configurableServiceProperties)
-
setPersistentFactoryComponent
public void setPersistentFactoryComponent(boolean persistentFactoryComponent)
-
setDeleteCallsModify
public void setDeleteCallsModify(boolean deleteCallsModify)
-
setObsoleteFactoryComponentFactory
public void setObsoleteFactoryComponentFactory(boolean obsoleteFactoryComponentFactory)
-
setConfigureWithInterfaces
public void setConfigureWithInterfaces(boolean configureWithInterfaces)
-
setDelayedKeepInstances
public void setDelayedKeepInstances(boolean delayedKeepInstances)
-
setActivationFields
public void setActivationFields(java.lang.String[] fields)
-
setInit
public void setInit(java.lang.String value)
-
getDSVersion
public DSVersion getDSVersion()
Returns the namespace code of the namespace of the component element declaring this component. This is one of the XmlHandler.DS_VERSION_* constants.
-
getName
public java.lang.String getName()
Returns the name of the component- Returns:
- A string containing the name of the component
-
getConfigurationPid
public java.util.List<java.lang.String> getConfigurationPid()
Returns the configuration pid for the component. The pid is the one specified in the component's configuration-pid DS 1.2 attribute, if specified. Else the component name is used as the pid by default.
-
getPidIndex
public int getPidIndex(TargetedPID pid)
-
isConfigurationPidDeclared
public boolean isConfigurationPidDeclared()
Returns whether the configuration-pid has been declared in the descriptor or not.- Returns:
- whether the configuration-pid has method has been declared in the descriptor or not.
- Since:
- DS 1.2
-
isEnabled
public boolean isEnabled()
Returns the value of the enabled flag- Returns:
- a boolean containing the value of the enabled flag
-
getFactoryIdentifier
public java.lang.String getFactoryIdentifier()
Returns the factory identifier- Returns:
- A string containing a factory identifier or null
-
isImmediate
public boolean isImmediate()
Returns the flag that defines the activation policy for the component.This method may only be trusted after this instance has been validated by the
validate( )call. Else it will either return the value of an explicitly set "immediate" attribute or return false if a service element or the factory attribute is set or true otherwise. This latter default value deduction may be unsafe while the descriptor has not been completely read.- Returns:
- a boolean that defines the activation policy
-
getImplementationClassName
public java.lang.String getImplementationClassName()
Returns the name of the implementation class- Returns:
- the name of the implementation class
-
getConfigurationPolicy
public java.lang.String getConfigurationPolicy()
Returns the configuration Policy- Returns:
- the configuration policy
- Since:
- 1.2.0 (DS 1.1)
-
getActivate
public java.lang.String getActivate()
Returns the name of the activate method- Returns:
- the name of the activate method
- Since:
- 1.2.0 (DS 1.1)
-
isActivateDeclared
public boolean isActivateDeclared()
Returns whether the activate method has been declared in the descriptor or not.- Returns:
- whether the activate method has been declared in the descriptor or not.
- Since:
- 1.2.0 (DS 1.1)
-
getNumberOfConstructorParameters
public int getNumberOfConstructorParameters()
Returns the number of constructor parameters (0 is default)- Returns:
- The number of constructor parameters
- Since:
- 2.1.0 (DS 1.4)
-
getActivationFields
public java.util.List<java.lang.String> getActivationFields()
Returns the names of the activation fields- Returns:
- the list of activation fields or
null - Since:
- 2.1.0 (DS 1.4)
-
getDeactivate
public java.lang.String getDeactivate()
Returns the name of the deactivate method- Returns:
- the name of the deactivate method
- Since:
- 1.2.0 (DS 1.1)
-
isDeactivateDeclared
public boolean isDeactivateDeclared()
Returns whether the deactivate method has been declared in the descriptor or not.- Returns:
- whether the deactivate method has been declared in the descriptor or not.
- Since:
- 1.2.0 (DS 1.1)
-
getModified
public java.lang.String getModified()
Returns the name of the modified method- Returns:
- the name of the modified method
- Since:
- 1.2.0 (DS 1.1)
-
getServiceMetadata
public ServiceMetadata getServiceMetadata()
Returns the associated ServiceMetadata- Returns:
- a ServiceMetadata object or null if the Component does not provide any service
-
getServiceScope
public ServiceMetadata.Scope getServiceScope()
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Returns the properties.- Returns:
- the properties as a Dictionary
-
getFactoryProperties
public java.util.Map<java.lang.String,java.lang.Object> getFactoryProperties()
Returns the factory properties.- Returns:
- the factory properties as a Dictionary
-
getPropertyMetaData
java.util.List<PropertyMetadata> getPropertyMetaData()
Returns the list of property meta data. Note: This method is intended for unit testing only- Returns:
- the list of property meta data.
-
getFactoryPropertyMetaData
java.util.List<PropertyMetadata> getFactoryPropertyMetaData()
Returns the list of factory property meta data. Note: This method is intended for unit testing only- Returns:
- the list of property meta data.
-
getDependencies
public java.util.List<ReferenceMetadata> getDependencies()
Returns the dependency descriptors- Returns:
- a Collection of dependency descriptors
-
isFactory
public boolean isFactory()
Test to see if this service is a factory- Returns:
- true if it is a factory, false otherwise
-
isConfigurationRequired
public boolean isConfigurationRequired()
Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_REQUIRE.
-
isConfigurationIgnored
public boolean isConfigurationIgnored()
Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_IGNORE.
-
isConfigurationOptional
public boolean isConfigurationOptional()
Returnstrueif the configuration policy is configured toCONFIGURATION_POLICY_OPTIONAL.
-
isConfigurableServiceProperties
public boolean isConfigurableServiceProperties()
-
isPersistentFactoryComponent
public boolean isPersistentFactoryComponent()
-
isDeleteCallsModify
public boolean isDeleteCallsModify()
-
isObsoleteFactoryComponentFactory
public boolean isObsoleteFactoryComponentFactory()
-
isConfigureWithInterfaces
public boolean isConfigureWithInterfaces()
-
isDelayedKeepInstances
public boolean isDelayedKeepInstances()
-
validate
public void validate()
Method used to verify if the semantics of this metadata are correct
-
validationFailure
org.osgi.service.component.ComponentException validationFailure(java.lang.String reason)
Returns aComponentExceptionfor this component with the given explanation for failure.- Parameters:
reason- The explanation for failing to validate this component.
-
collectStrings
public void collectStrings(java.util.Set<java.lang.String> strings)
-
collectStrings
private void collectStrings(java.util.Map.Entry<java.lang.String,java.lang.Object> entry, java.util.Set<java.lang.String> strings)
-
store
public void store(java.io.DataOutputStream out, MetadataStoreHelper.MetaDataWriter metaDataWriter) throws java.io.IOException- Throws:
java.io.IOException
-
load
public static ComponentMetadata load(java.io.DataInputStream in, MetadataStoreHelper.MetaDataReader metaDataReader) throws java.io.IOException
- Throws:
java.io.IOException
-
loadPropertyValue
static java.lang.Object loadPropertyValue(java.io.DataInputStream in, MetadataStoreHelper.MetaDataReader metaDataReader) throws java.io.IOException- Throws:
java.io.IOException
-
storePropertyValue
void storePropertyValue(java.lang.Object value, java.io.DataOutputStream out, MetadataStoreHelper.MetaDataWriter metaDataWriter) throws java.io.IOException- Throws:
java.io.IOException
-
getType
private byte getType(java.lang.Class<?> typeClass)
-
-