/** * Adds the specified resource as child. This method is syntactic sugar to * have a fluent-interface when adding resources to a tree. For instance, * consider the following example: * * <pre> * server.add( * new CoapResource("foo") * .add(new CoapResource("a") * .add(new CoapResource("a1")) * .add(new CoapResource("a2")) * .add(new CoapResource("a3")) * .add(new CoapResource("a4")) * ) * .add(new CoapResource("b") * .add(new CoapResource("b1") * ) * ) * ); * </pre> * * @param child the child to add * @return this */ public synchronized CoapResource add(CoapResource child) { add( (Resource) child); return this; }
/** * Adds the specified resource as child. This method is syntactic sugar to * have a fluent-interface when adding resources to a tree. For instance, * consider the following example: * * <pre> * server.add( * new CoapResource("foo") * .add(new CoapResource("a") * .add(new CoapResource("a1")) * .add(new CoapResource("a2")) * .add(new CoapResource("a3")) * .add(new CoapResource("a4")) * ) * .add(new CoapResource("b") * .add(new CoapResource("b1") * ) * ) * ); * </pre> * * @param child the child to add * @return this */ public synchronized CoapResource add(CoapResource child) { add( (Resource) child); return this; }
/** * Adds the specified resource as child. This method is syntactic sugar to * have a fluent-interface when adding resources to a tree. For instance, * consider the following example: * * <pre> * server.add( * new CoapResource("foo").add( * new CoapResource("a").add( * new CoapResource("a1"), * new CoapResource("a2"), * new CoapResource("a3"), * new CoapResource("a4") * ), * new CoapResource("b").add( * new CoapResource("b1") * ) * ) * ); * </pre> * * @param children the child(ren) to add * @return this */ public synchronized CoapResource add(CoapResource... children) { for (CoapResource child:children) add(child); return this; }
/** * Adds the specified resource as child. This method is syntactic sugar to * have a fluent-interface when adding resources to a tree. For instance, * consider the following example: * * <pre> * server.add( * new CoapResource("foo").add( * new CoapResource("a").add( * new CoapResource("a1"), * new CoapResource("a2"), * new CoapResource("a3"), * new CoapResource("a4") * ), * new CoapResource("b").add( * new CoapResource("b1") * ) * ) * ); * </pre> * * @param children the child(ren) to add * @return this */ public synchronized CoapResource add(CoapResource... children) { for (CoapResource child:children) add(child); return this; }
private void createServer() { CoapEndpoint endpoint = new CoapEndpoint(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); resource = new TestResource(NAME_1, PAYLOAD); server = new CoapServer(); server .add(new CoapResource(RES_A) .add(new CoapResource(RES_AA) .add(resource .add(new TestResource(CHILD, CHILD_PAYLOAD))))); server.addEndpoint(endpoint); server.start(); serverPort = endpoint.getAddress().getPort(); }
well_known.add(new DiscoveryResource(root)); root.add(well_known);
wellKnown.add(new DiscoveryResource(root)); root.add(wellKnown);