Skip to content

Commit e19bebc

Browse files
committed
Do not depend on lighty-restconf-nb-community
When implementing Netty module do not depend on lighty-restconf-nb-community which is going to be removed. Additionally we can got further and do not depend on the whole restconf-nb in both Netty and JAXRS modules and select dependencies we need instead. JIRA: LIGHTY-333 Signed-off-by: Ivan Hrasko <[email protected]> Signed-off-by: tobias.pobocik <[email protected]>
1 parent e544c9d commit e19bebc

File tree

5 files changed

+367
-18
lines changed

5 files changed

+367
-18
lines changed

lighty-examples/lighty-community-netty-restconf-app/src/main/java/io/lighty/controllers/nettyrestconfapp/Main.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
import io.lighty.core.controller.impl.util.ControllerConfigUtils;
2525
import io.lighty.modules.northbound.netty.restconf.community.impl.NettyRestConf;
2626
import io.lighty.modules.northbound.netty.restconf.community.impl.NettyRestConfBuilder;
27+
import io.lighty.modules.northbound.netty.restconf.community.impl.config.NettyRestConfConfiguration;
2728
import io.lighty.modules.northbound.netty.restconf.community.impl.util.NettyRestConfUtils;
28-
import io.lighty.modules.northbound.restconf.community.impl.config.RestConfConfiguration;
29-
import io.lighty.modules.northbound.restconf.community.impl.util.RestConfConfigUtils;
3029
import io.lighty.modules.southbound.netconf.impl.NetconfTopologyPluginBuilder;
3130
import io.lighty.modules.southbound.netconf.impl.config.NetconfConfiguration;
3231
import io.lighty.modules.southbound.netconf.impl.util.NetconfConfigUtils;
@@ -77,7 +76,7 @@ public void start(final String[] args, final boolean registerShutdownHook) {
7776
LOG.info("https://github.com/PANTHEONtech/lighty");
7877
try {
7978
final ControllerConfiguration singleNodeConfiguration;
80-
final RestConfConfiguration restconfConfiguration;
79+
final NettyRestConfConfiguration restconfConfiguration;
8180
final AAAConfiguration aaaConfiguration;
8281
final NetconfConfiguration netconfSBPConfiguration;
8382
if (args.length > 0) {
@@ -86,7 +85,8 @@ public void start(final String[] args, final boolean registerShutdownHook) {
8685
//1. get controller configuration
8786
singleNodeConfiguration = ControllerConfigUtils.getConfiguration(Files.newInputStream(configPath));
8887
//2. get RESTCONF NBP configuration
89-
restconfConfiguration = RestConfConfigUtils.getRestConfConfiguration(Files.newInputStream(configPath));
88+
restconfConfiguration = NettyRestConfUtils.getNettyRestConfConfiguration(
89+
Files.newInputStream(configPath));
9090
//3. get AAA config
9191
aaaConfiguration = AAAConfigUtils.getAAAConfiguration(Files.newInputStream(configPath));
9292
if (!aaaConfiguration.isEnableAAA()) {
@@ -99,7 +99,7 @@ public void start(final String[] args, final boolean registerShutdownHook) {
9999
NetconfConfigUtils.createNetconfConfiguration(Files.newInputStream(configPath));
100100
} else {
101101
LOG.info("using default configuration ...");
102-
Set<YangModuleInfo> modelPaths = Stream.concat(RestConfConfigUtils.YANG_MODELS.stream(),
102+
Set<YangModuleInfo> modelPaths = Stream.concat(NettyRestConfUtils.YANG_MODELS.stream(),
103103
NetconfConfigUtils.NETCONF_TOPOLOGY_MODELS.stream()).collect(Collectors.toSet());
104104
modelPaths.add(org.opendaylight.yang.svc.v1.urn.opendaylight.yang.aaa.cert.mdsal.rev160321
105105
.YangModuleInfoImpl.getInstance());
@@ -113,7 +113,7 @@ public void start(final String[] args, final boolean registerShutdownHook) {
113113
//1. get controller configuration
114114
singleNodeConfiguration = ControllerConfigUtils.getDefaultSingleNodeConfiguration(modelPaths);
115115
//2. get RESTCONF NBP configuration
116-
restconfConfiguration = RestConfConfigUtils.getDefaultRestConfConfiguration();
116+
restconfConfiguration = NettyRestConfUtils.getDefaultNettyRestConfConfiguration();
117117
//3. AAA configuration
118118
aaaConfiguration = AAAConfigUtils.createDefaultAAAConfiguration();
119119
//4. NETCONF SBP configuration
@@ -138,7 +138,7 @@ public void start(final String[] args, final boolean registerShutdownHook) {
138138
}
139139

140140
private void startLighty(final ControllerConfiguration controllerConfiguration,
141-
final RestConfConfiguration restconfConfiguration,
141+
final NettyRestConfConfiguration restconfConfiguration,
142142
final AAAConfiguration aaaConfiguration,
143143
final NetconfConfiguration netconfSBPConfiguration)
144144
throws ConfigurationException, ExecutionException, InterruptedException, TimeoutException,
@@ -158,7 +158,7 @@ private void startLighty(final ControllerConfiguration controllerConfiguration,
158158
lightyController.getServices().getRpcProviderService()));
159159

160160
this.restconf = NettyRestConfBuilder
161-
.from(RestConfConfigUtils.getRestConfConfiguration(restconfConfiguration,
161+
.from(NettyRestConfUtils.getNettyRestConfConfiguration(restconfConfiguration,
162162
this.lightyController.getServices()))
163163
.withWebEnvironment(NettyRestConfUtils.getAaaWebEnvironment(
164164
lightyController.getServices().getBindingDataBroker(),

lighty-modules/lighty-restconf-netty-nb-community/pom.xml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
2525
<groupId>io.lighty.core</groupId>
2626
<artifactId>lighty-controller</artifactId>
2727
</dependency>
28+
<dependency>
29+
<groupId>io.lighty.modules</groupId>
30+
<artifactId>lighty-aaa</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.opendaylight.netconf</groupId>
34+
<artifactId>odl-device-notification</artifactId>
35+
</dependency>
2836
<dependency>
2937
<groupId>org.opendaylight.netconf</groupId>
3038
<artifactId>restconf-server</artifactId>
@@ -34,12 +42,25 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
3442
<artifactId>restconf-server-mdsal</artifactId>
3543
</dependency>
3644
<dependency>
37-
<groupId>io.lighty.modules</groupId>
38-
<artifactId>lighty-restconf-nb-community</artifactId>
45+
<groupId>org.opendaylight.netconf.model</groupId>
46+
<artifactId>sal-remote</artifactId>
3947
</dependency>
48+
49+
<!--Tests-->
4050
<dependency>
41-
<groupId>io.lighty.modules</groupId>
42-
<artifactId>lighty-aaa</artifactId>
51+
<groupId>io.lighty.resources</groupId>
52+
<artifactId>singlenode-configuration</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.opendaylight.netconf</groupId>
57+
<artifactId>restconf-server-api-testlib</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.opendaylight.netconf.model</groupId>
62+
<artifactId>test-models</artifactId>
63+
<scope>test</scope>
4364
</dependency>
4465

4566
</dependencies>

lighty-modules/lighty-restconf-netty-nb-community/src/main/java/io/lighty/modules/northbound/netty/restconf/community/impl/NettyRestConfBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
*/
88
package io.lighty.modules.northbound.netty.restconf.community.impl;
99

10-
import io.lighty.modules.northbound.restconf.community.impl.config.RestConfConfiguration;
10+
import io.lighty.modules.northbound.netty.restconf.community.impl.config.NettyRestConfConfiguration;
1111
import org.apache.shiro.web.env.WebEnvironment;
1212

1313
public final class NettyRestConfBuilder {
1414

15-
private final RestConfConfiguration restconfConfiguration;
15+
private final NettyRestConfConfiguration restconfConfiguration;
1616
private WebEnvironment webEnvironment;
1717

18-
private NettyRestConfBuilder(final RestConfConfiguration configuration) {
18+
private NettyRestConfBuilder(final NettyRestConfConfiguration configuration) {
1919
this.restconfConfiguration = configuration;
2020
}
2121

2222
/**
23-
* Create new instance of {@link NettyRestConfBuilder} from {@link RestConfConfiguration}.
23+
* Create new instance of {@link NettyRestConfBuilder} from {@link NettyRestConfConfiguration}.
2424
* @param configuration input RestConf configuration.
2525
* @return instance of {@link NettyRestConfBuilder}.
2626
*/
27-
public static NettyRestConfBuilder from(final RestConfConfiguration configuration) {
27+
public static NettyRestConfBuilder from(final NettyRestConfConfiguration configuration) {
2828
return new NettyRestConfBuilder(configuration);
2929
}
3030

@@ -50,7 +50,7 @@ public NettyRestConf build() {
5050
restconfConfiguration.getDomNotificationService(),
5151
restconfConfiguration.getDomActionService(),
5252
restconfConfiguration.getDomMountPointService(),
53-
restconfConfiguration.getDomSchemaService(),
53+
restconfConfiguration.getSchemaService(),
5454
restconfConfiguration.getInetAddress(),
5555
restconfConfiguration.getHttpPort(),
5656
restconfConfiguration.getRestconfServletContextPath(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
* Copyright (c) 2025 PANTHEON.tech, s.r.o. and others. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
6+
* and is available at http://www.eclipse.org/legal/epl-v10.html
7+
*/
8+
package io.lighty.modules.northbound.netty.restconf.community.impl.config;
9+
10+
import com.fasterxml.jackson.annotation.JsonIgnore;
11+
import java.net.InetAddress;
12+
import java.util.Objects;
13+
import org.opendaylight.mdsal.dom.api.DOMActionService;
14+
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
15+
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
16+
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
17+
import org.opendaylight.mdsal.dom.api.DOMRpcService;
18+
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
19+
20+
public class NettyRestConfConfiguration {
21+
22+
@JsonIgnore
23+
private DOMDataBroker domDataBroker;
24+
@JsonIgnore
25+
private DOMSchemaService schemaService;
26+
@JsonIgnore
27+
private DOMRpcService domRpcService;
28+
@JsonIgnore
29+
private DOMActionService domActionService;
30+
@JsonIgnore
31+
private DOMNotificationService domNotificationService;
32+
@JsonIgnore
33+
private DOMMountPointService domMountPointService;
34+
35+
private InetAddress inetAddress = InetAddress.getLoopbackAddress();
36+
private int httpPort = 8888;
37+
private String restconfServletContextPath = "restconf";
38+
39+
public NettyRestConfConfiguration() {
40+
}
41+
42+
public NettyRestConfConfiguration(final NettyRestConfConfiguration restConfConfiguration) {
43+
this.inetAddress = restConfConfiguration.getInetAddress();
44+
this.httpPort = restConfConfiguration.getHttpPort();
45+
this.restconfServletContextPath = restConfConfiguration.getRestconfServletContextPath();
46+
this.domDataBroker = restConfConfiguration.getDomDataBroker();
47+
this.schemaService = restConfConfiguration.getSchemaService();
48+
this.domRpcService = restConfConfiguration.getDomRpcService();
49+
this.domActionService = restConfConfiguration.getDomActionService();
50+
this.domNotificationService = restConfConfiguration.getDomNotificationService();
51+
this.domMountPointService = restConfConfiguration.getDomMountPointService();
52+
}
53+
54+
public NettyRestConfConfiguration(final DOMDataBroker domDataBroker, final DOMSchemaService schemaService,
55+
final DOMRpcService domRpcService, final DOMActionService domActionService,
56+
final DOMNotificationService domNotificationService, final DOMMountPointService domMountPointService) {
57+
this.domDataBroker = domDataBroker;
58+
this.schemaService = schemaService;
59+
this.domRpcService = domRpcService;
60+
this.domActionService = domActionService;
61+
this.domNotificationService = domNotificationService;
62+
this.domMountPointService = domMountPointService;
63+
}
64+
65+
public InetAddress getInetAddress() {
66+
return this.inetAddress;
67+
}
68+
69+
public void setInetAddress(final InetAddress inetAddress) {
70+
this.inetAddress = inetAddress;
71+
}
72+
73+
public DOMDataBroker getDomDataBroker() {
74+
return this.domDataBroker;
75+
}
76+
77+
public void setDomDataBroker(final DOMDataBroker domDataBroker) {
78+
this.domDataBroker = domDataBroker;
79+
}
80+
81+
public DOMSchemaService getSchemaService() {
82+
return this.schemaService;
83+
}
84+
85+
public void setSchemaService(final DOMSchemaService schemaService) {
86+
this.schemaService = schemaService;
87+
}
88+
89+
public DOMRpcService getDomRpcService() {
90+
return this.domRpcService;
91+
}
92+
93+
public void setDomRpcService(final DOMRpcService domRpcService) {
94+
this.domRpcService = domRpcService;
95+
}
96+
97+
public DOMActionService getDomActionService() {
98+
return this.domActionService;
99+
}
100+
101+
public void setDomActionService(final DOMActionService domActionService) {
102+
this.domActionService = domActionService;
103+
}
104+
105+
public DOMNotificationService getDomNotificationService() {
106+
return this.domNotificationService;
107+
}
108+
109+
public void setDomNotificationService(final DOMNotificationService domNotificationService) {
110+
this.domNotificationService = domNotificationService;
111+
}
112+
113+
public DOMMountPointService getDomMountPointService() {
114+
return this.domMountPointService;
115+
}
116+
117+
public void setDomMountPointService(final DOMMountPointService domMountPointService) {
118+
this.domMountPointService = domMountPointService;
119+
}
120+
121+
public int getHttpPort() {
122+
return this.httpPort;
123+
}
124+
125+
public void setHttpPort(final int httpPort) {
126+
this.httpPort = httpPort;
127+
}
128+
129+
public String getRestconfServletContextPath() {
130+
return restconfServletContextPath;
131+
}
132+
133+
public void setRestconfServletContextPath(final String restconfServletContextPath) {
134+
this.restconfServletContextPath = restconfServletContextPath.startsWith("/")
135+
? restconfServletContextPath.substring(1) : restconfServletContextPath;
136+
}
137+
138+
@Override
139+
public boolean equals(final Object obj) {
140+
if (this == obj) {
141+
return true;
142+
}
143+
if (obj == null || getClass() != obj.getClass()) {
144+
return false;
145+
}
146+
NettyRestConfConfiguration that = (NettyRestConfConfiguration) obj;
147+
return httpPort == that.httpPort
148+
&& Objects.equals(domDataBroker, that.domDataBroker)
149+
&& Objects.equals(schemaService, that.schemaService)
150+
&& Objects.equals(domRpcService, that.domRpcService)
151+
&& Objects.equals(domActionService, that.domActionService)
152+
&& Objects.equals(domNotificationService, that.domNotificationService)
153+
&& Objects.equals(domMountPointService, that.domMountPointService)
154+
&& Objects.equals(inetAddress, that.inetAddress)
155+
&& Objects.equals(restconfServletContextPath, that.restconfServletContextPath);
156+
}
157+
158+
@Override
159+
public int hashCode() {
160+
return Objects.hash(domDataBroker, schemaService, domRpcService, domActionService, domNotificationService,
161+
domMountPointService, inetAddress, httpPort, restconfServletContextPath);
162+
}
163+
164+
}

0 commit comments

Comments
 (0)