使用OSGi-JAXRS-Connector实现Restful

OSGI系列 Servlet-Rest发布Http服务 除了WebService 和 Restful,我们还希望通过把servlet发布出去 1、在blueprint.xml中定义 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 阅读详情

Step1: 添加Connector支持

   

   

   

finish->oK完成

   

Step2:新建Plugin-in Project

源码结构

   

Blog.Java

package api;

   

public class Blog {

private String title;

private String content;

private String category;

private int readCnt;

   

public Blog(){}

   

public Blog(String title, String content, String category, int readCnt) {

super();

this.title = title;

this.content = content;

this.category = category;

this.readCnt = readCnt;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public String getContent() {

return content;

}

public void setContent(String content) {

this.content = content;

}

public String getCategory() {

return category;

}

public void setCategory(String category) {

this.category = category;

}

public int getReadCnt() {

return readCnt;

}

public void setReadCnt(int readCnt) {

this.readCnt = readCnt;

}

   

   

}

   

IBlogService.java

package api;

   

import java.util.List;

   

import javax.ws.rs.GET;

import javax.ws.rs.Path;

import javax.ws.rs.Produces;

import javax.ws.rs.core.MediaType;

   

@Path("/blog")

public interface IBlogApi {

@GET

@Produces(MediaType.TEXT_HTML)

public String getHtml();

   

@GET

@Path("/blogs")

@Produces(MediaType.APPLICATION_JSON)

public List<Blog> getBlogs();

}

   

BlogApiImpl.java

package api.impl;

   

import java.util.ArrayList;

import java.util.List;

   

import javax.ws.rs.GET;

import javax.ws.rs.Path;

import javax.ws.rs.Produces;

import javax.ws.rs.core.MediaType;

   

import api.Blog;

import api.IBlogApi;

   

@Path("/blog")

public class BlogApiImpl implements IBlogApi{

   

private static List<Blog> blogs = new ArrayList<Blog>();

   

static{

blogs.add(new Blog("blog1", "....", "hello", 1));

blogs.add(new Blog("blog1", "....", "hello", 1));

blogs.add(new Blog("blog1", "....", "hello", 1));

}

   

@Override

@GET

public String getHtml(){

return "<h1>BlogApi</h1>";

}

   

@Override

public List<Blog> getBlogs() {

return blogs;

}

}

   

GsonMessageBodyHandler.java

package providers;

   

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.io.OutputStreamWriter;

import java.io.UnsupportedEncodingException;

import java.lang.annotation.Annotation;

import java.lang.reflect.Type;

 

   

import javax.ws.rs.Consumes;

import javax.ws.rs.Produces;

import javax.ws.rs.WebApplicationException;

import javax.ws.rs.core.MediaType;

import javax.ws.rs.core.MultivaluedMap;

import javax.ws.rs.ext.MessageBodyReader;

import javax.ws.rs.ext.MessageBodyWriter;

import javax.ws.rs.ext.Provider;

 

   

import com.google.gson.Gson;

import com.google.gson.GsonBuilder;

 

@Provider

@Produces(MediaType.APPLICATION_JSON)

@Consumes(MediaType.APPLICATION_JSON)

public final class GsonMessageBodyHandler implements MessageBodyWriter<Object>,

MessageBodyReader<Object> {

 

private static final String UTF_8 = "UTF-8";

 

private Gson gson;

 

private Gson getGson() {

if (gson == null) {

final GsonBuilder gsonBuilder = new GsonBuilder();

gson = gsonBuilder.create();

}

return gson;

}

 

@Override

public boolean isReadable(Class<?> type, Type genericType,

java.lang.annotation.Annotation[] annotations, MediaType mediaType) {

return true;

}

 

@Override

public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {

InputStreamReader streamReader = new InputStreamReader(entityStream, UTF_8);

try {

Type jsonType;

if (type.equals(genericType)) {

jsonType = type;

} else {

jsonType = genericType;

}

return getGson().fromJson(streamReader, jsonType);

} finally {

streamReader.close();

}

}

 

@Override

public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {

return true;

}

 

@Override

public long getSize(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {

return -1;

}

 

@Override

public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {

OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);

try {

Type jsonType;

if (type.equals(genericType)) {

jsonType = type;

} else {

jsonType = genericType;

}

getGson().toJson(object, jsonType, writer);

} finally {

writer.close();

}

}

}

   

依赖关系

   

   

Step3: 配置DS Component, MANIFEST.MF

   

component-json-provider.xml

<?xml version="1.0" encoding="UTF-8"?>

<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Jersey-Test-Json-Provider">

<implementation class="providers.GsonMessageBodyHandler"/>

<service>

<provide interface="providers.GsonMessageBodyHandler"/>

</service>

</scr:component>

   

component.xml

<?xml version="1.0" encoding="UTF-8"?>

<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Jersey-Test">

<implementation class="api.impl.BlogApiImpl"/>

<service>

<provide interface="api.impl.BlogApiImpl"/>

</service>

</scr:component>

   

MANIFEST.MF

Manifest-Version: 1.0

Bundle-ManifestVersion: 2

Bundle-Name: Jersey-Test

Bundle-SymbolicName: Jersey-Test

Bundle-Version: 1.0.0.qualifier

Bundle-RequiredExecutionEnvironment: JavaSE-1.7

Service-Component: component.xml,

component-json-provider.xml

Import-Package: javax.ws.rs;version="2.0.0",

javax.ws.rs.core;version="2.0.0",

javax.ws.rs.ext;version="2.0.0"

Require-Bundle: com.google.gson

   

Step4: Run Configuration

需要添加的bundle有jetty、console、osgi、ds、gson等

   

Step5: 运行测试

注意路径是services打头

   

   

原理简介

通过DS/声明式服务将REST Service接口、GsonMessageBodyHandler注册为service;OSGI-JAXRS-Connector监听被注册的服务,并识别、处理。

   

另外,这里使用自定义的MessageBodyWriter,其实,OSGi-JAXRS-Connector已经有此功能的Bundle,我们可以直接使用。

将MANIFEST.MF中的component-json-provider.xml移除。

   

   

参考资料

http://eclipsesource.com/blogs/2014/02/04/step-by-step-how-to-bring-jax-rs-and-osgi-together/

https://github.com/hstaudacher/osgi-jax-rs-connector

https://github.com/hstaudacher/osgi-jax-rs-connector/tree/master/examples

http://eclipsesource.com/blogs/2012/11/02/integrating-gson-into-a-jax-rs-based-application/

  

OSGI系列 Restful发布服务 OSGI中bundle之间的桥梁是blueprint.xml 所以,一切从blueprint开始。 一、创建一个blueprint.xml文件,此文件必须符合规范 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSc 阅读详情

相关推荐

`javax.ws.rs.core` 是Java Representational State Transfer (JAX-RS)规范的一部分

JAX-RS规范的主要目标是提供一种简单而统一的方式来开发基于REST架构的Web服务,使得Java开发者能够利用Java语言创建符合REST原则(如资源定位、无状态性、自描述消息等)的HTTP服务。它是Java EE的一部分,支持通过注解驱动的方式进行开发,简化了API的定义与客户端的访问过程。是Java Representational State Transfer (JAX-RS)规范的核心组成部分,它提供了一系列的类和接口来支持RESTful Web服务的开发。),以及与资源处理相关的类(如。

[Blog][Domain] programb.blog.youkuaiyun.com 1473

java 利用JAX-RS快速开发RESTful 服务实例

首先看web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc...

新技术革命 1064

Equinox OSGi应用嵌入Jersey框架搭建REST服务

http://www.cnblogs.com/kira2will/p/5040264.html

JAX-RS的参考实现:Jersey构建RESTful Web服务攻略

本文由IBMDW的Yi Ming Huang, Dong Fei Wu, Qing Guo等三位IBM软件工程师联合撰写,原文标题为《使用 Jersey 和 Apache Tomcat 构建 RESTful Web 服务》。 RESTful Web 服务简介 REST 在 2000 年由 Roy Fielding 在博士论文中提出,他是 HTTP 规范 1.0 和 1.1 版的首席作者之一。

xian00000的专栏 2027

论文阅读 Quantum Convolutional neural network

在传统的局域序参量(如磁化强度 ⟨Xi⟩)无法有效区分某些拓扑相(如 Haldane 相)时,字符串序参量(SOP)提供了一种方法来识别这些相。字符串序参量的定义通常涉及多个远离的站点之间的长程关联,通常具有如下形式:Zi,Xk,Zj是泡利矩阵(Pauli operators)。指数项 eiπ∑k=ijXk表示一个相位因子。这意味着我们要计算两个远离站点 i,j 的Z 分量的关联,同时考虑它们之间的X 作用。这个非局域的字符串序参量可以用来检测对称保护拓扑(SPT)相。

m0_54373077的博客 2006

LVGL v9的lv_scale控件实战:5分钟打造动态仪表盘(附完整代码)

本文详细介绍了LVGL v9中lv_scale控件的实战应用,通过5个关键步骤快速打造动态仪表盘。文章涵盖核心特性解析、代码实现、样式定制及性能优化,适用于工业HMI、智能家居等场景,并附完整代码示例。

gin88的博客 262

spring+JAX-RS实现Restfull接口 demo

       JAX-RS是JAVA EE6 引入的一个新技术。 JAX-RS即Java API for RESTful Web Services,是一个Java 编程语言的应用程序接口,支持按照表述性状态转移(REST)架构风格创建Web服务。JAX-RS使用了Java SE5引入的Java注解来简化Web服务的客户端和服务端的开发和部署。 JAX-RS提供了一些注解将一个资源类,一个POJO...

wq_wangqiang的博客 1028

CoppeliaSim(原V-REP)新手上路

CoppeliaSim(原V-REP)是一个机器人仿真平台,里面有很多来自别的公司的机器人模型以及完备的物理引擎,我们可以通过python,c++,matlab等语言控制里面的机器人。,您也可以在官网中Downloads里找您需要的版本,一般只需要下载EDU版本就可以了,我下载的是v4.1.0 windows EDU版本。在版本V4之前,CoppeliaSim叫V-REP,在官网可以下载到之前的V-REP版本。

qq_37051669的博客 4万+

jax-rs和restful的理解

Java.ws.rs 是 jax-rs 规范中定义的包名。 jax-rs 全程 Java API for RESTful Services jax-rs 规范 目前版本是 2.0。 规范文档 jax-rs 中定义了 一组启动方式 (以jee作为http容器,还是配合servlet作为http容器) 一组注解 @GET, @POST, @DELETE, @PUT, @Con

The Best Or Nothing~ 6351

5分钟搞定Unity+Visual Studio开发环境配置(含C#游戏开发工作负载)

本文提供了一份详细的Unity与Visual Studio开发环境配置指南,帮助开发者在5分钟内完成C#游戏开发工作负载的设置。从Unity Hub安装到Visual Studio关键组件选择,再到常见问题排查,全面覆盖环境搭建的各个环节,显著提升游戏开发效率。

weixin_29014237的博客 251

MapGIS地质剖面图绘制实战:从数据准备到整饰出图

本文详细解析了MapGIS地质剖面图绘制的全流程,从数据准备到整饰出图,涵盖了等高线处理、GRD格网化、比例尺控制等关键步骤。通过实战技巧和案例分析,帮助地质工作者高效完成专业地质剖面图绘制,提升矿产勘探和工程勘察的工作效率。

weixin_28335283的博客 594

带有Jersey的JAX-RS教程,用于RESTful Web服务

在当今世界,数据扮演着非常重要的角色。 如此众多的应用程序将各种类型的数据用于不同的操作,所以最重要的方面是应用程序之间的通信。 当应用程序可以通信时,它们之间的数据共享变得容易。 就像在亚洲运行的应用程序向在欧洲运行的应用程序提供数据一样,反之亦然。 在美国托管的Facebook服务器如何在亚洲提供Facebook服务? 在世界不同地区托管的众多网站中,如何有可能使用Google帐户验...

最佳 Java 编程 577

PDF格式分析(一)简介

概述 PDF文件是一种编程形式的文档格式,它所有显示的内容,都是通过相应的操作符进行绘制的。 PDF基本显示单元包括:文字,图片,矢量图,图片 PDF扩展单元包括:水印,电子署名,注释,表单,多媒体,3D PDF动作单元:书签,超链接(初学者可以简单这么理解,对于研究比较深入的人员来说,拥有动作的单元有很多个,包括电子署名,多媒体,3D等等) 优势 一致性: 在所有可以打开PDF的机...

steve_cui的博客 2万+

OSGi各层之间的交互关系

此图说明了OSGi各层之间的交互关系。非常清晰。 OSGi的层次架构图

Mars Suburbs People 266

【图像超分】论文精读:Residual Dense Network for Image Super-Resolution(RDN)

一个非常深的卷积神经网络 (CNN) 最近在图像分类 (SR) 方面取得了巨大成功,并提供了分层特征。然而,大多数基于深度 CNN 的 SR 模型没有充分利用原始低分辨率 (LR) 图像中的层次特征,从而实现相对较低的性能。在本文中,我们提出了一种新的残差密集网络(RDN)来解决图像SR中的这个问题。我们充分利用所有卷积层的分层特征。具体来说,我们提出了残差密集块(RDB)通过密集连接的卷积层提取丰富的局部特征。RDB 进一步允许将前一个 RDB 的状态与当前 RDB 的所有层直接连接,从而产生连续的内存

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 7260

通过InoDriverShop伺服调试软件连接汇川SV660F系列伺服的具体方法示例

通过InoDriverShop伺服调试软件连接汇川SV660F系列伺服的具体方法示例

Robot_PLC_HMI_Automation 1万+

OSGi 基本原理

定义 OSGi(Open Service Gateway Initiative)技术是面向Java的动态模型系统。 这个框架实现了一个优雅、完整和动态地组价模型。应用程序(称为bundle)无序重新引导可以被远程安装、启动、升级和卸载。 OSGi服务平台提供在多种网络设备上无需重启的动态改变构造的功能。 为了最小化耦合度和促使这些耦合度可管理,OSGi技术提供一种面向服务的架构,...

weixin_33922670的博客 386

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

jax-rs jax-ws_开源JAX-RS实现进入OSGi

泽西岛1.2版现已上市。 Jersey是JAX-RS的开源参考实现。 此发行版使OSGi知道jersey-core,jersey-server,jersey-client和jersey-json模块,并计划在将来的版本中增加对OSGi的支持。 请注意,对于即将发布的1.3版本,Jersey仅适用于Java SE 6或更高版本。 翻译自: https://jaxenter.com/op...

197

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

开发:随笔记录之 OSGI的jar添加几个小问题及其注意的地方

OSGI的jar添加几个小问题及其注意的地方

Thancks 2420

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

JAX-RS RESTful webservice 服务端及客户端实现(基于HTTPS双向认证)

在ApacheCXF的Sample里以及网上很多有关RESTful HTTPS双向认证的文章介绍仅仅是理论,没有涉及实际环境的实现(客户端和服务端都是localhost);这几天使用Apache的CXF以及 Apache portable HttpClient实现跨IP的JAXRS HTTPS双向认证实现。 在实践中发现tomcat版本7.0.70和7.0.68在TLS/SSL支持上也存在差异。

学习记录和开发记录 6077

RESTful Web Services -- JAX-RS中的注解

RESTful Web Services -- JAX-RS中的注解 1)javax.ws.rs包下的注解: javax.ws.rs.GET、javax.ws.rs.Post、javax.ws.rs.Consumes、javax.ws.rs.Produces、javax.ws.rs.Path @GET 表示(被@GET注解修饰的)方法将处理(响应)来自HTTP的GET请求 @POS

java小兵 4779

JAX RS 常见注解小结

 JAX-RS即Java API for RESTful Web Services,它支持按照表述性状态转移(REST)架构风格创建Web服务。JAX-RS使用了Java SE5引入的Java注解来简化Web服务的客户端和服务端的开发和部署。 常见的类型有: @Path,标注资源类或者方法的相对路径 @GET,@PUT,@POST,@DELETE,标注方法是HTTP请求的类型。 @Produce...

旺仔 2910

OSGi中获取Service的几种方式

在OSGi中,Service是动态管理的,OSGi容器提供的好几种获取和使用Service的方式,那么这几种方式各有什么优、缺点呢,下面我们就以org.osgi.service.log.LogService为例来分别讲一讲。 一。最原始的方式: &lt;!--&lt;br /&gt; &lt;br /&gt; Code highlighting produced by Actipro Co...

iteye_4350的博客 305

JAX-RS与Jersey的Interceptor详解

在JAX-RS标准中,过滤器Filter是JAX-RS API的组成部分,主要用于操作HTTP请求或响应的Headers, Methods和URI等参数。而拦截器Interceptor作为JAX-RS extension API的组成部分,主要操作HTTP请求或响应的Body中的Entity数据流,如对Entity数据流进行压缩/解压缩,JSON格式与Java对象之间的转换等。可以说,在JAX-R...

成长的足迹 3816
上一篇: Equinox Servlet
iCode0410
博客等级 码龄14年 6粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值