io.quarkus.resteasy.links.runtime.hal.ResteasyHalService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-resteasy-links Show documentation
Show all versions of quarkus-resteasy-links Show documentation
Web Links support for RESTEasy Classic. Inject web links into response HTTP headers by annotating your endpoint resources.
The newest version!
package io.quarkus.resteasy.links.runtime.hal;
import java.util.HashMap;
import java.util.Map;
import jakarta.enterprise.context.RequestScoped;
import org.jboss.resteasy.links.LinksProvider;
import org.jboss.resteasy.links.RESTServiceDiscovery;
import io.quarkus.hal.HalLink;
import io.quarkus.hal.HalService;
@RequestScoped
public class ResteasyHalService extends HalService {
@Override
protected Map getClassLinks(Class> entityClass) {
return linksToMap(LinksProvider.getClassLinksProvider().getLinks(entityClass,
Thread.currentThread().getContextClassLoader()));
}
@Override
protected Map getInstanceLinks(Object entity) {
return linksToMap(LinksProvider.getObjectLinksProvider().getLinks(entity,
Thread.currentThread().getContextClassLoader()));
}
private Map linksToMap(RESTServiceDiscovery serviceDiscovery) {
Map links = new HashMap<>(serviceDiscovery.size());
for (RESTServiceDiscovery.AtomLink atomLink : serviceDiscovery) {
links.put(atomLink.getRel(), new HalLink(atomLink.getHref(), atomLink.getTitle(), atomLink.getType()));
}
return links;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy