-
Notifications
You must be signed in to change notification settings - Fork 605
/
Copy pathLocalUtils.java
86 lines (74 loc) · 3.04 KB
/
LocalUtils.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*******************************************************************************
* Copyright (c) 2021, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package io.openliberty.netty.internal.local;
import java.util.Map;
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;
import io.netty.channel.Channel;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.local.LocalServerChannel;
import io.openliberty.netty.internal.BootstrapExtended;
import io.openliberty.netty.internal.ServerBootstrapExtended;
import io.openliberty.netty.internal.exception.NettyException;
import io.openliberty.netty.internal.impl.NettyFrameworkImpl;
import io.openliberty.netty.internal.impl.NettyConstants;
public class LocalUtils {
private static final TraceComponent tc = Tr.register(LocalUtils.class, NettyConstants.NETTY_TRACE_NAME, NettyConstants.BASE_BUNDLE);
/**
* Create a {@link ServerBootstrapExtended} for local channels that are not
* based on host address/port addressing but can use {@link LocalAddress}
*
* @param framework
* @param channel class - this is the class of the channel that is added
* @param options
* @return the bootstrap to which a child handler can be added to deal with
* protocol specific tasks
* @throws NettyException
*/
public static ServerBootstrapExtended createLocalBootstrap(NettyFrameworkImpl framework,
Map<String, Object> options) throws NettyException {
ServerBootstrapExtended bs = new ServerBootstrapExtended();
bs.group(framework.getParentGroup(), framework.getChildGroup());
bs.channel(LocalServerChannel.class);
return bs;
}
/**
* Create a {@link BootstrapExtended} for outbound local channels TODO GDH - not
* found where we will use this from yet in WOLA.
*
* @param framework
* @param channel class - this is the class of the channel that is added
* @param options
* @return
* @throws NettyException
*/
public static BootstrapExtended createLocalBootstrapOutbound(NettyFrameworkImpl framework,
Map<String, Object> options) throws NettyException {
BootstrapExtended bs = new BootstrapExtended();
bs.group(framework.getChildGroup());
bs.channel(LocalChannel.class);
return bs;
}
/**
*
* @param channel
*/
public static void logChannelStopped(Channel channel) {
Tr.info(tc, "stopped" + channel.toString());
}
/**
*
* @param channel
*/
public static void logChannelStarted(Channel channel) {
Tr.info(tc, "started" + channel.toString());
}
}