|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.scrplugin.SCRDescriptorGenerator
public class SCRDescriptorGenerator
The SCRDescriptorGenerator
class does the hard work of
generating the SCR descriptors. This class is being instantiated and
configured by clients and the execute()
method called to generate
the descriptor files.
When using this class carefully consider calling all setter methods to properly configure the generator. All setter method document, which default value is assumed for the respective property if the setter is not called.
Instances of this class are not thread save and should not be reused.
Field Summary | |
---|---|
protected boolean |
strictMode
|
Constructor Summary | |
---|---|
SCRDescriptorGenerator(Log logger)
Create an instance of this generator using the given Log
instance of logging. |
Method Summary | |
---|---|
protected void |
addInterfaces(Service service,
JavaTag serviceTag,
JavaClassDescription description)
Recursively add interfaces to the service. |
protected Component |
createComponent(JavaClassDescription description,
JavaTag componentTag,
MetaData metaData,
IssueLog iLog)
Create a component for the java class description. |
protected OCD |
doComponent(JavaTag tag,
Component component,
MetaData metaData,
IssueLog iLog)
Fill the component object with the information from the tag. |
protected void |
doReference(JavaTag reference,
String name,
Component component,
String type)
|
protected void |
doServices(JavaTag[] services,
Component component,
JavaClassDescription description)
Process the service annotations |
boolean |
execute()
Actually generates the Declarative Services and Metatype descriptors scanning the java sources provided by the descriptor manager . |
static boolean |
getBoolean(JavaTag tag,
String name,
boolean defaultValue)
|
protected JavaField |
getReferencedField(JavaTag tag,
String ref)
|
protected String |
getReferenceName(JavaTag reference,
String defaultName)
|
void |
setDescriptorManager(JavaClassDescriptorManager descriptorManager)
Sets the JavaClassDescriptorManager instance used to access
existing descriptors and to parse JavaDoc tags as well as interpret
the SCR annotations. |
void |
setFinalName(String finalName)
Sets the name of the SCR declaration descriptor file. |
void |
setGenerateAccessors(boolean generateAccessors)
Defines whether bind and unbind methods are automatically created by the SCR descriptor generator. |
void |
setMetaTypeName(String metaTypeName)
Sets the name of the file taking the Metatype Service descriptors. |
void |
setOutputDirectory(File outputDirectory)
Sets the directory where the descriptor files will be created. |
void |
setProperties(Map<String,String> properties)
Sets global properties to be set for each descriptor. |
void |
setSpecVersion(String specVersion)
Sets the Declarative Services specification version number to be forced on the declarations. |
void |
setStrictMode(boolean strictMode)
Defines whether warnings should be considered as errors and thus cause the generation process to fail. |
protected void |
testReference(Map<String,Object[]> references,
JavaTag reference,
String defaultName,
boolean isInspectedClass)
Test a newly found reference |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean strictMode
Constructor Detail |
---|
public SCRDescriptorGenerator(Log logger)
Log
instance of logging.
Method Detail |
---|
public void setOutputDirectory(File outputDirectory)
This field has no default value and this setter must called prior
to calling execute()
.
public void setDescriptorManager(JavaClassDescriptorManager descriptorManager)
JavaClassDescriptorManager
instance used to access
existing descriptors and to parse JavaDoc tags as well as interpret
the SCR annotations.
This field has no default value and this setter must called prior
to calling execute()
.
public void setFinalName(String finalName)
output directory
.
This file will be overwritten if already existing. If no descriptors are created the file is actually removed.
The default value of this property is serviceComponents.xml
.
public void setMetaTypeName(String metaTypeName)
output directory
.
This file will be overwritten if already existing. If no descriptors are created the file is actually removed.
The default value of this property is metatype.xml
.
public void setGenerateAccessors(boolean generateAccessors)
The generator uses the ASM library to create the method byte codes directly inside the class files. If bind and unbind methods are not to be created, the generator fails if such methods are missing.
The default value of this property is true
.
public void setStrictMode(boolean strictMode)
The default value of this property is false
.
public void setProperties(Map<String,String> properties)
The are no default global properties.
public void setSpecVersion(String specVersion)
Supported values for this property are null
to autodetect
the specification version, 1.0
to force 1.0 descriptors and
1.1
to force 1.1 descriptors. If 1.0 descriptors are forced
the generation fails if a descriptor requires 1.1 functionality.
The default is to generate the descriptor version according to the
capabilities used by the descriptors. If no 1.1 capabilities, such as
configuration-policy
, are used, version 1.0 is used,
otherwise a 1.1 descriptor is generated.
public boolean execute() throws SCRDescriptorException, SCRDescriptorFailureException
descriptor manager
.
true
if descriptors have been generated.
SCRDescriptorException
SCRDescriptorFailureException
protected Component createComponent(JavaClassDescription description, JavaTag componentTag, MetaData metaData, IssueLog iLog) throws SCRDescriptorException
description
-
SCRDescriptorException
protected OCD doComponent(JavaTag tag, Component component, MetaData metaData, IssueLog iLog) throws SCRDescriptorException
tag
- component
-
SCRDescriptorException
protected void doServices(JavaTag[] services, Component component, JavaClassDescription description) throws SCRDescriptorException
services
- component
- description
-
SCRDescriptorException
protected void addInterfaces(Service service, JavaTag serviceTag, JavaClassDescription description) throws SCRDescriptorException
SCRDescriptorException
protected void testReference(Map<String,Object[]> references, JavaTag reference, String defaultName, boolean isInspectedClass) throws SCRDescriptorException
references
- reference
- defaultName
- isInspectedClass
-
SCRDescriptorException
protected String getReferenceName(JavaTag reference, String defaultName) throws SCRDescriptorException
SCRDescriptorException
protected JavaField getReferencedField(JavaTag tag, String ref) throws SCRDescriptorException
SCRDescriptorException
protected void doReference(JavaTag reference, String name, Component component, String type) throws SCRDescriptorException
reference
- defaultName
- component
-
SCRDescriptorException
public static boolean getBoolean(JavaTag tag, String name, boolean defaultValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |