Package org.apache.wink.common.internal.registry

Examples of org.apache.wink.common.internal.registry.ProvidersRegistry


    protected void setUp() throws Exception {
        super.setUp();

        LifecycleManagersRegistry ofFactoryRegistry = new LifecycleManagersRegistry();
        ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
        ProvidersRegistry providersRegistry =
            new ProvidersRegistry(ofFactoryRegistry, new ApplicationValidator());

        Set<Class<?>> classes = new ApplicationFileLoader(true).getClasses();
        if (classes != null) {
            for (Class<?> cls : classes) {
                if (ProviderMetadataCollector.isProvider(cls)) {
                    providersRegistry.addProvider(cls);
                }
            }
        }
        AbstractRuntimeContext runtimeContext = new AbstractRuntimeContext() {
View Full Code Here


            return null;
        }
        if (ClientResponse.class.equals(type)) {
            return (T)this;
        }
        ProvidersRegistry providersRegistry = getAttribute(ProvidersRegistry.class);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContextTLS.setRuntimeContext(runtimeContext);
        try {
            String contentType = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
            if (contentType == null || contentType.length() == 0) {
                contentType = MediaType.APPLICATION_OCTET_STREAM;
            }
            MediaType contentMediaType = MediaType.valueOf(contentType);
            MessageBodyReader<T> reader =
                providersRegistry.getMessageBodyReader(type,
                                                       genericType,
                                                       null,
                                                       contentMediaType,
                                                       runtimeContext);
            if (reader == null) {
View Full Code Here

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

        Object entity = request.getEntity();
        if (entity == null) {
            return;
        }

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);
        try {
            Class<?> type = entity.getClass();
            Type genericType = type;
            if (entity instanceof GenericEntity) {
                GenericEntity<?> genericEntity = (GenericEntity<?>)entity;
                type = genericEntity.getRawType();
                genericType = genericEntity.getType();
                entity = genericEntity.getEntity();
            }
            MessageBodyWriter writer = null;
            MediaType contentMediaType = null;
            String contentType = request.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
            if (contentType == null) {
                // attempt to infer the media type based on the providers available for this type
                contentMediaType = providersRegistry.getMessageBodyWriterMediaTypeLimitByIsWritable(type, runtimeContext);
                if(contentMediaType == null) {
                    // default if we still couldn't find it
                    contentType = MediaType.APPLICATION_OCTET_STREAM;
                }
            } else
                contentMediaType = MediaType.valueOf(contentType);
            request.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, contentMediaType.toString());
            writer =
                providersRegistry.getMessageBodyWriter(type,
                                                       genericType,
                                                       null,
                                                       contentMediaType,
                                                       runtimeContext);
            if (writer == null) {
View Full Code Here

        if (ofFactoryRegistry == null) {
            ofFactoryRegistry = new LifecycleManagersRegistry();
            ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
        }
        ApplicationValidator applicationValidator = new ApplicationValidator();
        providersRegistry = new ProvidersRegistry(ofFactoryRegistry, applicationValidator);
        resourceRegistry = new ResourceRegistry(ofFactoryRegistry, applicationValidator);
    }
View Full Code Here

            public String getFilterName() {
                return getServletName();
            }
        });

        ProvidersRegistry providers = config.getProvidersRegistry();
        providers.addProvider(new DataBindingJAXRSReader(registry), 0.001, true);
        providers.addProvider(new DataBindingJAXRSWriter(registry), 0.001, true);
       
        return config;
    }
View Full Code Here

            public String getFilterName() {
                return getServletName();
            }
        });

        ProvidersRegistry providers = config.getProvidersRegistry();
        providers.addProvider(new DataBindingJAXRSReader(registry), 0.2, true);
        providers.addProvider(new DataBindingJAXRSWriter(registry), 0.2, true);

        config.getResponseUserHandlers().add(new TuscanyResponseHandler());

        return config;
    }
View Full Code Here

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

    public void testGoodAppStartupInfoLogOutput() throws Exception {
        WinkLogHandler.turnLoggingCaptureOn(WinkLogHandler.LEVEL.INFO);
        MockAppValidator mockAppValidator = new MockAppValidator();
        ResourceRegistry mockResourceRegistry =
            new ResourceRegistry(new LifecycleManagersRegistry(), mockAppValidator);
        ProvidersRegistry mockProvidersRegistry =
            new ProvidersRegistry(new LifecycleManagersRegistry(), mockAppValidator);
        ApplicationProcessor appProcessor =
            new ApplicationProcessor(new MyApp(), mockResourceRegistry, mockProvidersRegistry, false);
        appProcessor.process();
        WinkLogHandler.turnLoggingCaptureOff();
        List<LogRecord> records = WinkLogHandler.getRecords();
View Full Code Here

                }

                if (providers == null) {
                    LifecycleManagersRegistry ofFactoryRegistry = new LifecycleManagersRegistry();
                    ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
                    ProvidersRegistry providersRegistry =
                        new ProvidersRegistry(ofFactoryRegistry, new ApplicationValidator());

                    final Set<Class<?>> classes = new ApplicationFileLoader(true).getClasses();

                    processApplication(providersRegistry, new WinkApplication() {
                        @Override
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.registry.ProvidersRegistry

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.