@Service(value=ImageReaderService.class) @Reference(name="imageReaders", referenceInterface=ImageReader.class, cardinality=MANDATORY_MULTIPLE, policy=STATIC, strategy=LOOKUP) public class ImageReaderService extends Object implements ImageReader
ImageReader
with the
highest service ranking.Constructor and Description |
---|
ImageReaderService() |
Modifier and Type | Method and Description |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context)
Called when this component is enabled (when this services references are
satisfied and this service is referenced by some other service).
|
protected void |
deactivate(org.osgi.service.component.ComponentContext context)
Called when this component is disabled (when this services references are
not satisfied or this service is not referenced by some other service).
|
BufferedImage |
getBufferedImage(File file)
Creates a
BufferedImage from an File . |
BufferedImage |
getBufferedImage(InputStream in)
Creates a
BufferedImage from an InputStream . |
BufferedImage |
getBufferedImage(URL url)
Creates a
BufferedImage from a URL . |
ImageReader |
getImageReader()
Returns the
ImageReader with the highest service ranking. |
public ImageReader getImageReader()
ImageReader
with the highest service ranking.
In case of a tie, the service with the lower service id (in general the
service that got registered first) is returned.ImageReader
service instancepublic BufferedImage getBufferedImage(File file) throws IOException
BufferedImage
from an File
.
This method delegates to the ImageReader
service with the
highest service ranking. In case of a tie the service with the lowest
service id is used.
getBufferedImage
in interface ImageReader
file
- the image file.BufferedImage
containing the data of the specified
image.IOException
public BufferedImage getBufferedImage(InputStream in) throws IOException
BufferedImage
from an InputStream
.
This method delegates to the ImageReader
service with the
highest service ranking. In case of a tie the service with the lowest
service id is used.
getBufferedImage
in interface ImageReader
in
- a stream from which the image data can be read.BufferedImage
containing the data of the specified
image.IOException
public BufferedImage getBufferedImage(URL url) throws IOException
BufferedImage
from a URL
.
This method delegates to the ImageReader
service with the
highest service ranking. In case of a tie the service with the lowest
service id is used.
getBufferedImage
in interface ImageReader
url
- the location of the image described as a URL.BufferedImage
containing the data of the specified
image.IOException
@Activate protected void activate(org.osgi.service.component.ComponentContext context)
context
- the component context.@Deactivate protected void deactivate(org.osgi.service.component.ComponentContext context)
context
- the component context.Copyright © 2014 The Apache Software Foundation. All Rights Reserved.