Class StreamResourceRegistry
- All Implemented Interfaces:
Serializable
StreamResource
instances.- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Internal wrapper class for wrappingElementRequestHandler
instances asAbstractStreamResource
compatible instances. -
Constructor Summary
ConstructorsConstructorDescriptionStreamResourceRegistry
(VaadinSession session) Creates stream resource registry for providedsession
. -
Method Summary
Modifier and TypeMethodDescription<T extends AbstractStreamResource>
Optional<T>getResource
(Class<T> type, URI uri) Get a registered resource of given type.getResource
(URI uri) Get a registered resource for givenURI
.getTargetURI
(AbstractStreamResource resource) Returns the URI path to the given resource in the context of this registry (relevant in portlet context).static URI
getURI
(AbstractStreamResource resource) Gets the URI for the givenresource
.registerResource
(AbstractStreamResource resource) Registers a stream resource in the session and returns registration handler.registerResource
(ElementRequestHandler elementRequestHandler) Registers a stream resource in the session and returns registration handler.registerResource
(ElementRequestHandler elementRequestHandler, Element owner) Registers a stream resource in the session and returns registration handler.void
unregisterResource
(StreamReceiver resource) Unregister a stream receiver resource.
-
Constructor Details
-
StreamResourceRegistry
Creates stream resource registry for providedsession
.- Parameters:
session
- vaadin session
-
-
Method Details
-
registerResource
Registers a stream resource in the session and returns registration handler.You can get resource URI to use it in the application (e.g. set an attribute value or property value) via the registration handler. The registration handler should be used to unregister resource when it's not needed anymore. Note that it is the developer's responsibility to unregister resources. Otherwise, resources won't be garbage collected until the session expires which causes memory leak.
- Parameters:
resource
- stream resource to register- Returns:
- registration handler
-
registerResource
Registers a stream resource in the session and returns registration handler. Registration is done without a specific owner element and thus bound to UI element.You can get resource URI to use it in the application (e.g. set an attribute value or property value) via the registration handler. The registration handler should be used to unregister the resource when it's not needed anymore. Note that it is the developer's responsibility to unregister resources. Otherwise, resources won't be garbage collected until the session expires which causes memory leak.
- Parameters:
elementRequestHandler
- element request handler to register- Returns:
- registration handler
-
registerResource
public StreamRegistration registerResource(ElementRequestHandler elementRequestHandler, Element owner) Registers a stream resource in the session and returns registration handler.You can get resource URI to use it in the application (e.g. set an attribute value or property value) via the registration handler. The registration handler should be used to unregister the resource when it's not needed anymore. Note that it is the developer's responsibility to unregister resources. Otherwise, resources won't be garbage collected until the session expires which causes memory leak.
- Parameters:
elementRequestHandler
- element request handler to registerowner
- owner element this request handler is scoped to- Returns:
- registration handler
-
unregisterResource
Unregister a stream receiver resource.- Parameters:
resource
- stream receiver resource to unregister
-
getURI
Gets the URI for the givenresource
.The URI won't be handled (and won't work) if
resource
is not registered in the session.- Parameters:
resource
- stream resource- Returns:
- resource URI
- See Also:
-
getTargetURI
Returns the URI path to the given resource in the context of this registry (relevant in portlet context).- Parameters:
resource
- stream resource- Returns:
- resource URI
-
getResource
Get a registered resource for givenURI
.Resource may be a StreamResource or a StreamReceiver
- Parameters:
uri
- resource URI- Returns:
- an optional resource, or an empty optional if no resource has been registered with this URI
-
getResource
Get a registered resource of given type.- Type Parameters:
T
- resource extending AbstractStreamResource- Parameters:
type
- resource class typeuri
- resource URI- Returns:
- an optional resource, or an empty optional if no resource has been registered with this URI
-