Class MetaInfService
java.lang.Object
aQute.bnd.osgi.metainf.MetaInfService
Holds our knowledge about the META-INF/services/ files.
These are files that are used by Java in the Service Loader. Normally they have the name of a service type and are filled with their implementations, one per line.
We allow these lines to be annotated like Java types. Annotations are in the comments to not disturb other users of these files. They look like:
#import aQute.bnd.annotation.spi.ServiceProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA MetaInfService file consists of implementations. -
Constructor Summary
ConstructorsConstructorDescriptionMetaInfService(String serviceName) Create an emptyMetaInfService(String serviceName, Resource resource) Create a MetaInfService from a resourceMetaInfService(String serviceName, InputStream in) Create a MetaInfService from an input streamMetaInfService(String serviceName, Reader in) Create a MetaInfService from a readerMetaInfService(String serviceName, String source) Create from a source. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(String serviceImpl, Parameters annotations, String... comments) Add an extra implementation to the service files.voidappend(StringBuilder sb) Get the current list of implementationsstatic Map<String, MetaInfService> getServiceFiles(Jar jar) get the META-INF service files from a JARbooleanisDirty()Return if changes were made after the constructor parsing the source.toString()
-
Constructor Details
-
MetaInfService
-
MetaInfService
Create a MetaInfService from an input stream- Parameters:
serviceName- the fqn for the service interfacein- the input stream- Throws:
IOException
-
MetaInfService
Create a MetaInfService from a reader- Parameters:
serviceName- the fqn for the service interfacein- the reader- Throws:
IOException
-
MetaInfService
Create an empty- Parameters:
serviceName- the fqn for the service interface
-
MetaInfService
Create from a source. The source should be the content as defined for files in the META-INF/services directory. This may include imports and annotations in the comments.- Parameters:
serviceName- the fqn for the service interfacesource- the source code
-
-
Method Details
-
getServiceFiles
-
add
Add an extra implementation to the service files.- Parameters:
serviceImpl- the implementation fqnannotations- the annotations for this implementationcomments- the comments that come before the definition
-
getImplementations
Get the current list of implementations -
isDirty
public boolean isDirty()Return if changes were made after the constructor parsing the source. -
toString
-
append
-