public class StreamResource extends AbstractStreamResource
The instance should be registered via
StreamResourceRegistry.registerResource(AbstractStreamResource)
. This
method returns an object which may be used to get resource URI.
Constructor and Description |
---|
StreamResource(String name,
InputStreamFactory factory)
Creates
StreamResource instance using mandatory parameters
name as a resource file name and input stream factory as
a factory for data. |
StreamResource(String name,
StreamResourceWriter writer)
Creates
StreamResource instance using mandatory parameters
name as a resource file name and output stream writer as
a data producer. |
Modifier and Type | Method and Description |
---|---|
ContentTypeResolver |
getContentTypeResolver()
Gets the resolver which is used to lookup the content type of the
resource.
|
String |
getName()
Get the resource name.
|
StreamResourceWriter |
getWriter()
Returns the stream resource writer.
|
StreamResource |
setContentType(String contentType)
Set content type for the resource.
|
StreamResource |
setContentTypeResolver(ContentTypeResolver resolver)
Sets the resolver which is used to lookup the content type of the
resource.
|
getCacheTime, getId, setCacheTime
public StreamResource(String name, StreamResourceWriter writer)
StreamResource
instance using mandatory parameters
name
as a resource file name and output stream writer
as
a data producer. writer
should write data in the output stream
provided as an argument to its
StreamResourceWriter.accept(OutputStream, VaadinSession)
method.
name
parameter value will be used in URI (generated when resource
is registered) in a way that the name
is the last segment of the
path. So this is synthetic file name (not real one).
name
- resource file name. May not be null.writer
- data output stream consumerpublic StreamResource(String name, InputStreamFactory factory)
StreamResource
instance using mandatory parameters
name
as a resource file name and input stream factory
as
a factory for data.
name
parameter value will be used in URI (generated when resource
is registered) in a way that the name
is the last segment of the
path. So this is synthetic file name (not real one).
name
- resource file name. May not be null.factory
- data input stream factory. May not be null.public StreamResourceWriter getWriter()
Writer writes data in the output stream provided as an argument to its
StreamResourceWriter.accept(OutputStream, VaadinSession)
method.
public StreamResource setContentTypeResolver(ContentTypeResolver resolver)
By default a resolver based on servletContext.getMimeType() is used.
resolver
- content type resolver, not null
public StreamResource setContentType(String contentType)
This is a shorthand for
setContentTypeResolver(ContentTypeResolver)
with resolver which
always returns contentType
contentType
- resource content type, not null
public ContentTypeResolver getContentTypeResolver()
public String getName()
AbstractStreamResource
The value will be used in URI (generated when resource is registered) in
a way that the name
is the last segment of the path. So this is a
synthetic name.
getName
in class AbstractStreamResource
Copyright © 2018. All rights reserved.