Skip to content

Commit

Permalink
WIP transport refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinherron committed Sep 22, 2022
1 parent f33e963 commit ff7dc61
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 90 deletions.
@@ -0,0 +1,14 @@
///*
// * Copyright (c) 2022 the Eclipse Milo Authors
// *
// * This program and the accompanying materials are made
// * available under the terms of the Eclipse Public License 2.0
// * which is available at https://www.eclipse.org/legal/epl-2.0/
// *
// * SPDX-License-Identifier: EPL-2.0
// */
//
//package org.eclipse.milo.opcua.stack.transport.server;
//
//public interface Endpoint {
//}
@@ -1,39 +1,39 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public abstract class InboundServiceRequestHandler
extends SimpleChannelInboundHandler<ServiceRequest> implements ServiceRequestHandler {

@Override
protected void channelRead0(ChannelHandlerContext ctx, ServiceRequest serviceRequest) throws Exception {
handleRequest(serviceRequest);
}

public static class DelegatingServiceRequestHandler extends InboundServiceRequestHandler {

private final ServiceRequestHandler delegate;

public DelegatingServiceRequestHandler(ServiceRequestHandler delegate) {
this.delegate = delegate;
}

@Override
public void handleRequest(ServiceRequest serviceRequest) {
delegate.handleRequest(serviceRequest);
}

}

}
///*
// * Copyright (c) 2022 the Eclipse Milo Authors
// *
// * This program and the accompanying materials are made
// * available under the terms of the Eclipse Public License 2.0
// * which is available at https://www.eclipse.org/legal/epl-2.0/
// *
// * SPDX-License-Identifier: EPL-2.0
// */
//
//package org.eclipse.milo.opcua.stack.transport.server;
//
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.SimpleChannelInboundHandler;
//
//public abstract class InboundServiceRequestHandler
// extends SimpleChannelInboundHandler<ServiceRequest> implements ServiceRequestHandler {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, ServiceRequest serviceRequest) throws Exception {
// handleRequest(serviceRequest);
// }
//
// public static class DelegatingServiceRequestHandler extends InboundServiceRequestHandler {
//
// private final ServiceRequestHandler delegate;
//
// public DelegatingServiceRequestHandler(ServiceRequestHandler delegate) {
// this.delegate = delegate;
// }
//
// @Override
// public void handleRequest(ServiceRequest serviceRequest) {
// delegate.handleRequest(serviceRequest);
// }
//
// }
//
//}
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

public interface OpcServerTransport {

void bind() throws Exception;

void unbind() throws Exception;

// TODO settable after transport is instantiated or part of config?
void setServiceInterface(ServiceInterface serviceInterface);

}
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

import java.util.List;

import org.eclipse.milo.opcua.stack.core.channel.EncodingLimits;
import org.eclipse.milo.opcua.stack.core.security.CertificateManager;
import org.eclipse.milo.opcua.stack.core.security.CertificateValidator;
import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;

public interface OpcServerTransportConfig {

List<EndpointDescription> getEndpointDescriptions();

CertificateManager getCertificateManager();

CertificateValidator getCertificateValidator();

EncodingLimits getEncodingLimits();

ServiceInterface getServiceInterface();

}
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

import java.util.concurrent.CompletableFuture;

import org.eclipse.milo.opcua.stack.core.types.UaRequestMessageType;
import org.eclipse.milo.opcua.stack.core.types.UaResponseMessageType;

public interface ServiceInterface {

CompletableFuture<UaResponseMessageType> handleServiceRequest(
ServiceRequestContext context,
UaRequestMessageType requestMessage
);

}
Expand Up @@ -10,27 +10,52 @@

package org.eclipse.milo.opcua.stack.transport.server;

import java.net.InetAddress;

import org.eclipse.milo.opcua.stack.core.channel.SecureChannel;
import org.eclipse.milo.opcua.stack.core.types.UaRequestMessageType;

public class ServiceRequest {
public class ServiceRequest implements ServiceRequestContext {

private final long receivedAtNanos = System.nanoTime();

private final String endpointUrl;
private final SecureChannel secureChannel;
private final long requestId;
private final UaRequestMessageType requestMessage;

public ServiceRequest(
String endpointUrl,
SecureChannel secureChannel,
long requestId,
UaRequestMessageType requestMessage
) {

this.endpointUrl = endpointUrl;
this.secureChannel = secureChannel;
this.requestId = requestId;
this.requestMessage = requestMessage;
}

public UaRequestMessageType getRequestMessage() {
return requestMessage;
}

@Override
public String getEndpointUrl() {
return endpointUrl;
}

@Override
public SecureChannel getSecureChannel() {
return secureChannel;
}

@Override
public InetAddress getClientAddress() {
return getClientAddress();
}

@Override
public Long receivedAtNanos() {
return receivedAtNanos;
}

}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

import java.net.InetAddress;

import org.eclipse.milo.opcua.stack.core.channel.SecureChannel;

public interface ServiceRequestContext {

String getEndpointUrl();

SecureChannel getSecureChannel();

InetAddress getClientAddress();

Long receivedAtNanos();

}
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

public interface ServiceRequestHandler {

void handleRequest(ServiceRequest serviceRequest);

}
///*
// * Copyright (c) 2022 the Eclipse Milo Authors
// *
// * This program and the accompanying materials are made
// * available under the terms of the Eclipse Public License 2.0
// * which is available at https://www.eclipse.org/legal/epl-2.0/
// *
// * SPDX-License-Identifier: EPL-2.0
// */
//
//package org.eclipse.milo.opcua.stack.transport.server;
//
//public interface ServiceRequestHandler {
//
// void handleRequest(ServiceRequest serviceRequest);
//
//}
Expand Up @@ -10,35 +10,16 @@

package org.eclipse.milo.opcua.stack.transport.server;

import org.eclipse.milo.opcua.stack.core.types.UaRequestMessageType;
import org.eclipse.milo.opcua.stack.core.types.UaResponseMessageType;

public class ServiceResponse {

private final long requestId;
private final UaRequestMessageType requestMessage;
private final UaResponseMessageType responseMessage;


public ServiceResponse(
long requestId,
UaRequestMessageType requestMessage,
UaResponseMessageType responseMessage
) {

this.requestId = requestId;
this.requestMessage = requestMessage;
public ServiceResponse(UaResponseMessageType responseMessage) {
this.responseMessage = responseMessage;
}

public long getRequestId() {
return requestId;
}

public UaRequestMessageType getRequestMessage() {
return requestMessage;
}

public UaResponseMessageType getResponseMessage() {
return responseMessage;
}
Expand Down
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server;

public class Test {

public static void main(String[] args) {

}

}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.milo.opcua.stack.transport.server.tcp;

import org.eclipse.milo.opcua.stack.transport.server.OpcServerTransport;
import org.eclipse.milo.opcua.stack.transport.server.ServiceInterface;

public class OpcTcpServerTransport implements OpcServerTransport {

@Override
public void bind() throws Exception {

}

@Override
public void unbind() throws Exception {

}

@Override
public void setServiceInterface(ServiceInterface serviceInterface) {

}

}

0 comments on commit ff7dc61

Please sign in to comment.