File tree Expand file tree Collapse file tree
extending-membrane/embedding-java
src/main/java/com/predic8/membrane/api
websockets/custom-websocket-interceptor/embedded
src/main/java/com/predic8/application Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 </plugins >
2020 </build >
2121
22-
2322 <dependencies >
24- <dependency >
25- <groupId >ch.qos.logback</groupId >
26- <artifactId >logback-classic</artifactId >
27- <version >1.5.16</version >
28- </dependency >
2923 <dependency >
3024 <groupId >org.membrane-soa</groupId >
3125 <artifactId >service-proxy-core</artifactId >
3226 <version >7.0.6-SNAPSHOT</version >
3327 </dependency >
3428 <dependency >
35- <groupId >org.projectlombok</groupId >
36- <artifactId >lombok</artifactId >
37- <version >1.18.36</version >
38- <scope >provided</scope >
29+ <groupId >org.apache.logging.log4j</groupId >
30+ <artifactId >log4j-core</artifactId >
31+ <version >2.25.3</version >
32+ </dependency >
33+ <dependency >
34+ <groupId >org.apache.logging.log4j</groupId >
35+ <artifactId >log4j-slf4j2-impl</artifactId >
36+ <version >2.25.3</version >
3937 </dependency >
4038 </dependencies >
4139</project >
Original file line number Diff line number Diff line change 1313 limitations under the License. */
1414package com .predic8 .membrane .api ;
1515
16- import com .predic8 .membrane .core .exchange . Exchange ;
17- import com .predic8 .membrane .core .interceptor . AbstractInterceptor ;
18- import com .predic8 .membrane .core .interceptor . Outcome ;
19- import lombok . extern . log4j . Log4j2 ;
20- import java . lang . Override ;
16+ import com .predic8 .membrane .core .* ;
17+ import com .predic8 .membrane .core .router .* ;
18+ import com .predic8 .membrane .core .exchange .* ;
19+ import com . predic8 . membrane . core . interceptor .* ;
20+ import org . slf4j .* ;
2121
2222/**
2323 * A custom interceptor which adds the header 'X-Hello' to the HTTP request.
2424 *
2525 * @author Oliver Weiler
2626 */
27- @ Log4j2
2827public class AddMyHeaderInterceptor extends AbstractInterceptor {
28+
29+ private static final Logger log = LoggerFactory .getLogger (AddMyHeaderInterceptor .class );
30+
2931 @ Override
3032 public Outcome handleRequest (Exchange exchange ) {
31- log .info (exchange .getRequest ().getHeader ().getUserAgent ());
33+ // Reading an HTTP Header
34+ log .info ("User agent: {}" ,exchange .getRequest ().getHeader ().getUserAgent ());
35+
36+ // Adding a HTTP Header
3237 exchange .getRequest ().getHeader ().add ("X-Hello" , "Hello World!" );
33- log .info (exchange .getRequest ());
38+
39+ // Logging the HTTP Request
40+ log .info ("Request: {}" , exchange .getRequest ());
3441 return Outcome .CONTINUE ;
3542 }
3643}
Original file line number Diff line number Diff line change 1313 limitations under the License. */
1414package com .predic8 .membrane .api ;
1515
16- import com .predic8 .membrane .core .HttpRouter ;
16+ import com .predic8 .membrane .core .*;
17+ import com .predic8 .membrane .core .router .*;
1718import com .predic8 .membrane .core .openapi .serviceproxy .APIProxy ;
1819import com .predic8 .membrane .core .proxies .ServiceProxyKey ;
1920
@@ -42,14 +43,13 @@ public static void main(String[] args) throws Exception {
4243
4344 APIProxy api = new APIProxy ();
4445 api .setKey (key );
45- api .setTargetHost ("api.predic8.de" );
46- api .setTargetPort (80 );
46+ api .getTarget ().setUrl ("https://api.predic8.de" );
4747
48- // Add a simple interceptor as plugin
49- api .getInterceptors ().add (new AddMyHeaderInterceptor ());
48+ // Add a simple interceptor
49+ api .getFlow ().add (new AddMyHeaderInterceptor ());
5050
51- HttpRouter router = new HttpRouter ();
51+ Router router = new DefaultRouter ();
5252 router .add (api );
53- router .init ();
53+ router .start ();
5454 }
5555}
Original file line number Diff line number Diff line change 1212 <!-- https://mvnrepository.com/artifact/org.membrane-soa/membrane-service-proxy -->
1313 <dependency >
1414 <groupId >org.membrane-soa</groupId >
15- <artifactId >membrane-service-proxy</artifactId >
16- <version >5.3.6-SNAPSHOT</version >
15+ <artifactId >service-proxy-core</artifactId >
16+ <version >7.0.6-SNAPSHOT</version >
17+ </dependency >
18+ <dependency >
19+ <groupId >org.apache.logging.log4j</groupId >
20+ <artifactId >log4j-core</artifactId >
21+ <version >2.25.3</version >
22+ </dependency >
23+ <dependency >
24+ <groupId >org.apache.logging.log4j</groupId >
25+ <artifactId >log4j-slf4j2-impl</artifactId >
26+ <version >2.25.3</version >
1727 </dependency >
1828 </dependencies >
1929
2333 <groupId >org.apache.maven.plugins</groupId >
2434 <artifactId >maven-compiler-plugin</artifactId >
2535 <configuration >
26- <source >1.8 </source >
27- <target >1.8 </target >
36+ <source >21 </source >
37+ <target >21 </target >
2838 </configuration >
2939 </plugin >
3040 <plugin >
Original file line number Diff line number Diff line change 1616
1717package com .predic8 .application ;
1818
19- import com .predic8 .membrane .core .HttpRouter ;
2019import com .predic8 .membrane .core .interceptor .tunnel .WebSocketInterceptor ;
2120import com .predic8 .membrane .core .interceptor .websocket .custom .MyWebSocketLogInterceptor ;
2221import com .predic8 .membrane .core .proxies .ServiceProxy ;
2322import com .predic8 .membrane .core .proxies .ServiceProxyKey ;
23+ import com .predic8 .membrane .core .*;
2424
2525public class MyApplication {
2626
@@ -32,15 +32,15 @@ public static void main(String[] args) throws Exception {
3232
3333 // create an enclosing WebSocket interceptor to add our own Logging interceptor to it
3434 WebSocketInterceptor ws = new WebSocketInterceptor ();
35- ws .getInterceptors ().add (new MyWebSocketLogInterceptor ());
35+ ws .getFlow ().add (new MyWebSocketLogInterceptor ());
3636
3737 // attach the WebSocket interceptor to the service proxy
38- sp .getInterceptors ().add (ws );
38+ sp .getFlow ().add (ws );
3939
4040 // add the service proxy to a new router instance and start it
41- HttpRouter router = new HttpRouter ();
41+ Router router = new DefaultRouter ();
4242 router .add (sp );
43- router .init ();
43+ router .start ();
4444
4545 System .out .println ("Starting finished - Waiting for WebSocket communication" );
4646 }
Original file line number Diff line number Diff line change 1414
1515# 7.X
1616
17+ - Fix maven central publish job
1718- JMXExporter:
1819 - Tutorial
1920 - Documentation
You can’t perform that action at this time.
0 commit comments