com.peterphi.std.guice.web.rest.jaxrs.GuiceRestApplicationRegistry Maven / Gradle / Ivy
package com.peterphi.std.guice.web.rest.jaxrs;
import com.peterphi.std.guice.apploader.impl.GuiceRegistry;
import com.peterphi.std.guice.serviceregistry.rest.RestResource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
class GuiceRestApplicationRegistry
{
private final Map resources = new HashMap<>();
private final GuiceRegistry guiceRegistry;
public GuiceRestApplicationRegistry(final GuiceRegistry guiceRegistry)
{
this.guiceRegistry = guiceRegistry;
}
public void registerAll(Collection resources)
{
for (RestResource resource : resources)
{
register(resource);
}
}
public void register(RestResource resource)
{
if (!this.resources.containsKey(resource))
{
this.resources.put(resource, new GuiceDynamicProxyProvider(guiceRegistry, resource.getResourceClass()));
}
}
public void clear()
{
resources.clear();
}
public Collection getDynamicProxyProviders()
{
return new ArrayList<>(this.resources.values());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy