- 浏览: 1119927 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (1055)
- quartz定时任务 (1)
- json (9)
- 接口 (1)
- http (1)
- sccket (2)
- xmlbean (1)
- webservice (1)
- flex (1)
- sitemesh (2)
- json组装 (2)
- 存储过程 (6)
- ajax后台返回前台上下问 (3)
- flect反射机制 (1)
- 页面列表 (1)
- oracal结果集合并 (1)
- lucene (1)
- 读取配置文件工具 (1)
- 框架整合 (1)
- jms (3)
- 断点续传 (1)
- 页面之间的传值 (1)
- jpa (6)
- sql (8)
- jsp跳转 (1)
- jsp (6)
- jquery (2)
- ui (1)
- js与jsp之间的值的交互应用 (1)
- js空值判断 (1)
- Ajax (9)
- web-inf 编译目录 (1)
- 多线程 (9)
- 资料 (0)
- oracal (4)
- 多线程webservice (1)
- ztree (1)
- 加载与内容的变化 (1)
- 页面的公用变量 (1)
- web-inf目录结构 (1)
- 登陆系列 (1)
- jass应用于webservice认证 (2)
- 路径问题 (1)
- list合并 (1)
- list map中的value获取 (2)
- 标签tag (4)
- 方法 (1)
- 树形数据及其渲染 (1)
- require js 回调 (1)
- tab 页面切换 (2)
- 计时获取验证码 (1)
- 模式 (6)
- easyui (3)
- dialog (2)
- 乱码问题 (1)
- spring (29)
- sqlserver (1)
- iis,netframework (0)
- iis (1)
- netframework (1)
- 处理乱码问题 (1)
- struts-ajax (0)
- ,理论,了;,; (0)
- 排错方法 (1)
- hibernate (1)
- 二级缓存 (1)
- portal (1)
- date类型 (0)
- jvm out of memery StackOverflowError (1)
- echart数据填充 (0)
- echart (1)
- jmv (1)
- 学习 (0)
- java基础 (1)
- oracle性能优化 (1)
- 数据库三范式 (1)
- easy UI (1)
- oracle11g (1)
- form (3)
- servlet (2)
- spring mvc (1)
- htm5 (0)
- ibatise (1)
- 序列化 (1)
- tomcat双认证 (1)
- maven Lib (1)
- tomcat eclipse (2)
- ehcache (1)
- http 代替 ajax (2)
- rest (6)
- script脚本占位模板 (1)
- strust 标签 el表达式 (1)
- js bo (1)
- 公司资料 (0)
- js return (1)
- spring 第三方插件的工具类 (1)
- linux (10)
- linux 克隆 (1)
- linux xshell连接 (1)
- yum expect (1)
- linux 应用命令 (1)
- yum 缓存rmp包 (1)
- yum 本地库离线安装 (2)
- yum错误 (1)
- jsp页面用定时调用 (1)
- ajax setup (2)
- Exception,RuntimeException (1)
- 对话框 dialog (1)
- maven (17)
- PropertyPlaceholderConfigurer properties文件 (1)
- 错误集 (1)
- mybatise (0)
- 拦截器filter (1)
- http get post 区别 (1)
- rest 客户端两种返回的数据处理方式 (1)
- listener (2)
- maven工程 (1)
- ContainerResponseFilter (1)
- ajax action 打印任意实体类jsp (1)
- yum svn mvn (1)
- 分页 (1)
- angularjs (1)
- memcached (1)
- git (12)
- yyyyyyyy (0)
- oracal安装 (4)
- jaxwswebservice (1)
- spring bean (1)
- 排方法 (0)
- java 生成pdf (2)
- 创建目录 (1)
- 下载与生产pdf文件 (1)
- base64 (2)
- 配置文件 (2)
- blob (1)
- pdf (1)
- yum linux 安装Oracle (1)
- excl 插入数据库 (1)
- 搭建框架 (1)
- .classpath和jdk jre (1)
- mybatise 配置文件通配 (1)
- 用Maven插件生成Mybatis代码 (2)
- springmvc值的传递 (1)
- js jsp html (1)
- ajax跨域 (1)
- javamail (0)
- 提交复杂格式json数据 (1)
- get中文乱码/post (1)
- 弹出框,承载弹出链接----页面,显示大图 (1)
- @RequestBody list bean (1)
- 隐藏域 (1)
- 多页保存 (1)
- form 校验 (1)
- 注册,上传图片 (1)
- 登录验证 (1)
- 全局的异常处理 (0)
- 异常捕获,显示在页面 (0)
- mybatise事物配置 (1)
- maven compile (1)
- 时间格式 (1)
- js 跳转页面 (1)
- pringsecurity 角色授资源要重启服务 (0)
- Retrofi restfull (1)
- session过期推出,直接点击退出,退出 (0)
- 参数放于requestbody (1)
- maven本地仓库jar包 (1)
- 编译环境出错jdk1.6 1,7 (1)
- jsonarray ---json数组格式 (1)
- java后台文件上传,接受的2种方式 (0)
- 生成保存图片 (1)
- 权限mysql数据库Md5加密sql (1)
- mysql一对多关联查询 (1)
- mysql批量更新 (0)
- oracle in exists 区别 (1)
- https (1)
- linux发布脚本 (1)
- dubbo zookeepr (1)
- request.getParameter() (1)
- request.setAttribute() (1)
- @RequestMapping @ResponseBody (1)
- @RequestMapping @responsebody src控件 后台如何写入src值 (1)
- dwz (8)
- lib jar maven (1)
- web服务访问名称 (1)
- mvc返回内容设置,拦截 (1)
- @ResponseBody 返回json处理 (1)
- 视图,函数,存储过程 (1)
- <context:annotation-config/> (1)
- <context:component-scan/> (1)
- xml路劲通配 (2)
- 杂项 (1)
- dubbo (34)
- redis (25)
- mybatis (34)
- springmvc (15)
- js (7)
- sprinvmvc (1)
- 设计理念 (1)
- 工程 (1)
- 其他 (149)
- 导出,下载 (1)
- session (4)
- token (1)
- Exception处理 (2)
- 注解 (2)
- 框架 (3)
- shrio (1)
- login (1)
- 项目结构设计 (1)
- mybatis两种关联查询 (1)
- mybaits (2)
- 迭代模式 (1)
- oralce树形数据结构构建 (2)
- 树形结构的jsp展现 (1)
- filter intecept(Struts) (1)
- 树形结构数据的提交 (1)
- @RequestBody @RequestParam (1)
- div (1)
- equals重写 (1)
- 程序设计 (1)
- f多层for循环跳出 (1)
- 看源码 (0)
- 权限系统普遍通性 (1)
- 设计程序 (1)
- 动态拼接元素样式问题 (1)
- sql迭代 (1)
- debug断点 (1)
- spring mvc 扫描注解(ioc (1)
- di) (1)
- jdk (2)
- cglib (1)
- mybatis 多层括号(超过三层)解析不了 (1)
- tiles (2)
- cacheManager缓存的切换 (1)
- jsp,xml中el表达式等占位符中的数据操作 (1)
- jpa 及spring data jpa开发 (1)
- compareTo equals toString (1)
- 子页面用父页面js (1)
- jsp相对路径自加问题 (1)
- bean之间的相互拷贝 (1)
- DECODE (2)
- 泛型 (2)
- NVL (1)
- jsp jstl函数 用标签声明页面变量,供jstl使用,时间格式问题 (1)
- form表单切换action值 (1)
- response.getWriter().write()功能优于springMvc的返回 (1)
- 快速复制构建项目 (1)
- activeMq (15)
- cache (2)
- sql获取序列号 (1)
- 上传 (2)
- tfs (1)
- jsp标签 (2)
- qita (1)
- 触发器 (1)
- Exception (1)
- mybais (1)
- 标签 (1)
- connect by (1)
- for ... in (1)
- map转化为list (1)
- 树形结构list构建(树形实体) (1)
- 左侧菜单的设计 (1)
- response.getWriter().write() (1)
- eclipse打断点之后断无效 (1)
- 直接访问/web-inf/下的页面 (1)
- clob (1)
- freemark (1)
- 框架的设计 (1)
- get方式处理乱码 (1)
- Request的getParameter和getAttribute方法的区别 (1)
- cas (9)
- 时间格式问题 (1)
- ResponseUtil.writeToResponse (1)
- 树形数据的反选 (1)
- spring data jpa (1)
- jsp异常提示 (1)
- jquery js (1)
- eclipse (1)
- 乱码 (1)
- Json OBJETC (1)
- PROCEDURE (1)
- pl/sql oracle (1)
- 设计 (1)
- el表达式 (3)
- iframe (1)
- map (1)
- jsp中调用Java (1)
- response.getWriter().write() ajax (1)
- mybatis xml 传入参数 (0)
- response与request在返回时作用区别 (1)
- spring cache (1)
- 模型驱动 (1)
- 关于mybatis传空值的处理 (1)
- 日志配置 (1)
- mapper (1)
- mapper mybatis (1)
- mapper mybatis-spring spring-data-jpa (1)
- js插件 (1)
- spring-data-jpa (2)
- 字节流转化过程 (1)
- 数据库 (11)
- jsp页面 (1)
- 局域网络访问问题 (1)
- plsql (2)
- response (1)
- plsq (1)
- Proxool (1)
- cas security (1)
- 系统配置化 (1)
- 集群 (4)
- springboot (24)
- 设计模式 (5)
- 通知 (1)
- 架构 (48)
- zookeeper (5)
- mvc框架 (1)
- 事物隔离策略 (1)
- jvm (8)
- 调研 (1)
- Java工具类 (1)
- 并发容器 (3)
- 多线程管理器 (4)
- 简历 (0)
- 查询 (1)
- 集群工具 (1)
- springMcv (1)
- ConcurrentHashMap (1)
- hashtable (1)
- cac (1)
- 树形结构 (1)
- 定时任务 (1)
- tortoiseGit (2)
- struts (11)
- shiro (31)
- log4j (3)
- struts2 (2)
- 编码 (1)
- request (3)
- Nginx (14)
- tomcat (1)
- idea (12)
- mvc (2)
- BeanUtils (2)
- image (1)
- mino (1)
- httpClient (1)
- volecity (1)
- swagger (3)
- 调错 (0)
- data (1)
- log (1)
- shell (1)
- 事物 (3)
- junit (1)
- RestTemplate (2)
- 线程 (0)
- Exception异常处理 (1)
- Exception异常注解 (1)
- lock (1)
- HashMap (1)
- 面试 (0)
- rabbitMq (1)
- rainCat (1)
- 其它 (1)
- activemq消息传送机制以及ACK机制详解 (0)
- mysql (7)
- fildder (1)
- UML (1)
- 校验 (1)
- 反射 (1)
- 切面 (1)
- springioc (1)
- urule2 (0)
- skywalking (1)
- urule (2)
- docker (2)
- 前端 (1)
- bootstrap (1)
- eureka (2)
- springcloud (16)
- jenkins (2)
- springsecurity (1)
- 数据结构 (4)
- gradle (1)
- mycat (3)
- nacos (1)
- canary (1)
- 线程池 (1)
- solr (1)
- resteasy (2)
- BI (1)
- dfs (2)
- elasticsearch (1)
- ruby (1)
- logstash (1)
- clickhouse (2)
- davinci (15)
- java (1)
- davinvi (1)
- fastdfs (1)
- vue (1)
- 《将博客搬至CSDN》 (1)
最新评论
-
nizhipeng123:
private SessionFactory sessio ...
用map接收参数的几个注意的问题
web.xml
<servlet>
<servlet-name>RESTEntrance</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.certusnet.nfv.mano.vim.RestApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
//这里定义好路径组成格式
<servlet-mapping>
<servlet-name>RESTEntrance</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
客户端:
public SummeryOfResourcesVO getSummeryOfResource() {
logger.info("查询一组资源使用情况(云主机、虚拟内核、虚拟内存、安全组)信息");
final SummeryOfResourcesVO vo = new SummeryOfResourcesVO();
final JSONObject[] provider = new JSONObject[1];
final String[] reslt= new String[1];
/**取资源使用情况*/
HttpClientRequest request = new HttpClientGetRequest(ConfigFileLoad.getConfContent("API_IP") + "/rest/resource_used");
try {
request.process(new HttpClientResponseHandler() {
@Override
public void handle(String response, String retCode, String msg) throws HttpClientException {
logger.debug("查询一组资源使用情况信息,返回状态:" + retCode + ",返回信息:" + msg);
JSONObject obj = JSONObject.parseObject(response);
if(obj.get("result")!=null){
System.out.println(obj.get("result").toString());
JSONObject jsonObj = JSONObject.parseObject(obj.get("result").toString());
if (jsonObj == null){
//&&!reslt[0].equals("0")
return;
}
// 一 、请求并计算 云主机信息
Integer vms = jsonObj.getInteger(Constants.OverView.VMS);
Integer used_vms = jsonObj.getInteger(Constants.OverView.USED_VMS);
Integer unused_vms = 0;
if (vms == null || vms.equals("")) {
vms = 0;
} else if (used_vms == null || used_vms.equals("")) {
used_vms = 0;
} else {
unused_vms = vms - used_vms;
}
vo.setCloudPlatformAll(String.valueOf(vms));
vo.setCloudPlatformUsed(String.valueOf(used_vms));
vo.setCloudPlatformUnUsed(String.valueOf(unused_vms));
// 二 、请求 虚拟内核
Integer cpus = jsonObj.getInteger(Constants.OverView.CPUS);
Integer used_cpus = jsonObj.getInteger(Constants.OverView.USED_CPUS);
Integer unused_cpus = 0;
if (cpus == null || cpus.equals("")) {
cpus = 0;
} else if (used_cpus == null || used_cpus.equals("")) {
used_cpus = 0;
} else {
unused_cpus = cpus - used_cpus;
}
vo.setVirtualKernelAll(String.valueOf(cpus));
vo.setVirtualKernelUsed(String.valueOf(used_cpus));
vo.setVirtualKernelUnUsed(String.valueOf(unused_cpus));
// 三、请求 虚拟内存
Integer mems = jsonObj.getInteger(Constants.OverView.MEMS);
Integer used_mem = jsonObj.getInteger(Constants.OverView.USED_MEM);
Integer unused_mem = 0;
if (mems == null || mems.equals("")) {
mems = 0;
} else if (used_mem == null || used_mem.equals("")) {
used_mem = 0;
} else {
unused_mem = mems - used_mem;
}
vo.setVirtualMemoryAll(String.valueOf(mems));
vo.setVirtualMemoryUsed(String.valueOf(used_mem));
vo.setVirtualMemoryUnUsed(String.valueOf(unused_mem));
// 四、请求 安全组
Integer security_group = jsonObj.getInteger(Constants.OverView.SECURITY_GROUP);
Integer used_security_group = jsonObj.getInteger(Constants.OverView.USED_SECURITY_GROUP);
Integer unused_security_group = 0;
if (security_group == null || security_group.equals("")) {
security_group = 0;
} else if (used_security_group == null || used_security_group.equals("")) {
used_security_group = 0;
} else {
unused_security_group = security_group - used_security_group;
}
vo.setSecurityGroupAll(String.valueOf(security_group));
vo.setSecurityGroupUsed(String.valueOf(used_security_group));
vo.setSecurityGroupUnUsed(String.valueOf(unused_security_group));
}else{
/**provider连接数*/
HttpClientRequest requestProvider = new HttpClientGetRequest(ConfigFileLoad.getConfContent("API_IP") + "/rest/provider_network_cn");
try {
requestProvider.process(new HttpClientResponseHandler() {
@Override
public void handle(String response, String retCode, String msg) throws HttpClientException {
logger.debug("查询一组资源使用情况信息,返回状态:" + retCode + ",返回信息:" + msg);
provider[0] = JSONObject.parseObject(response);
System.out.println(provider[0].get("result").toString()+"rrrrrrrrrrrrr");
String jsonObj = provider[0].get("result").toString();
reslt[0] =jsonObj;
if (jsonObj == null)
return;
}
});
} catch (HttpClientException e) {
e.printStackTrace();
}
if(reslt[0].equals("0")){
throw new ManoException("0","没建立与openstack的连接,请检查openstack资源中openstack提供者是否已添加");
}else{
throw new ManoException("1","没有数据");
}
//throw new HttpClientException("没建立连接");
}
}});
} catch (HttpClientException e) {
throw new ManoException("1","没建立连接");
}
logger.info("SummeryOfResourcesVO is " + vo.toString());
return vo;
}
服务端:
package com.certusnet.nfv.mano.vim.providernet.rest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.certusnet.nfv.mano.exception.ManoException;
import com.certusnet.nfv.mano.rest.ContentType;
import com.certusnet.nfv.mano.vim.ExceptionCode;
import com.certusnet.nfv.mano.vim.HttpsUtil;
import com.certusnet.nfv.mano.vim.host.rsclient.IHostRsClient;
import com.certusnet.nfv.mano.vim.host.rsclient.impl.HostRsClient;
import com.certusnet.nfv.mano.vim.providernet.rsclient.IProvidernetRsClient;
import com.certusnet.nfv.mano.vim.providernet.rsclient.impl.ProvidernetRsClient;
import com.certusnet.nfv.mano.vim.vm.rest.VmRest;
import com.certusnet.nfv.mano.vim.vm.rsclient.IVmRsClient;
@Component
@Path("/")
public class ProvidernetRest {
private static Logger logger = Logger.getLogger(ProvidernetRest.class);
@Autowired
private IProvidernetRsClient providernetRsClient;
// private IProvidernetRsClient providernetRsClient = new ProvidernetRsClient();
@Autowired
private IHostRsClient hostRsClient;
// private IHostRsClient hostRsClient = new HostRsClient();
@GET
@Path("provider_networks")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetList(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetList(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernets");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks/show/{providernet_id}")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetById(@PathParam("providernet_id") String providernet_id,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_id=" + providernet_id);
if ((null == providernet_id) || (providernet_id.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String returnStr= providernetRsClient.findProvidernetById(providernet_id,token);
logger.debug("providernetwork-detail-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode. FIND_PROVIDER_NETWORK_DETAIL_FAILED);
JSONObject networkJsonObj = jsonObj.getJSONObject("providernet");
logger.info("provider_networkJsonObj_detail" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode. FIND_PROVIDER_NETWORK_DETAIL_FAILED, ex);
}
}
@GET
@Path("provider_networks/{provider_network_uuid}/tenant_networks")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findTenantNetworkListByProvidernetId(@PathParam("provider_network_uuid") String providernet_id,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_id=" + providernet_id);
if ((null == providernet_id) || (providernet_id.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String returnStr= providernetRsClient.findTenantNetworkList( providernet_id,token) ;
logger.debug("providernetwork-TenantNetworkList-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
logger.debug("providernetwork-TenantNetworkList-jsonOjb:"+jsonObj);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernet_network");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks/{provider_network_name}/interfaces")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findInterfaceListByProvidernetId(@PathParam("provider_network_name") String providernet_name,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_name=" + providernet_name);
if ((null == providernet_name) || (providernet_name.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String hostReturnStr= hostRsClient.findHostList(token);
logger.debug("hostReturnStr:"+hostReturnStr);
JSONObject hostJsonObj = JSONObject.fromObject(hostReturnStr);
logger.debug("hostJsonObj-jsonObj:"+hostJsonObj);
if (!"200".equalsIgnoreCase(hostJsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_HOST_LIST_FAILED);
JSONArray ihostArray = hostJsonObj.getJSONArray("ihost");
logger.debug("ihostArray-jsonObj:"+ihostArray);
JSONArray returnJsonArray = new JSONArray();
int ihostArray_length = ihostArray.size();
for(int i=0; i < ihostArray_length; i++){
String tempIhostId= "" + ihostArray.getJSONObject(i).getString("uuid");
logger.info("tempIhostId="+tempIhostId);
String interfaceReturnStr= providernetRsClient.findInterfaceListByHostId(tempIhostId,token) ;
logger.debug("interfaceReturnStr="+interfaceReturnStr);
interfaceReturnStr= interfaceReturnStr.replace("null", "\"\"");
JSONObject interfaceJsonObj = JSONObject.fromObject(interfaceReturnStr);
logger.debug("interfaceJsonObj="+interfaceJsonObj);
JSONArray interfaceArray = interfaceJsonObj.getJSONArray("iinterfaces");
int interfaceArray_length = interfaceArray.size();
for(int j=0; j < interfaceArray_length; j++){
JSONObject tmpJSONObject = interfaceArray.getJSONObject(j);
String tempProvidernetNameList = tmpJSONObject.getString("providernetworks");
if (tempProvidernetNameList.indexOf(providernet_name) > -1){
returnJsonArray.add(tmpJSONObject);
}
}
}
logger.info("returnJsonArray=" + returnJsonArray);
return returnJsonArray;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("logical_topology")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetListDetail(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetListDetail(token);
returnStr=returnStr.replace("nil", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernet_list_detail");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks_without_tenant_network")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetListWithoutNetwork(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetListWithoutNetwork(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernets");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
/**
* 获取provider的连接数
* @author admin
* @param token
* @return
*/
@GET
@Path("provider_network_cn")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidercnCount(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidercnCount(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
String networkJsonObj = jsonObj.getString("ems_num");
logger.info("provider_networkJsonObj_list" + networkJsonObj);
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
public static void main(String[] args) {
ProvidernetRest providernet = new ProvidernetRest();
// providernet.findProvidernetList();a
// providernet.findProvidernetById("e59cf271-34fb-4c77-8cf1-bb9792c48e3c");
// providernet.findTenantNetworkListByProvidernetId("6f0ca883-e581-4dc5-a14f-3e9a5a4651a7");
// providernet.findInterfaceListByProvidernetId("provider-data-15");
// providernet.findProvidernetListDetail();
}
}
服务端接口注册:
package com.certusnet.nfv.mano.vim;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.web.filter.RequestContextFilter;
import com.certusnet.nfv.mano.rest.ManoExceptionMapper;
import com.certusnet.nfv.mano.rest.RestResponseFilter;
import com.certusnet.nfv.mano.vim.host.rest.HostRest;
import com.certusnet.nfv.mano.vim.alarm.rest.AlarmRest;
import com.certusnet.nfv.mano.vim.cpu_utilization_history.rest.Cpu_utilization_historyRest;
import com.certusnet.nfv.mano.vim.network.rest.NetworkRest;
import com.certusnet.nfv.mano.vim.port.rest.PortRest;
import com.certusnet.nfv.mano.vim.providernet.rest.ProvidernetRest;
import com.certusnet.nfv.mano.vim.usage_history.rest.Usage_historyRest;
import com.certusnet.nfv.mano.vim.vm.rest.VmRest;
import com.certusnet.nfv.mano.vim.vnf.rest.HelloNfvRest;
public class RestApplication extends ResourceConfig {
/**
* Register JAX-RS application components.
*/
public RestApplication () {
register(RequestContextFilter.class);
register(HelloNfvRest.class);
register(VmRest.class);
register(Usage_historyRest.class);
register(Cpu_utilization_historyRest.class);
register(ProvidernetRest.class);
register(ManoExceptionMapper.class);
register(RestResponseFilter.class);
register(NetworkRest.class);
register(HostRest.class);
register(AlarmRest.class);
register(PortRest.class);
}
}
<servlet>
<servlet-name>RESTEntrance</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.certusnet.nfv.mano.vim.RestApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
//这里定义好路径组成格式
<servlet-mapping>
<servlet-name>RESTEntrance</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
客户端:
public SummeryOfResourcesVO getSummeryOfResource() {
logger.info("查询一组资源使用情况(云主机、虚拟内核、虚拟内存、安全组)信息");
final SummeryOfResourcesVO vo = new SummeryOfResourcesVO();
final JSONObject[] provider = new JSONObject[1];
final String[] reslt= new String[1];
/**取资源使用情况*/
HttpClientRequest request = new HttpClientGetRequest(ConfigFileLoad.getConfContent("API_IP") + "/rest/resource_used");
try {
request.process(new HttpClientResponseHandler() {
@Override
public void handle(String response, String retCode, String msg) throws HttpClientException {
logger.debug("查询一组资源使用情况信息,返回状态:" + retCode + ",返回信息:" + msg);
JSONObject obj = JSONObject.parseObject(response);
if(obj.get("result")!=null){
System.out.println(obj.get("result").toString());
JSONObject jsonObj = JSONObject.parseObject(obj.get("result").toString());
if (jsonObj == null){
//&&!reslt[0].equals("0")
return;
}
// 一 、请求并计算 云主机信息
Integer vms = jsonObj.getInteger(Constants.OverView.VMS);
Integer used_vms = jsonObj.getInteger(Constants.OverView.USED_VMS);
Integer unused_vms = 0;
if (vms == null || vms.equals("")) {
vms = 0;
} else if (used_vms == null || used_vms.equals("")) {
used_vms = 0;
} else {
unused_vms = vms - used_vms;
}
vo.setCloudPlatformAll(String.valueOf(vms));
vo.setCloudPlatformUsed(String.valueOf(used_vms));
vo.setCloudPlatformUnUsed(String.valueOf(unused_vms));
// 二 、请求 虚拟内核
Integer cpus = jsonObj.getInteger(Constants.OverView.CPUS);
Integer used_cpus = jsonObj.getInteger(Constants.OverView.USED_CPUS);
Integer unused_cpus = 0;
if (cpus == null || cpus.equals("")) {
cpus = 0;
} else if (used_cpus == null || used_cpus.equals("")) {
used_cpus = 0;
} else {
unused_cpus = cpus - used_cpus;
}
vo.setVirtualKernelAll(String.valueOf(cpus));
vo.setVirtualKernelUsed(String.valueOf(used_cpus));
vo.setVirtualKernelUnUsed(String.valueOf(unused_cpus));
// 三、请求 虚拟内存
Integer mems = jsonObj.getInteger(Constants.OverView.MEMS);
Integer used_mem = jsonObj.getInteger(Constants.OverView.USED_MEM);
Integer unused_mem = 0;
if (mems == null || mems.equals("")) {
mems = 0;
} else if (used_mem == null || used_mem.equals("")) {
used_mem = 0;
} else {
unused_mem = mems - used_mem;
}
vo.setVirtualMemoryAll(String.valueOf(mems));
vo.setVirtualMemoryUsed(String.valueOf(used_mem));
vo.setVirtualMemoryUnUsed(String.valueOf(unused_mem));
// 四、请求 安全组
Integer security_group = jsonObj.getInteger(Constants.OverView.SECURITY_GROUP);
Integer used_security_group = jsonObj.getInteger(Constants.OverView.USED_SECURITY_GROUP);
Integer unused_security_group = 0;
if (security_group == null || security_group.equals("")) {
security_group = 0;
} else if (used_security_group == null || used_security_group.equals("")) {
used_security_group = 0;
} else {
unused_security_group = security_group - used_security_group;
}
vo.setSecurityGroupAll(String.valueOf(security_group));
vo.setSecurityGroupUsed(String.valueOf(used_security_group));
vo.setSecurityGroupUnUsed(String.valueOf(unused_security_group));
}else{
/**provider连接数*/
HttpClientRequest requestProvider = new HttpClientGetRequest(ConfigFileLoad.getConfContent("API_IP") + "/rest/provider_network_cn");
try {
requestProvider.process(new HttpClientResponseHandler() {
@Override
public void handle(String response, String retCode, String msg) throws HttpClientException {
logger.debug("查询一组资源使用情况信息,返回状态:" + retCode + ",返回信息:" + msg);
provider[0] = JSONObject.parseObject(response);
System.out.println(provider[0].get("result").toString()+"rrrrrrrrrrrrr");
String jsonObj = provider[0].get("result").toString();
reslt[0] =jsonObj;
if (jsonObj == null)
return;
}
});
} catch (HttpClientException e) {
e.printStackTrace();
}
if(reslt[0].equals("0")){
throw new ManoException("0","没建立与openstack的连接,请检查openstack资源中openstack提供者是否已添加");
}else{
throw new ManoException("1","没有数据");
}
//throw new HttpClientException("没建立连接");
}
}});
} catch (HttpClientException e) {
throw new ManoException("1","没建立连接");
}
logger.info("SummeryOfResourcesVO is " + vo.toString());
return vo;
}
服务端:
package com.certusnet.nfv.mano.vim.providernet.rest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.certusnet.nfv.mano.exception.ManoException;
import com.certusnet.nfv.mano.rest.ContentType;
import com.certusnet.nfv.mano.vim.ExceptionCode;
import com.certusnet.nfv.mano.vim.HttpsUtil;
import com.certusnet.nfv.mano.vim.host.rsclient.IHostRsClient;
import com.certusnet.nfv.mano.vim.host.rsclient.impl.HostRsClient;
import com.certusnet.nfv.mano.vim.providernet.rsclient.IProvidernetRsClient;
import com.certusnet.nfv.mano.vim.providernet.rsclient.impl.ProvidernetRsClient;
import com.certusnet.nfv.mano.vim.vm.rest.VmRest;
import com.certusnet.nfv.mano.vim.vm.rsclient.IVmRsClient;
@Component
@Path("/")
public class ProvidernetRest {
private static Logger logger = Logger.getLogger(ProvidernetRest.class);
@Autowired
private IProvidernetRsClient providernetRsClient;
// private IProvidernetRsClient providernetRsClient = new ProvidernetRsClient();
@Autowired
private IHostRsClient hostRsClient;
// private IHostRsClient hostRsClient = new HostRsClient();
@GET
@Path("provider_networks")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetList(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetList(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernets");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks/show/{providernet_id}")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetById(@PathParam("providernet_id") String providernet_id,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_id=" + providernet_id);
if ((null == providernet_id) || (providernet_id.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String returnStr= providernetRsClient.findProvidernetById(providernet_id,token);
logger.debug("providernetwork-detail-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode. FIND_PROVIDER_NETWORK_DETAIL_FAILED);
JSONObject networkJsonObj = jsonObj.getJSONObject("providernet");
logger.info("provider_networkJsonObj_detail" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode. FIND_PROVIDER_NETWORK_DETAIL_FAILED, ex);
}
}
@GET
@Path("provider_networks/{provider_network_uuid}/tenant_networks")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findTenantNetworkListByProvidernetId(@PathParam("provider_network_uuid") String providernet_id,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_id=" + providernet_id);
if ((null == providernet_id) || (providernet_id.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String returnStr= providernetRsClient.findTenantNetworkList( providernet_id,token) ;
logger.debug("providernetwork-TenantNetworkList-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
logger.debug("providernetwork-TenantNetworkList-jsonOjb:"+jsonObj);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernet_network");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks/{provider_network_name}/interfaces")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findInterfaceListByProvidernetId(@PathParam("provider_network_name") String providernet_name,@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
logger.info("providernet_name=" + providernet_name);
if ((null == providernet_name) || (providernet_name.trim().equalsIgnoreCase(""))) {
throw new ManoException(ExceptionCode.PARAM_NEEDED_IS_NULL);
}
try {
String hostReturnStr= hostRsClient.findHostList(token);
logger.debug("hostReturnStr:"+hostReturnStr);
JSONObject hostJsonObj = JSONObject.fromObject(hostReturnStr);
logger.debug("hostJsonObj-jsonObj:"+hostJsonObj);
if (!"200".equalsIgnoreCase(hostJsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_HOST_LIST_FAILED);
JSONArray ihostArray = hostJsonObj.getJSONArray("ihost");
logger.debug("ihostArray-jsonObj:"+ihostArray);
JSONArray returnJsonArray = new JSONArray();
int ihostArray_length = ihostArray.size();
for(int i=0; i < ihostArray_length; i++){
String tempIhostId= "" + ihostArray.getJSONObject(i).getString("uuid");
logger.info("tempIhostId="+tempIhostId);
String interfaceReturnStr= providernetRsClient.findInterfaceListByHostId(tempIhostId,token) ;
logger.debug("interfaceReturnStr="+interfaceReturnStr);
interfaceReturnStr= interfaceReturnStr.replace("null", "\"\"");
JSONObject interfaceJsonObj = JSONObject.fromObject(interfaceReturnStr);
logger.debug("interfaceJsonObj="+interfaceJsonObj);
JSONArray interfaceArray = interfaceJsonObj.getJSONArray("iinterfaces");
int interfaceArray_length = interfaceArray.size();
for(int j=0; j < interfaceArray_length; j++){
JSONObject tmpJSONObject = interfaceArray.getJSONObject(j);
String tempProvidernetNameList = tmpJSONObject.getString("providernetworks");
if (tempProvidernetNameList.indexOf(providernet_name) > -1){
returnJsonArray.add(tmpJSONObject);
}
}
}
logger.info("returnJsonArray=" + returnJsonArray);
return returnJsonArray;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_TENANT_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("logical_topology")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetListDetail(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetListDetail(token);
returnStr=returnStr.replace("nil", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernet_list_detail");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
@GET
@Path("provider_networks_without_tenant_network")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidernetListWithoutNetwork(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidernetListWithoutNetwork(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
JSONArray networkJsonObj = jsonObj.getJSONArray("providernets");
logger.info("provider_networkJsonObj_list" + networkJsonObj.toString());
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
/**
* 获取provider的连接数
* @author admin
* @param token
* @return
*/
@GET
@Path("provider_network_cn")
@Produces(ContentType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.TEXT_PLAIN)
public Object findProvidercnCount(@HeaderParam("X-Auth-Token") String token)
{
logger.info("X-Auth-Token=" + token);
try {
String returnStr= providernetRsClient.findProvidercnCount(token);
logger.debug("providernetwork-string:"+returnStr);
returnStr=returnStr.replace("null", "\"\"");
JSONObject jsonObj = JSONObject.fromObject(returnStr);
if (!"200".equalsIgnoreCase(jsonObj.getString("retCode")))
throw new ManoException(
ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED);
String networkJsonObj = jsonObj.getString("ems_num");
logger.info("provider_networkJsonObj_list" + networkJsonObj);
return networkJsonObj;
} catch (ManoException ex) {
throw ex;
} catch (Exception ex) {
throw new ManoException(ExceptionCode.FIND_PROVIDER_NETWORK_LIST_FAILED, ex);
}
}
public static void main(String[] args) {
ProvidernetRest providernet = new ProvidernetRest();
// providernet.findProvidernetList();a
// providernet.findProvidernetById("e59cf271-34fb-4c77-8cf1-bb9792c48e3c");
// providernet.findTenantNetworkListByProvidernetId("6f0ca883-e581-4dc5-a14f-3e9a5a4651a7");
// providernet.findInterfaceListByProvidernetId("provider-data-15");
// providernet.findProvidernetListDetail();
}
}
服务端接口注册:
package com.certusnet.nfv.mano.vim;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.web.filter.RequestContextFilter;
import com.certusnet.nfv.mano.rest.ManoExceptionMapper;
import com.certusnet.nfv.mano.rest.RestResponseFilter;
import com.certusnet.nfv.mano.vim.host.rest.HostRest;
import com.certusnet.nfv.mano.vim.alarm.rest.AlarmRest;
import com.certusnet.nfv.mano.vim.cpu_utilization_history.rest.Cpu_utilization_historyRest;
import com.certusnet.nfv.mano.vim.network.rest.NetworkRest;
import com.certusnet.nfv.mano.vim.port.rest.PortRest;
import com.certusnet.nfv.mano.vim.providernet.rest.ProvidernetRest;
import com.certusnet.nfv.mano.vim.usage_history.rest.Usage_historyRest;
import com.certusnet.nfv.mano.vim.vm.rest.VmRest;
import com.certusnet.nfv.mano.vim.vnf.rest.HelloNfvRest;
public class RestApplication extends ResourceConfig {
/**
* Register JAX-RS application components.
*/
public RestApplication () {
register(RequestContextFilter.class);
register(HelloNfvRest.class);
register(VmRest.class);
register(Usage_historyRest.class);
register(Cpu_utilization_historyRest.class);
register(ProvidernetRest.class);
register(ManoExceptionMapper.class);
register(RestResponseFilter.class);
register(NetworkRest.class);
register(HostRest.class);
register(AlarmRest.class);
register(PortRest.class);
}
}
发表评论
-
rest路径形式相同的话,通过@GET @DELETE 区别
2015-05-18 14:17 1543通过位置对应接收参数,如果rest路径形式相同的话,通过@GE ... -
rest 调用有参数接口
2015-05-06 17:22 3044//有参数rest,调用客户端 OperateLogSer ... -
rest 应用demo 3 客户端的另一中方式
2015-04-30 14:53 931//rest接口访问地址特征 API_IP = http:// ... -
rest 应用demo
2015-04-22 12:58 1273web.xml <servlet> < ... -
rest
2015-04-14 14:18 849http://blog.sina.com.cn/s/blog_ ...
相关推荐
这个"REST api demo"项目提供了学习和实践REST API设计和实现的一个基础平台,对于理解如何将这些技术结合使用以构建现代Web服务非常有帮助。通过深入研究和扩展这个项目,开发者可以更好地掌握RESTful API设计原则...
2. **创建REST Controller** - 使用`@RestController`注解标记Controller类,表明该类将处理HTTP请求并返回JSON或其他资源。 - 使用`@RequestMapping`注解来定义处理请求的URL模式。 - `@GetMapping`、`@...
Spring MVC 是一个强大的Java框架,用于构建Web应用程序,而REST(Representational State Transfer)是一种软件架构风格,常用于创建Web服务。"Spring MVC REST Demo"是一个示例项目,旨在展示如何在Spring MVC框架...
本示例"rest webservice demo spring"是一个使用Spring框架实现的RESTful Web服务的演示项目。Spring是Java领域的一个开源框架,特别适合于构建企业级应用,它提供了全面的编程和配置模型,包括对REST的支持。 1. *...
2、测试Demo应用对电话号码有限制,只能对开发者控制台中号码管理页面配置的号码发起业务请求。 3、应用和子帐号需要配套使用。不能将自建应用与测试Demo所属子帐号结合使用。 4、本rest sdk源码在sdk目录中提供,...
"云通讯CCP_REST_DEMO_Python_v2.7r.zip"是容联云通讯为Python开发者量身定制的一个版本为2.7的SDK,它通过RESTful API接口封装了多项功能,使得Python开发者能够更便捷地调用这些接口,实现高效的应用开发。...
2. **配置服务暴露**:在服务提供者的配置文件(通常是`dubbo.properties`或`application.xml`)中,你需要指定服务接口、实现类以及注册中心地址。例如: ```xml ...
【标题】"rest_demo.zip" 是一个包含RESTful API开发示例的压缩文件,它基于Spring Boot框架构建,旨在提供一个快速理解REST API开发的简易平台。REST(Representational State Transfer)是一种网络应用程序的设计...
**jQuery + JSON + REST WCF DEMO 知识点详解** 在IT行业中,开发Web应用程序时,经常会使用到jQuery、JSON、RESTful API以及WCF(Windows Communication Foundation)等技术。"Jquery+JSON+REST WCF DEMO"是一个...
【Spring CXF REST Demo】项目是一个使用Maven构建的Java应用程序,它展示了如何将Spring框架与Apache CXF集成,以创建RESTful风格的服务。在这个项目中,开发者可以学习到如何利用CXF作为服务端的REST服务提供者,...
"SPRING-MVC-MQ-CXF-REST_Demo"这个项目很可能是用来演示如何在同一个应用中整合Spring MVC、MQ、CXF和REST技术。项目可能包含了以下部分: 1. Spring MVC配置:展示了如何设置DispatcherServlet、视图解析器以及...
在这个“rest webservice demo”中,我们将会探讨如何使用Java来快速实现一个RESTful Web服务。 Java中实现REST服务最常用的框架是JAX-RS,它提供了一套标准API,使得开发者可以方便地创建RESTful接口。JAX-RS的...
Spring休息演示在此示例代码演示中,如何使用[Jackson Databind]( )使用Spring将信息从Rest-Client传递到Rest-Web...testapi / helloapp-显示Hello应用/ spring-rest-demo / api / rules-显示json数据当Tomcat服
【标题】"Spring+Mybatis+REST全注解Demo"是一个综合性的开发示例,它展示了如何使用Spring框架、Mybatis持久层框架以及RESTful API设计原则,通过注解方式来构建一个完整的Java应用程序。这个Demo旨在帮助开发者...
本文将深入探讨这两个技术,并结合一个实际的Demo来解释它们的工作原理和如何在项目中应用。 首先,SpringBoot Data JPA是Spring Data项目的一部分,它简化了Java Persistence API (JPA) 的使用。JPA是Java平台上的...
在本项目"activiti+springMVC+mybatis rest风格整合demo"中,开发者通过集成Activiti、Spring MVC和MyBatis三个核心组件,构建了一个基于RESTful API的工作流管理系统。这个项目对于初学者来说是一个很好的学习资源...
本示例将详细讲解如何使用Spring、Apache CXF和Maven来创建一个基于REST的WebService服务端Demo。 首先,让我们理解这些关键组件的作用: 1. **Spring**:这是一个全面的开发框架,用于构建Java应用程序,特别是...
2. **自定义分页**:DRF提供了一些默认的分页类,如`LimitOffsetPagination`和`PageNumberPagination`。如果你需要更复杂的分页逻辑,可以创建自己的分页类,继承`BasePagination`,并覆盖`get_paginated_response`...
在这个"Rest风格前后端分离 web项目demo"中,我们可以深入理解这一模式的应用。 **前后端分离** 前后端分离的核心理念是让前端专注于用户交互和界面展示,而后端则专注于数据处理和业务逻辑。这样,前端可以通过...
通过运行,服务器主要是用于插入和列出框架的REST api。 所有逻辑都在客户端中运行。 该逻辑通过spock测试在groovy中完成,并通过转换为javascript。 使用require.js加载所有JavaScript内容。 创建创意项目: ./...