Skip to content

Commit 99b0675

Browse files
committed
Reduce top-level package dependencies
This commit extracts interfaces for ClientRSocketFactory, ServerRSocketFactory, and ConnectionSetupPayload, and moves the implementations into a sub-package with no references to it from the top-level package. This removes a large package cycle with io.rsocket at the center of everything since it currently contains both high level abstractions that (accessed by everything), as well as core protocol implementations classes (accessing everything). The refactoring is functionally neutral and backwards compatible.
1 parent c76fdb0 commit 99b0675

24 files changed

+1183
-805
lines changed
Lines changed: 13 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,43 @@
11
/*
2-
* Copyright 2015-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.rsocket;
1817

1918
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;
2320
import javax.annotation.Nullable;
2421

2522
/**
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.
2824
*/
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 {
3426

35-
public abstract int keepAliveInterval();
27+
String metadataMimeType();
3628

37-
public abstract int keepAliveMaxLifetime();
29+
String dataMimeType();
3830

39-
public abstract String metadataMimeType();
31+
int keepAliveInterval();
4032

41-
public abstract String dataMimeType();
33+
int keepAliveMaxLifetime();
4234

43-
public abstract int getFlags();
35+
int getFlags();
4436

45-
public abstract boolean willClientHonorLease();
37+
boolean willClientHonorLease();
4638

47-
public abstract boolean isResumeEnabled();
39+
boolean isResumeEnabled();
4840

4941
@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();
15943
}

0 commit comments

Comments
 (0)