Skip to content

Move RSocketFactory implementation to core sub-package to avoid dependencies from top-level package #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 13 additions & 129 deletions rsocket-core/src/main/java/io/rsocket/ConnectionSetupPayload.java
Original file line number Diff line number Diff line change
@@ -1,159 +1,43 @@
/*
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.rsocket;

import io.netty.buffer.ByteBuf;
import io.netty.util.AbstractReferenceCounted;
import io.rsocket.frame.FrameHeaderFlyweight;
import io.rsocket.frame.SetupFrameFlyweight;
import io.netty.util.ReferenceCounted;
import javax.annotation.Nullable;

/**
* Exposed to server for determination of ResponderRSocket based on mime types and SETUP
* metadata/data
* Exposes information from the {@code SETUP} frame to a server, as well as to client responders.
*/
public abstract class ConnectionSetupPayload extends AbstractReferenceCounted implements Payload {

public static ConnectionSetupPayload create(final ByteBuf setupFrame) {
return new DefaultConnectionSetupPayload(setupFrame);
}
public interface ConnectionSetupPayload extends ReferenceCounted, Payload {

public abstract int keepAliveInterval();
String metadataMimeType();

public abstract int keepAliveMaxLifetime();
String dataMimeType();

public abstract String metadataMimeType();
int keepAliveInterval();

public abstract String dataMimeType();
int keepAliveMaxLifetime();

public abstract int getFlags();
int getFlags();

public abstract boolean willClientHonorLease();
boolean willClientHonorLease();

public abstract boolean isResumeEnabled();
boolean isResumeEnabled();

@Nullable
public abstract ByteBuf resumeToken();

@Override
public ConnectionSetupPayload retain() {
super.retain();
return this;
}

@Override
public ConnectionSetupPayload retain(int increment) {
super.retain(increment);
return this;
}

@Override
public abstract ConnectionSetupPayload touch();

@Override
public abstract ConnectionSetupPayload touch(Object hint);

private static final class DefaultConnectionSetupPayload extends ConnectionSetupPayload {
private final ByteBuf setupFrame;

public DefaultConnectionSetupPayload(ByteBuf setupFrame) {
this.setupFrame = setupFrame;
}

@Override
public boolean hasMetadata() {
return FrameHeaderFlyweight.hasMetadata(setupFrame);
}

@Override
public int keepAliveInterval() {
return SetupFrameFlyweight.keepAliveInterval(setupFrame);
}

@Override
public int keepAliveMaxLifetime() {
return SetupFrameFlyweight.keepAliveMaxLifetime(setupFrame);
}

@Override
public String metadataMimeType() {
return SetupFrameFlyweight.metadataMimeType(setupFrame);
}

@Override
public String dataMimeType() {
return SetupFrameFlyweight.dataMimeType(setupFrame);
}

@Override
public int getFlags() {
return FrameHeaderFlyweight.flags(setupFrame);
}

@Override
public boolean willClientHonorLease() {
return SetupFrameFlyweight.honorLease(setupFrame);
}

@Override
public boolean isResumeEnabled() {
return SetupFrameFlyweight.resumeEnabled(setupFrame);
}

@Override
public ByteBuf resumeToken() {
return SetupFrameFlyweight.resumeToken(setupFrame);
}

@Override
public ConnectionSetupPayload touch() {
setupFrame.touch();
return this;
}

@Override
public ConnectionSetupPayload touch(Object hint) {
setupFrame.touch(hint);
return this;
}

@Override
protected void deallocate() {
setupFrame.release();
}

@Override
public ByteBuf sliceMetadata() {
return SetupFrameFlyweight.metadata(setupFrame);
}

@Override
public ByteBuf sliceData() {
return SetupFrameFlyweight.data(setupFrame);
}

@Override
public ByteBuf data() {
return sliceData();
}

@Override
public ByteBuf metadata() {
return sliceMetadata();
}
}
ByteBuf resumeToken();
}
Loading