
com.peterphi.std.guice.web.rest.jaxrs.GuiceRestApplication Maven / Gradle / Ivy
package com.peterphi.std.guice.web.rest.jaxrs;
import com.google.inject.Inject;
import com.peterphi.std.guice.apploader.GuiceApplication;
import com.peterphi.std.guice.apploader.impl.GuiceRegistry;
import com.peterphi.std.guice.serviceregistry.rest.RestResourceRegistry;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;
/**
* A jax-rs REST {@link Application} implementation that returns singletons whih are dynamic proxies bound to objects built by
* Guice
* This allows for a vanilla jax rs implementation, albeit at a small runtime performance penalty.
*/
public class GuiceRestApplication extends Application implements GuiceApplication
{
private final GuiceRegistry guiceRegistry;
private final GuiceRestApplicationRegistry registry;
public GuiceRestApplication()
{
this(new GuiceRegistry());
}
/**
* If constructing from within a guice environment we should use the existing GuiceRegistry
*
* @param guiceRegistry
*/
@Inject
public GuiceRestApplication(GuiceRegistry guiceRegistry)
{
this.guiceRegistry = guiceRegistry;
guiceRegistry.register(this, true);
this.registry = new GuiceRestApplicationRegistry(guiceRegistry);
}
@Override
public Set
© 2015 - 2025 Weber Informatics LLC | Privacy Policy