Skip to content

Commit

Permalink
feat: support new OpenTelemetry feature
Browse files Browse the repository at this point in the history
BREAKING CHANGE: tracer and components are no longer allowed for groovy context
  • Loading branch information
jhaeyaert authored and guillaumelamirand committed Nov 6, 2024
1 parent 132ba2b commit 14ca260
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 66 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>io.gravitee.policy</groupId>
<artifactId>gravitee-policy-groovy</artifactId>
<version>2.6.2</version>
<version>3.0.0-archi-401-opentelemetry-SNAPSHOT</version>

<name>Gravitee.io APIM - Policy - Groovy</name>
<description>Run Groovy scripts at any stage of request or message processing</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author GraviteeSource Team
*/
@Value
public class BindableExecutionContext implements GenericExecutionContext {
public class BindableExecutionContext {

private static final String CONTEXT_DICTIONARIES_VARIABLE = "dictionaries";

Expand All @@ -44,17 +44,14 @@ public Map<String, String> getDictionaries() {
.lookupVariable(CONTEXT_DICTIONARIES_VARIABLE);
}

@Override
public GenericRequest request() {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public GenericResponse response() {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public Metrics metrics() {
return executionContext.metrics();
}
Expand All @@ -63,73 +60,31 @@ public Metrics getMetrics() {
return executionContext.metrics();
}

@Override
public <T> T getComponent(Class<T> aClass) {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public void setAttribute(String s, Object o) {
executionContext.setAttribute(s, o);
}

@Override
public void putAttribute(String s, Object o) {
executionContext.putAttribute(s, o);
}

@Override
public void removeAttribute(String s) {
executionContext.removeAttribute(s);
}

@Override
public <T> T getAttribute(String s) {
return executionContext.getAttribute(s);
}

@Override
public <T> List<T> getAttributeAsList(String s) {
return executionContext.getAttributeAsList(s);
}

@Override
public Set<String> getAttributeNames() {
return executionContext.getAttributeNames();
}

@Override
public <T> Map<String, T> getAttributes() {
return executionContext.getAttributes();
}

@Override
public void setInternalAttribute(String s, Object o) {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public void putInternalAttribute(String s, Object o) {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public void removeInternalAttribute(String s) {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public <T> T getInternalAttribute(String s) {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public <T> Map<String, T> getInternalAttributes() {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}

@Override
public TemplateEngine getTemplateEngine() {
throw new UnsupportedOperationException("Groovy scripts do not support accessing this method");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
public class AttributesBasedExecutionContext implements ExecutionContext {
public class AttributesBasedExecutionContext {

private static final String CONTEXT_DICTIONARIES_VARIABLE = "dictionaries";
private final ExecutionContext context;
Expand All @@ -42,53 +42,35 @@ public Map<String, Map<String, String>> getDictionaries() {
.lookupVariable(CONTEXT_DICTIONARIES_VARIABLE);
}

@Override
public Request request() {
return context.request();
}

@Override
public Response response() {
return context.response();
}

@Override
public <T> T getComponent(Class<T> aClass) {
return context.getComponent(aClass);
}

@Override
public void setAttribute(String s, Object o) {
context.setAttribute(s, o);
}

@Override
public void removeAttribute(String s) {
context.removeAttribute(s);
}

@Override
public Object getAttribute(String s) {
return context.getAttribute(s);
}

@Override
public Enumeration<String> getAttributeNames() {
return context.getAttributeNames();
}

@Override
public Map<String, Object> getAttributes() {
return context.getAttributes();
}

@Override
public TemplateEngine getTemplateEngine() {
return context.getTemplateEngine();
}

@Override
public Tracer getTracer() {
return context.getTracer();
}
}

0 comments on commit 14ca260

Please sign in to comment.