• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Resource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setName

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
public synchronized void setName(String name) {
	if (name == null)
		throw new NullPointerException();
	String old = this.name;
	
	// adjust parent if in tree
	Resource parent = getParent();
	if (parent!=null) {
		synchronized (parent) {
			parent.delete(this);
			this.name = name;
			parent.add(this);
		}
	} else {
		this.name = name;
	}
	adjustChildrenPath();
	
	for (ResourceObserver obs:observers)
		obs.changedName(old);
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:22,代码来源:CoapResource.java


示例2: deliverRequest

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public void deliverRequest(final Exchange exchange) {
	Request request = exchange.getRequest();
	List<String> path = request.getOptions().getUriPath();
	final Resource resource = findResource(path);
	if (resource != null) {
		checkForObserveOption(exchange, resource);
		
		// Get the executor and let it process the request
		Executor executor = resource.getExecutor();
		if (executor != null) {
			exchange.setCustomExecutor();
			executor.execute(new Runnable() {
				public void run() {
					resource.handleRequest(exchange);
				} });
		} else {
			resource.handleRequest(exchange);
		}
	} else {
		LOGGER.info("Did not find resource " + path.toString() + " requested by " + request.getSource()+":"+request.getSourcePort());
		exchange.sendResponse(new Response(ResponseCode.NOT_FOUND));
	}
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:25,代码来源:ServerMessageDeliverer.java


示例3: serializeTree

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
public static void serializeTree(Resource resource, List<String> queries, StringBuilder buffer) {
	// add the current resource to the buffer
	if (resource.isVisible()
			&& LinkFormat.matches(resource, queries)) {
		buffer.append(LinkFormat.serializeResource(resource));
	}
	
	// sort by resource name
	List<Resource> childs = new ArrayList<Resource>(resource.getChildren());
	Collections.sort(childs, new Comparator<Resource>() {
	    @Override
	    public int compare(Resource o1, Resource o2) {
	        return o1.getName().compareTo(o2.getName());
	    }
	});
	
	for (Resource child:childs) {
		serializeTree(child, queries, buffer);
	}
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:21,代码来源:LinkFormat.java


示例4: CoAPServer

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
public CoAPServer(int port, RESTHandler root)
{
  server = new CoapServer(port) {
    @Override
    protected Resource createRoot()
    {
      return new CoAPRESTResource(root);
    }
  };
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:11,代码来源:CoAPServer.java


示例5: addRec

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
protected void addRec(String path, Resource resource, Resource parent) {
  for (Resource r : parent.getChildren()) {
    if (path.contains(path(r))) {
      addRec(path, resource, r);
      return;
    }
  }
  parent.add(resource);
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:10,代码来源:CoAPServer.java


示例6: deleteRec

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
protected void deleteRec(String path, Resource parent) {
  if (path(parent).equals(path)) {
    parent.getParent().remove(parent);
    return;
  }
  for (Resource r : parent.getChildren()) {
    if (path.contains(path(r))) {
      deleteRec(path, r);
      return;
    }
  }
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:13,代码来源:CoAPServer.java


示例7: ObserveRelation

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
/**
 * Constructs a new observe relation.
 * 
 * @param endpoint the observing endpoint
 * @param resource the observed resource
 * @param exchange the exchange that tries to establish the observe relation
 */
public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) {
	if (endpoint == null)
		throw new NullPointerException();
	if (resource == null)
		throw new NullPointerException();
	if (exchange == null)
		throw new NullPointerException();
	this.endpoint = endpoint;
	this.resource = resource;
	this.exchange = exchange;
	this.established = false;
	
	this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString();
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:22,代码来源:ObserveRelation.java


示例8: CoapResource

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
/**
 * Constructs a new resource with the specified name and makes it visible to
 * clients if the flag is true.
 * 
 * @param name the name
 * @param visible if the resource is visible
 */
public CoapResource(String name, boolean visible) {
	this.name = name;
	this.path = "";
	this.visible = visible;
	this.attributes = new ResourceAttributes();
	this.children = new ConcurrentHashMap<String, Resource>();
	this.observers = new CopyOnWriteArrayList<ResourceObserver>();
	this.observeRelations = new ObserveRelationContainer();
	this.notificationOrderer = new ObserveNotificationOrderer();
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:18,代码来源:CoapResource.java


示例9: add

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public synchronized void add(Resource child) {
	if (child.getName() == null)
		throw new NullPointerException("Child must have a name");
	if (child.getParent() != null)
		child.getParent().delete(child);
	children.put(child.getName(), child);
	child.setParent(this);
	for (ResourceObserver obs:observers)
		obs.addedChild(child);
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:12,代码来源:CoapResource.java


示例10: delete

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public synchronized boolean delete(Resource child) {
	Resource deleted = delete(child.getName());
	if (deleted == child) {
		child.setParent(null);
		child.setPath(null);
		for (ResourceObserver obs : observers)
			obs.removedChild(child);
		return true;
	}
	return false;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:13,代码来源:CoapResource.java


示例11: findResource

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
/**
 * Searches in the resource tree for the specified path. A parent resource
 * may accept requests to subresources, e.g., to allow addresses with
 * wildcards like <code>coap://example.com:5683/devices/*</code>
 * 
 * @param list the path as list of resource names
 * @return the resource or null if not found
 */
private Resource findResource(List<String> list) {
	LinkedList<String> path = new LinkedList<String>(list);
	Resource current = root;
	
	while (!path.isEmpty() && current != null) {
		String name = path.removeFirst();
		current = current.getChild(name);
		if(current != null && current.isAllChildFilter()) {	
			break;
		}
	}
	
	return current;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:23,代码来源:ServerMessageDeliverer.java


示例12: serializeResource

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
public static StringBuilder serializeResource(Resource resource) {
	StringBuilder buffer = new StringBuilder();
	buffer.append("<")
		.append(resource.getPath())
		.append(resource.getName())
		.append(">")
		.append(LinkFormat.serializeAttributes(resource.getAttributes()))
		.append(",");
	return buffer;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:11,代码来源:LinkFormat.java


示例13: add

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
/**
 * Add a resource to the server.
 * @param resources the resource(s)
 * @return the server
 */
@Override
public CoapServer add(Resource... resources) {
	for (Resource r:resources)
		root.add(r);
	return this;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:12,代码来源:CoapServer.java


示例14: doStart

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    super.doStart();
    
    String path = endpoint.getUri().getPath();
    if (path.startsWith("/")) {
        path = path.substring(1);
    }
    Resource cr = endpoint.getCoapServer().getRoot();
    while (!path.isEmpty()) {
        int idx = path.indexOf('/');
        String part1 = path;
        if (idx != -1) {
            part1 = path.substring(0, idx);
            path = path.substring(idx + 1);
        } else {
            path = "";
        }
        Resource child = cr.getChild(part1);
        if (child == null) {
            child = new CamelCoapResource(part1, this);
            cr.add(child);
            cr = child;
        } else if (path.isEmpty()) {
            ((CamelCoapResource)child).addConsumer(this);
        } else {
            cr = child;
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:CoAPConsumer.java


示例15: discoverTree

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
/**
 * Get all the resources hosted by this server. (Could be done by accessing
 * /.well-known/core (COAP Bug))
 *
 * @return
 */
String discoverTree() {
	StringBuilder buffer = new StringBuilder();
	for (Resource child : server.getRoot().getChildren()) {
		LinkFormat.serializeTree(child, null, buffer);
	}
	// remove last comma ',' of the buffer
	if (buffer.length() > 1)
		buffer.delete(buffer.length() - 1, buffer.length());

	return buffer.toString();
}
 
开发者ID:mkovatsc,项目名称:iot-semantics,代码行数:18,代码来源:ResourceDirectorySynchronizationService.java


示例16: NodeServer

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
public NodeServer(int node_nr) {
	//this(node_nr.to);
	//Integer.par
	super("node_" + Integer.toString(node_nr));
	
	

	Resource seg2 = new NodeServer("led");
	Resource seg2_1 = new NodeServer("on");
	Resource seg2_2 = new NodeServer("off");

	add(seg2);
	seg2.add(seg2_1);
	seg2.add(seg2_2);
}
 
开发者ID:telecombretagne,项目名称:LoRaFABIAN_OLD,代码行数:16,代码来源:NodeServer.java


示例17: getChild

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public Resource getChild(String name) {
  return this;
}
 
开发者ID:osswangxining,项目名称:iothub,代码行数:5,代码来源:CoapTransportResource.java


示例18: path

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
protected String path(Resource r) {
  return r.getPath() + r.getName();
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:4,代码来源:CoAPServer.java


示例19: getChild

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public Resource getChild(String name) {
    return this;
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:5,代码来源:CoapTransportResource.java


示例20: getParent

import org.eclipse.californium.core.server.resources.Resource; //导入依赖的package包/类
@Override
public Resource getParent() {
	return parent;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:5,代码来源:CoapResource.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServerCommandEvent类代码示例发布时间:2022-05-22
下一篇:
Java XmlRpcCommonsTransportFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap