javax.ws.rs.container.DynamicFeature Java Examples
The following examples show how to use
javax.ws.rs.container.DynamicFeature.
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: UserAdminModule.java From jweb-cms with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void configure() { UserAdminOptions options = options("user-admin", UserAdminOptions.class); bind(UserAdminOptions.class).toInstance(options); web().bindExceptionMapper(requestInjection(new AdminForbiddenExceptionHandler())); web().bindExceptionMapper(requestInjection(new AdminNotAuthorizedExceptionHandler())); app().register((DynamicFeature) (resourceInfo, context) -> { if (resourceInfo.getResourceMethod().isAnnotationPresent(RolesAllowed.class)) { context.register(RolesAllowedAdminInterceptor.class); } }); web().bindRequestFilter(requestInjection(new UserAdminInterceptor())); admin().controller(UserGroupAdminAJAXController.class); admin().controller(UserAdminAJAXController.class); admin().controller(UserStatisticsAdminAJAXController.class); admin().install(jsModule()); admin().bundle("dashboardBundle") .addMessages("conf/messages/user-dashboard") .addScriptFiles("admin/static/user/userDashboard.min.js"); }
Example #2
Source File: ServerProviderFactory.java From cxf with Apache License 2.0 | 5 votes |
private void doApplyDynamicFeatures(ClassResourceInfo cri) { Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos(); for (OperationResourceInfo ori : oris) { String nameBinding = DEFAULT_FILTER_NAME_BINDING + ori.getClassResourceInfo().getServiceClass().getName() + "." + ori.getMethodToInvoke().toString(); for (DynamicFeature feature : dynamicFeatures) { FeatureContext featureContext = createServerFeatureContext(); feature.configure(new ResourceInfoImpl(ori), featureContext); Configuration cfg = featureContext.getConfiguration(); for (Object provider : cfg.getInstances()) { Map<Class<?>, Integer> contracts = cfg.getContracts(provider.getClass()); if (contracts != null && !contracts.isEmpty()) { Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider); registerUserProvider(new FilterProviderInfo<Object>(provider.getClass(), providerCls, provider, getBus(), Collections.singleton(nameBinding), true, contracts)); ori.addNameBindings(Collections.singletonList(nameBinding)); } } } } Collection<ClassResourceInfo> subs = cri.getSubResources(); for (ClassResourceInfo sub : subs) { if (sub != cri) { doApplyDynamicFeatures(sub); } } }
Example #3
Source File: ServerProviderFactory.java From cxf with Apache License 2.0 | 5 votes |
@Override public boolean isEnabled(Class<? extends Feature> featureCls) { for (DynamicFeature f : dynamicFeatures) { if (featureCls.isAssignableFrom(f.getClass())) { return true; } } return false; }
Example #4
Source File: SisuResteasyProviderFactory.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
/** * Unregisters a @Provider type from this factory. */ public void removeRegistrations(final Class<?> type) { checkNotNull(type); log.debug("Removing registrations for: {}", type.getName()); classContracts.remove(type); removeInstancesOf(type, providerInstances); providerClasses.remove(type); if (ExceptionMapper.class.isAssignableFrom(type)) { removeInstancesOf(type, exceptionMappers.values()); } else if (MessageBodyReader.class.isAssignableFrom(type)) { clearInstancesOf(type, clientMessageBodyReaders, DUMMY_READER); clearInstancesOf(type, serverMessageBodyReaders, DUMMY_READER); } else if (MessageBodyWriter.class.isAssignableFrom(type)) { clearInstancesOf(type, clientMessageBodyWriters, DUMMY_WRITER); clearInstancesOf(type, serverMessageBodyWriters, DUMMY_WRITER); } else if (ContextResolver.class.isAssignableFrom(type)) { Type[] args = Types.getActualTypeArgumentsOfAnInterface(type, ContextResolver.class); contextResolvers.remove(Types.getRawType(args[0])); } else if (Feature.class.isAssignableFrom(type)) { removeInstancesOf(type, featureInstances); removeInstancesOf(type, enabledFeatures); featureClasses.remove(type); } else if (DynamicFeature.class.isAssignableFrom(type)) { removeInstancesOf(type, clientDynamicFeatures); removeInstancesOf(type, serverDynamicFeatures); } else if (ParamConverterProvider.class.isAssignableFrom(type)) { removeInstancesOf(type, paramConverterProviders); } else if (StringConverter.class.isAssignableFrom(type)) { removeInstancesOf(type, stringConverters.values()); } else if (StringParameterUnmarshaller.class.isAssignableFrom(type)) { stringParameterUnmarshallers.values().remove(type); } else { log.warn("Unable to remove registrations for: {}", type.getName()); } }
Example #5
Source File: JerseyConfig.java From dropwizard-guicey with MIT License | 2 votes |
/** * Show dynamic features {@link DynamicFeature}. * * @return config instance for chained calls */ public JerseyConfig showDynamicFeatures() { types.add(DynamicFeature.class); return this; }