当前位置: 首页>>代码示例>>Java>>正文


Java Provider类代码示例

本文整理汇总了Java中javax.ws.rs.ext.Provider的典型用法代码示例。如果您正苦于以下问题:Java Provider类的具体用法?Java Provider怎么用?Java Provider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Provider类属于javax.ws.rs.ext包,在下文中一共展示了Provider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetClasses

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
private Set<Class<?>> doGetClasses() {
  String packages =
      servletContext.getInitParameter(OryxApplication.class.getName() + ".packages");
  log.info("Creating JAX-RS from endpoints in package(s) {}", packages);
  Objects.requireNonNull(packages);
  Set<Class<?>> classes = new HashSet<>();
  for (String thePackage : packages.split(",")) {
    Reflections reflections = new Reflections(thePackage);
    classes.addAll(getClassesInPackageAnnotatedBy(thePackage, reflections, Path.class));
    classes.addAll(getClassesInPackageAnnotatedBy(thePackage, reflections, Produces.class));
    classes.addAll(getClassesInPackageAnnotatedBy(thePackage, reflections, Provider.class));
  }
  // Want to configure these globally, but not depend on Jersey, even though it's
  // what will be used in practice by the provided apps.
  for (String optionalJerseyClass : new String[] {
        "org.glassfish.jersey.message.DeflateEncoder",
        "org.glassfish.jersey.message.GZipEncoder",
        "org.glassfish.jersey.server.filter.EncodingFilter"}) {
    if (ClassUtils.classExists(optionalJerseyClass)) {
      classes.add(ClassUtils.loadClass(optionalJerseyClass));
    }
  }
  log.debug("Found JAX-RS resources: {}", classes);
  return classes;
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:26,代码来源:OryxApplication.java

示例2: deployToResteasy

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Override
public Single<Void> deployToResteasy(VertxResteasyDeployment deployment) {
	JsonArray packages = AppGlobals.get().getConfig().getJsonArray("scan");
	if(packages == null) {
		System.err.println("Not scanning any packages, please specify the 'scan' array of packages in configuration");
	}else {
		String[] packagesToScan = (String[]) packages.getList().toArray(new String[packages.size()+1]);
		packagesToScan[packagesToScan.length-1] = "net.redpipe.engine";
		new FastClasspathScanner(packagesToScan)
			.matchClassesWithAnnotation(Path.class, klass -> {
				if(!Modifier.isAbstract(klass.getModifiers()))
					deployment.getActualResourceClasses().add(klass);
			})
			.matchClassesWithAnnotation(Provider.class, klass -> {
				if(!Modifier.isAbstract(klass.getModifiers()))
					deployment.getActualProviderClasses().add(klass);
			})
			.scan();
	}
	return Single.just(null);
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:22,代码来源:FCSPlugin.java

示例3: setupResteasy

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
protected Single<VertxResteasyDeployment> setupResteasy(Class<?>... resourceOrProviderClasses) {
	// Build the Jax-RS hello world deployment
	VertxResteasyDeployment deployment = new VertxResteasyDeployment();
	deployment.getDefaultContextObjects().put(Vertx.class, AppGlobals.get().getVertx());
	deployment.getDefaultContextObjects().put(AppGlobals.class, AppGlobals.get());
	
	return doOnPlugins(plugin -> plugin.deployToResteasy(deployment)).map(v -> {
		for(Class<?> klass : resourceOrProviderClasses) {
			if(klass.isAnnotationPresent(Path.class))
				deployment.getActualResourceClasses().add(klass);
			if(klass.isAnnotationPresent(Provider.class))
				deployment.getActualProviderClasses().add(klass);
		}
		try {
			deployment.start();
		}catch(ExceptionInInitializerError err) {
			// rxjava behaves badly on LinkageError
			rethrow(err.getCause());
		}
		return deployment;
	}).doOnError(t -> t.printStackTrace());
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:23,代码来源:Server.java

示例4: isJaxrsResourceClass

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
/**
 * Check whether given bean definition is a valid {@link Provider} or {@link Path} resource.
 * @param definition Bean definition
 * @param beanClass Bean class
 * @return <code>true</code> if it is a valid JAX-RS resource class
 */
private static boolean isJaxrsResourceClass(BeanDefinition definition, Class<?> beanClass) {
	// check Provider
	if (beanClass.isAnnotationPresent(Provider.class)) {
		if (!definition.isSingleton()) {
			throw new BeanDefinitionValidationException("Invalid JAX-RS @Provider bean definition for bean class ["
					+ beanClass + "]: JAX-RS providers must be singleton beans");
		}
		return true;
	}
	// check Path resource
	Class<?> pathClass = AnnotationUtils.getClassWithAnnotation(beanClass, Path.class);
	if (pathClass != null) {
		return true;
	}
	return false;
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:23,代码来源:JerseyResourcesPostProcessor.java

示例5: jaxRsServer

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Bean
public Server jaxRsServer() {

  // List<Object> restServiceBeans = new
  // ArrayList<>(this.applicationContext.getBeansOfType(RestService.class).values());
  Collection<Object> restServices = findRestServices();
  if (restServices.isEmpty()) {
    LOG.info("No REST Services have been found. Rest Endpoint will not be enabled in CXF.");
    return null;
  }
  Collection<Object> providers = this.applicationContext.getBeansWithAnnotation(Provider.class).values();

  JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
  factory.setBus(springBus());
  factory.setAddress(URL_FOLDER_REST);
  // factory.set
  factory.setServiceBeans(new ArrayList<>(restServices));
  factory.setProviders(new ArrayList<>(providers));

  return factory.create();
}
 
开发者ID:oasp,项目名称:oasp-tutorial-sources,代码行数:22,代码来源:ServiceConfig.java

示例6: start

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
public void start() {

		ResteasyDeployment dp = new ResteasyDeployment();

		Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
		Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();

		Assert.notEmpty(controllers);

		// extract providers
		if (providers != null) {
			dp.getProviders().addAll(providers);
		}
		// extract only controller annotated beans
		dp.getResources().addAll(controllers);
		
        netty = new NettyJaxrsServer();
		netty.setDeployment(dp);
        netty.setIoWorkerCount(ioWorkerCount);
        netty.setExecutorThreadCount(executorThreadCount);
		netty.setPort(port);
        netty.setRootResourcePath(rootResourcePath);
		netty.setSecurityDomain(null);
		netty.start();
        LOGGER.info("rest-netty-server started , port {}", port);
	}
 
开发者ID:netboynb,项目名称:coco,代码行数:27,代码来源:CocoRestServer.java

示例7: RestResourceConfig

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Autowired
public RestResourceConfig(final ApplicationContext applicationContext) {
    property("contextConfig", applicationContext);
    scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.resetFilters(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(Path.class));
    scanner.addIncludeFilter(new AnnotationTypeFilter(Provider.class));
    register(RequestContextFilter.class);
    register(MultiPartFeature.class);
    register(ObjectMapperProvider.class);
    register(JacksonFeature.class);
    registerResources("com.clicktravel.cheddar.rest.exception.mapper", "com.clicktravel.cheddar.server.http.filter",
            "com.clicktravel.cheddar.server.rest.resource.status", "com.clicktravel.services",
            "com.clicktravel.cheddar.rest.body.writer");
    property(ServerProperties.LOCATION_HEADER_RELATIVE_URI_RESOLUTION_DISABLED, true);
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:17,代码来源:RestResourceConfig.java

示例8: configure

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void configure() {
	logger.entry();
	String[] pkgs = GenericBootstrapConstants.REST_EASY_REST_PACKAGES.split(",");
	
	for(String pkg:pkgs){
		//if(pkg.trim().endsWith(GenericBootstrapConstants.REST_EASY_REST_PACKAGES_SUFFIX)){
			logger.info("found RESTful package: {}",pkg.trim());
			Class[] lst = null;
			try {
				lst = getClasses(pkg.trim());
			} catch (ClassNotFoundException | IOException e) {
				logger.error("{}, {}", e.getClass().getName() ,e.getMessage());
				e.printStackTrace();
			}
			for (Class c: lst){
				if(c.isAnnotationPresent(Path.class) || c.isAnnotationPresent(Provider.class)){
					logger.info("found RestEasy Resource: {}",c.getName());
					bind(c);
				}
			}
		//}
	}
	logger.exit();
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:27,代码来源:BootstrapRestPackagesModule.java

示例9: configure

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Override
protected void configure() {
	install(new RequestScopeModule());
	install(new JaxrsModule());
	requireBinding(ObjectMapper.class);

	findResourcesWith(Path.class);
	findResourcesWith(Provider.class);

	bind(BaseApi.class).to(BaseApiImpl.class);
	bind(UsersApi.class).to(UsersApiImpl.class);
	bind(GroupsApi.class).to(GroupsApiImpl.class);
	bind(RepositoriesApi.class).to(RepositoriesApiImpl.class);
	bind(RepositoryFacadeFactory.class).to(JGitRepositoryFacadeFactory.class);

	bindSubResourceFactory(GroupApi.class, GroupApiImpl.class, GroupApiFactory.class);
	bindSubResourceFactory(CommitApi.class, CommitApiImpl.class, CommitApiFactory.class);
	bindSubResourceFactory(BranchApi.class, BranchApiImpl.class, BranchApiFactory.class);
	bindSubResourceFactory(RepositoryApi.class, RepositoryApiImpl.class, RepositoryApiFactory.class);

	bind(Config.class).toInstance(config);
}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:23,代码来源:GitServerModule.java

示例10: init

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@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);
                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());
            }
        }
    }
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-resteasy-webapp,代码行数:25,代码来源:GuiceRestEasyFilterDispatcher.java

示例11: separateProvidersAndResources

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
private void separateProvidersAndResources(Application application, List<Class<?>> resourceClasses, List<Object> providerInstances) {
  Set<Class<?>> classes = application.getClasses();

  for (Class<?> clazz : classes) {
    Annotation[] annotations = clazz.getAnnotations();
    for (Annotation annotation : annotations) {
      if (annotation.annotationType().equals(Provider.class)) {
        // for providers we have to create an instance
        try {
          providerInstances.add(clazz.newInstance());
          break;
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      } else if (annotation.annotationType().equals(Path.class)) {
        resourceClasses.add(clazz);
        break;
      }
    }
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:CXFServerBootstrap.java

示例12: testConfiguration

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Test
public void testConfiguration() throws Exception {
	logger.info("start REST Configuration test");
	Client client = newClient();
	Configuration configuration = client.getConfiguration();
	Set<Class<?>> classes = configuration.getClasses();
	for (Class<?> clazz : classes) {
		assertTrue("verify if the class is a rest component or provider",
				MessageBodyReader.class.isAssignableFrom(clazz) || MessageBodyWriter.class.isAssignableFrom(clazz)
						|| clazz.isAnnotationPresent(Provider.class)
						|| DynamicFeature.class.isAssignableFrom(clazz));
		Map<Class<?>, Integer> contracts = configuration.getContracts(clazz);
		assertFalse("each class has different contracts", contracts.isEmpty());
		for (Class<?> contract : contracts.keySet()) {
			int value = contracts.get(contract);
			assertTrue("verify if the contract is a rest component or provider",
					value == 5000 || value == 4000 || value == 3000 || value == 0);
		}
	}
	Set<Object> instances = configuration.getInstances();
	assertTrue("by default there are not instances", instances.isEmpty());
	Map<String, Object> properties = configuration.getProperties();
	assertTrue("by default there are not properties", properties.isEmpty());
	MyComponent myComponent = new MyComponent();
	client.register(myComponent);
	instances = configuration.getInstances();
	assertFalse("Added instance", instances.isEmpty());
	for (Object instance : instances) {
		if (instance instanceof MyComponent)
			assertTrue("MyComponent is registered and active", configuration.isEnabled((Feature) instance));
	}
	assertEquals("Added property through MyComponent", 1, properties.size());
	boolean property = (Boolean) properties.get("configured_myComponent");
	assertEquals("configured_myComponent ok!", true, property);
	assertEquals("type CLIENT by default", CLIENT, configuration.getRuntimeType());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:37,代码来源:ComponentTestCase.java

示例13: configure

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Override
protected void configure() {
  bindAnnotatedClasses(API_PACKAGE, Path.class);
  bindAnnotatedClasses(MAPPINGS_PACKAGE, Provider.class);
  bindSwagger();
  bind(ApiServer.class).in(Scopes.SINGLETON);
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:8,代码来源:RestModule.java

示例14: jerseyApplication

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
/**
 * Construct a Jersey {@link javax.ws.rs.core.Application} with all the resources
 * required by the Eureka server.
 */
@Bean
public javax.ws.rs.core.Application jerseyApplication(Environment environment,
		ResourceLoader resourceLoader) {

	ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
			false, environment);

	// Filter to include only classes that have a particular annotation.
	//
	provider.addIncludeFilter(new AnnotationTypeFilter(Path.class));
	provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class));

	// Find classes in Eureka packages (or subpackages)
	//
	Set<Class<?>> classes = new HashSet<Class<?>>();
	for (String basePackage : EUREKA_PACKAGES) {
		Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
		for (BeanDefinition bd : beans) {
			Class<?> cls = ClassUtils.resolveClassName(bd.getBeanClassName(),
					resourceLoader.getClassLoader());
			classes.add(cls);
		}
	}

	// Construct the Jersey ResourceConfig
	//
	Map<String, Object> propsAndFeatures = new HashMap<String, Object>();
	propsAndFeatures.put(
			// Skip static content used by the webapp
			ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
			EurekaConstants.DEFAULT_PREFIX + "/(fonts|images|css|js)/.*");

	DefaultResourceConfig rc = new DefaultResourceConfig(classes);
	rc.setPropertiesAndFeatures(propsAndFeatures);

	return rc;
}
 
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:42,代码来源:EurekaServerAutoConfiguration.java

示例15: getClasses

import javax.ws.rs.ext.Provider; //导入依赖的package包/类
@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> resources = new HashSet<>();
    String PACKAGE_NAME = RestApplication.class.getPackage().getName();
    resources.addAll(getTypesAnnotatedWith(PACKAGE_NAME, Path.class));
    resources.addAll(getTypesAnnotatedWith(PACKAGE_NAME, Provider.class));
    resources.add(JacksonFeature.class);
    return resources;
}
 
开发者ID:igorzg,项目名称:payara-micro-docker-starter-kit,代码行数:10,代码来源:RestApplication.java


注:本文中的javax.ws.rs.ext.Provider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。