Package org.jboss.resteasy.spi

Examples of org.jboss.resteasy.spi.ResteasyProviderFactory


   @Test
   public void testUserPrecendence2() throws Exception
   {
      // register PlainTextWriter first
      ResteasyProviderFactory factory = new ResteasyProviderFactory();

      factory.registerProviderInstance(new PlainTextWriter());
      RegisterBuiltin.register(factory);

      verifyPlainWriter(factory);

      factory.registerProviderInstance(new IntegerPlainTextWriter());
      verifyIntegerWriter(factory);

   }
View Full Code Here


   @Test
   public void testUserPrecendence3() throws Exception
   {
      // register PlainTextWriter first
      ResteasyProviderFactory factory = new ResteasyProviderFactory();

      factory.registerProviderInstance(new IntegerPlainTextWriter());
      factory.registerProviderInstance(new PlainTextWriter());
      RegisterBuiltin.register(factory);

      verifyIntegerWriter(factory);

   }
View Full Code Here

     */
    @SuppressWarnings("rawtypes")
    protected void processInjector(ServletContext context, Injector inj) {
        final Registry registry = (Registry) context
                .getAttribute(Registry.class.getName());
        final ResteasyProviderFactory providerFactory = (ResteasyProviderFactory) context
                .getAttribute(ResteasyProviderFactory.class.getName());

        for (final Binding<?> binding : inj.getBindings().values()) {
            final Type type = binding.getKey().getTypeLiteral().getType();
            if (type instanceof Class) {
                final Class<?> beanClass = (Class) type;
                if (GetRestful.isRootResource(beanClass)) {
                    final ResourceFactory resourceFactory = new GuiceResourceFactory(
                            binding.getProvider(), beanClass);
                    log.info("Registering factory for {}", beanClass.getName());
                    registry.addResourceFactory(resourceFactory);
                }
                if (beanClass.isAnnotationPresent(Provider.class)) {
                    log.info("Registering provider instance for {}", beanClass.getName());
                    providerFactory.registerProviderInstance(binding
                            .getProvider().get());
                }
            }
        }
    }
View Full Code Here

@Produces({"application/*+json", "text/json"})
@Consumes({"application/*+json", "text/json"})
public class JsonProvider extends JacksonJsonProvider {

    public static void register(boolean indentJson) {
        ResteasyProviderFactory rpf = ResteasyProviderFactory.getInstance();
        JsonProvider jsonprovider = new JsonProvider(indentJson);
        rpf.addMessageBodyReader(jsonprovider);
        rpf.addMessageBodyWriter(jsonprovider);
        RegisterBuiltin.register(rpf);
    }
View Full Code Here

     */
    @SuppressWarnings("rawtypes")
    protected void processInjector(ServletContext context, Injector inj) {
        final Registry registry = (Registry) context
                .getAttribute(Registry.class.getName());
        final ResteasyProviderFactory providerFactory = (ResteasyProviderFactory) context
                .getAttribute(ResteasyProviderFactory.class.getName());

        for (final Binding<?> binding : inj.getBindings().values()) {
            final Type type = binding.getKey().getTypeLiteral().getType();
            if (type instanceof Class) {
                final Class<?> beanClass = (Class) type;
                if (GetRestful.isRootResource(beanClass)) {
                    final ResourceFactory resourceFactory = new GuiceResourceFactory(
                            binding.getProvider(), beanClass);
                    log.info("Registering factory for {}", beanClass.getName());
                    registry.addResourceFactory(resourceFactory);
                }
                if (beanClass.isAnnotationPresent(Provider.class)) {
                    log.info("Registering provider instance for {}", beanClass.getName());
                    providerFactory.registerProviderInstance(binding
                            .getProvider().get());
                }
            }
        }
    }
View Full Code Here

@Produces({"application/*+json", "text/json"})
@Consumes({"application/*+json", "text/json"})
public class JsonProvider extends JacksonJsonProvider {

    public static void register(boolean indentJson) {
        ResteasyProviderFactory rpf = ResteasyProviderFactory.getInstance();
        JsonProvider jsonprovider = new JsonProvider(indentJson);
        rpf.addMessageBodyReader(jsonprovider);
        rpf.addMessageBodyWriter(jsonprovider);
        RegisterBuiltin.register(rpf);
    }
View Full Code Here

*/
public class CandlepinConnection {

    @Inject
    public CandlepinConnection(Configuration config) {
        ResteasyProviderFactory rpf = ResteasyProviderFactory.getInstance();
        JsonProvider jsonprovider = new JsonProvider(config);
        rpf.addMessageBodyReader(jsonprovider);
        rpf.addMessageBodyWriter(jsonprovider);
        RegisterBuiltin.register(rpf);
    }
View Full Code Here

    public void init(FilterConfig servletConfig) throws ServletException {
        super.init(servletConfig);

        ServletContext context = servletConfig.getServletContext();
        Registry registry = (Registry) context.getAttribute(Registry.class.getName());
        ResteasyProviderFactory providerFactory = (ResteasyProviderFactory) context.getAttribute
                (ResteasyProviderFactory.class.getName());

        for (final Binding<?> binding : injector.getBindings().values()) {
            Type type = binding.getKey().getTypeLiteral().getType();
            if (type instanceof Class) {
                Class<?> beanClass = (Class) type;
                if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                    registry.addResourceFactory(resourceFactory);
                }

                if (beanClass.isAnnotationPresent(Provider.class)) {
                    providerFactory.registerProviderInstance(binding.getProvider().get());
                }
            }
        }
    }
View Full Code Here

    @Override
    public void init(FilterConfig servletConfig) throws ServletException {
        super.init(servletConfig);

        Registry registry = getDispatcher().getRegistry();
        ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

        for (final Binding<?> binding : injector.getBindings().values()) {
            Type type = binding.getKey().getTypeLiteral().getType();
            if (type instanceof Class) {
                Class<?> beanClass = (Class) type;
                if (GetRestful.isRootResource(beanClass)) {
                    ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                    registry.addResourceFactory(resourceFactory);
                }

                if (beanClass.isAnnotationPresent(Provider.class)) {
                    providerFactory.registerProviderInstance(binding.getProvider().get());
                }
            }
        }
    }
View Full Code Here

    public void init(FilterConfig servletConfig) throws ServletException {
        super.init(servletConfig);

        ServletContext context = servletConfig.getServletContext();
        Registry registry = (Registry) context.getAttribute(Registry.class.getName());
        ResteasyProviderFactory providerFactory = (ResteasyProviderFactory) context.getAttribute
                (ResteasyProviderFactory.class.getName());

        for (final Binding<?> binding : injector.getBindings().values()) {
            final Type type = binding.getKey().getTypeLiteral().getType();
            if (type instanceof Class) {
                final Class<?> beanClass = (Class) type;
                if (GetRestful.isRootResource(beanClass)) {
                    final ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                    logger.info("Registering factory for" + beanClass.getName());
                    registry.addResourceFactory(resourceFactory);
                }

                if (beanClass.isAnnotationPresent(Provider.class)) {
                    logger.info("registering provider instance for" + beanClass.getName());
                    providerFactory.registerProviderInstance(binding.getProvider().get());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.spi.ResteasyProviderFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.