org.glassfish.jersey.internal.inject.Providers Java Examples

The following examples show how to use org.glassfish.jersey.internal.inject.Providers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketAddon.java    From ameba with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public boolean configure(FeatureContext context) {
    context.register(new WebSocketBinder());
    if (serverContainer == null) {
        logger.warn(Messages.get("web.socket.server.unsupported"));
    }

    for (Class endpointClass : endpointClasses) {
        WebSocket webSocket = getAnnotation(WebSocket.class, endpointClass);
        if (webSocket == null) continue;
        Class<? extends Annotation> scope = getScope(endpointClass);
        final Binding binding = Bindings.service(endpointClass).to(endpointClass).in(scope);
        Providers.getProviderContracts(endpointClass).forEach(binding::to);
        injectionManager.register(binding);
        DefaultServerEndpointConfig endpointConfig = new DefaultServerEndpointConfig(
                injectionManager,
                endpointClass,
                webSocket
        );
        if (serverContainer != null) {
            try {
                serverContainer.addEndpoint(endpointConfig);
            } catch (DeploymentException e) {
                throw new WebSocketException(e);
            }
        }
        if (webSocket.withSockJS()) {
            // create resource use modelProcessor
        }
    }

    return true;
}
 
Example #2
Source File: ViewableMessageBodyWriter.java    From ameba with MIT License 5 votes vote down vote up
/**
 * Get a {@link java.util.LinkedHashSet collection} of available template processors.
 *
 * @return set of template processors.
 */
private Set<TemplateProcessor> getTemplateProcessors() {
    final Set<TemplateProcessor> templateProcessors = Sets.newLinkedHashSet();

    templateProcessors.addAll(Providers.getCustomProviders(injectionManager, TemplateProcessor.class));
    templateProcessors.addAll(Providers.getProviders(injectionManager, TemplateProcessor.class));

    return templateProcessors;
}
 
Example #3
Source File: ViewableMessageBodyWriter.java    From ameba with MIT License 5 votes vote down vote up
/**
 * Get {@link org.glassfish.jersey.server.mvc.spi.ViewableContext viewable context}.
 * User defined (custom) contexts have higher priority than the default ones
 * (i.e. {@link ResolvingViewableContext}).
 *
 * @return {@code non-null} viewable context.
 */
private ViewableContext getViewableContext() {
    final Set<ViewableContext> customProviders =
            Providers.getCustomProviders(injectionManager, ViewableContext.class);
    if (!customProviders.isEmpty()) {
        return customProviders.iterator().next();
    }
    return Providers.getProviders(injectionManager, ViewableContext.class).iterator().next();
}
 
Example #4
Source File: NotFoundForward.java    From ameba with MIT License 5 votes vote down vote up
private Set<TemplateProcessor> getTemplateProcessors() {
    Set<TemplateProcessor> templateProcessors = Sets.newLinkedHashSet();

    templateProcessors.addAll(Providers.getCustomProviders(injectionManager, TemplateProcessor.class));
    templateProcessors.addAll(Providers.getProviders(injectionManager, TemplateProcessor.class));
    return templateProcessors;
}
 
Example #5
Source File: OptionsMethodProcessor.java    From ameba with MIT License 5 votes vote down vote up
/**
 * Creates new instance.
 *
 * @param manager a {@link InjectionManager} object.
 */
@Inject
public OptionsMethodProcessor(InjectionManager manager) {
    methodList = Lists.newArrayList();

    methodList.add(new ModelProcessorUtil.Method(HttpMethod.OPTIONS, WILDCARD_TYPE, WILDCARD_TYPE,
            GenericOptionsInflector.class));

    generators = Providers.getAllRankedSortedProviders(manager, OptionsResponseGenerator.class);
}
 
Example #6
Source File: MessageHelper.java    From ameba with MIT License 2 votes vote down vote up
/**
 * <p>getStreamingProcesses.</p>
 *
 * @param manager InjectionManager.
 * @return a {@link java.lang.Iterable} object.
 */
public static Iterable<StreamingProcess> getStreamingProcesses(InjectionManager manager) {
    return Providers.getAllProviders(manager, StreamingProcess.class);
}
 
Example #7
Source File: EbeanExprInvoker.java    From ameba with MIT License 2 votes vote down vote up
/**
 * <p>getTransformer.</p>
 *
 * @param transformerClass a {@link java.lang.Class} object.
 * @param <R>              Result.
 * @param <T>              Transformer.
 * @return a {@link java.lang.Iterable} object.
 */
protected <R, T extends Transformer<Transformed<R>>> Iterable<T> getTransformer(Class<T> transformerClass) {
    return Providers.getAllRankedSortedProviders(manager, transformerClass);
}