|
1 | 1 | /*
|
2 |
| - * Copyright 2015-2018 the original author or authors. |
| 2 | + * Copyright 2015-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
6 | 6 | * You may obtain a copy of the License at
|
7 | 7 | *
|
8 |
| - * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 | *
|
10 | 10 | * Unless required by applicable law or agreed to in writing, software
|
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| - |
17 | 16 | package io.rsocket;
|
18 | 17 |
|
19 | 18 | import io.netty.buffer.ByteBuf;
|
20 |
| -import io.netty.util.AbstractReferenceCounted; |
21 |
| -import io.rsocket.frame.FrameHeaderFlyweight; |
22 |
| -import io.rsocket.frame.SetupFrameFlyweight; |
| 19 | +import io.netty.util.ReferenceCounted; |
23 | 20 | import javax.annotation.Nullable;
|
24 | 21 |
|
25 | 22 | /**
|
26 |
| - * Exposed to server for determination of ResponderRSocket based on mime types and SETUP |
27 |
| - * metadata/data |
| 23 | + * Exposes information from the {@code SETUP} frame to a server, as well as to client responders. |
28 | 24 | */
|
29 |
| -public abstract class ConnectionSetupPayload extends AbstractReferenceCounted implements Payload { |
30 |
| - |
31 |
| - public static ConnectionSetupPayload create(final ByteBuf setupFrame) { |
32 |
| - return new DefaultConnectionSetupPayload(setupFrame); |
33 |
| - } |
| 25 | +public interface ConnectionSetupPayload extends ReferenceCounted, Payload { |
34 | 26 |
|
35 |
| - public abstract int keepAliveInterval(); |
| 27 | + String metadataMimeType(); |
36 | 28 |
|
37 |
| - public abstract int keepAliveMaxLifetime(); |
| 29 | + String dataMimeType(); |
38 | 30 |
|
39 |
| - public abstract String metadataMimeType(); |
| 31 | + int keepAliveInterval(); |
40 | 32 |
|
41 |
| - public abstract String dataMimeType(); |
| 33 | + int keepAliveMaxLifetime(); |
42 | 34 |
|
43 |
| - public abstract int getFlags(); |
| 35 | + int getFlags(); |
44 | 36 |
|
45 |
| - public abstract boolean willClientHonorLease(); |
| 37 | + boolean willClientHonorLease(); |
46 | 38 |
|
47 |
| - public abstract boolean isResumeEnabled(); |
| 39 | + boolean isResumeEnabled(); |
48 | 40 |
|
49 | 41 | @Nullable
|
50 |
| - public abstract ByteBuf resumeToken(); |
51 |
| - |
52 |
| - @Override |
53 |
| - public ConnectionSetupPayload retain() { |
54 |
| - super.retain(); |
55 |
| - return this; |
56 |
| - } |
57 |
| - |
58 |
| - @Override |
59 |
| - public ConnectionSetupPayload retain(int increment) { |
60 |
| - super.retain(increment); |
61 |
| - return this; |
62 |
| - } |
63 |
| - |
64 |
| - @Override |
65 |
| - public abstract ConnectionSetupPayload touch(); |
66 |
| - |
67 |
| - @Override |
68 |
| - public abstract ConnectionSetupPayload touch(Object hint); |
69 |
| - |
70 |
| - private static final class DefaultConnectionSetupPayload extends ConnectionSetupPayload { |
71 |
| - private final ByteBuf setupFrame; |
72 |
| - |
73 |
| - public DefaultConnectionSetupPayload(ByteBuf setupFrame) { |
74 |
| - this.setupFrame = setupFrame; |
75 |
| - } |
76 |
| - |
77 |
| - @Override |
78 |
| - public boolean hasMetadata() { |
79 |
| - return FrameHeaderFlyweight.hasMetadata(setupFrame); |
80 |
| - } |
81 |
| - |
82 |
| - @Override |
83 |
| - public int keepAliveInterval() { |
84 |
| - return SetupFrameFlyweight.keepAliveInterval(setupFrame); |
85 |
| - } |
86 |
| - |
87 |
| - @Override |
88 |
| - public int keepAliveMaxLifetime() { |
89 |
| - return SetupFrameFlyweight.keepAliveMaxLifetime(setupFrame); |
90 |
| - } |
91 |
| - |
92 |
| - @Override |
93 |
| - public String metadataMimeType() { |
94 |
| - return SetupFrameFlyweight.metadataMimeType(setupFrame); |
95 |
| - } |
96 |
| - |
97 |
| - @Override |
98 |
| - public String dataMimeType() { |
99 |
| - return SetupFrameFlyweight.dataMimeType(setupFrame); |
100 |
| - } |
101 |
| - |
102 |
| - @Override |
103 |
| - public int getFlags() { |
104 |
| - return FrameHeaderFlyweight.flags(setupFrame); |
105 |
| - } |
106 |
| - |
107 |
| - @Override |
108 |
| - public boolean willClientHonorLease() { |
109 |
| - return SetupFrameFlyweight.honorLease(setupFrame); |
110 |
| - } |
111 |
| - |
112 |
| - @Override |
113 |
| - public boolean isResumeEnabled() { |
114 |
| - return SetupFrameFlyweight.resumeEnabled(setupFrame); |
115 |
| - } |
116 |
| - |
117 |
| - @Override |
118 |
| - public ByteBuf resumeToken() { |
119 |
| - return SetupFrameFlyweight.resumeToken(setupFrame); |
120 |
| - } |
121 |
| - |
122 |
| - @Override |
123 |
| - public ConnectionSetupPayload touch() { |
124 |
| - setupFrame.touch(); |
125 |
| - return this; |
126 |
| - } |
127 |
| - |
128 |
| - @Override |
129 |
| - public ConnectionSetupPayload touch(Object hint) { |
130 |
| - setupFrame.touch(hint); |
131 |
| - return this; |
132 |
| - } |
133 |
| - |
134 |
| - @Override |
135 |
| - protected void deallocate() { |
136 |
| - setupFrame.release(); |
137 |
| - } |
138 |
| - |
139 |
| - @Override |
140 |
| - public ByteBuf sliceMetadata() { |
141 |
| - return SetupFrameFlyweight.metadata(setupFrame); |
142 |
| - } |
143 |
| - |
144 |
| - @Override |
145 |
| - public ByteBuf sliceData() { |
146 |
| - return SetupFrameFlyweight.data(setupFrame); |
147 |
| - } |
148 |
| - |
149 |
| - @Override |
150 |
| - public ByteBuf data() { |
151 |
| - return sliceData(); |
152 |
| - } |
153 |
| - |
154 |
| - @Override |
155 |
| - public ByteBuf metadata() { |
156 |
| - return sliceMetadata(); |
157 |
| - } |
158 |
| - } |
| 42 | + ByteBuf resumeToken(); |
159 | 43 | }
|
0 commit comments