Example usage for org.apache.wicket.request.resource ResourceReference of

List of usage examples for org.apache.wicket.request.resource ResourceReference of

Introduction

In this page you can find the example usage for org.apache.wicket.request.resource ResourceReference of.

Prototype

public static final ResourceReference of(Key key, SerializableSupplier<IResource> resourceSupplier) 

Source Link

Document

Factory method to build a resource reference that uses the provided supplier to return the resource.

Usage

From source file:org.wicketstuff.rest.lambda.mounter.LambdaRestMounter.java

License:Apache License

/**
 * Mount rest resource./*from   w  w  w.  j  a  v a2  s .co m*/
 *
 * @param httpMethod the http method
 * @param path the mounting path
 * @param resource the resource
 * @return the resource mapper
 */
protected ResourceMapper mountRestResource(final HttpMethod httpMethod, final String path, IResource resource) {
    ResourceReference reference = ResourceReference.of(path + "_" + httpMethod.name(), () -> resource);

    if (reference.canBeRegistered()) {
        application.getResourceReferenceRegistry().registerResourceReference(reference);
    }

    RestResourceMapper mapper = new RestResourceMapper(path, reference, httpMethod);
    application.mount(mapper);
    return mapper;
}