blob: 817ad581d41ea3aaa9902e3117bdb3f67c3bed55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.test;
import com.yahoo.test.StandardConfig.Builder;
import com.yahoo.config.model.producer.TreeConfigProducer;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.PortAllocBridge;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* This is a service that creates child services
*/
public class ParentService extends AbstractService implements com.yahoo.test.StandardConfig.Producer {
/**
* Creates a new ParentService instance
*
* @param parent The parent ConfigProducer.
* @param name Service name
* @param config The xml config Element for this Service
*/
public ParentService(TreeConfigProducer parent, String name,
Element config)
{
super(parent, name);
int s,p; s=p=0;
NodeList childNodes = config.getChildNodes();
for (int i=0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (! (child instanceof Element)) {
// skip #text and #comment nodes
continue;
}
Element e = (Element)child;
String service = e.getTagName();
if (service.equals("simpleservice")) {
new SimpleService(this, "simpleservice."+s);
s++;
}
else if (service.equals("parentservice")) {
new ParentService(this, "parentservice."+p, e);
p++;
}
else {
throw new IllegalArgumentException("Unknown service: " + service);
}
}
}
@Override
public void getConfig(Builder builder) {
builder.astring("parentservice");
}
public int getPortCount() { return 0; }
@Override public void allocatePorts(int start, PortAllocBridge from) { }
}
|