├── .circleci └── config.yml ├── .github ├── CODEOWNERS ├── pull_request_template.md └── renovate.json ├── .gitignore ├── .prettierrc ├── CHANGELOG.md ├── CONTRIBUTING.adoc ├── LICENSE.txt ├── README.adoc ├── pom.xml └── src ├── main └── java │ └── io │ └── gravitee │ └── gateway │ ├── api │ ├── Connector.java │ ├── ExecutionContext.java │ ├── Invoker.java │ ├── Request.java │ ├── RequestWrapper.java │ ├── Response.java │ ├── buffer │ │ ├── Buffer.java │ │ └── BufferFactory.java │ ├── context │ │ ├── MutableExecutionContext.java │ │ └── SimpleExecutionContext.java │ ├── el │ │ ├── EmptyEvaluableSSLPrincipal.java │ │ ├── EvaluableExtractor.java │ │ ├── EvaluableRequest.java │ │ ├── EvaluableResponse.java │ │ ├── EvaluableSSLPrincipal.java │ │ └── EvaluableSSLSession.java │ ├── endpoint │ │ ├── AbstractEndpoint.java │ │ ├── Endpoint.java │ │ ├── EndpointAvailabilityListener.java │ │ ├── EndpointManager.java │ │ └── resolver │ │ │ ├── EndpointResolver.java │ │ │ └── ProxyEndpoint.java │ ├── handler │ │ └── Handler.java │ ├── http │ │ ├── DefaultHttpHeaders.java │ │ ├── HttpHeaderNames.java │ │ ├── HttpHeaders.java │ │ └── stream │ │ │ ├── TransformableRequestStream.java │ │ │ ├── TransformableRequestStreamBuilder.java │ │ │ ├── TransformableResponseStream.java │ │ │ ├── TransformableResponseStreamBuilder.java │ │ │ ├── TransformableSourceStream.java │ │ │ └── TransformableStreamBuilder.java │ ├── http2 │ │ ├── HttpFrame.java │ │ └── HttpFrameImpl.java │ ├── processor │ │ └── ProcessorFailure.java │ ├── proxy │ │ ├── ProxyConnection.java │ │ ├── ProxyRequest.java │ │ ├── ProxyResponse.java │ │ ├── builder │ │ │ ├── ProxyRequestBuilder.java │ │ │ └── ProxyRequestImpl.java │ │ └── ws │ │ │ ├── WebSocketProxyRequest.java │ │ │ └── WebSocketProxyRequestImpl.java │ ├── service │ │ ├── ApiKey.java │ │ ├── ApiKeyService.java │ │ ├── Subscription.java │ │ ├── SubscriptionConfiguration.java │ │ └── SubscriptionService.java │ ├── stream │ │ ├── BufferedReadWriteStream.java │ │ ├── ReadStream.java │ │ ├── ReadWriteStream.java │ │ ├── SimpleReadWriteStream.java │ │ ├── TransformableStream.java │ │ ├── WriteStream.java │ │ └── exception │ │ │ └── TransformationException.java │ └── ws │ │ ├── WebSocket.java │ │ └── WebSocketFrame.java │ └── reactive │ └── api │ ├── ApiType.java │ ├── ConnectorMode.java │ ├── ExecutionFailure.java │ ├── ExecutionPhase.java │ ├── ListenerType.java │ ├── apiservice │ ├── ApiService.java │ ├── ApiServiceConfiguration.java │ └── ApiServiceFactory.java │ ├── connector │ ├── Connector.java │ ├── ConnectorConfiguration.java │ ├── ConnectorFactory.java │ ├── endpoint │ │ ├── BaseEndpointConnector.java │ │ ├── BaseEndpointConnectorFactory.java │ │ ├── EndpointConnector.java │ │ ├── EndpointConnectorConfiguration.java │ │ ├── EndpointConnectorFactory.java │ │ ├── EndpointConnectorSharedConfiguration.java │ │ ├── HttpEndpointConnector.java │ │ ├── HttpEndpointConnectorFactory.java │ │ ├── TcpEndpointConnector.java │ │ ├── async │ │ │ ├── EndpointAsyncConnector.java │ │ │ ├── EndpointAsyncConnectorFactory.java │ │ │ ├── HttpEndpointAsyncConnector.java │ │ │ └── HttpEndpointAsyncConnectorFactory.java │ │ └── sync │ │ │ ├── EndpointSyncConnector.java │ │ │ ├── EndpointSyncConnectorFactory.java │ │ │ ├── HttpEndpointSyncConnector.java │ │ │ └── HttpEndpointSyncConnectorFactory.java │ └── entrypoint │ │ ├── BaseEntrypointConnector.java │ │ ├── EntrypointConnector.java │ │ ├── EntrypointConnectorConfiguration.java │ │ ├── EntrypointConnectorFactory.java │ │ ├── HttpEntrypointConnector.java │ │ ├── TcpEntrypointConnector.java │ │ ├── async │ │ ├── EntrypointAsyncConnector.java │ │ ├── EntrypointAsyncConnectorFactory.java │ │ ├── HttpEntrypointAsyncConnector.java │ │ └── HttpEntrypointAsyncConnectorFactory.java │ │ └── sync │ │ ├── EntrypointSyncConnector.java │ │ ├── EntrypointSyncConnectorFactory.java │ │ ├── HttpEntrypointSyncConnector.java │ │ └── HttpEntrypointSyncConnectorFactory.java │ ├── context │ ├── ContextAttributes.java │ ├── DeploymentContext.java │ ├── ExecutionContext.java │ ├── GenericExecutionContext.java │ ├── GenericRequest.java │ ├── GenericResponse.java │ ├── HttpExecutionContext.java │ ├── HttpRequest.java │ ├── HttpResponse.java │ ├── InternalContextAttributes.java │ ├── MessageExecutionContext.java │ ├── MessageRequest.java │ ├── MessageResponse.java │ ├── Request.java │ ├── Response.java │ ├── TcpExecutionContext.java │ ├── TcpRequest.java │ ├── TcpResponse.java │ ├── TlsSession.java │ ├── base │ │ ├── BaseExecutionContext.java │ │ ├── BaseMessageExecutionContext.java │ │ ├── BaseMessageRequest.java │ │ ├── BaseMessageResponse.java │ │ ├── BaseRequest.java │ │ ├── BaseResponse.java │ │ ├── NativeExecutionContext.java │ │ ├── NativeMessageExecutionContext.java │ │ ├── NativeRequest.java │ │ └── NativeResponse.java │ ├── http │ │ ├── HttpBaseExecutionContext.java │ │ ├── HttpBaseRequest.java │ │ ├── HttpBaseResponse.java │ │ ├── HttpExecutionContext.java │ │ ├── HttpMessageExecutionContext.java │ │ ├── HttpMessageRequest.java │ │ ├── HttpMessageResponse.java │ │ ├── HttpPlainExecutionContext.java │ │ ├── HttpPlainRequest.java │ │ ├── HttpPlainResponse.java │ │ ├── HttpRequest.java │ │ └── HttpResponse.java │ ├── kafka │ │ ├── KafkaConnectionContext.java │ │ ├── KafkaExecutionContext.java │ │ ├── KafkaMessageExecutionContext.java │ │ ├── KafkaMessageRequest.java │ │ ├── KafkaMessageResponse.java │ │ ├── KafkaRequest.java │ │ ├── KafkaResponse.java │ │ ├── NetworkController.java │ │ └── topicidentity │ │ │ ├── TopicIdentity.java │ │ │ └── TopicIdentityRegistry.java │ └── tcp │ │ ├── TcpExecutionContext.java │ │ ├── TcpRequest.java │ │ └── TcpResponse.java │ ├── el │ ├── EvaluableMessage.java │ ├── EvaluableRequest.java │ └── EvaluableResponse.java │ ├── exception │ ├── MessageProcessingException.java │ └── PluginConfigurationException.java │ ├── helper │ └── PluginConfigurationHelper.java │ ├── hook │ ├── ChainHook.java │ ├── Hook.java │ ├── Hookable.java │ ├── HttpHook.java │ ├── InvokerHook.java │ ├── InvokerMessageHook.java │ ├── MessageHook.java │ ├── PolicyHook.java │ ├── PolicyMessageHook.java │ ├── ProcessorHook.java │ └── SecurityPlanHook.java │ ├── invoker │ ├── BaseInvoker.java │ ├── HttpInvoker.java │ ├── Invoker.java │ └── TcpInvoker.java │ ├── message │ ├── AbstractMessage.java │ ├── DefaultMessage.java │ ├── Message.java │ └── kafka │ │ └── KafkaMessage.java │ ├── policy │ ├── Policy.java │ ├── SecurityPolicy.java │ ├── SecurityToken.java │ ├── base │ │ ├── BasePolicy.java │ │ └── BaseSecurityPolicy.java │ ├── http │ │ ├── HttpPolicy.java │ │ └── HttpSecurityPolicy.java │ └── kafka │ │ ├── KafkaPolicy.java │ │ └── KafkaSecurityPolicy.java │ ├── qos │ ├── Qos.java │ ├── QosCapability.java │ └── QosRequirement.java │ ├── service │ └── dlq │ │ ├── DlqService.java │ │ └── DlqServiceFactory.java │ ├── tracing │ ├── Tracer.java │ └── message │ │ ├── TracingMessage.java │ │ ├── TracingMessageAttribute.java │ │ ├── TracingMessageMessagingSystem.java │ │ └── TracingMessageOperationType.java │ └── ws │ └── WebSocket.java └── test ├── java └── io │ └── gravitee │ └── gateway │ ├── api │ ├── el │ │ ├── EvaluableExtractorTest.java │ │ └── EvaluableSSLSessionTest.java │ ├── http │ │ ├── DefaultHttpHeadersTest.java │ │ └── HttpHeadersTest.java │ └── service │ │ └── SubscriptionTest.java │ └── reactive │ └── api │ ├── connector │ ├── PluginConfigurationHelperTest.java │ └── entrypoint │ │ └── async │ │ ├── EntrypointAsyncConnectorImpl.java │ │ └── EntrypointAsyncConnectorTest.java │ ├── context │ └── GenericResponseTest.java │ ├── el │ ├── EvaluableRequestTest.java │ └── EvaluableResponseTest.java │ └── message │ └── DefaultMessageTest.java └── resources └── mockito-extensions └── org.mockito.plugins.MockMaker /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | # this allows you to use CircleCI's dynamic configuration feature 4 | setup: true 5 | 6 | orbs: 7 | gravitee: gravitee-io/gravitee@4.12.1 8 | 9 | # our single workflow, that triggers the setup job defined above, filters on tag and branches are needed otherwise 10 | # some workflow and job will not be triggered for tags (default CircleCI behavior) 11 | workflows: 12 | setup_build: 13 | when: 14 | not: << pipeline.git.tag >> 15 | jobs: 16 | - gravitee/setup_lib-build-config: 17 | filters: 18 | tags: 19 | ignore: 20 | - /.*/ 21 | 22 | setup_release: 23 | when: 24 | matches: 25 | pattern: "/^[0-9]+\\.[0-9]+\\.[0-9]+(-(alpha|beta|rc)\\.[0-9]+)?$/" 26 | value: << pipeline.git.tag >> 27 | jobs: 28 | - gravitee/setup_lib-release-config: 29 | filters: 30 | branches: 31 | ignore: 32 | - /.*/ 33 | tags: 34 | only: 35 | - /^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?$/ 36 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default 2 | * @gravitee-io/apim @gravitee-io/archi 3 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Issue** 2 | 3 | https://github.com/gravitee-io/issues/issues/XXXXX 4 | 5 | **Description** 6 | 7 | A small description of what you did in that PR. 8 | 9 | **Additional context** 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["local>gravitee-io/renovate-config:lib"] 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | 3 | build/ 4 | target/ 5 | .idea/ 6 | .DS_Store 7 | *.iml 8 | 9 | *.class 10 | 11 | # Mobile Tools for Java (J2ME) 12 | .mtj.tmp/ 13 | 14 | 15 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 16 | hs_err_pid* 17 | 18 | # Node 19 | node_modules/ 20 | admin/console/dist 21 | 22 | # Eclipse 23 | .settings/ 24 | .classpath 25 | .project 26 | # -- Cicd : Git ignore the [.circleci/**/*] which contains 27 | # files which do not need to be commited (password to artifactory) 28 | .circleci/**/* 29 | # -- Cicd : Do not git ignore the [!./.circleci/config.yml] which contains 30 | # the pipeline definition 31 | !./.circleci/config.yml 32 | # -- Cicd : Git ignore the [gpg.script.snippet.sh] which contains 33 | # secrets (password to artifactory) 34 | gpg.script.snippet.sh 35 | # -- Cicd : The [graviteebot.gpg.priv.key] file contains secrets 36 | # which should not be commited 37 | graviteebot.gpg.priv.key 38 | # -- Cicd : The [.secrethub.credential] file contains secrets 39 | # which should not be commited 40 | graviteebot.gpg.pub.key 41 | # -- Cicd : The [.secrets.json] file contains secrets 42 | # which should not be commited 43 | .secrets.json 44 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | printWidth: 140 2 | tabWidth: 4 3 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | 2 | = Gravitee.IO - Gateway API 3 | 4 | image:https://img.shields.io/badge/License-Apache%202.0-blue.svg["License", link="https://github.com/gravitee-io/gravitee-gateway-api/blob/master/LICENSE.txt"] 5 | image:https://img.shields.io/badge/semantic--release-conventional%20commits-e10079?logo=semantic-release["Releases", link="https://github.com/gravitee-io/gravitee-gateway-api/releases"] 6 | image:https://circleci.com/gh/gravitee-io/gravitee-gateway-api.svg?style=svg["CircleCI", link="https://circleci.com/gh/gravitee-io/gravitee-gateway-api"] 7 | image:https://f.hubspotusercontent40.net/hubfs/7600448/gravitee-github-button.jpg["Join the community forum", link="https://community.gravitee.io?utm_source=readme", height=20] 8 | 9 | 10 | == Description 11 | The gateway API provides APIs to interact with the Gravitee.io APIM Gateway. It is mainly used in plugins (like policies or resources). 12 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/Connector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api; 17 | 18 | import io.gravitee.common.component.LifecycleComponent; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.proxy.ProxyConnection; 21 | import io.gravitee.gateway.api.proxy.ProxyRequest; 22 | 23 | /** 24 | * A simple marker interface to define a way to invoke / call something. 25 | * 26 | * @author David BRASSELY (david.brassely at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface Connector extends LifecycleComponent { 30 | default void request(ProxyRequest request, Handler proxyConnectionHandler) { 31 | request(request, null, proxyConnectionHandler); 32 | } 33 | 34 | void request(ProxyRequest request, ExecutionContext context, Handler proxyConnectionHandler); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/Invoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.proxy.ProxyConnection; 21 | import io.gravitee.gateway.api.stream.ReadStream; 22 | 23 | /** 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | @FunctionalInterface 28 | public interface Invoker { 29 | void invoke(ExecutionContext context, ReadStream stream, Handler connectionHandler); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.http.HttpHeaders; 21 | import io.gravitee.gateway.api.http2.HttpFrame; 22 | import io.gravitee.gateway.api.stream.WriteStream; 23 | 24 | /** 25 | * Represents a server-side HTTP response. 26 | * 27 | * @author David BRASSELY (david.brassely at graviteesource.com) 28 | * @author GraviteeSource Team 29 | */ 30 | public interface Response extends WriteStream { 31 | Response status(int statusCode); 32 | 33 | int status(); 34 | 35 | default void end() {} 36 | 37 | default Response endHandler(Handler endHandler) { 38 | return this; 39 | } 40 | 41 | /** 42 | * Reason-Phrase is intended to give a short textual description of the Status-Code. 43 | * @return 44 | */ 45 | String reason(); 46 | 47 | Response reason(String message); 48 | 49 | /** 50 | * @return the headers in the response. 51 | */ 52 | HttpHeaders headers(); 53 | 54 | /** 55 | * @return has the response already ended? 56 | */ 57 | boolean ended(); 58 | 59 | HttpHeaders trailers(); 60 | 61 | default Response writeCustomFrame(HttpFrame frame) { 62 | return this; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/buffer/BufferFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.buffer; 17 | 18 | import io.netty.buffer.ByteBuf; 19 | 20 | /** 21 | * @author David BRASSELY (david at gravitee.io) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface BufferFactory { 25 | Buffer buffer(ByteBuf nativeBuffer); 26 | 27 | Buffer buffer(io.vertx.core.buffer.Buffer vertxBuffer); 28 | 29 | Buffer buffer(io.vertx.rxjava3.core.buffer.Buffer vertxBuffer); 30 | 31 | Buffer buffer(int initialSizeHint); 32 | 33 | Buffer buffer(); 34 | 35 | Buffer buffer(String str); 36 | 37 | Buffer buffer(String str, String enc); 38 | 39 | Buffer buffer(byte[] bytes); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/context/MutableExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.context; 17 | 18 | import io.gravitee.gateway.api.ExecutionContext; 19 | import io.gravitee.gateway.api.Request; 20 | import io.gravitee.gateway.api.Response; 21 | import io.gravitee.gateway.reactive.api.tracing.Tracer; 22 | 23 | public interface MutableExecutionContext extends ExecutionContext { 24 | MutableExecutionContext request(Request request); 25 | 26 | MutableExecutionContext response(Response response); 27 | 28 | MutableExecutionContext tracer(Tracer tracer); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/el/EvaluableResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.el; 17 | 18 | import io.gravitee.gateway.api.Response; 19 | import io.gravitee.gateway.api.http.HttpHeaders; 20 | 21 | /** 22 | * @author David BRASSELY (david.brassely at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public class EvaluableResponse { 26 | 27 | private final Response response; 28 | private final String content; 29 | 30 | public EvaluableResponse(final Response response) { 31 | this(response, null); 32 | } 33 | 34 | public EvaluableResponse(final Response response, final String content) { 35 | this.response = response; 36 | this.content = content; 37 | } 38 | 39 | public int getStatus() { 40 | return response.status(); 41 | } 42 | 43 | public HttpHeaders getHeaders() { 44 | return response.headers(); 45 | } 46 | 47 | public String getContent() { 48 | return content; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/el/EvaluableSSLSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.el; 17 | 18 | import javax.net.ssl.SSLPeerUnverifiedException; 19 | import javax.net.ssl.SSLSession; 20 | 21 | /** 22 | * @author Florent CHAMFROY (florent.chamfroy at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public class EvaluableSSLSession { 26 | 27 | private final SSLSession sslSession; 28 | 29 | public static final EmptyEvaluableSSLPrincipal EMPTY_EVALUABLE_SSL_PRINCIPAL = new EmptyEvaluableSSLPrincipal(); 30 | 31 | public EvaluableSSLSession(final SSLSession sslSession) { 32 | this.sslSession = sslSession; 33 | } 34 | 35 | public String getClientHost() { 36 | if (sslSession != null) { 37 | return sslSession.getPeerHost(); 38 | } 39 | return null; 40 | } 41 | 42 | public Integer getClientPort() { 43 | if (sslSession != null) { 44 | return sslSession.getPeerPort(); 45 | } 46 | return null; 47 | } 48 | 49 | public EvaluableSSLPrincipal getClient() { 50 | try { 51 | if (sslSession != null && sslSession.getPeerPrincipal() != null) { 52 | return new EvaluableSSLPrincipal(sslSession.getPeerPrincipal()); 53 | } 54 | } catch (SSLPeerUnverifiedException ignored) {} 55 | return EMPTY_EVALUABLE_SSL_PRINCIPAL; 56 | } 57 | 58 | public EvaluableSSLPrincipal getServer() { 59 | if (sslSession != null && sslSession.getLocalPrincipal() != null) { 60 | return new EvaluableSSLPrincipal(sslSession.getLocalPrincipal()); 61 | } 62 | return EMPTY_EVALUABLE_SSL_PRINCIPAL; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/AbstractEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | /** 22 | * @author David BRASSELY (david.brassely at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public abstract class AbstractEndpoint implements Endpoint { 26 | 27 | protected final Set listeners = new HashSet<>(); 28 | 29 | @Override 30 | public void addEndpointAvailabilityListener(EndpointAvailabilityListener listener) { 31 | listeners.add(listener); 32 | } 33 | 34 | @Override 35 | public void removeEndpointAvailabilityListener(EndpointAvailabilityListener listener) { 36 | listeners.remove(listener); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/Endpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint; 17 | 18 | import io.gravitee.gateway.api.Connector; 19 | 20 | /** 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface Endpoint { 25 | /** 26 | * Endpoint name. 27 | * @return Endpoint name. 28 | */ 29 | String name(); 30 | 31 | /** 32 | * Endpoint target. 33 | * @return Endpoint target. 34 | */ 35 | String target(); 36 | 37 | /** 38 | * Endpoint weight. 39 | * 40 | * @return 41 | */ 42 | int weight(); 43 | 44 | /** 45 | * The {@link Connector} used to invoke the endpoint. 46 | * @return {@link Connector} used to invoke the endpoint. 47 | */ 48 | Connector connector(); 49 | 50 | /** 51 | * Can the endpoint be reach ? 52 | * 53 | * @return 54 | */ 55 | boolean available(); 56 | 57 | /** 58 | * When an endpoint is marked as a secondary endpoint, it can be selected by the load-balancer only when no 59 | * more primary endpoint are available. 60 | * 61 | * @return 62 | */ 63 | boolean primary(); 64 | 65 | void addEndpointAvailabilityListener(EndpointAvailabilityListener listener); 66 | 67 | void removeEndpointAvailabilityListener(EndpointAvailabilityListener listener); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/EndpointAvailabilityListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint; 17 | 18 | /** 19 | * @author David BRASSELY (david.brassely at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface EndpointAvailabilityListener { 23 | void onAvailabilityChange(Endpoint endpoint, boolean available); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/EndpointManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint; 17 | 18 | /** 19 | * @author David BRASSELY (david.brassely at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface EndpointManager { 23 | /** 24 | * Get an endpoint reference to access the underlying connector. 25 | * 26 | * @param name The name of the endpoint (single endpoint or group endpoint). 27 | * @return Endpoint reference. Can be null. 28 | */ 29 | Endpoint get(String name); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/resolver/EndpointResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint.resolver; 17 | 18 | /** 19 | * @author David BRASSELY (david.brassely at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface EndpointResolver { 23 | /** 24 | * A reference to the best endpoint / endpoint group according to the target. 25 | * 26 | * Reference could be of three different types: 27 | * - A classical URL: http[s]://my_backend/api 28 | * - An endpoint or endpoint group reference: endpoint:/my_api 29 | * - Just a path: /my_api in that case the gateway will automatically select the default endpoint 30 | * 31 | * @param reference A reference to something (an endpoint) 32 | * @return Endpoint reference. Can be null 33 | */ 34 | ProxyEndpoint resolve(String reference); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/endpoint/resolver/ProxyEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.endpoint.resolver; 17 | 18 | import io.gravitee.gateway.api.Request; 19 | import io.gravitee.gateway.api.endpoint.Endpoint; 20 | import io.gravitee.gateway.api.proxy.ProxyRequest; 21 | import io.gravitee.gateway.api.proxy.builder.ProxyRequestBuilder; 22 | import java.util.function.Function; 23 | 24 | /** 25 | * @author David BRASSELY (david.brassely at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | public interface ProxyEndpoint extends Endpoint { 29 | default ProxyRequest createProxyRequest(Request request) { 30 | return createProxyRequest(request, null); 31 | } 32 | 33 | ProxyRequest createProxyRequest(Request request, Function mapper); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/handler/Handler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.handler; 17 | 18 | /** 19 | * A generic event handler 20 | * 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | @FunctionalInterface 25 | public interface Handler { 26 | void handle(T result); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http/stream/TransformableRequestStreamBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http.stream; 17 | 18 | import io.gravitee.gateway.api.Request; 19 | import io.gravitee.gateway.api.stream.TransformableStream; 20 | 21 | /** 22 | * @author David BRASSELY (david.brassely at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public final class TransformableRequestStreamBuilder extends TransformableStreamBuilder { 26 | 27 | private TransformableRequestStreamBuilder(Request request) { 28 | super(request); 29 | } 30 | 31 | public static TransformableRequestStreamBuilder on(Request request) { 32 | return new TransformableRequestStreamBuilder(request); 33 | } 34 | 35 | @Override 36 | public TransformableStream build() { 37 | return new TransformableRequestStream(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http/stream/TransformableResponseStreamBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http.stream; 17 | 18 | import io.gravitee.gateway.api.Response; 19 | import io.gravitee.gateway.api.stream.TransformableStream; 20 | 21 | /** 22 | * @author David BRASSELY (david.brassely at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public final class TransformableResponseStreamBuilder extends TransformableStreamBuilder { 26 | 27 | private TransformableResponseStreamBuilder(Response response) { 28 | super(response); 29 | } 30 | 31 | public static TransformableResponseStreamBuilder on(Response response) { 32 | return new TransformableResponseStreamBuilder(response); 33 | } 34 | 35 | @Override 36 | public TransformableStream build() { 37 | return new TransformableResponseStream(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http/stream/TransformableSourceStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http.stream; 17 | 18 | import io.gravitee.gateway.api.stream.TransformableStream; 19 | 20 | /** 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | abstract class TransformableSourceStream extends TransformableStream { 25 | 26 | protected final T source; 27 | 28 | TransformableSourceStream(TransformableStreamBuilder builder) { 29 | super(builder.contentLength); 30 | this.source = builder.container; 31 | this.contentType = builder.contentType; 32 | this.transform = builder.transform; 33 | this.policyChain = builder.policyChain; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http/stream/TransformableStreamBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http.stream; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | import io.gravitee.gateway.api.stream.TransformableStream; 20 | import io.gravitee.policy.api.PolicyChain; 21 | import java.util.function.Function; 22 | 23 | /** 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public abstract class TransformableStreamBuilder { 28 | 29 | protected final T container; 30 | protected String contentType; 31 | protected PolicyChain policyChain; 32 | protected Function transform; 33 | protected int contentLength = -1; 34 | 35 | protected TransformableStreamBuilder(T container) { 36 | this.container = container; 37 | } 38 | 39 | public TransformableStreamBuilder contentType(String contentType) { 40 | this.contentType = contentType; 41 | return this; 42 | } 43 | 44 | public TransformableStreamBuilder contentLength(int contentLength) { 45 | this.contentLength = contentLength; 46 | return this; 47 | } 48 | 49 | public TransformableStreamBuilder transform(Function function) { 50 | this.transform = function; 51 | return this; 52 | } 53 | 54 | public TransformableStreamBuilder chain(PolicyChain policyChain) { 55 | this.policyChain = policyChain; 56 | return this; 57 | } 58 | 59 | public abstract TransformableStream build(); 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http2/HttpFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http2; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | 20 | /** 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpFrame { 25 | /** 26 | * @return the 8-bit type of the frame 27 | */ 28 | int type(); 29 | 30 | /** 31 | * @return the 8-bit flags specific to the frame 32 | */ 33 | int flags(); 34 | 35 | /** 36 | * @return the frame payload 37 | */ 38 | Buffer payload(); 39 | 40 | static HttpFrame create(int type, int flags, Buffer payload) { 41 | return new HttpFrameImpl(type, flags, payload); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/http2/HttpFrameImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.http2; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | 20 | /** 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | class HttpFrameImpl implements HttpFrame { 25 | 26 | private final int type; 27 | 28 | private final int flags; 29 | 30 | private final Buffer payload; 31 | 32 | HttpFrameImpl(int type, int flags, Buffer payload) { 33 | this.type = type; 34 | this.flags = flags; 35 | this.payload = payload; 36 | } 37 | 38 | @Override 39 | public int type() { 40 | return type; 41 | } 42 | 43 | @Override 44 | public int flags() { 45 | return flags; 46 | } 47 | 48 | @Override 49 | public Buffer payload() { 50 | return payload; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/processor/ProcessorFailure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.processor; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * @author David BRASSELY (david.brassely at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ProcessorFailure { 25 | int statusCode(); 26 | 27 | String message(); 28 | 29 | String key(); 30 | 31 | Map parameters(); 32 | 33 | String contentType(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/proxy/ProxyConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.proxy; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.http2.HttpFrame; 21 | import io.gravitee.gateway.api.stream.WriteStream; 22 | 23 | /** 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface ProxyConnection extends WriteStream { 28 | /** 29 | * Write custom HTTP Frame to upstream. 30 | * 31 | * //TODO: How-to make this specific to HTTP/2 proxy connection only? 32 | * // This should be handle when the gateway will be able to manage other connectors 33 | * 34 | * @param frame 35 | * @return 36 | */ 37 | default ProxyConnection writeCustomFrame(HttpFrame frame) { 38 | return this; 39 | } 40 | 41 | default ProxyConnection cancel() { 42 | return this; 43 | } 44 | 45 | default ProxyConnection cancelHandler(Handler cancelHandler) { 46 | return this; 47 | } 48 | 49 | default ProxyConnection exceptionHandler(Handler exceptionHandler) { 50 | return this; 51 | } 52 | 53 | default ProxyConnection responseHandler(Handler responseHandler) { 54 | return this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/proxy/ProxyRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.proxy; 17 | 18 | import io.gravitee.common.http.HttpMethod; 19 | import io.gravitee.common.util.MultiValueMap; 20 | import io.gravitee.gateway.api.handler.Handler; 21 | import io.gravitee.gateway.api.http.HttpHeaders; 22 | import io.gravitee.reporter.api.http.Metrics; 23 | 24 | /** 25 | * @author David BRASSELY (david.brassely at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | public interface ProxyRequest { 29 | /** 30 | * @return the target URI of the request. 31 | */ 32 | String uri(); 33 | 34 | /** 35 | * @return the query parameters in the request 36 | */ 37 | MultiValueMap parameters(); 38 | 39 | /** 40 | * @return the path parameters in the request 41 | */ 42 | MultiValueMap pathParameters(); 43 | 44 | /** 45 | * @return the HTTP method for the request. 46 | */ 47 | HttpMethod method(); 48 | 49 | /** 50 | * The raw method in case the method() returns HttpMethod.OTHER 51 | * @return 52 | */ 53 | String rawMethod(); 54 | 55 | /** 56 | * @return the headers in the request. 57 | */ 58 | HttpHeaders headers(); 59 | 60 | /** 61 | * @return the metrics attached to the request. 62 | */ 63 | Metrics metrics(); 64 | 65 | ProxyRequest closeHandler(Handler closeHandler); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/proxy/ProxyResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.proxy; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.http.HttpHeaders; 21 | import io.gravitee.gateway.api.http2.HttpFrame; 22 | import io.gravitee.gateway.api.stream.ReadStream; 23 | 24 | /** 25 | * @author David BRASSELY (david.brassely at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | public interface ProxyResponse extends ReadStream { 29 | /** 30 | * @return HTTP status code. 31 | */ 32 | int status(); 33 | 34 | /** 35 | * Reason-Phrase is intended to give a short textual description of the Status-Code. 36 | * @return 37 | */ 38 | default String reason() { 39 | return null; 40 | } 41 | 42 | /** 43 | * @return the headers in the response. 44 | */ 45 | HttpHeaders headers(); 46 | 47 | /** 48 | * Is the response connected to an upstream or it is a 'direct' response from the proxy itself. 49 | * 50 | * @return 51 | */ 52 | default boolean connected() { 53 | return true; 54 | } 55 | 56 | /** 57 | * For HTTP/2 request 58 | * 59 | * @param frameHandler The handler to call when getting a custom HTTP Frame. 60 | * @return 61 | */ 62 | default ProxyResponse customFrameHandler(Handler frameHandler) { 63 | return this; 64 | } 65 | 66 | default HttpHeaders trailers() { 67 | return null; 68 | } 69 | 70 | default ProxyResponse cancelHandler(Handler cancelHandler) { 71 | return this; 72 | } 73 | 74 | default void cancel() {} 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/proxy/ws/WebSocketProxyRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.proxy.ws; 17 | 18 | import io.gravitee.gateway.api.handler.Handler; 19 | import io.gravitee.gateway.api.proxy.ProxyRequest; 20 | import io.gravitee.gateway.api.ws.WebSocketFrame; 21 | import java.util.concurrent.CompletableFuture; 22 | 23 | /** 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface WebSocketProxyRequest extends ProxyRequest { 28 | CompletableFuture upgrade(); 29 | 30 | WebSocketProxyRequest reject(int statusCode); 31 | 32 | WebSocketProxyRequest write(WebSocketFrame frame); 33 | 34 | WebSocketProxyRequest close(); 35 | 36 | WebSocketProxyRequest frameHandler(Handler handler); 37 | 38 | WebSocketProxyRequest closeHandler(Handler handler); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/proxy/ws/WebSocketProxyRequestImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.proxy.ws; 17 | 18 | import io.gravitee.gateway.api.Request; 19 | import io.gravitee.gateway.api.handler.Handler; 20 | import io.gravitee.gateway.api.proxy.builder.ProxyRequestImpl; 21 | import io.gravitee.gateway.api.ws.WebSocket; 22 | import io.gravitee.gateway.api.ws.WebSocketFrame; 23 | import java.util.concurrent.CompletableFuture; 24 | 25 | public class WebSocketProxyRequestImpl extends ProxyRequestImpl implements WebSocketProxyRequest { 26 | 27 | private final WebSocket websocket; 28 | 29 | public WebSocketProxyRequestImpl(final Request request) { 30 | super(request); 31 | this.websocket = request.websocket(); 32 | } 33 | 34 | @Override 35 | public CompletableFuture upgrade() { 36 | return websocket.upgrade().thenApply(webSocket -> WebSocketProxyRequestImpl.this); 37 | } 38 | 39 | @Override 40 | public WebSocketProxyRequest reject(int statusCode) { 41 | websocket.reject(statusCode); 42 | return this; 43 | } 44 | 45 | @Override 46 | public WebSocketProxyRequest write(WebSocketFrame frame) { 47 | this.websocket.write(frame); 48 | return this; 49 | } 50 | 51 | @Override 52 | public WebSocketProxyRequest close() { 53 | this.websocket.close(); 54 | return this; 55 | } 56 | 57 | @Override 58 | public WebSocketProxyRequest frameHandler(Handler handler) { 59 | this.websocket.frameHandler(handler); 60 | return this; 61 | } 62 | 63 | @Override 64 | public WebSocketProxyRequest closeHandler(Handler handler) { 65 | this.websocket.closeHandler(handler); 66 | return this; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/service/ApiKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.service; 17 | 18 | import java.util.Date; 19 | import lombok.AllArgsConstructor; 20 | import lombok.Builder; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @Builder 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | @Getter 31 | @Setter 32 | @ToString 33 | @EqualsAndHashCode 34 | public class ApiKey { 35 | 36 | private String id; 37 | 38 | private String key; 39 | 40 | private String api; 41 | 42 | private String plan; 43 | 44 | private String subscription; 45 | 46 | private String application; 47 | 48 | private Date expireAt; 49 | 50 | private boolean revoked; 51 | 52 | private boolean paused; 53 | 54 | private boolean active; 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/service/ApiKeyService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.service; 17 | 18 | import java.util.Optional; 19 | 20 | /** 21 | * This manages api keys. 22 | */ 23 | public interface ApiKeyService { 24 | /** 25 | * Register the given api key. 26 | * Will load it if active, or unload it otherwise. 27 | * 28 | * @param apiKey the api key to register 29 | */ 30 | void register(final ApiKey apiKey); 31 | 32 | void unregister(ApiKey apiKey); 33 | 34 | /** 35 | * Unregister all api key from the given api id. 36 | * 37 | * @param apiId the api id attached to apikeys to unregister 38 | */ 39 | void unregisterByApiId(String apiId); 40 | 41 | /** 42 | * Get api key by its api and key. 43 | * 44 | * @param api Searched api 45 | * @param key Searched key 46 | * @return Found ApiKey 47 | */ 48 | Optional getByApiAndKey(String api, String key); 49 | 50 | /** 51 | * Get api key by its api and md5 hash of the key. 52 | * 53 | * @param api Searched api 54 | * @param md5ApiKey Searched md5 hash of the key 55 | * @return Found ApiKey 56 | */ 57 | Optional getByApiAndMd5Key(String api, String md5ApiKey); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/service/Subscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.service; 17 | 18 | import java.util.Date; 19 | import java.util.Map; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Builder 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @Getter 32 | @Setter 33 | @ToString 34 | @EqualsAndHashCode 35 | public class Subscription { 36 | 37 | private String id; 38 | 39 | private String api; 40 | 41 | private String plan; 42 | 43 | private String application; 44 | 45 | private String applicationName; 46 | 47 | private String clientId; 48 | 49 | private String clientCertificate; 50 | 51 | private String status; 52 | 53 | @Builder.Default 54 | private ConsumerStatus consumerStatus = ConsumerStatus.STARTED; 55 | 56 | private Date startingAt; 57 | 58 | private Date endingAt; 59 | 60 | private SubscriptionConfiguration configuration; 61 | 62 | private Map metadata; 63 | 64 | @Builder.Default 65 | private Type type = Type.STANDARD; 66 | 67 | @EqualsAndHashCode.Exclude 68 | private boolean forceDispatch; 69 | 70 | private String environmentId; 71 | 72 | public boolean isTimeValid(long requestTimestamp) { 73 | Date requestDate = new Date(requestTimestamp); 74 | return (endingAt == null || endingAt.after(requestDate)) && (startingAt == null || startingAt.before(requestDate)); 75 | } 76 | 77 | public enum Type { 78 | STANDARD, 79 | PUSH, 80 | } 81 | 82 | public enum ConsumerStatus { 83 | STOPPED, 84 | STARTED, 85 | FAILURE, 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/service/SubscriptionConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.service; 17 | 18 | import com.fasterxml.jackson.annotation.JsonRawValue; 19 | import com.fasterxml.jackson.annotation.JsonSetter; 20 | import com.fasterxml.jackson.databind.JsonNode; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.ToString; 28 | 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @Getter 32 | @Setter 33 | @Builder 34 | @EqualsAndHashCode 35 | @ToString 36 | public class SubscriptionConfiguration { 37 | 38 | private String channel; 39 | 40 | private String entrypointId; 41 | 42 | @JsonRawValue 43 | private String entrypointConfiguration; 44 | 45 | @JsonSetter 46 | public void setEntrypointConfiguration(final JsonNode configuration) { 47 | if (configuration != null) { 48 | this.entrypointConfiguration = configuration.toString(); 49 | } 50 | } 51 | 52 | public void setEntrypointConfiguration(final String configuration) { 53 | this.entrypointConfiguration = configuration; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/service/SubscriptionService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.service; 17 | 18 | import io.gravitee.gateway.reactive.api.policy.SecurityToken; 19 | import java.util.Optional; 20 | 21 | /** 22 | * This manages subscriptions. 23 | */ 24 | public interface SubscriptionService { 25 | /** 26 | * Get subscription by its API, client ID, and plan. 27 | * 28 | * @param api Searched API 29 | * @param clientId Searched client ID 30 | * @param plan Searched plan ID 31 | * @return Found subscription 32 | */ 33 | Optional getByApiAndClientIdAndPlan(String api, String clientId, String plan); 34 | 35 | /** 36 | * Get subscription by its ID. 37 | * 38 | * @param subscriptionId Searched subscription ID 39 | * @return Found subscription 40 | */ 41 | Optional getById(String subscriptionId); 42 | 43 | /** 44 | * Get subscription by its API, security token, and plan. 45 | * 46 | * @param api Searched API 47 | * @param securityToken Searched security token 48 | * @param plan Searched plan ID 49 | * @return Found subscription 50 | */ 51 | Optional getByApiAndSecurityToken(String api, SecurityToken securityToken, String plan); 52 | 53 | /** 54 | * Register the given subscription. 55 | * Will load it if active, or unload it otherwise. 56 | * 57 | * @param subscription the subscription to save 58 | */ 59 | void register(Subscription subscription); 60 | 61 | void unregister(Subscription subscription); 62 | 63 | /** 64 | * Unregister all subscriptions key from the given api id. 65 | * 66 | * @param apiId the api id attached to subscriptions to unregister 67 | */ 68 | void unregisterByApiId(String apiId); 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/BufferedReadWriteStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | 20 | /** 21 | * @author David BRASSELY (david at gravitee.io) 22 | * @author GraviteeSource Team 23 | */ 24 | public class BufferedReadWriteStream extends SimpleReadWriteStream {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/ReadStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream; 17 | 18 | import io.gravitee.gateway.api.handler.Handler; 19 | 20 | /** 21 | * Stream reader. 22 | * 23 | * Mainly inspired from Vertx.io 24 | * @see io.vertx.core.streams.ReadStream 25 | * 26 | * @author David BRASSELY (david.brassely at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface ReadStream { 30 | ReadStream bodyHandler(Handler bodyHandler); 31 | 32 | ReadStream endHandler(Handler endHandler); 33 | 34 | default ReadStream pause() { 35 | return this; 36 | } 37 | 38 | default ReadStream resume() { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/ReadWriteStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream; 17 | 18 | /** 19 | * @author David BRASSELY (david.brassely at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface ReadWriteStream extends ReadStream, WriteStream {} 23 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/SimpleReadWriteStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream; 17 | 18 | import io.gravitee.gateway.api.handler.Handler; 19 | 20 | /** 21 | * @author David BRASSELY (david at gravitee.io) 22 | * @author GraviteeSource Team 23 | */ 24 | public abstract class SimpleReadWriteStream implements ReadWriteStream { 25 | 26 | protected Handler bodyHandler; 27 | protected Handler endHandler; 28 | 29 | @Override 30 | public SimpleReadWriteStream bodyHandler(Handler bodyHandler) { 31 | this.bodyHandler = bodyHandler; 32 | return this; 33 | } 34 | 35 | @Override 36 | public SimpleReadWriteStream endHandler(Handler endHandler) { 37 | this.endHandler = endHandler; 38 | return this; 39 | } 40 | 41 | @Override 42 | public SimpleReadWriteStream write(T content) { 43 | if (this.bodyHandler != null) { 44 | this.bodyHandler.handle(content); 45 | } 46 | 47 | return this; 48 | } 49 | 50 | @Override 51 | public void end() { 52 | if (this.endHandler != null) { 53 | this.endHandler.handle(null); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/WriteStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream; 17 | 18 | import io.gravitee.gateway.api.handler.Handler; 19 | 20 | /** 21 | * Stream writer. 22 | * 23 | * Mainly inspired from Vertx.io 24 | * @see io.vertx.core.streams.WriteStream 25 | * 26 | * @author David BRASSELY (david at gravitee.io) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface WriteStream { 30 | WriteStream write(T content); 31 | 32 | void end(); 33 | 34 | default void end(T t) { 35 | write(t); 36 | end(); 37 | } 38 | 39 | default WriteStream drainHandler(Handler drainHandler) { 40 | return this; 41 | } 42 | 43 | default boolean writeQueueFull() { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/stream/exception/TransformationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.stream.exception; 17 | 18 | /** 19 | * @author David BRASSELY (david at gravitee.io) 20 | * @author GraviteeSource Team 21 | */ 22 | public class TransformationException extends RuntimeException { 23 | 24 | public TransformationException() { 25 | super(); 26 | } 27 | 28 | public TransformationException(Throwable cause) { 29 | super(cause); 30 | } 31 | 32 | public TransformationException(String message) { 33 | super(message); 34 | } 35 | 36 | public TransformationException(String message, Throwable cause) { 37 | super(message, cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/ws/WebSocket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.ws; 17 | 18 | import io.gravitee.gateway.api.handler.Handler; 19 | import java.util.concurrent.CompletableFuture; 20 | 21 | /** 22 | * Represents a server-side WebSocket request. 23 | * 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface WebSocket { 28 | /** 29 | * Upgrade the HTTP request to a WS connection 30 | * @return 31 | */ 32 | CompletableFuture upgrade(); 33 | 34 | /** 35 | * WS connection has been rejected by upstream. 36 | * @param statusCode 37 | * @return 38 | */ 39 | WebSocket reject(int statusCode); 40 | 41 | WebSocket write(WebSocketFrame frame); 42 | 43 | WebSocket close(); 44 | 45 | WebSocket frameHandler(Handler frameHandler); 46 | 47 | WebSocket closeHandler(Handler closeHandler); 48 | 49 | boolean upgraded(); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/api/ws/WebSocketFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.ws; 17 | 18 | import io.gravitee.gateway.api.buffer.Buffer; 19 | 20 | /** 21 | * Represents a WebSocket frame. 22 | * 23 | * @author David BRASSELY (david.brassely at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface WebSocketFrame { 27 | Type type(); 28 | 29 | /** 30 | * This one is only valid in case of a TEXT or BINARY frame type. 31 | * @return 32 | */ 33 | Buffer data(); 34 | 35 | boolean isFinal(); 36 | 37 | enum Type { 38 | // Continuation / 0 39 | CONTINUATION, 40 | // Text / 1 41 | TEXT, 42 | // Binary / 2 43 | BINARY, 44 | // Connection Close / 8 45 | CLOSE, 46 | // Ping / 9 47 | PING, 48 | // Pong / 10 49 | PONG, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/ApiType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api; 17 | 18 | import com.fasterxml.jackson.annotation.JsonValue; 19 | import java.util.Map; 20 | import lombok.Getter; 21 | import lombok.RequiredArgsConstructor; 22 | 23 | /** 24 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | @RequiredArgsConstructor 28 | @Getter 29 | public enum ApiType { 30 | PROXY("proxy"), 31 | MESSAGE("message"), 32 | NATIVE("native"); 33 | 34 | private static final Map LABELS_MAP = Map.of(PROXY.label, PROXY, MESSAGE.label, MESSAGE, NATIVE.label, NATIVE); 35 | 36 | @JsonValue 37 | private final String label; 38 | 39 | public static ApiType fromLabel(final String label) { 40 | if (label != null) { 41 | return LABELS_MAP.get(label); 42 | } 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/ConnectorMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api; 17 | 18 | import com.fasterxml.jackson.annotation.JsonValue; 19 | import java.util.Map; 20 | import lombok.Getter; 21 | import lombok.RequiredArgsConstructor; 22 | 23 | /** 24 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | @RequiredArgsConstructor 28 | @Getter 29 | public enum ConnectorMode { 30 | CONNECT("connect"), 31 | INTERACT("interact"), 32 | SUBSCRIBE("subscribe"), 33 | PUBLISH("publish"), 34 | REQUEST_RESPONSE("request_response"), 35 | SOCKET("socket"); 36 | 37 | private static final Map LABELS_MAP = Map.of( 38 | CONNECT.label, 39 | CONNECT, 40 | INTERACT.label, 41 | INTERACT, 42 | SUBSCRIBE.label, 43 | SUBSCRIBE, 44 | PUBLISH.label, 45 | PUBLISH, 46 | REQUEST_RESPONSE.label, 47 | REQUEST_RESPONSE, 48 | SOCKET.label, 49 | SOCKET 50 | ); 51 | 52 | @JsonValue 53 | private final String label; 54 | 55 | public static ConnectorMode fromLabel(final String label) { 56 | if (label != null) { 57 | return LABELS_MAP.get(label); 58 | } 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/ExecutionFailure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api; 17 | 18 | import java.util.Map; 19 | import lombok.EqualsAndHashCode; 20 | 21 | /** 22 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | @EqualsAndHashCode 26 | public class ExecutionFailure { 27 | 28 | private int statusCode; 29 | private String message; 30 | private String key; 31 | private Map parameters; 32 | private String contentType; 33 | 34 | public ExecutionFailure() {} 35 | 36 | public ExecutionFailure(int statusCode) { 37 | this.statusCode = statusCode; 38 | } 39 | 40 | public int statusCode() { 41 | return statusCode; 42 | } 43 | 44 | public ExecutionFailure statusCode(int statusCode) { 45 | this.statusCode = statusCode; 46 | return this; 47 | } 48 | 49 | public String message() { 50 | return message; 51 | } 52 | 53 | public ExecutionFailure message(String message) { 54 | this.message = message; 55 | return this; 56 | } 57 | 58 | public String key() { 59 | return key; 60 | } 61 | 62 | public ExecutionFailure key(String key) { 63 | this.key = key; 64 | return this; 65 | } 66 | 67 | public Map parameters() { 68 | return parameters; 69 | } 70 | 71 | public ExecutionFailure parameters(Map parameters) { 72 | this.parameters = parameters; 73 | return this; 74 | } 75 | 76 | public String contentType() { 77 | return contentType; 78 | } 79 | 80 | public ExecutionFailure contentType(String contentType) { 81 | this.contentType = contentType; 82 | return this; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/ListenerType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api; 17 | 18 | import com.fasterxml.jackson.annotation.JsonValue; 19 | import java.util.Map; 20 | import lombok.Getter; 21 | import lombok.RequiredArgsConstructor; 22 | 23 | /** 24 | * @author David BRASSELY (david.brassely at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | @RequiredArgsConstructor 28 | @Getter 29 | public enum ListenerType { 30 | HTTP("http"), 31 | SUBSCRIPTION("subscription"), 32 | TCP("tcp"), 33 | KAFKA("kafka"); 34 | 35 | private static final Map LABELS_MAP = Map.of( 36 | HTTP.label, 37 | HTTP, 38 | SUBSCRIPTION.label, 39 | SUBSCRIPTION, 40 | TCP.label, 41 | TCP, 42 | KAFKA.label, 43 | KAFKA 44 | ); 45 | 46 | @JsonValue 47 | private final String label; 48 | 49 | public static ListenerType fromLabel(final String label) { 50 | if (label != null) { 51 | return LABELS_MAP.get(label); 52 | } 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/apiservice/ApiService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.apiservice; 17 | 18 | import io.reactivex.rxjava3.core.Completable; 19 | 20 | /** 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ApiService { 25 | String id(); 26 | 27 | String kind(); 28 | 29 | Completable start(); 30 | 31 | Completable stop(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/apiservice/ApiServiceConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.apiservice; 17 | 18 | /** 19 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface ApiServiceConfiguration {} 23 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/apiservice/ApiServiceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.apiservice; 17 | 18 | import io.gravitee.gateway.reactive.api.context.DeploymentContext; 19 | 20 | /** 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ApiServiceFactory { 25 | /** 26 | * Allow creating new api service from the given string configuration. 27 | * 28 | * @param deploymentContext the deployment context containing useful information to create the service. 29 | * @return the newly created api service. 30 | */ 31 | T createService(final DeploymentContext deploymentContext); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/Connector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector; 17 | 18 | import io.gravitee.common.component.LifecycleComponent; 19 | import io.gravitee.gateway.reactive.api.ApiType; 20 | import io.gravitee.gateway.reactive.api.ConnectorMode; 21 | import java.util.Set; 22 | 23 | /** 24 | * Interface describing Connector which could be implemented to deal with new protocol specification 25 | * 26 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface Connector extends LifecycleComponent { 30 | /** 31 | * Returns the id of the connector 32 | * 33 | * @return identifier of this connector 34 | */ 35 | String id(); 36 | 37 | /** 38 | * Returns the {@link ApiType} supported by this endpoint. It will be used to filter available connector when creating a new API 39 | * 40 | * @return {@link ApiType} supported by this connector. 41 | */ 42 | ApiType supportedApi(); 43 | 44 | /** 45 | * Returns a set of {@link ConnectorMode} supported by this connector. It will be used to resolve the proper connector. 46 | * 47 | * @return set of {@link ConnectorMode} supported by this connector. 48 | */ 49 | Set supportedModes(); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/ConnectorConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector; 17 | 18 | /** 19 | * Simple connector configuration interface 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ConnectorConfiguration {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/ConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.context.DeploymentContext; 21 | import java.util.Set; 22 | 23 | /** 24 | * Factory used to create new {@link Connector} 25 | * 26 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface ConnectorFactory { 30 | /** 31 | * @return {@link ApiType} supported by this connector. 32 | */ 33 | ApiType supportedApi(); 34 | 35 | /** 36 | * @return {@link ConnectorMode} supported by this connector. 37 | */ 38 | Set supportedModes(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/BaseEndpointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.connector.Connector; 19 | import io.gravitee.gateway.reactive.api.context.base.BaseExecutionContext; 20 | import io.reactivex.rxjava3.core.Completable; 21 | 22 | /** 23 | * Interface describing Endpoint Connector which could be implemented to deal with new protocol specification 24 | * @author GraviteeSource Team 25 | */ 26 | public interface BaseEndpointConnector extends Connector { 27 | Completable connect(final C ctx); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/BaseEndpointConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.connector.ConnectorFactory; 19 | import io.gravitee.gateway.reactive.api.context.DeploymentContext; 20 | 21 | /** 22 | * Specialized factory for {@link BaseEndpointConnector} 23 | */ 24 | public interface BaseEndpointConnectorFactory extends ConnectorFactory { 25 | /** 26 | * Allow creating new endpoint connector from the given strings configuration. 27 | * 28 | * @param deploymentContext context containing useful deployment entities (api, services, ...). 29 | * @param configuration the configuration as json string. 30 | * @param sharedConfiguration the shared configuration as json string. 31 | * 32 | * @return new connector instance. 33 | */ 34 | T createConnector(final DeploymentContext deploymentContext, final String configuration, final String sharedConfiguration); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/EndpointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 20 | import io.reactivex.rxjava3.core.Completable; 21 | 22 | /** 23 | * Interface describing Endpoint Connector which could be implemented to deal with new protocol specification 24 | * @deprecated see {@link HttpEndpointConnector} 25 | * @author GraviteeSource Team 26 | */ 27 | @Deprecated(forRemoval = true) 28 | public interface EndpointConnector extends HttpEndpointConnector { 29 | Completable connect(final ExecutionContext ctx); 30 | 31 | @Override 32 | default Completable connect(final HttpExecutionContext ctx) { 33 | return connect((ExecutionContext) ctx); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/EndpointConnectorConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.connector.ConnectorConfiguration; 19 | 20 | /** 21 | * Default empty configuration for {@link EndpointConnector} 22 | * 23 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface EndpointConnectorConfiguration extends ConnectorConfiguration {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/EndpointConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.DeploymentContext; 19 | 20 | /** 21 | * Specialized factory for {@link EndpointConnector} 22 | * @deprecated see {@link HttpEndpointConnectorFactory} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface EndpointConnectorFactory extends HttpEndpointConnectorFactory { 26 | /** 27 | * Allow creating new endpoint connector from the given strings configuration. 28 | * This method might look redundant with {@link BaseEndpointConnectorFactory#createConnector(DeploymentContext, String, String)} but it needs to remain here for the existing plugins which inherit from it. 29 | * 30 | * @param deploymentContext context containing useful deployment entities (api, services, ...). 31 | * @param configuration the configuration as json string. 32 | * @param sharedConfiguration the shared configuration as json string. 33 | * 34 | * @return new connector instance. 35 | */ 36 | default T createConnector(final DeploymentContext deploymentContext, final String configuration, final String sharedConfiguration) { 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/EndpointConnectorSharedConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | /** 19 | * @author Yann TAVERNIER (yann.tavernier at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface EndpointConnectorSharedConfiguration {} 23 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/HttpEndpointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 20 | import io.reactivex.rxjava3.core.Completable; 21 | 22 | /** 23 | * Interface describing Endpoint Connector which could be implemented to deal with new protocol specification 24 | * 25 | * @author GraviteeSource Team 26 | */ 27 | public interface HttpEndpointConnector extends BaseEndpointConnector { 28 | @Override 29 | default Completable connect(final HttpExecutionContext ctx) { 30 | return connect((ExecutionContext) ctx); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/HttpEndpointConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | /** 19 | * Specialized factory for {@link BaseEndpointConnector} 20 | */ 21 | public interface HttpEndpointConnectorFactory extends BaseEndpointConnectorFactory {} 22 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/TcpEndpointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 20 | import io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext; 21 | import io.reactivex.rxjava3.core.Completable; 22 | 23 | /** 24 | * Interface describing Endpoint Connector which could be implemented to deal with new protocol specification 25 | * 26 | * @author GraviteeSource Team 27 | */ 28 | public interface TcpEndpointConnector extends BaseEndpointConnector { 29 | @Override 30 | default Completable connect(final TcpExecutionContext ctx) { 31 | return connect((ExecutionContext) ctx); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/async/EndpointAsyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.async; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.connector.endpoint.EndpointConnector; 20 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 21 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 22 | import io.reactivex.rxjava3.core.Completable; 23 | 24 | /** 25 | * Specialized {@link EndpointConnector} for {@link ApiType#MESSAGE} 26 | * @deprecated see {@link HttpEndpointAsyncConnector} 27 | */ 28 | @Deprecated(forRemoval = true) 29 | public abstract class EndpointAsyncConnector extends HttpEndpointAsyncConnector implements EndpointConnector { 30 | 31 | public abstract Completable subscribe(final ExecutionContext ctx); 32 | 33 | @Override 34 | public Completable subscribe(HttpExecutionContext ctx) { 35 | return subscribe((ExecutionContext) ctx); 36 | } 37 | 38 | public abstract Completable publish(final ExecutionContext ctx); 39 | 40 | @Override 41 | public Completable publish(HttpExecutionContext ctx) { 42 | return publish((ExecutionContext) ctx); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/async/EndpointAsyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.async; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.endpoint.EndpointConnectorFactory; 21 | import io.gravitee.gateway.reactive.api.qos.Qos; 22 | import java.util.Set; 23 | 24 | /** 25 | * Specialized factory for {@link EndpointAsyncConnector} 26 | * @deprecated see {@link HttpEndpointAsyncConnectorFactory} 27 | */ 28 | @Deprecated(forRemoval = true) 29 | public interface EndpointAsyncConnectorFactory extends EndpointConnectorFactory { 30 | @Override 31 | default ApiType supportedApi() { 32 | return ApiType.MESSAGE; 33 | } 34 | 35 | /** 36 | * Returns a set of {@link ConnectorMode} supported by this connector. It will be used to resolve the proper connector. 37 | * 38 | * @return set of {@link ConnectorMode} supported by this connector. 39 | */ 40 | Set supportedQos(); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/async/HttpEndpointAsyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.async; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.endpoint.HttpEndpointConnectorFactory; 21 | import io.gravitee.gateway.reactive.api.qos.Qos; 22 | import java.util.Set; 23 | 24 | /** 25 | * Specialized factory for {@link HttpEndpointAsyncConnector} 26 | */ 27 | public interface HttpEndpointAsyncConnectorFactory extends HttpEndpointConnectorFactory { 28 | @Override 29 | default ApiType supportedApi() { 30 | return ApiType.MESSAGE; 31 | } 32 | 33 | /** 34 | * Returns a set of {@link ConnectorMode} supported by this connector. It will be used to resolve the proper connector. 35 | * 36 | * @return set of {@link ConnectorMode} supported by this connector. 37 | */ 38 | Set supportedQos(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/sync/EndpointSyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.connector.endpoint.EndpointConnector; 20 | 21 | /** 22 | * Specialized {@link EndpointConnector} for {@link ApiType#PROXY} 23 | * @deprecated see {@link HttpEndpointSyncConnector 24 | */ 25 | @Deprecated(forRemoval = true) 26 | public abstract class EndpointSyncConnector extends HttpEndpointSyncConnector implements EndpointConnector {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/sync/EndpointSyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.endpoint.EndpointConnectorFactory; 21 | import java.util.Set; 22 | 23 | /** 24 | * Specialized factory for {@link EndpointSyncConnector} 25 | * @deprecated see {@link HttpEndpointSyncConnectorFactory} 26 | */ 27 | @Deprecated(forRemoval = true) 28 | public interface EndpointSyncConnectorFactory extends EndpointConnectorFactory { 29 | @Override 30 | default Set supportedModes() { 31 | return Set.of(ConnectorMode.REQUEST_RESPONSE); 32 | } 33 | 34 | @Override 35 | default ApiType supportedApi() { 36 | return ApiType.PROXY; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/sync/HttpEndpointSyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.sync; 17 | 18 | import io.gravitee.common.service.AbstractService; 19 | import io.gravitee.gateway.reactive.api.ApiType; 20 | import io.gravitee.gateway.reactive.api.connector.Connector; 21 | import io.gravitee.gateway.reactive.api.connector.endpoint.HttpEndpointConnector; 22 | 23 | /** 24 | * Specialized {@link HttpEndpointConnector} for {@link ApiType#PROXY} 25 | */ 26 | public abstract class HttpEndpointSyncConnector extends AbstractService implements HttpEndpointConnector { 27 | 28 | @Override 29 | public ApiType supportedApi() { 30 | return ApiType.PROXY; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/endpoint/sync/HttpEndpointSyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.endpoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.endpoint.HttpEndpointConnectorFactory; 21 | import java.util.Set; 22 | 23 | /** 24 | * Specialized factory for {@link HttpEndpointSyncConnector} 25 | */ 26 | public interface HttpEndpointSyncConnectorFactory extends HttpEndpointConnectorFactory { 27 | @Override 28 | default Set supportedModes() { 29 | return Set.of(ConnectorMode.REQUEST_RESPONSE); 30 | } 31 | 32 | @Override 33 | default ApiType supportedApi() { 34 | return ApiType.PROXY; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/EntrypointConnectorConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint; 17 | 18 | import io.gravitee.gateway.reactive.api.connector.ConnectorConfiguration; 19 | 20 | /** 21 | * Default empty configuration for {@link EntrypointConnector} 22 | * 23 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface EntrypointConnectorConfiguration extends ConnectorConfiguration {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/EntrypointConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint; 17 | 18 | import io.gravitee.gateway.reactive.api.ListenerType; 19 | import io.gravitee.gateway.reactive.api.connector.ConnectorFactory; 20 | import io.gravitee.gateway.reactive.api.context.DeploymentContext; 21 | 22 | /** 23 | * Specialized factory for {@link BaseEntrypointConnector} 24 | */ 25 | public interface EntrypointConnectorFactory extends ConnectorFactory { 26 | ListenerType supportedListenerType(); 27 | 28 | /** 29 | * Allow creating new entrypoint connector from the given string configuration. 30 | * 31 | * @param deploymentContext context containing useful deployment entities (api, services, ...). 32 | * @param configuration the configuration as json string. 33 | * 34 | * @return new connector instance. 35 | */ 36 | T createConnector(final DeploymentContext deploymentContext, final String configuration); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/HttpEntrypointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 19 | 20 | /** 21 | * Interface describing Entrypoint Connector which could be implemented to deal with HTTP protocol specification 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpEntrypointConnector extends BaseEntrypointConnector {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/TcpEntrypointConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint; 17 | 18 | import io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext; 19 | 20 | /** 21 | * Interface describing Entrypoint Connector which could be implemented to deal with TCP protocol specification 22 | * @author GraviteeSource Team 23 | */ 24 | public interface TcpEntrypointConnector extends BaseEntrypointConnector {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/async/EntrypointAsyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.async; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnector; 20 | 21 | /** 22 | * Specialized {@link EntrypointConnector} for {@link ApiType#MESSAGE} 23 | * @deprecated see {@link HttpEntrypointAsyncConnector} 24 | */ 25 | @Deprecated(forRemoval = true) 26 | public abstract class EntrypointAsyncConnector extends HttpEntrypointAsyncConnector implements EntrypointConnector {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/sync/EntrypointSyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnector; 20 | 21 | /** 22 | * Specialized {@link EntrypointConnector} for {@link ApiType#PROXY} 23 | * @deprecated see {@link HttpEntrypointSyncConnector} 24 | */ 25 | @Deprecated(forRemoval = true) 26 | public abstract class EntrypointSyncConnector extends HttpEntrypointSyncConnector implements EntrypointConnector {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/sync/EntrypointSyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnectorFactory; 21 | import java.util.Set; 22 | 23 | /** 24 | * Specialized factory for {@link EntrypointSyncConnector} 25 | * @deprecated see {@link HttpEntrypointSyncConnectorFactory} 26 | */ 27 | @Deprecated(forRemoval = true) 28 | public interface EntrypointSyncConnectorFactory extends EntrypointConnectorFactory { 29 | @Override 30 | default Set supportedModes() { 31 | return Set.of(ConnectorMode.REQUEST_RESPONSE); 32 | } 33 | 34 | @Override 35 | default ApiType supportedApi() { 36 | return ApiType.PROXY; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/sync/HttpEntrypointSyncConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.sync; 17 | 18 | import io.gravitee.common.service.AbstractService; 19 | import io.gravitee.gateway.reactive.api.ApiType; 20 | import io.gravitee.gateway.reactive.api.connector.Connector; 21 | import io.gravitee.gateway.reactive.api.connector.entrypoint.HttpEntrypointConnector; 22 | 23 | /** 24 | * Specialized {@link HttpEntrypointConnector} for {@link ApiType#PROXY} 25 | */ 26 | public abstract class HttpEntrypointSyncConnector extends AbstractService implements HttpEntrypointConnector { 27 | 28 | @Override 29 | public ApiType supportedApi() { 30 | return ApiType.PROXY; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/connector/entrypoint/sync/HttpEntrypointSyncConnectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.sync; 17 | 18 | import io.gravitee.gateway.reactive.api.ApiType; 19 | import io.gravitee.gateway.reactive.api.ConnectorMode; 20 | import io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnectorFactory; 21 | import java.util.Set; 22 | 23 | /** 24 | * Specialized factory for {@link HttpEntrypointSyncConnector} 25 | */ 26 | public interface HttpEntrypointSyncConnectorFactory extends EntrypointConnectorFactory { 27 | @Override 28 | default Set supportedModes() { 29 | return Set.of(ConnectorMode.REQUEST_RESPONSE); 30 | } 31 | 32 | @Override 33 | default ApiType supportedApi() { 34 | return ApiType.PROXY; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/DeploymentContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.el.TemplateEngine; 19 | import io.gravitee.el.TemplateVariableProvider; 20 | import java.util.Collection; 21 | 22 | /** 23 | * The {@link DeploymentContext} allows to access useful information at deployment time. 24 | * It is the responsibility of the implementation to give access to the component of its choice (ex: api definition, services components, ...). 25 | * 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface DeploymentContext { 30 | /** 31 | * Returns the component corresponding to the specified componentClass. 32 | * 33 | * @param componentClass the {@link Class} of the expected component to retrieve. 34 | * @param the expected instance type. 35 | * 36 | * @return the component or null if no component found. 37 | */ 38 | T getComponent(Class componentClass); 39 | 40 | /** 41 | * Get the {@link TemplateEngine} that can be used to evaluate EL expressions. 42 | * 43 | * @return the El {@link TemplateEngine}. 44 | */ 45 | TemplateEngine getTemplateEngine(); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/ExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext} 20 | */ 21 | @Deprecated(forRemoval = true) 22 | public interface ExecutionContext 23 | extends 24 | HttpExecutionContext, 25 | MessageExecutionContext, 26 | TcpExecutionContext, 27 | io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext, 28 | io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext { 29 | @Override 30 | Request request(); 31 | 32 | @Override 33 | Response response(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/GenericExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpBaseExecutionContext; 19 | 20 | /** 21 | * @deprecated see {@link HttpBaseExecutionContext} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface GenericExecutionContext extends HttpBaseExecutionContext { 25 | /** 26 | * Get the current request stuck to this execution context. 27 | * 28 | * @return the request attached to this execution context. 29 | */ 30 | GenericRequest request(); 31 | 32 | /** 33 | * Get the current response stuck to this execution context. 34 | * 35 | * @return the response attached to this execution context. 36 | */ 37 | GenericResponse response(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/GenericRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpBaseRequest; 19 | import javax.net.ssl.SSLSession; 20 | 21 | /** 22 | * @deprecated see {@link HttpBaseRequest} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface GenericRequest extends HttpBaseRequest { 26 | /** 27 | * @return SSLSession associated to the request. Returns null if not an SSL connection. 28 | * @see SSLSession 29 | * @deprecated use {@link #tlsSession()} instead 30 | */ 31 | @Deprecated(since = "4.5.0", forRemoval = true) 32 | SSLSession sslSession(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/GenericResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpBaseResponse; 19 | 20 | /** 21 | * @deprecated see {@link HttpBaseResponse} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface GenericResponse extends HttpBaseResponse { 25 | GenericResponse status(int statusCode); 26 | 27 | GenericResponse reason(final String message); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/HttpExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpPlainExecutionContext; 19 | 20 | /** 21 | * @deprecated see {@link HttpPlainExecutionContext} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface HttpExecutionContext extends GenericExecutionContext, HttpPlainExecutionContext { 25 | @Override 26 | HttpRequest request(); 27 | 28 | @Override 29 | HttpResponse response(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/HttpRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpPlainRequest; 19 | 20 | /** 21 | * @deprecated see {@link HttpPlainRequest} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface HttpRequest extends GenericRequest, HttpPlainRequest {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/HttpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpPlainResponse; 19 | 20 | /** 21 | * @deprecated see {@link HttpPlainResponse} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface HttpResponse extends GenericResponse, HttpPlainResponse {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/MessageExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpMessageExecutionContext; 19 | 20 | /** 21 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpMessageExecutionContext} 22 | */ 23 | @Deprecated(forRemoval = true) 24 | public interface MessageExecutionContext extends GenericExecutionContext, HttpMessageExecutionContext { 25 | /** 26 | * Get the current request stuck to this execution context. 27 | * 28 | * @return the request attached to this execution context. 29 | */ 30 | MessageRequest request(); 31 | 32 | /** 33 | * Get the current response stuck to this execution context. 34 | * 35 | * @return the response attached to this execution context. 36 | */ 37 | MessageResponse response(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/MessageRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpMessageRequest; 19 | import io.gravitee.gateway.reactive.api.message.Message; 20 | import io.reactivex.rxjava3.core.Completable; 21 | import io.reactivex.rxjava3.core.Flowable; 22 | import io.reactivex.rxjava3.core.FlowableTransformer; 23 | import io.reactivex.rxjava3.core.Maybe; 24 | import java.util.function.Function; 25 | 26 | /** 27 | * Represents a request that can manipulate a flow of messages. 28 | * 29 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 30 | * @author GraviteeSource Team 31 | * 32 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpMessageRequest} 33 | */ 34 | @Deprecated(forRemoval = true) 35 | public interface MessageRequest extends GenericRequest, HttpMessageRequest {} 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/MessageResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpMessageResponse; 19 | import io.gravitee.gateway.reactive.api.message.Message; 20 | import io.reactivex.rxjava3.core.Completable; 21 | import io.reactivex.rxjava3.core.Flowable; 22 | import io.reactivex.rxjava3.core.FlowableTransformer; 23 | import io.reactivex.rxjava3.core.Maybe; 24 | import java.util.function.Function; 25 | 26 | /** 27 | * Represents a response that can manipulate a flow of messages. 28 | * 29 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 30 | * @author GraviteeSource Team 31 | * 32 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpMessageResponse} 33 | */ 34 | @Deprecated(forRemoval = true) 35 | public interface MessageResponse extends GenericResponse, HttpMessageResponse {} 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 20 | * @author GraviteeSource Team 21 | * 22 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpRequest} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface Request extends HttpRequest, MessageRequest, TcpRequest, io.gravitee.gateway.reactive.api.context.http.HttpRequest {} 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 20 | * @author GraviteeSource Team 21 | * 22 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.http.HttpResponse} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface Response extends HttpResponse, MessageResponse, TcpResponse, io.gravitee.gateway.reactive.api.context.http.HttpResponse {} 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/TcpExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext} 20 | */ 21 | @Deprecated(forRemoval = true) 22 | public interface TcpExecutionContext extends GenericExecutionContext, io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext { 23 | @Override 24 | TcpRequest request(); 25 | 26 | @Override 27 | TcpResponse response(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/TcpRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) 20 | * @author GraviteeSource Team 21 | * 22 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.tcp.TcpRequest} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface TcpRequest extends GenericRequest, io.gravitee.gateway.reactive.api.context.tcp.TcpRequest {} 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/TcpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | /** 19 | * @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) 20 | * @author GraviteeSource Team 21 | * 22 | * @deprecated see {@link io.gravitee.gateway.reactive.api.context.tcp.TcpResponse} 23 | */ 24 | @Deprecated(forRemoval = true) 25 | public interface TcpResponse extends GenericResponse, io.gravitee.gateway.reactive.api.context.tcp.TcpResponse {} 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/TlsSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context; 17 | 18 | import javax.net.ssl.SSLSession; 19 | 20 | public interface TlsSession extends SSLSession { 21 | /** 22 | * @return true if request is an SSL connection 23 | */ 24 | boolean isSSLConnection(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/BaseMessageExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.el.TemplateEngine; 19 | import io.gravitee.gateway.reactive.api.message.Message; 20 | import io.reactivex.rxjava3.core.Flowable; 21 | import io.reactivex.rxjava3.core.Maybe; 22 | 23 | /** 24 | * Base interface any message execution context interface can inherit from. 25 | * 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface BaseMessageExecutionContext extends BaseExecutionContext { 30 | String TEMPLATE_ATTRIBUTE_MESSAGE = "message"; 31 | 32 | /** 33 | * Interrupts the current execution while indicating that the flow of messages can be consumed "as is" to the downstream. 34 | * This has direct impact on how the remaining execution flow will behave (ex: remaining policies in a policy chain won't be executed). 35 | */ 36 | Flowable interruptMessages(); 37 | 38 | /** 39 | * Same as {@link BaseMessageExecutionContext#interruptMessages} but at message level 40 | */ 41 | Maybe interruptMessage(); 42 | 43 | /** 44 | * Get the {@link TemplateEngine} that can be used to evaluate EL expressions. 45 | * 46 | * @return the El {@link TemplateEngine}. 47 | */ 48 | TemplateEngine getTemplateEngine(Message message); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/BaseRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.gateway.reactive.api.context.TlsSession; 19 | import javax.net.ssl.SSLSession; 20 | 21 | /** 22 | * Defines the common information that can be accessed for any request type. 23 | * 24 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface BaseRequest {} 28 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/BaseResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | /** 19 | * Defines the common information that can be accessed for any response type. 20 | * 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface BaseResponse {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/NativeExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.gateway.reactive.api.context.kafka.KafkaExecutionContext; 19 | 20 | /** 21 | * Base interface any specialized native execution context interface can inherit from (e.g. {@link KafkaExecutionContext}). 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface NativeExecutionContext extends BaseExecutionContext {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/NativeMessageExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.gateway.reactive.api.context.kafka.KafkaMessageExecutionContext; 19 | 20 | /** 21 | * Base interface any specialized native message execution context interfaces can inherit from (e.g. {@link KafkaMessageExecutionContext}). 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface NativeMessageExecutionContext extends BaseExecutionContext {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/NativeRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.BaseRequest; 19 | 20 | /** 21 | * Represents a native request that can be specialized (e.g. Kafka). 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface NativeRequest extends BaseRequest {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/base/NativeResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.base; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.BaseRequest; 19 | 20 | /** 21 | * Represents a native response that can be specialized (e.g. Kafka). 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface NativeResponse extends BaseResponse {} 27 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/http/HttpBaseExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.http; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.BaseExecutionContext; 19 | 20 | /** 21 | * Base interface any http-based execution context interface can inherit from. 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface HttpBaseExecutionContext extends BaseExecutionContext { 27 | /** 28 | * Get the current request stuck to this execution context. 29 | * 30 | * @return the request attached to this execution context. 31 | */ 32 | HttpBaseRequest request(); 33 | 34 | /** 35 | * Get the current response stuck to this execution context. 36 | * 37 | * @return the response attached to this execution context. 38 | */ 39 | HttpBaseResponse response(); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/http/HttpExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.http; 17 | 18 | /** 19 | * Allows accessing the specificities related to {@link HttpPlainExecutionContext} and {@link HttpMessageExecutionContext} from a http context that can mutate from plain to messages. 20 | * 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpExecutionContext extends HttpPlainExecutionContext, HttpMessageExecutionContext { 25 | @Override 26 | HttpRequest request(); 27 | 28 | @Override 29 | HttpResponse response(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/http/HttpRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.http; 17 | 18 | /** 19 | * Allows accessing the specificities related to {@link HttpPlainRequest} and {@link HttpMessageResponse} from a http request that can mutate from plain to messages. 20 | * 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpRequest extends HttpPlainRequest, HttpMessageRequest {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/http/HttpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.http; 17 | 18 | /** 19 | * Allows accessing the specificities related to {@link HttpPlainRequest} and {@link HttpMessageResponse} from a http request that can mutate from plain to messages. 20 | * 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpResponse extends HttpPlainResponse, HttpMessageResponse {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/KafkaMessageExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka; 17 | 18 | import io.gravitee.el.TemplateEngine; 19 | import io.gravitee.gateway.reactive.api.context.base.NativeMessageExecutionContext; 20 | import io.gravitee.gateway.reactive.api.message.kafka.KafkaMessage; 21 | import org.apache.kafka.common.security.auth.KafkaPrincipal; 22 | 23 | /** 24 | * Message execution context specialized for Kafka. 25 | * 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | public interface KafkaMessageExecutionContext extends NativeMessageExecutionContext { 30 | String TEMPLATE_ATTRIBUTE_MESSAGE = "message"; 31 | 32 | /** 33 | * Access the execution context. 34 | * @return the execution context. 35 | */ 36 | KafkaExecutionContext executionContext(); 37 | 38 | /** 39 | * Get the current request attached to this execution context. 40 | * @return the request. 41 | */ 42 | KafkaMessageRequest request(); 43 | 44 | /** 45 | * Get the current response attached to this execution context when it is available. 46 | * @return the response. 47 | */ 48 | KafkaMessageResponse response(); 49 | 50 | /** 51 | * Access the principal of the current execution context. 52 | * @return the principal of the current execution context. 53 | */ 54 | KafkaPrincipal principal(); 55 | 56 | /** 57 | * Get the {@link TemplateEngine} that can be used to evaluate EL expressions. 58 | * 59 | * @param message the message to evaluate. 60 | * @return the El {@link TemplateEngine}. 61 | */ 62 | TemplateEngine getTemplateEngine(KafkaMessage message); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/KafkaRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.NativeRequest; 19 | import org.apache.kafka.common.requests.AbstractRequest; 20 | 21 | /** 22 | * Represents a request that can manipulate a Kafka native request. 23 | * 24 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface KafkaRequest extends NativeRequest { 28 | /** 29 | * Access the underlying native Kafka request. 30 | * @return the Kafka native request. 31 | */ 32 | T delegate(); 33 | 34 | /** 35 | * Register that the request has been updated during its processing and need to be rebuilt before sending it. 36 | */ 37 | void notifyChange(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/KafkaResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.NativeResponse; 19 | import org.apache.kafka.common.requests.AbstractResponse; 20 | 21 | /** 22 | * Represents a response that can manipulate a Kafka native response. 23 | * 24 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface KafkaResponse extends NativeResponse { 28 | /** 29 | * Access the underlying native Kafka response. 30 | * @return the Kafka native response. 31 | */ 32 | T delegate(); 33 | 34 | /** 35 | * Register that the response has been updated during its processing and need to be rebuilt before sending it. 36 | */ 37 | void notifyChange(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/NetworkController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka; 17 | 18 | import java.time.Duration; 19 | 20 | public interface NetworkController { 21 | /** 22 | * Pauses the acceptance of incoming data for the specified duration. 23 | * The flow is resumed once the duration is over or an explicit call to {@link #resume()} is performed. 24 | * 25 | * @param duration the duration to apply before calling resume. 26 | */ 27 | void pause(Duration duration); 28 | 29 | /** 30 | * Immediately resume the flow of incoming data. 31 | */ 32 | void resume(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/topicidentity/TopicIdentity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka.topicidentity; 17 | 18 | import org.apache.kafka.common.Uuid; 19 | 20 | public record TopicIdentity(Uuid id, String name, Source source) { 21 | public enum Source { 22 | BROKER, 23 | CLIENT, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/kafka/topicidentity/TopicIdentityRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.kafka.topicidentity; 17 | 18 | import java.util.Optional; 19 | import org.apache.kafka.common.Uuid; 20 | 21 | public interface TopicIdentityRegistry { 22 | /** 23 | * Find a topic identity by its name 24 | * @param name the name of the topic. 25 | * @return Optional of {@link TopicIdentity} 26 | */ 27 | Optional findByName(String name); 28 | 29 | /** 30 | * Find a topic identity by its id 31 | * @param id Uuid of the topic. 32 | * @return Optional of {@link TopicIdentity}. 33 | */ 34 | Optional findById(Uuid id); 35 | 36 | /** 37 | * Put a topic identity in the registry 38 | * @param topicIdentity {@link TopicIdentity} 39 | */ 40 | void put(TopicIdentity topicIdentity); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/context/tcp/TcpExecutionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.context.tcp; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.BaseExecutionContext; 19 | 20 | /** 21 | * Execution context specialized for Tcp. 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface TcpExecutionContext extends BaseExecutionContext { 27 | /** 28 | * Get the current request stuck to this execution context. 29 | * 30 | * @return the request attached to this execution context. 31 | */ 32 | TcpRequest request(); 33 | 34 | /** 35 | * Get the current response stuck to this execution context. 36 | * 37 | * @return the response attached to this execution context. 38 | */ 39 | TcpResponse response(); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/el/EvaluableMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.el; 17 | 18 | import io.gravitee.gateway.api.http.HttpHeaders; 19 | import io.gravitee.gateway.reactive.api.message.Message; 20 | import java.util.Map; 21 | import java.util.Set; 22 | 23 | /** 24 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public class EvaluableMessage { 28 | 29 | private final Message message; 30 | 31 | public EvaluableMessage(Message message) { 32 | this.message = message; 33 | } 34 | 35 | public Set geAttributeNames() { 36 | return message.attributeNames(); 37 | } 38 | 39 | public Map getAttributes() { 40 | return message.attributes(); 41 | } 42 | 43 | public String getId() { 44 | return message.id(); 45 | } 46 | 47 | public boolean getError() { 48 | return message.error(); 49 | } 50 | 51 | public Map getMetadata() { 52 | return message.metadata(); 53 | } 54 | 55 | public HttpHeaders getHeaders() { 56 | return message.headers(); 57 | } 58 | 59 | public String getContent() { 60 | return message.content().toString(); 61 | } 62 | 63 | public int getContentLength() { 64 | return message.content().length(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/exception/MessageProcessingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.exception; 17 | 18 | public class MessageProcessingException extends Exception { 19 | 20 | public MessageProcessingException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/exception/PluginConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.exception; 17 | 18 | public class PluginConfigurationException extends Exception { 19 | 20 | public PluginConfigurationException(String message, Exception cause) { 21 | super(message, cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/ChainHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour on a chain 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ChainHook extends Hook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/Hook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | import io.gravitee.gateway.reactive.api.ExecutionFailure; 19 | import io.gravitee.gateway.reactive.api.ExecutionPhase; 20 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 21 | import io.reactivex.rxjava3.annotations.Nullable; 22 | import io.reactivex.rxjava3.core.Completable; 23 | 24 | /** 25 | * Interface that can be used to add generic behaviour 26 | * 27 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 28 | * @author GraviteeSource Team 29 | * 30 | * @deprecated see {@link HttpHook} 31 | */ 32 | @Deprecated(forRemoval = true) 33 | public interface Hook extends HttpHook {} 34 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/Hookable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | /** 22 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 23 | * @author GraviteeSource Team 24 | */ 25 | public interface Hookable { 26 | default void addHooks(final T... hooks) { 27 | addHooks(Arrays.asList(hooks)); 28 | } 29 | 30 | void addHooks(final List hooks); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/InvokerHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface InvokerHook extends HttpHook {} 23 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/InvokerMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour on messages on invoker 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface InvokerMessageHook extends MessageHook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/PolicyHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour while executing a policy phase 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface PolicyHook extends HttpHook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/PolicyMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour on messages on policy 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface PolicyMessageHook extends MessageHook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/ProcessorHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour on processors 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface ProcessorHook extends HttpHook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/hook/SecurityPlanHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.hook; 17 | 18 | /** 19 | * Interface that can be used to add hook behaviour while executing a security plan execution 20 | * 21 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface SecurityPlanHook extends HttpHook {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/invoker/BaseInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.invoker; 17 | 18 | import io.gravitee.gateway.reactive.api.context.base.BaseExecutionContext; 19 | import io.reactivex.rxjava3.core.Completable; 20 | 21 | /** 22 | * Dedicated interface inspired from original {@link io.gravitee.gateway.api.Invoker} interface allowing to invoke an invoker in a reactive manner. 23 | * 24 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 25 | * @author GraviteeSource Team 26 | */ 27 | public interface BaseInvoker { 28 | String getId(); 29 | 30 | Completable invoke(C ctx); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/invoker/HttpInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.invoker; 17 | 18 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 19 | 20 | /** 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface HttpInvoker extends BaseInvoker {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/invoker/Invoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.invoker; 17 | 18 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.http.HttpExecutionContext; 20 | import io.reactivex.rxjava3.core.Completable; 21 | 22 | /** 23 | * Dedicated interface inspired from original {@link io.gravitee.gateway.api.Invoker} interface allowing to invoke an invoker in a reactive manner. 24 | * @deprecated see {@link HttpInvoker} 25 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | @Deprecated(forRemoval = true) 29 | public interface Invoker extends HttpInvoker { 30 | Completable invoke(ExecutionContext ctx); 31 | 32 | @Override 33 | default Completable invoke(HttpExecutionContext ctx) { 34 | return invoke((ExecutionContext) ctx); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/invoker/TcpInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.invoker; 17 | 18 | import io.gravitee.gateway.reactive.api.context.tcp.TcpExecutionContext; 19 | 20 | /** 21 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 22 | * @author GraviteeSource Team 23 | */ 24 | public interface TcpInvoker extends BaseInvoker {} 25 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/policy/Policy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.policy; 17 | 18 | import io.gravitee.gateway.reactive.api.context.HttpExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.MessageExecutionContext; 20 | import io.gravitee.gateway.reactive.api.context.http.HttpMessageExecutionContext; 21 | import io.gravitee.gateway.reactive.api.context.http.HttpPlainExecutionContext; 22 | import io.gravitee.gateway.reactive.api.policy.http.HttpPolicy; 23 | import io.reactivex.rxjava3.core.Completable; 24 | 25 | /** 26 | * @deprecated see {@link HttpPolicy} 27 | */ 28 | @Deprecated(forRemoval = true) 29 | public interface Policy extends HttpPolicy { 30 | default Completable onRequest(final HttpExecutionContext ctx) { 31 | return Completable.complete(); 32 | } 33 | 34 | default Completable onResponse(final HttpExecutionContext ctx) { 35 | return Completable.complete(); 36 | } 37 | 38 | default Completable onMessageRequest(final MessageExecutionContext ctx) { 39 | return Completable.complete(); 40 | } 41 | 42 | default Completable onMessageResponse(final MessageExecutionContext ctx) { 43 | return Completable.complete(); 44 | } 45 | 46 | default Completable onRequest(final HttpPlainExecutionContext ctx) { 47 | return onRequest((HttpExecutionContext) ctx); 48 | } 49 | 50 | default Completable onResponse(final HttpPlainExecutionContext ctx) { 51 | return onResponse((HttpExecutionContext) ctx); 52 | } 53 | 54 | default Completable onMessageRequest(final HttpMessageExecutionContext ctx) { 55 | return onMessageRequest((MessageExecutionContext) ctx); 56 | } 57 | 58 | default Completable onMessageResponse(final HttpMessageExecutionContext ctx) { 59 | return onMessageResponse((MessageExecutionContext) ctx); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/policy/SecurityPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.policy; 17 | 18 | import io.gravitee.gateway.reactive.api.context.HttpExecutionContext; 19 | import io.gravitee.gateway.reactive.api.context.MessageExecutionContext; 20 | import io.gravitee.gateway.reactive.api.context.http.HttpMessageExecutionContext; 21 | import io.gravitee.gateway.reactive.api.context.http.HttpPlainExecutionContext; 22 | import io.gravitee.gateway.reactive.api.policy.http.HttpSecurityPolicy; 23 | import io.reactivex.rxjava3.core.Completable; 24 | import io.reactivex.rxjava3.core.Maybe; 25 | 26 | /** 27 | * @deprecated see {@link HttpSecurityPolicy} 28 | */ 29 | @Deprecated(forRemoval = true) 30 | public interface SecurityPolicy extends HttpSecurityPolicy, Policy { 31 | default Maybe extractSecurityToken(HttpPlainExecutionContext ctx) { 32 | return extractSecurityToken((HttpExecutionContext) ctx); 33 | } 34 | 35 | Maybe extractSecurityToken(final HttpExecutionContext ctx); 36 | 37 | @Override 38 | default Completable onResponse(final HttpExecutionContext ctx) { 39 | return Policy.super.onResponse(ctx); 40 | } 41 | 42 | @Override 43 | default Completable onResponse(final HttpPlainExecutionContext ctx) { 44 | return HttpSecurityPolicy.super.onResponse(ctx); 45 | } 46 | 47 | @Override 48 | default Completable onMessageResponse(final MessageExecutionContext ctx) { 49 | return Policy.super.onMessageResponse(ctx); 50 | } 51 | 52 | @Override 53 | default Completable onMessageResponse(final HttpMessageExecutionContext ctx) { 54 | return HttpSecurityPolicy.super.onMessageResponse(ctx); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/policy/base/BasePolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.policy.base; 17 | 18 | /** 19 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 20 | * @author GraviteeSource Team 21 | */ 22 | public interface BasePolicy { 23 | /** 24 | * The id of the policy (usually the same id as defined in the policy manifest) 25 | * 26 | * @return the id of the policy. 27 | */ 28 | String id(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/qos/QosCapability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.qos; 17 | 18 | import com.fasterxml.jackson.annotation.JsonValue; 19 | import io.gravitee.gateway.reactive.api.message.Message; 20 | import java.util.Map; 21 | import lombok.Getter; 22 | import lombok.RequiredArgsConstructor; 23 | 24 | /** 25 | * This enum list the qos capabilities required or supportted respectively by {@link io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnector} and {@link io.gravitee.gateway.reactive.api.connector.endpoint.EndpointConnector}. 26 | * 27 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 28 | * @author GraviteeSource Team 29 | */ 30 | @RequiredArgsConstructor 31 | @Getter 32 | public enum QosCapability { 33 | /** 34 | * This means manual acknowledgment are required or supported. Specific action must be done at message level to perform the acknowledgment. 35 | * 36 | * @see Message#ack() 37 | */ 38 | MANUAL_ACK("manual-ack"), 39 | /** 40 | * This means auto acknowledgment is required or supported. No specific action is required at message level. 41 | */ 42 | AUTO_ACK("auto-ack"), 43 | /** 44 | * Capability offers a way to recover from an event id. 45 | * */ 46 | RECOVER("recover"); 47 | 48 | private static final Map maps = Map.of( 49 | MANUAL_ACK.label, 50 | MANUAL_ACK, 51 | AUTO_ACK.label, 52 | AUTO_ACK, 53 | RECOVER.label, 54 | RECOVER 55 | ); 56 | 57 | @JsonValue 58 | private final String label; 59 | 60 | public static QosCapability fromLabel(final String label) { 61 | if (label != null) { 62 | return maps.get(label); 63 | } 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/qos/QosRequirement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.qos; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Builder; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | 25 | /** 26 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @Getter 32 | @Builder 33 | public class QosRequirement { 34 | 35 | /** 36 | * This refers to the {@link Qos} configured on the {@link io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnector}. 37 | * By default, the qos is {@link Qos#AUTO} 38 | */ 39 | @Builder.Default 40 | private Qos qos = Qos.AUTO; 41 | 42 | /** 43 | * Set of {@link QosCapability} required to support the related {@link QosRequirement#qos} 44 | */ 45 | @Builder.Default 46 | private Set capabilities = new HashSet<>(); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/service/dlq/DlqService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.service.dlq; 17 | 18 | import io.gravitee.gateway.reactive.api.message.Message; 19 | import io.reactivex.rxjava3.core.Flowable; 20 | import java.util.concurrent.Flow; 21 | 22 | /** 23 | * Allows applying behavior on a flow of messages in order to filter messages in error and send them ot a Dead Letter Queue. 24 | * 25 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | public interface DlqService { 29 | /** 30 | * Set up the dead letter queue mechanism on the incoming flow of messages. 31 | * It is the responsibility of the implementation to filter incoming messages and send only the appropriate subset of messages to the DLQ 32 | * (ex: message in error, message matching a particular condition, ..). 33 | * 34 | * @param messages the incoming flow of messages. 35 | * 36 | * @return the original flow of messages, so it can be chained easily. 37 | */ 38 | Flowable apply(Flowable messages); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/service/dlq/DlqServiceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.service.dlq; 17 | 18 | import io.gravitee.gateway.reactive.api.connector.entrypoint.EntrypointConnector; 19 | 20 | /** 21 | * Factory allowing to instantiate a {@link DlqService} for the specified {@link EntrypointConnector}. 22 | * 23 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 24 | * @author GraviteeSource Team 25 | */ 26 | public interface DlqServiceFactory { 27 | /** 28 | * Create and return a {@link DlqService} that can be used for the specified connector. 29 | * In any cases, it always returns a {@link DlqService} that can be safely used without checking for nullability.. 30 | * 31 | * @param connector the entrypoint connector for which create a {@link DlqService}. 32 | * @return the created {@link DlqService}. 33 | */ 34 | DlqService create(final EntrypointConnector connector); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/tracing/message/TracingMessageMessagingSystem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.tracing.message; 17 | 18 | import lombok.Getter; 19 | import lombok.RequiredArgsConstructor; 20 | import lombok.experimental.Accessors; 21 | 22 | /** 23 | * See {@link Semantic Conventions Messaging} 24 | * 25 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | @RequiredArgsConstructor 29 | @Getter 30 | @Accessors(fluent = true) 31 | public enum TracingMessageMessagingSystem { 32 | ACTIVEMQ("activemq"), 33 | AWS_SQS("aws_sqs"), 34 | EVENTGRID("eventgrid"), 35 | EVENTHUBS("eventhubs"), 36 | GCP_PUBSUB("gcp_pubsub"), 37 | JMS("jms"), 38 | KAFKA("kafka"), 39 | PULSAR("pulsar"), 40 | RABBITMQ("rabbitmq"), 41 | ROCKETMQ("rocketmq"), 42 | SERVICEBUS("servicebus"); 43 | 44 | private final String value; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/gravitee/gateway/reactive/api/tracing/message/TracingMessageOperationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.tracing.message; 17 | 18 | import lombok.Getter; 19 | import lombok.RequiredArgsConstructor; 20 | import lombok.experimental.Accessors; 21 | 22 | /** 23 | * See {@link Semantic Conventions Messaging} 24 | * 25 | * @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) 26 | * @author GraviteeSource Team 27 | */ 28 | @RequiredArgsConstructor 29 | @Getter 30 | @Accessors(fluent = true) 31 | public enum TracingMessageOperationType { 32 | CREATE("create"), 33 | PROCESS("process"), 34 | RECEIVE("receive"), 35 | SEND("send"), 36 | SETTLE("settle"); 37 | 38 | private final String value; 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/io/gravitee/gateway/api/el/EvaluableExtractorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.api.el; 17 | 18 | import java.io.IOException; 19 | import org.junit.jupiter.api.Test; 20 | 21 | public class EvaluableExtractorTest { 22 | 23 | @Test 24 | public void generateGrammarJson() throws IOException { 25 | EvaluableExtractor extractor = new EvaluableExtractor(); 26 | extractor.run(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/io/gravitee/gateway/reactive/api/connector/entrypoint/async/EntrypointAsyncConnectorImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.connector.entrypoint.async; 17 | 18 | import io.gravitee.gateway.reactive.api.ConnectorMode; 19 | import io.gravitee.gateway.reactive.api.ListenerType; 20 | import io.gravitee.gateway.reactive.api.context.ExecutionContext; 21 | import io.gravitee.gateway.reactive.api.qos.QosRequirement; 22 | import io.reactivex.rxjava3.core.Completable; 23 | import java.util.Set; 24 | 25 | /** 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | class EntrypointAsyncConnectorImpl extends EntrypointAsyncConnector { 30 | 31 | @Override 32 | public String id() { 33 | return null; 34 | } 35 | 36 | @Override 37 | public Set supportedModes() { 38 | return null; 39 | } 40 | 41 | @Override 42 | public ListenerType supportedListenerType() { 43 | return null; 44 | } 45 | 46 | @Override 47 | public int matchCriteriaCount() { 48 | return 0; 49 | } 50 | 51 | @Override 52 | public boolean matches(ExecutionContext executionContext) { 53 | return false; 54 | } 55 | 56 | @Override 57 | public Completable handleRequest(ExecutionContext executionContext) { 58 | return null; 59 | } 60 | 61 | @Override 62 | public Completable handleResponse(ExecutionContext executionContext) { 63 | return null; 64 | } 65 | 66 | @Override 67 | public QosRequirement qosRequirement() { 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/test/java/io/gravitee/gateway/reactive/api/el/EvaluableRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.el; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 19 | 20 | import io.gravitee.gateway.reactive.api.context.GenericRequest; 21 | import io.gravitee.gateway.reactive.api.context.http.HttpBaseRequest; 22 | import org.junit.jupiter.api.Test; 23 | import org.mockito.Mockito; 24 | 25 | /** 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | class EvaluableRequestTest { 30 | 31 | @Test 32 | void should_construct_with_http_base_request() { 33 | HttpBaseRequest httpBaseRequest = Mockito.mock(HttpBaseRequest.class); 34 | assertDoesNotThrow(() -> new EvaluableRequest(httpBaseRequest)); 35 | } 36 | 37 | @Test 38 | void should_construct_with_http_base_request_and_content() { 39 | HttpBaseRequest httpBaseRequest = Mockito.mock(HttpBaseRequest.class); 40 | assertDoesNotThrow(() -> new EvaluableRequest(httpBaseRequest, "content")); 41 | } 42 | 43 | @Test 44 | void should_construct_with_generic_request() { 45 | GenericRequest genericRequest = Mockito.mock(GenericRequest.class); 46 | assertDoesNotThrow(() -> new EvaluableRequest(genericRequest)); 47 | } 48 | 49 | @Test 50 | void should_construct_with_generic_request_and_content() { 51 | GenericRequest genericRequest = Mockito.mock(GenericRequest.class); 52 | assertDoesNotThrow(() -> new EvaluableRequest(genericRequest, "content")); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/io/gravitee/gateway/reactive/api/el/EvaluableResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gravitee.gateway.reactive.api.el; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 19 | 20 | import io.gravitee.gateway.reactive.api.context.GenericResponse; 21 | import io.gravitee.gateway.reactive.api.context.http.HttpBaseResponse; 22 | import org.junit.jupiter.api.Test; 23 | import org.mockito.Mockito; 24 | 25 | /** 26 | * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com) 27 | * @author GraviteeSource Team 28 | */ 29 | class EvaluableResponseTest { 30 | 31 | @Test 32 | void should_construct_with_http_base_response() { 33 | HttpBaseResponse httpBaseResponse = Mockito.mock(HttpBaseResponse.class); 34 | assertDoesNotThrow(() -> new EvaluableResponse(httpBaseResponse)); 35 | } 36 | 37 | @Test 38 | void should_construct_with_http_base_response_and_content() { 39 | HttpBaseResponse httpBaseResponse = Mockito.mock(HttpBaseResponse.class); 40 | assertDoesNotThrow(() -> new EvaluableResponse(httpBaseResponse, "content")); 41 | } 42 | 43 | @Test 44 | void should_construct_with_generic_response() { 45 | GenericResponse genericResponse = Mockito.mock(GenericResponse.class); 46 | assertDoesNotThrow(() -> new EvaluableResponse(genericResponse)); 47 | } 48 | 49 | @Test 50 | void should_construct_with_generic_response_and_content() { 51 | GenericResponse genericResponse = Mockito.mock(GenericResponse.class); 52 | assertDoesNotThrow(() -> new EvaluableResponse(genericResponse, "content")); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline --------------------------------------------------------------------------------