Skip to content

Commit 8b7fe85

Browse files
committed
Merge remote-tracking branch 'origin/patch-with-no-body-fix' into patch-with-no-body-fix
2 parents 4359f43 + 75fc9dd commit 8b7fe85

69 files changed

Lines changed: 3045 additions & 1170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ api:
5656
htpasswdPath: .htpasswd
5757
- request:
5858
- template:
59+
contentType: application/json
5960
src: |
6061
{
61-
"sub": "${fn.user()}"
62+
"sub": ${user()}
6263
}
6364
- jwtSign:
6465
jwk:
@@ -716,7 +717,7 @@ api:
716717
contentType: application/json
717718
src: |
718719
{
719-
"destination": "${json.city}"
720+
"destination": ${json.city}
720721
}
721722
- return:
722723
status: 200
@@ -750,7 +751,7 @@ api:
750751
- request:
751752
- template:
752753
src: |
753-
Buenas noches, ${fn.xpath('/person/@firstname')}
754+
Buenas noches, ${xpath('/person/@firstname')}
754755
- return:
755756
status: 200
756757
```

annot/pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
15-
--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
15+
-->
16+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1618

1719
<modelVersion>4.0.0</modelVersion>
1820
<artifactId>service-proxy-annot</artifactId>
1921
<name>${project.artifactId}</name>
2022
<packaging>jar</packaging>
2123

22-
<parent>
23-
<groupId>org.membrane-soa</groupId>
24-
<artifactId>service-proxy-parent</artifactId>
25-
<relativePath>../pom.xml</relativePath>
26-
<version>7.0.7-SNAPSHOT</version>
27-
</parent>
24+
<parent>
25+
<groupId>org.membrane-soa</groupId>
26+
<artifactId>service-proxy-parent</artifactId>
27+
<relativePath>../pom.xml</relativePath>
28+
<version>7.0.7-SNAPSHOT</version>
29+
</parent>
2830

2931
<dependencies>
3032
<dependency>
@@ -64,6 +66,11 @@
6466
<artifactId>jakarta.annotation-api</artifactId>
6567
<version>3.0.0</version>
6668
</dependency>
69+
<dependency>
70+
<groupId>com.jayway.jsonpath</groupId>
71+
<artifactId>json-path</artifactId>
72+
<version>2.10.0</version>
73+
</dependency>
6774

6875
<!-- Test dependencies -->
6976
<dependency>

annot/src/main/java/com/predic8/membrane/annot/MCChildElement.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
limitations under the License. */
1414
package com.predic8.membrane.annot;
1515

16-
import java.lang.annotation.ElementType;
17-
import java.lang.annotation.Retention;
18-
import java.lang.annotation.RetentionPolicy;
19-
import java.lang.annotation.Target;
16+
import java.lang.annotation.*;
2017

21-
@Target(ElementType.METHOD)
22-
@Retention(RetentionPolicy.RUNTIME)
18+
import static java.lang.annotation.ElementType.*;
19+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
20+
21+
@Target(METHOD)
22+
@Retention(RUNTIME)
2323
public @interface MCChildElement {
2424

2525
/**

annot/src/main/java/com/predic8/membrane/annot/bean/BeanFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
package com.predic8.membrane.annot.bean;
1616

1717
import com.fasterxml.jackson.databind.*;
18-
import com.predic8.membrane.annot.beanregistry.BeanRegistry;
18+
import com.predic8.membrane.annot.beanregistry.*;
1919
import com.predic8.membrane.annot.util.*;
20+
import com.predic8.membrane.annot.yaml.*;
2021
import org.jetbrains.annotations.*;
2122

2223
import java.lang.reflect.*;
2324
import java.util.*;
2425
import java.util.stream.*;
2526

26-
import static com.predic8.membrane.annot.util.ReflectionUtil.isWrapperOfPrimitive;
27+
import static com.predic8.membrane.annot.util.ReflectionUtil.*;
2728

2829
/**
2930
* Builds Java objects from a "bean" JSON node (YAML).

annot/src/main/java/com/predic8/membrane/annot/beanregistry/BeanContainer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import com.predic8.membrane.annot.Grammar;
1818
import com.predic8.membrane.annot.bean.BeanFactory;
19-
import com.predic8.membrane.annot.yaml.GenericYamlParser;
19+
import com.predic8.membrane.annot.yaml.*;
2020
import org.jetbrains.annotations.*;
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ public class BeanContainer {
3030
/**
3131
* The class of the bean.
3232
*/
33-
private final Class clazz;
33+
private final Class<?> clazz;
3434
/**
3535
* Constructed bean after initialization.
3636
*/
@@ -88,7 +88,11 @@ public String toString() {
8888
grammar,
8989
definition.getNode(),
9090
registry);
91-
} catch (Exception e) {
91+
} catch (ConfigurationParsingException e) {
92+
throw e;
93+
}
94+
catch (Exception e) {
95+
log.error("Could not instantiate bean: {}", definition.getNode(), e);
9296
throw new RuntimeException(e);
9397
}
9498
}
@@ -101,7 +105,6 @@ public String toString() {
101105
return define(registry, grammar);
102106
}
103107

104-
105108
// Singleton: ensure define() runs at most once per BeanContainer.
106109
synchronized (this) {
107110
Object existing = getSingleton();

annot/src/main/java/com/predic8/membrane/annot/beanregistry/BeanRegistryImplementation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.predic8.membrane.annot.beanregistry;
1515

1616
import com.predic8.membrane.annot.*;
17-
import com.predic8.membrane.annot.bean.*;
1817
import com.predic8.membrane.annot.yaml.*;
1918
import org.jetbrains.annotations.*;
2019
import org.slf4j.*;
@@ -126,7 +125,10 @@ private void activationRun() {
126125
bcs.remove(bc.getDefinition().getUid());
127126
}
128127
uidsToRemove.add(uidAction);
129-
} catch (Exception e) {
128+
} catch (ConfigurationParsingException e) {
129+
throw e;
130+
}
131+
catch (Exception e) {
130132
log.error("Could not handle {} {}/{}", uidAction.action,
131133
bc.getDefinition().getNamespace(), bc.getDefinition().getName(), e);
132134
throw new RuntimeException(e);
@@ -156,7 +158,6 @@ public Object resolve(String url) {
156158
public List<Object> getBeans() {
157159
return bcs.values().stream().filter(bd -> !bd.getDefinition().isComponent())
158160
.map(bc -> bc.getOrCreate(this, grammar))
159-
.filter(Objects::nonNull)
160161
.toList();
161162
}
162163

@@ -170,7 +171,6 @@ public <T> List<T> getBeans(Class<T> clazz) {
170171
return bcs.values().stream()
171172
.filter(bd -> bd.produces(clazz))
172173
.map(bc -> bc.getOrCreate(this, grammar))
173-
.filter(Objects::nonNull)
174174
.filter(clazz::isInstance)
175175
.map(clazz::cast)
176176
.toList();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* Copyright 2026 predic8 GmbH, www.predic8.com
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
14+
15+
package com.predic8.membrane.annot.yaml;
16+
17+
import com.fasterxml.jackson.core.*;
18+
import com.fasterxml.jackson.databind.*;
19+
20+
import static com.predic8.membrane.annot.yaml.error.LineYamlErrorRenderer.renderErrorReport;
21+
22+
public class ConfigurationParsingException extends RuntimeException {
23+
24+
private ParsingContext<?> parsingContext;
25+
private JsonNode wrong;
26+
27+
public ConfigurationParsingException(String message) {
28+
super(message);
29+
}
30+
31+
public ConfigurationParsingException(Throwable cause) {
32+
super(cause);
33+
}
34+
35+
public ConfigurationParsingException(String message, Throwable cause, ParsingContext<?> pc) {
36+
super(message, cause);
37+
this.parsingContext = pc;
38+
}
39+
40+
public ParsingContext<?> getParsingContext() {
41+
return parsingContext;
42+
}
43+
44+
public void setParsingContext(ParsingContext<?> parsingContext) {
45+
this.parsingContext = parsingContext;
46+
}
47+
48+
/**
49+
* Returns a complete formatted error report including highlighted YAML.
50+
*/
51+
public String getFormattedReport() throws JsonProcessingException {
52+
return renderErrorReport(this.parsingContext);
53+
}
54+
55+
public JsonNode getWrong() {
56+
return wrong;
57+
}
58+
59+
public void setWrong(JsonNode wrong) {
60+
this.wrong = wrong;
61+
}
62+
}

0 commit comments

Comments
 (0)