1 package software.amazon.awssdk.crt.io; 2 3 import software.amazon.awssdk.crt.CrtResource; 4 import software.amazon.awssdk.crt.CrtRuntimeException; 5 6 /** 7 * This class wraps the aws_server_bootstrap from aws-c-io to provide 8 * a server context for all protocol stacks in the AWS Common Runtime. 9 */ 10 public class ServerBootstrap extends CrtResource { 11 private EventLoopGroup eventLoopGroup = null; 12 13 /** 14 * @param elg event loop group to map server connections into 15 */ ServerBootstrap(final EventLoopGroup elg)16 public ServerBootstrap(final EventLoopGroup elg) { 17 eventLoopGroup = elg; 18 acquireNativeHandle(serverBootstrapNew(this, eventLoopGroup.getNativeHandle())); 19 addReferenceTo(eventLoopGroup); 20 } 21 22 @Override releaseNativeHandle()23 protected void releaseNativeHandle() { 24 if (!isNull()) { 25 serverBootstrapDestroy(getNativeHandle()); 26 removeReferenceTo(eventLoopGroup); 27 } 28 } 29 30 @Override canReleaseReferencesImmediately()31 protected boolean canReleaseReferencesImmediately() { 32 return false; 33 } 34 serverBootstrapNew(ServerBootstrap bootstrap, long elg)35 private static native long serverBootstrapNew(ServerBootstrap bootstrap, long elg) throws CrtRuntimeException; serverBootstrapDestroy(long bootstrap)36 private static native void serverBootstrapDestroy(long bootstrap); 37 } 38