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


Java GetRestful类代码示例

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


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

示例1: doExport

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    Class implClass = ServiceImplHolder.getInstance().popServiceImpl().getClass();
    RestServer server = servers.get(addr);
    if (server == null) {
        server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
        server.start(url);
        servers.put(addr, server);
    }

    final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
    server.deploy(resourceDef, impl, getContextPath(url));

    final RestServer s = server;
    return new Runnable() {
        public void run() {
            // TODO due to dubbo's current architecture,
            // it will be called from registry protocol in the shutdown process and won't appear in logs
            s.undeploy(resourceDef);
        }
    };
}
 
开发者ID:lsjiguang,项目名称:dangdangdotcom,代码行数:23,代码来源:RestProtocol.java

示例2: init

import org.jboss.resteasy.util.GetRestful; //导入依赖的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

示例3: doExport

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    Class implClass = ServiceClassHolder.getInstance().popServiceClass();
    RestServer server = servers.get(addr);
    if (server == null) {
        server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
        server.start(url);
        servers.put(addr, server);
    }

    String contextPath = getContextPath(url);
    if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
        ServletContext servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
        if (servletContext == null) {
            throw new RpcException("No servlet context found. Since you are using server='servlet', " +
                    "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
        }
        String webappPath = servletContext.getContextPath();
        if (StringUtils.isNotEmpty(webappPath)) {
            webappPath = webappPath.substring(1);
            if (!contextPath.startsWith(webappPath)) {
                throw new RpcException("Since you are using server='servlet', " +
                        "make sure that the 'contextpath' property starts with the path of external webapp");
            }
            contextPath = contextPath.substring(webappPath.length());
            if (contextPath.startsWith("/")) {
                contextPath = contextPath.substring(1);
            }
        }
    }

    final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;

    server.deploy(resourceDef, impl, contextPath);

    final RestServer s = server;
    return new Runnable() {
        public void run() {
            // TODO due to dubbo's current architecture,
            // it will be called from registry protocol in the shutdown process and won't appear in logs
            s.undeploy(resourceDef);
        }
    };
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:45,代码来源:RestProtocol.java

示例4: resourcePackages

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
/**
 * Returns a comma separated list of resource packages.
 */
private String resourcePackages() {
    return injector.getBindings().keySet().stream()
            .map(key -> key.getTypeLiteral().getRawType())
            .filter(GetRestful::isRootResource)
            .map(clazz -> clazz.getPackage().getName())
            .distinct()
            .collect(Collectors.joining(","));
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:12,代码来源:SwaggerServletContextListener.java

示例5: init

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
    logger.entry();
    servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);

    if (injector == null)
        injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());

    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);
                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());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:webshooters,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例6: init

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
	logger.entry();
	servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);
    
    if(injector == null)
    	injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());
    
    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);
                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());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例7: doExport

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    Class implClass = ServiceClassHolder.getInstance().popServiceClass();
    RestServer server = servers.get(addr);
    if (server == null) {
        server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
        server.start(url);
        servers.put(addr, server);
    }

    String contextPath = getContextPath(url);
    if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
        ServletContext servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
        if (servletContext == null) {
            throw new RpcException("No servlet context found. Since you are using server='servlet', " +
                    "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
        }
        String webappPath = servletContext.getContextPath();
        if (StringUtils.isNotEmpty(webappPath)) {
            webappPath = webappPath.substring(1);
            if (!contextPath.startsWith(webappPath)) {
                throw new RpcException("Since you are using server='servlet', " +
                        "make sure that the 'contextpath' property starts with the path of external webapp");
            }
            contextPath = contextPath.substring(webappPath.length());
            if (contextPath.startsWith("/")) {
                contextPath = contextPath.substring(1);
            }
        }
    }

    final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;

    // dubbo 服务多版本
    String version = url.getParameter(Constants.VERSION_KEY);
    if (StringUtils.isNotEmpty(version)) {
        contextPath = version + "/" + contextPath;
    }
    server.deploy(resourceDef, impl, contextPath);

    final RestServer s = server;
    return new Runnable() {
        public void run() {
            // TODO due to dubbo's current architecture,
            // it will be called from registry protocol in the shutdown process and won't appear in logs
            s.undeploy(resourceDef);
        }
    };
}
 
开发者ID:sdcuike,项目名称:dubbo-rpc-rest,代码行数:50,代码来源:RestProtocol.java

示例8: doExport

import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws JahhanException {
	String addr = url.getIp() + ":" + url.getPort();
	Class implClass = ServiceClassHolder.getInstance().popServiceClass();
	RestServer server = servers.get(addr);
	if (server == null) {
		serverFactory.setHttpBinder(httpBinder);
		server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
		server.start(url);
		servers.put(addr, server);
	}

	String contextPath = getContextPath(url);
	if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
		ServletContext servletContext = BaseContext.CTX.getServletContext(url.getPort());
		if (servletContext == null) {
			throw new JahhanException("No servlet context found. Since you are using server='servlet', "
					+ "make sure that you've configured in web.xml");
		}
		String webappPath = servletContext.getContextPath();
		if (StringUtils.isNotEmpty(webappPath)) {
			webappPath = webappPath.substring(1);
			if (!contextPath.startsWith(webappPath)) {
				throw new JahhanException("Since you are using server='servlet', "
						+ "make sure that the 'contextpath' property starts with the path of external webapp");
			}
			contextPath = contextPath.substring(webappPath.length());
			if (contextPath.startsWith("/")) {
				contextPath = contextPath.substring(1);
			}
		}
	}

	final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;

	server.deploy(resourceDef, impl, contextPath);

	final RestServer s = server;
	return new Runnable() {
		public void run() {
			// TODO due to dubbo's current architecture,
			// it will be called from registry protocol in the shutdown
			// process and won't appear in logs
			s.undeploy(resourceDef);
		}
	};
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:47,代码来源:RestProtocol.java


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