Merge pull request #1 from a-rekkusu/master
initial project push
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a33e1f0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+# ignore eclipse files
+.project
+.classpath
+.settings
+.metadata
+target
+
+# ignore IDEA files
+*.iml
+*.ipr
+*.iws
+.idea
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..57bc88a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..860361e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,6 @@
+Apache OpenWebBeans
+Copyright 2008 - 2020 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/README.md b/README.md
index 1333ed7..f02bf37 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,51 @@
-TODO
+# Peeco: an OWB centric HTTP microserver
+
+This repository is one of the results of a [GSOC 2020 (Google Summer of Code) project]((https://gist.github.com/a-rekkusu/b98ecd201d25102ca3e118a2fa38fbb4)) for [OpenWebBeans](https://openwebbeans.apache.org/) at ASF.
+Its intention is to provide a very small and lightweight HTTP server with CDI functionalities at its core, that should hopefully become natively runnable soon, as a GraalVM native-image.
+For the server components, [Netty](https://netty.io/) is used.
+This repository contains the API, implementation and a showcase in the respective sub-modules.
+
+Here's an example for how to configure and build this server:
+```java
+public HttpServer init()
+{
+ return new HttpServer.Builder()
+ .port(0) //applies a random valid port
+ .ssl(false)
+ .host("localhost")
+ .build();
+}
+```
+
+And here's how you can use the API with the `HttpHandler` annotation:
+```java
+@Inject private HttpServer httpServer;
+
+@HttpHandler(method = {HttpMethod.GET}, url = "/hello/*", matching = Matching.WILDCARD)
+public CompletionStage<Response> helloWorld(Request request)
+{
+ String responseContent = "Hello World from " + httpServer.getHost() + ":" + httpServer.getPort() + " !";
+ ByteArrayInputStream output = new ByteArrayInputStream(responseContent.getBytes(StandardCharsets.UTF_8));
+
+ return CompletableFuture.supplyAsync(() ->
+ {
+ Response response = new Response();
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+ response.setOutput(output);
+ return response;
+ });
+}
+```
+
+This is a reactive example with CompletionStage; you can also straight up use Response as the method return type.
+The formal requirements of a valid handler method and annotation are:
+- return type must be `CompletionStage<Response>` or `Response`
+- first method parameter must be `Request`
+- `Matching.WILDCARD` needs a star at the end of the given url
+
+For more examples please refer to the respective [showcase.](https://github.com/a-rekkusu/owb-centric-microserver/blob/master/showcase/src/main/java/org/apache/peeco/showcase/HelloWorldHandler.java)
+The implementation is found [here.](https://github.com/a-rekkusu/owb-centric-microserver/tree/master/impl/src/main/java/org/apache/peeco/impl)
+
+[`PeecoExtension.java`](https://github.com/a-rekkusu/owb-centric-microserver/blob/master/impl/src/main/java/org/apache/peeco/impl/PeecoExtension.java#L25) collects all methods that are annotated with our `@HttpHandler` and starts up the Netty Server.
+The flow of the request/response handling is then happening in [`PeecoChannelHandler.java`](https://github.com/a-rekkusu/owb-centric-microserver/blob/master/impl/src/main/java/org/apache/peeco/impl/PeecoChannelHandler.java#L44).
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..a9c99a0
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>peeco-api</artifactId>
+ <packaging>jar</packaging>
+
+ <build>
+ <finalName>peeco-api</finalName>
+ </build>
+</project>
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/peeco/api/HttpHandler.java b/api/src/main/java/org/apache/peeco/api/HttpHandler.java
new file mode 100644
index 0000000..59ffde9
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/HttpHandler.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target({METHOD})
+public @interface HttpHandler
+{
+ String url();
+
+ HttpMethod[] method();
+
+ Matching matching();
+}
diff --git a/api/src/main/java/org/apache/peeco/api/HttpMethod.java b/api/src/main/java/org/apache/peeco/api/HttpMethod.java
new file mode 100644
index 0000000..1031b92
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/HttpMethod.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+public enum HttpMethod
+{
+ GET,
+ POST,
+ PUT,
+ DELETE,
+ OPTIONS,
+ HEAD,
+ TRACE,
+ PATCH,
+ CONNECT
+}
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/peeco/api/HttpServer.java b/api/src/main/java/org/apache/peeco/api/HttpServer.java
new file mode 100644
index 0000000..3794907
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/HttpServer.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+public class HttpServer
+{
+
+
+ private int port;
+ private boolean ssl;
+ private String host;
+
+ protected HttpServer()
+ {
+ }
+
+ private HttpServer(Builder builder)
+ {
+ this.port = builder.port;
+ this.ssl = builder.ssl;
+ this.host = builder.host;
+ }
+
+ public void setPort(int port)
+ {
+ this.port = this.port == 0 ? port : this.port;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public boolean isSsl()
+ {
+ return ssl;
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public static class Builder
+ {
+ private int port = 8080;
+ private boolean ssl = false;
+ private String host = "localhost";
+
+ public Builder()
+ {
+ }
+
+ Builder(int port, boolean ssl, String host)
+ {
+ this.port = port;
+ this.ssl = ssl;
+ this.host = host;
+ }
+
+ public Builder port(int port)
+ {
+ this.port = port;
+ return Builder.this;
+ }
+
+ public Builder ssl(boolean ssl)
+ {
+ this.ssl = ssl;
+ return Builder.this;
+ }
+
+ public Builder host(String host)
+ {
+ this.host = host;
+ return Builder.this;
+ }
+
+ public HttpServer build()
+ {
+
+ return new HttpServer(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/peeco/api/Matching.java b/api/src/main/java/org/apache/peeco/api/Matching.java
new file mode 100644
index 0000000..78ce29e
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/Matching.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+public enum Matching
+{
+ EXACT,
+ WILDCARD
+}
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/peeco/api/Request.java b/api/src/main/java/org/apache/peeco/api/Request.java
new file mode 100644
index 0000000..20538c9
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/Request.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class Request
+{
+ private HttpMethod httpMethod;
+ private String url;
+ private InputStream inputStream;
+ private Map<String, List<String>> headers;
+ private Map<String, List<String>> bodyParameters;
+ private Map<String, List<String>> queryParameters;
+
+ public Request(HttpMethod httpMethod, String url, InputStream stream)
+ {
+ this.httpMethod = httpMethod;
+ this.url = url;
+ this.inputStream = stream;
+ this.headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ this.bodyParameters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ this.queryParameters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ }
+
+ public HttpMethod httpMethod()
+ {
+ return httpMethod;
+ }
+
+ public String url()
+ {
+ return url;
+ }
+
+ public InputStream inputStream()
+ {
+ return inputStream;
+ }
+
+ public Map<String, List<String>> headers()
+ {
+ return headers;
+ }
+
+ public Map<String, List<String>> parameters()
+ {
+ Map<String, List<String>> parameters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ parameters.putAll(queryParameters());
+
+ bodyParameters().forEach((s, strings) ->
+ parameters.merge(s, strings, (strings1, strings2) ->
+ {
+ strings1.addAll(strings2);
+ return strings1;
+ }));
+
+ return parameters;
+ }
+
+ public Map<String, List<String>> bodyParameters()
+ {
+ return bodyParameters;
+ }
+
+ public Map<String, List<String>> queryParameters()
+ {
+ return queryParameters;
+ }
+}
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/peeco/api/Response.java b/api/src/main/java/org/apache/peeco/api/Response.java
new file mode 100644
index 0000000..4161e79
--- /dev/null
+++ b/api/src/main/java/org/apache/peeco/api/Response.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.api;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.*;
+
+public class Response
+{
+ private InputStream output;
+ private Map<String, List<String>> headers;
+
+ public Response()
+ {
+ this.output = new ByteArrayInputStream(new byte[0]);
+ this.headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ }
+
+ public Response(InputStream output)
+ {
+ this.output = output;
+ this.headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ }
+
+ public Map<String, List<String>> headers()
+ {
+ return headers;
+ }
+
+ public void addHeader(String name, String value)
+ {
+ headers().computeIfAbsent(name, k -> new ArrayList<>())
+ .add(value);
+ }
+
+ public InputStream output()
+ {
+ return output;
+ }
+
+ public void setOutput(InputStream stream)
+ {
+ this.output = stream;
+ }
+
+ public void setOutput(String output)
+ {
+ setOutput(new ByteArrayInputStream(output.getBytes()));
+ }
+}
\ No newline at end of file
diff --git a/impl/pom.xml b/impl/pom.xml
new file mode 100644
index 0000000..b0d7f73
--- /dev/null
+++ b/impl/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>peeco-impl</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.graalvm.nativeimage</groupId>
+ <artifactId>svm</artifactId>
+ <version>20.2.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>peeco-impl</finalName>
+ </build>
+</project>
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/peeco/impl/HttpHandlerInfo.java b/impl/src/main/java/org/apache/peeco/impl/HttpHandlerInfo.java
new file mode 100644
index 0000000..cb1cc3c
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/HttpHandlerInfo.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.peeco.api.HttpHandler;
+
+public class HttpHandlerInfo
+{
+ Class clazz;
+ Object bean;
+ Method method;
+ HttpHandler annotation;
+
+ HttpHandlerInfo(Class clazz, Method method, HttpHandler annotation)
+ {
+ this.clazz = clazz;
+ this.method = method;
+ this.annotation = annotation;
+ }
+}
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/peeco/impl/NettySubstitutions.java b/impl/src/main/java/org/apache/peeco/impl/NettySubstitutions.java
new file mode 100644
index 0000000..eaeac3e
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/NettySubstitutions.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import io.netty.util.internal.logging.InternalLoggerFactory;
+import io.netty.util.internal.logging.JdkLoggerFactory;
+
+@TargetClass(io.netty.util.internal.logging.InternalLoggerFactory.class)
+final class Target_io_netty_util_internal_logging_InternalLoggerFactory {
+ @Substitute
+ private static InternalLoggerFactory newDefaultFactory(String name) {
+ return JdkLoggerFactory.INSTANCE;
+ }
+}
+public class NettySubstitutions
+{
+}
diff --git a/impl/src/main/java/org/apache/peeco/impl/PeecoChannelHandler.java b/impl/src/main/java/org/apache/peeco/impl/PeecoChannelHandler.java
new file mode 100644
index 0000000..b2d99f1
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/PeecoChannelHandler.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.*;
+import io.netty.handler.codec.http.*;
+import io.netty.handler.codec.http.multipart.*;
+
+import javax.enterprise.context.control.RequestContextController;
+import javax.enterprise.inject.spi.CDI;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletionStage;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.peeco.api.Request;
+import org.apache.peeco.api.Response;
+
+public class PeecoChannelHandler extends SimpleChannelInboundHandler<HttpObject>
+{
+ private static final HttpDataFactory factory = new DefaultHttpDataFactory(16384L);
+ private static final Logger logger = Logger.getLogger(PeecoChannelHandler.class.getName());
+
+ private List<HttpHandlerInfo> httpHandlerInfos;
+ private RequestContextController requestContextController;
+
+ public PeecoChannelHandler(List<HttpHandlerInfo> httpHandlerInfos)
+ {
+ this.httpHandlerInfos = httpHandlerInfos;
+ this.requestContextController = CDI.current().select(RequestContextController.class).get();
+ }
+
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx)
+ {
+ ctx.flush();
+ }
+
+ @Override
+ public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception
+ {
+ if (msg instanceof HttpRequest)
+ {
+ try
+ {
+ requestContextController.activate();
+ HttpRequest nettyRequest = (HttpRequest) msg;
+
+ logger.log(Level.FINE, "Request received: HttpMethod: " + nettyRequest.method() + "; URI: " + nettyRequest.uri());
+
+ HttpHandlerInfo info = PeecoUtils.getMatchingHandler(nettyRequest, httpHandlerInfos);
+
+ logger.log(Level.FINE, "Calling matching HttpHandler: " + info.annotation);
+
+ if (info == null)
+ {
+ throw new Exception("No matching HttpHandler found for incoming URI from Netty Request: " + nettyRequest.uri());
+ }
+
+ Request request = new Request(PeecoUtils.mapHttpMethod(nettyRequest.method()), nettyRequest.uri(), null);
+
+ parseHeaders(nettyRequest, request);
+ parseQueryParams(nettyRequest, request);
+ parseBodyParams(nettyRequest, request);
+
+ Object handlerParentBean = info.bean;
+
+ try
+ {
+ Object returnValue = info.method.invoke(handlerParentBean, request);
+
+ if (returnValue instanceof Response)
+ {
+ Response response = (Response) returnValue;
+
+ ctx.write(createNettyResponse(ctx, response, nettyRequest), ctx.voidPromise());
+ }
+ else if (returnValue instanceof CompletionStage)
+ {
+ CompletionStage<Response> completionStageResponse = (CompletionStage<Response>) returnValue;
+
+ completionStageResponse.thenAccept(response ->
+ {
+ try
+ {
+ ctx.write(createNettyResponse(ctx, response, nettyRequest))
+ .addListener((ChannelFutureListener) channelFuture ->
+ logger.log(Level.FINE, "CompletionStage<Response> is finished"));
+ }
+ catch (IOException ex)
+ {
+ //redundant catch as it's caught in createNettyResponse() already, but IDE requires to catch it here again
+ }
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Failed to create Netty Response from given HttpHandler Response object, Netty ChannelHandlerContext and Netty Request.");
+ }
+ }
+ finally
+ {
+ requestContextController.deactivate();
+ }
+ }
+ }
+
+ public FullHttpResponse createNettyResponse(ChannelHandlerContext ctx, Response response, HttpRequest nettyRequest) throws IOException
+ {
+
+ ByteBuf nettyBuffer = ctx.alloc().buffer(response.output().available());
+
+ try
+ {
+ nettyBuffer.writeBytes(response.output(), response.output().available());
+ }
+ catch (IOException ex)
+ {
+ throw new IOException("Response output from HttpHandler could not be written to Netty ByteBuffer.");
+ }
+
+ FullHttpResponse nettyResponse = new DefaultFullHttpResponse(
+ nettyRequest.protocolVersion(),
+ HttpResponseStatus.OK,
+ nettyBuffer);
+
+ for (Map.Entry<String, List<String>> headers : response.headers().entrySet())
+ {
+ nettyResponse.headers().add(headers.getKey(), headers.getValue());
+ }
+
+ nettyResponse.headers()
+ .setInt(HttpHeaderNames.CONTENT_LENGTH, nettyResponse.content().readableBytes());
+
+ return nettyResponse;
+ }
+
+ protected void parseHeaders(HttpRequest nettyRequest, Request request)
+ {
+ for (Map.Entry<String, String> headers : nettyRequest.headers())
+ {
+ List<String> values = request.headers().computeIfAbsent(headers.getKey(), k -> new ArrayList<>());
+
+ List<String> nettyHeaderValues = Arrays.asList(headers.getValue().split(","));
+
+ for (String value : nettyHeaderValues)
+ {
+ values.add(value);
+ }
+ }
+ }
+
+ protected void parseBodyParams(HttpRequest nettyRequest, Request request)
+ {
+ if (nettyRequest.method().equals(HttpMethod.POST))
+ {
+ HttpPostRequestDecoder decoder = null;
+ try
+ {
+ decoder = new HttpPostRequestDecoder(factory, nettyRequest);
+ for (InterfaceHttpData data : decoder.getBodyHttpDatas())
+ {
+ if (data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute)
+ {
+ Attribute attr = (Attribute) data;
+ List<String> values = request.bodyParameters().computeIfAbsent(data.getName(), k -> new ArrayList<>());
+
+ try
+ {
+ values.add(attr.getValue());
+ }
+ catch (IOException ex)
+ {
+ throw new RuntimeException("Failed to parse attribute values from Netty Request body to " + Request.class.toString());
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (decoder != null)
+ {
+ decoder.destroy();
+ }
+ }
+ }
+ }
+
+ protected void parseQueryParams(HttpRequest nettyRequest, Request request)
+ {
+ QueryStringDecoder decoder = new QueryStringDecoder(nettyRequest.uri());
+
+ for (Map.Entry<String, List<String>> queryParameters : decoder.parameters().entrySet())
+ {
+ List<String> values = request.queryParameters().computeIfAbsent(queryParameters.getKey(), k -> new ArrayList<>());
+
+ for (String value : queryParameters.getValue())
+ {
+ values.add(value);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/peeco/impl/PeecoChannelInitializer.java b/impl/src/main/java/org/apache/peeco/impl/PeecoChannelInitializer.java
new file mode 100644
index 0000000..0d0232e
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/PeecoChannelInitializer.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpServerCodec;
+import io.netty.handler.codec.http.HttpServerExpectContinueHandler;
+import io.netty.handler.ssl.SslContext;
+
+import java.util.List;
+
+public class PeecoChannelInitializer extends ChannelInitializer<SocketChannel>
+{
+ private final SslContext sslCtx;
+ private List<HttpHandlerInfo> httpHandlerInfos;
+
+ public PeecoChannelInitializer(SslContext sslCtx, List<HttpHandlerInfo> httpHandlerInfos)
+ {
+ this.sslCtx = sslCtx;
+ this.httpHandlerInfos = httpHandlerInfos;
+ }
+
+ @Override
+ public void initChannel(SocketChannel ch)
+ {
+ ChannelPipeline p = ch.pipeline();
+ if (this.sslCtx != null)
+ {
+ p.addLast(this.sslCtx.newHandler(ch.alloc()));
+ }
+
+ p.addLast(new HttpServerCodec());
+ p.addLast(new HttpServerExpectContinueHandler());
+ p.addLast("aggregator", new HttpObjectAggregator(Short.MAX_VALUE));
+ p.addLast(new PeecoChannelHandler(httpHandlerInfos));
+ }
+}
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/peeco/impl/PeecoExtension.java b/impl/src/main/java/org/apache/peeco/impl/PeecoExtension.java
new file mode 100644
index 0000000..43dbcbc
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/PeecoExtension.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+import io.netty.handler.ssl.SslContext;
+import io.netty.handler.ssl.SslContextBuilder;
+import io.netty.handler.ssl.util.SelfSignedCertificate;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.peeco.api.HttpHandler;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.*;
+import java.util.*;
+
+import org.apache.peeco.api.HttpServer;
+
+public class PeecoExtension implements Extension
+{
+ private static final Logger logger = Logger.getLogger(PeecoExtension.class.getName());
+ private static final LoggingHandler loggingHandler = new LoggingHandler(LogLevel.DEBUG);
+ private static boolean enabled = true;
+
+ private List<HttpHandlerInfo> httpHandlerInfos = new ArrayList<>();
+
+ public static void disable()
+ {
+ enabled = false;
+ }
+
+ <T> void processAnnotatedType(@Observes @WithAnnotations(HttpHandler.class) ProcessAnnotatedType<T> patEvent) throws Exception
+ {
+ if (!enabled)
+ {
+ return;
+ }
+
+ logger.log(Level.INFO, "----PROCESS ANNOTATED TYPE----");
+
+ List<HttpHandlerInfo> infos = PeecoUtils.collectInfos(patEvent.getAnnotatedType().getJavaClass());
+
+ for (HttpHandlerInfo info : infos)
+ {
+ logger.log(Level.INFO, "Valid HttpHandler found: Class: " + info.clazz +
+ ", Method: " + info.method +
+ ", Annotation: " + info.annotation.url() + ", " + Arrays.toString(info.annotation.method()) + ", " + info.annotation.matching());
+ }
+
+ httpHandlerInfos.addAll(infos);
+ }
+
+ void afterDeploymentValidation(@Observes AfterDeploymentValidation adv, HttpServer httpServer) throws Exception
+ {
+ if (!enabled)
+ {
+ return;
+ }
+
+ for (HttpHandlerInfo info : httpHandlerInfos)
+ {
+ info.bean = CDI.current().select(info.clazz).get();
+ }
+
+ logger.log(Level.INFO, "----AFTER DEPLOYMENT VALIDATION----");
+
+ SslContext sslCtx = null;
+ if (httpServer.isSsl())
+ {
+ SelfSignedCertificate ssc = new SelfSignedCertificate();
+ sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
+ }
+
+ EventLoopGroup bossGroup = new NioEventLoopGroup(1);
+ NioEventLoopGroup workerGroup = new NioEventLoopGroup();
+
+ try
+ {
+ ServerBootstrap b = new ServerBootstrap();
+ b.option(ChannelOption.SO_BACKLOG, 1024);
+ b.group(bossGroup, workerGroup)
+ .channel(NioServerSocketChannel.class)
+ .handler(loggingHandler)
+ .childHandler(new PeecoChannelInitializer(sslCtx, httpHandlerInfos));
+ Channel ch = b.bind(httpServer.getPort()).sync().channel();
+
+ String[] localAddressSplitted = ch.localAddress().toString().split(":");
+ String port = localAddressSplitted[localAddressSplitted.length - 1];
+ System.out.println(port);
+ httpServer.setPort(Integer.parseInt(port));
+
+ //TODO set host in Configuration
+
+ logger.log(Level.INFO, "Peeco started successfully on " + (httpServer.isSsl() ? "https" : "http") +
+ "://127.0.0.1:" + httpServer.getPort() + '/');
+ ch.closeFuture().sync();
+
+ }
+ finally
+ {
+ bossGroup.shutdownGracefully();
+ workerGroup.shutdownGracefully();
+ }
+ }
+
+ public List<HttpHandlerInfo> getHttpHandlerInfos()
+ {
+ return httpHandlerInfos;
+ }
+}
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/peeco/impl/PeecoUtils.java b/impl/src/main/java/org/apache/peeco/impl/PeecoUtils.java
new file mode 100644
index 0000000..7fd9480
--- /dev/null
+++ b/impl/src/main/java/org/apache/peeco/impl/PeecoUtils.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.impl;
+
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpRequest;
+
+import java.lang.reflect.Method;
+
+import org.apache.peeco.api.Matching;
+
+import java.util.*;
+import java.util.concurrent.CompletionStage;
+
+import org.apache.peeco.api.HttpHandler;
+import org.apache.peeco.api.Request;
+import org.apache.peeco.api.Response;
+
+public class PeecoUtils
+{
+
+ public static org.apache.peeco.api.HttpMethod mapHttpMethod(HttpMethod method)
+ {
+ switch (method.name())
+ {
+ case "GET":
+ return org.apache.peeco.api.HttpMethod.GET;
+ case "POST":
+ return org.apache.peeco.api.HttpMethod.POST;
+ case "PUT":
+ return org.apache.peeco.api.HttpMethod.PUT;
+ case "DELETE":
+ return org.apache.peeco.api.HttpMethod.DELETE;
+ case "OPTIONS":
+ return org.apache.peeco.api.HttpMethod.OPTIONS;
+ case "HEAD":
+ return org.apache.peeco.api.HttpMethod.HEAD;
+ case "TRACE":
+ return org.apache.peeco.api.HttpMethod.TRACE;
+ case "CONNECT":
+ return org.apache.peeco.api.HttpMethod.CONNECT;
+ case "PATCH":
+ return org.apache.peeco.api.HttpMethod.PATCH;
+ }
+
+ return null;
+ }
+
+ public static HttpHandlerInfo getMatchingHandler(HttpRequest nettyRequest, List<HttpHandlerInfo> infos) throws RuntimeException
+ {
+ List<HttpHandlerInfo> matchings = new ArrayList<>();
+
+ for (HttpHandlerInfo info : infos)
+ {
+ String handlerUrl = info.annotation.url();
+ String incomingUrl = nettyRequest.uri();
+
+ if (isMatching(info.annotation.matching(), handlerUrl, incomingUrl)
+ && Arrays.asList(info.annotation.method()).contains(mapHttpMethod(nettyRequest.method())))
+ {
+ if (info.annotation.matching() == Matching.EXACT)
+ {
+ return info;
+ }
+
+ matchings.add(info);
+ }
+ }
+
+ if (matchings.size() > 1)
+ {
+ throw new RuntimeException("Multiple HttpHandlers were found for the incoming Netty Request URI: " + nettyRequest.uri() +
+ ". Only one method is allowed.");
+ }
+
+ return matchings.isEmpty() ? null : matchings.get(0);
+ }
+
+ public static boolean isMatching(Matching matching, String configuredUrl, String incomingUrl)
+ {
+ //cut off query parameters
+ if (incomingUrl.contains("?"))
+ {
+ incomingUrl = incomingUrl.substring(0, incomingUrl.indexOf("?"));
+ }
+
+ if (matching == Matching.EXACT)
+ {
+ if (configuredUrl.equals(incomingUrl))
+ {
+ return true;
+ }
+ }
+ else if (matching == Matching.WILDCARD)
+ {
+ if (configuredUrl.startsWith("*"))
+ {
+ if (incomingUrl.endsWith(configuredUrl.substring(1)))
+ {
+ return true;
+ }
+ }
+ else if (configuredUrl.endsWith("*"))
+ {
+ if (incomingUrl.startsWith(configuredUrl.substring(0, configuredUrl.length() - 1)))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static List<HttpHandlerInfo> collectInfos(Class clazz) throws RuntimeException
+ {
+ ArrayList<HttpHandlerInfo> infos = new ArrayList<>();
+
+ for (Method method : clazz.getDeclaredMethods())
+ {
+ if (method.isAnnotationPresent(HttpHandler.class))
+ {
+ Class type = method.getDeclaringClass();
+ HttpHandler annotation = method.getAnnotation(HttpHandler.class);
+ boolean isRequestInParameterTypes = false;
+
+ for (Class parameterType : method.getParameterTypes())
+ {
+ if (parameterType.equals(Request.class))
+ {
+ isRequestInParameterTypes = true;
+ }
+ }
+
+ if (annotation != null
+ && (method.getReturnType() == Response.class || method.getReturnType() == CompletionStage.class)
+ && isRequestInParameterTypes)
+ {
+ infos.add(new HttpHandlerInfo(type, method, annotation));
+ }
+ else
+ {
+ throw new RuntimeException("Invalid method signature: " + method + ". The return type of the annotated method must be " +
+ Response.class.toString() + " or " + CompletionStage.class.toString() + "<Response>. The method signature must contain " +
+ Request.class.toString() + ".");
+ }
+ }
+ }
+
+ //Matching.EXACT should be first in the list
+ Comparator<HttpHandlerInfo> infoMatchingComparator = Comparator.comparing((HttpHandlerInfo info) -> info.annotation.matching());
+ infos.sort(infoMatchingComparator);
+
+ return infos;
+ }
+
+}
\ No newline at end of file
diff --git a/impl/src/main/resources/META-INF/beans.xml b/impl/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..d94996a
--- /dev/null
+++ b/impl/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
+ bean-discovery-mode="all" version="2.0">
+</beans>
diff --git a/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000..039c8ed
--- /dev/null
+++ b/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1,17 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements. See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership. The ASF licenses this file
+#to you under the Apache License, Version 2.0 (the
+#"License"); you may not use this file except in compliance
+#with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing,
+#software distributed under the License is distributed on an
+#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#KIND, either express or implied. See the License for the
+#specific language governing permissions and limitations
+#under the License.
+org.apache.peeco.impl.PeecoExtension
\ No newline at end of file
diff --git a/impl/src/test/java/PeecoUtilsTest.java b/impl/src/test/java/PeecoUtilsTest.java
new file mode 100644
index 0000000..33fd863
--- /dev/null
+++ b/impl/src/test/java/PeecoUtilsTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import org.apache.peeco.api.Matching;
+import org.apache.peeco.impl.PeecoUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PeecoUtilsTest
+{
+ @Test
+ public void testGetMatchingHandlerWildcard()
+ {
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "/hello3/*", "/hello3/id=2342"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "/hello/*", "/hello/world/?lang=en-en"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "/hello/*", "/hello/?lang=de-de"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "/hello3/world/*", "/hello3/world/?id=2342"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "/hello/world*", "/hello/world/?lang=de-de"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.WILDCARD, "*.jpg", "/hello/blub.jpg?lang=de-de"));
+ }
+
+ @Test
+ public void testGetMatchingHandlerExact(){
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.EXACT, "/hello/", "/hello/?lang=de-de"));
+ Assert.assertTrue(PeecoUtils.isMatching(Matching.EXACT, "/hello", "/hello?lang=de-de"));
+ Assert.assertFalse(PeecoUtils.isMatching(Matching.EXACT, "/hello3", "/hello?lang=de-de"));
+ Assert.assertFalse(PeecoUtils.isMatching(Matching.EXACT, "/hello3/", "/hello?lang=de-de"));
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..627356f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <modules>
+ <module>api</module>
+ <module>impl</module>
+ <module>showcase</module>
+ </modules>
+ <packaging>pom</packaging>
+
+ <name>openwebbeans-peeco</name>
+ <url>https://github.com/apache/openwebbeans-peeco/</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.13</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_2.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.3_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <version>2.0.18-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-spi</artifactId>
+ <version>2.0.17</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-se</artifactId>
+ <version>2.0.17</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.50.Final</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>openwebbeans-peeco</finalName>
+ <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
+ <plugins>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>3.2.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.5.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/showcase/pom.xml b/showcase/pom.xml
new file mode 100644
index 0000000..fce0107
--- /dev/null
+++ b/showcase/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>peeco-showcase</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.peeco</groupId>
+ <artifactId>peeco-impl</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>peeco-showcase</finalName>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.2.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>org.apache.peeco.showcase.Bootstrapper</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
\ No newline at end of file
diff --git a/showcase/src/main/java/org/apache/peeco/showcase/Bootstrapper.java b/showcase/src/main/java/org/apache/peeco/showcase/Bootstrapper.java
new file mode 100644
index 0000000..7cd4a78
--- /dev/null
+++ b/showcase/src/main/java/org/apache/peeco/showcase/Bootstrapper.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.showcase;
+
+import org.apache.webbeans.service.ClassLoaderProxyService;
+import org.apache.webbeans.spi.DefiningClassService;
+
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+public class Bootstrapper
+{
+ public static void main(String[] args) throws Exception
+ {
+ try (final SeContainer container = SeContainerInitializer.newInstance()
+ .addProperty(DefiningClassService.class.getName(), ClassLoaderProxyService.LoadFirst.class.getName())
+ .addProperty("org.apache.webbeans.proxy.useStaticNames", "true")
+ .initialize())
+ {
+ HelloWorldHandler handler = container.select(HelloWorldHandler.class).get();
+ System.out.println(handler);
+ }
+ }
+}
diff --git a/showcase/src/main/java/org/apache/peeco/showcase/HelloWorldHandler.java b/showcase/src/main/java/org/apache/peeco/showcase/HelloWorldHandler.java
new file mode 100644
index 0000000..2991bce
--- /dev/null
+++ b/showcase/src/main/java/org/apache/peeco/showcase/HelloWorldHandler.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.showcase;
+
+import org.apache.peeco.api.HttpHandler;
+import org.apache.peeco.api.Matching;
+import org.apache.peeco.api.*;
+
+import javax.enterprise.context.RequestScoped;
+import java.io.ByteArrayInputStream;
+
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+import javax.inject.Inject;
+
+@RequestScoped
+public class HelloWorldHandler
+{
+ @Inject private HttpServer httpServer;
+
+ @HttpHandler(method = {HttpMethod.GET, HttpMethod.POST}, url = "/hello/*", matching = Matching.WILDCARD)
+ public CompletionStage<Response> apply(Request request)
+ {
+ String responseContent = "Responding to /hello/* : Hello World with CompletionStage from " + getClass().getName()
+ + " on " + httpServer.getHost() + " and port " + httpServer.getPort();
+ ByteArrayInputStream output = new ByteArrayInputStream(responseContent.getBytes(StandardCharsets.UTF_8));
+
+ return CompletableFuture.supplyAsync(() ->
+ {
+ Response response = new Response();
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+ response.setOutput(output);
+ return response;
+ });
+ }
+
+ @HttpHandler(method = {HttpMethod.GET}, url = "/hello2", matching = Matching.EXACT)
+ public Response applyWithoutCompletionStage(Request request)
+ {
+ String responseContent = "Responding to /hello2 : Hello World from " + getClass().getName() + "Request query Params: " + request.queryParameters();
+ ByteArrayInputStream output = new ByteArrayInputStream(
+ responseContent.getBytes(StandardCharsets.UTF_8));
+
+ Response response = new Response(output);
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+
+ return response;
+ }
+
+ @HttpHandler(method = {HttpMethod.GET}, url = "/hello3/*", matching = Matching.WILDCARD)
+ public Response applyWithWildcardMatching(Request request){
+ String responseContent = "Responding to /hello3/* : Hello with Wildcard URL from " + getClass().getName();
+ ByteArrayInputStream output = new ByteArrayInputStream(
+ responseContent.getBytes(StandardCharsets.UTF_8));
+
+ Response response = new Response(output);
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+
+ return response;
+ }
+
+ @HttpHandler(method = {HttpMethod.GET, HttpMethod.POST}, url = "/input", matching = Matching.EXACT)
+ public Response inputForm(Request request){
+ StringBuilder builder = new StringBuilder();
+ builder.append("<!DOCTYPE html>\r\n")
+ .append("<html><head><meta charset='utf-8' /><title>")
+ .append("Name Input Form")
+ .append("</title></head><body>\r\n")
+ .append("<form action=\"post\" method=\"POST\">\r\n")
+ .append("Enter your name: \r\n")
+ .append("<input type=\"text\" name=\"user\" />\r\n")
+ .append("<input type=\"submit\" value=\"Submit\" />\r\n")
+ .append("</form>\r\n")
+ .append("</body></html>\r\n");
+
+ String responseContent = builder.toString();
+ ByteArrayInputStream output = new ByteArrayInputStream(
+ responseContent.getBytes(StandardCharsets.UTF_8));
+
+ Response response = new Response(output);
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+
+ return response;
+ }
+
+ @HttpHandler(method = {HttpMethod.POST}, url = "/post", matching = Matching.EXACT)
+ public Response postRequest(Request request){
+ StringBuilder builder = new StringBuilder();
+ builder.append("<!DOCTYPE html>\r\n")
+ .append("<html><head><meta charset='utf-8' /><title>")
+ .append("Welcome title")
+ .append("</title></head><body>\r\n")
+ .append("Echo from Netty: welcome " + request.bodyParameters().get("user").get(0) + "!\r\n")
+ .append("</body></html>\r\n");
+
+ String responseContent = builder.toString();
+ ByteArrayInputStream output = new ByteArrayInputStream(
+ responseContent.getBytes(StandardCharsets.UTF_8));
+
+ Response response = new Response(output);
+ response.addHeader("statusCode", "200");
+ response.addHeader("content-type", "text/html");
+
+ return response;
+ }
+}
diff --git a/showcase/src/main/java/org/apache/peeco/showcase/HttpServerProducer.java b/showcase/src/main/java/org/apache/peeco/showcase/HttpServerProducer.java
new file mode 100644
index 0000000..dee256b
--- /dev/null
+++ b/showcase/src/main/java/org/apache/peeco/showcase/HttpServerProducer.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.showcase;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import org.apache.peeco.api.HttpServer;
+
+@ApplicationScoped
+public class HttpServerProducer
+{
+ @Produces
+ @ApplicationScoped
+ public HttpServer init()
+ {
+ return new HttpServer.Builder()
+ .port(0)
+ .ssl(false)
+ .host("localhost")
+ .build();
+ }
+}
diff --git a/showcase/src/main/java/org/apache/peeco/showcase/proxyGeneration/ProxyGenerator.java b/showcase/src/main/java/org/apache/peeco/showcase/proxyGeneration/ProxyGenerator.java
new file mode 100644
index 0000000..2c8ba3b
--- /dev/null
+++ b/showcase/src/main/java/org/apache/peeco/showcase/proxyGeneration/ProxyGenerator.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.peeco.showcase.proxyGeneration;
+
+import org.apache.peeco.impl.PeecoExtension;
+import org.apache.webbeans.component.ExtensionBean;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.service.ClassLoaderProxyService;
+import org.apache.webbeans.spi.DefiningClassService;
+
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+import javax.enterprise.inject.spi.PassivationCapable;
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static java.util.stream.Collectors.joining;
+
+public class ProxyGenerator
+{
+ public static void main(String[] args)
+ {
+ try
+ {
+ PeecoExtension.disable();
+ final SeContainer container = SeContainerInitializer.newInstance()
+ .addProperty(DefiningClassService.class.getName(), ClassLoaderProxyService.Spy.class.getName()) // no unsafe usage
+ .addProperty("org.apache.webbeans.proxy.useStaticNames", "true") // a bit unsafe but otherwise no way to get pregenerated proxies
+ .initialize();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ ProxyGenerator proxyGenerator = new ProxyGenerator();
+ proxyGenerator.run();
+ }
+
+ public void run()
+ {
+ //TODO: specify some working directory to output the proxy classes to
+ final Path out = Paths.get("");
+ if (!Files.exists(out))
+ {
+ throw new IllegalStateException("You should run compile before this task, missing: " + out);
+ }
+
+ BeanManager beanManager = CDI.current().getBeanManager();
+
+ beanManager.getBeans(Object.class).stream()
+ .filter(b -> beanManager.isNormalScope(b.getScope()) && !isIgnoredBean(b)) // todo: do it also for interception
+ .forEach(it ->
+ {
+ try
+ { // triggers the proxy creation
+ beanManager.getReference(it, Object.class, beanManager.createCreationalContext(null));
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ });
+
+ final String config = ClassLoaderProxyService.Spy.class.cast(WebBeansContext.currentInstance().getService(DefiningClassService.class))
+ .getProxies().entrySet().stream()
+ .map(e ->
+ {
+ final Path target = out.resolve(e.getKey().replace('.', '/') + ".class");
+ try
+ {
+ Files.createDirectories(target.getParent());
+ Files.write(target, e.getValue());
+ }
+ catch (final IOException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ System.out.println("Created proxy '{" + e.getKey() + "}'" );
+ return "<reflection>\n" +
+ "<name>" + e.getKey().replace("$$", "$$$$") + "</name>\n" +
+ "<allDeclaredConstructors>true</allDeclaredConstructors>\n" +
+ "<allDeclaredMethods>true</allDeclaredMethods>\n" +
+ "<allDeclaredFields>true</allDeclaredFields>\n" +
+ "</reflection>";
+ })
+ .collect(joining("\n"));
+ }
+
+
+ private boolean isIgnoredBean(final Bean<?> b)
+ { // we don't want a proxy for java.util.Set
+ return (PassivationCapable.class.isInstance(b) && "apache.openwebbeans.OwbInternalConversationStorageBean".equals(PassivationCapable.class.cast(b).getId())) ||
+ ExtensionBean.class.isInstance(b) /*not needed*/;
+ }
+}
diff --git a/showcase/src/main/resources/META-INF/beans.xml b/showcase/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..b472e1b
--- /dev/null
+++ b/showcase/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
+ bean-discovery-mode="all" version="2.0">
+</beans>
diff --git a/showcase/src/main/resources/META-INF/native-image/jni-config.json b/showcase/src/main/resources/META-INF/native-image/jni-config.json
new file mode 100644
index 0000000..71b67fa
--- /dev/null
+++ b/showcase/src/main/resources/META-INF/native-image/jni-config.json
@@ -0,0 +1,9 @@
+[
+{
+ "name":"java.lang.ClassLoader",
+ "methods":[{"name":"loadClass","parameterTypes":["java.lang.String"] }]
+},
+{
+ "name":"java.lang.ClassNotFoundException"
+}
+]
diff --git a/showcase/src/main/resources/META-INF/native-image/proxy-config.json b/showcase/src/main/resources/META-INF/native-image/proxy-config.json
new file mode 100644
index 0000000..37cf6fc
--- /dev/null
+++ b/showcase/src/main/resources/META-INF/native-image/proxy-config.json
@@ -0,0 +1,3 @@
+[
+ ["java.lang.reflect.TypeVariable"]
+]
diff --git a/showcase/src/main/resources/META-INF/native-image/reflect-config.json b/showcase/src/main/resources/META-INF/native-image/reflect-config.json
new file mode 100644
index 0000000..c4c45a5
--- /dev/null
+++ b/showcase/src/main/resources/META-INF/native-image/reflect-config.json
@@ -0,0 +1,363 @@
+[
+{
+ "name":"io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor",
+ "methods":[
+ {"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"exceptionCaught","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Throwable"] }
+ ]
+},
+{
+ "name":"io.netty.buffer.AbstractByteBufAllocator",
+ "allDeclaredMethods":true
+},
+{
+ "name":"io.netty.channel.ChannelDuplexHandler",
+ "methods":[{"name":"read","parameterTypes":["io.netty.channel.ChannelHandlerContext"] }]
+},
+{
+ "name":"io.netty.channel.ChannelHandler$Sharable"
+},
+{
+ "name":"io.netty.channel.ChannelHandlerAdapter",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"io.netty.channel.ChannelInboundHandlerAdapter",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true,
+ "methods":[
+ {"name":"channelActive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelInactive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"channelReadComplete","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRegistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelUnregistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelWritabilityChanged","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"userEventTriggered","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] }
+ ]
+},
+{
+ "name":"io.netty.channel.ChannelInitializer",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true,
+ "methods":[
+ {"name":"channelRegistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"exceptionCaught","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Throwable"] }
+ ]
+},
+{
+ "name":"io.netty.channel.DefaultChannelPipeline$HeadContext",
+ "methods":[
+ {"name":"bind","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.net.SocketAddress","io.netty.channel.ChannelPromise"] },
+ {"name":"channelActive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelInactive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"channelReadComplete","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRegistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelUnregistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelWritabilityChanged","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"close","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"connect","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.net.SocketAddress","java.net.SocketAddress","io.netty.channel.ChannelPromise"] },
+ {"name":"deregister","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"disconnect","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"exceptionCaught","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Throwable"] },
+ {"name":"flush","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"read","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"userEventTriggered","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"write","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object","io.netty.channel.ChannelPromise"] }
+ ]
+},
+{
+ "name":"io.netty.channel.DefaultChannelPipeline$TailContext",
+ "methods":[
+ {"name":"channelActive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelInactive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"channelReadComplete","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRegistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelUnregistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelWritabilityChanged","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"exceptionCaught","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Throwable"] },
+ {"name":"userEventTriggered","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] }
+ ]
+},
+{
+ "name":"io.netty.channel.SimpleChannelInboundHandler",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"io.netty.channel.socket.nio.NioServerSocketChannel",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"io.netty.handler.logging.LoggingHandler",
+ "methods":[
+ {"name":"bind","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.net.SocketAddress","io.netty.channel.ChannelPromise"] },
+ {"name":"channelActive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelInactive","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"channelReadComplete","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelRegistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelUnregistered","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"channelWritabilityChanged","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"close","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"connect","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.net.SocketAddress","java.net.SocketAddress","io.netty.channel.ChannelPromise"] },
+ {"name":"deregister","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"disconnect","parameterTypes":["io.netty.channel.ChannelHandlerContext","io.netty.channel.ChannelPromise"] },
+ {"name":"exceptionCaught","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Throwable"] },
+ {"name":"flush","parameterTypes":["io.netty.channel.ChannelHandlerContext"] },
+ {"name":"userEventTriggered","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] },
+ {"name":"write","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object","io.netty.channel.ChannelPromise"] }
+ ]
+},
+{
+ "name":"io.netty.util.internal.SuppressJava6Requirement"
+},
+{
+ "name":"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
+ "fields":[{"name":"producerLimit", "allowUnsafeAccess":true}]
+},
+{
+ "name":"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
+ "fields":[{"name":"consumerIndex", "allowUnsafeAccess":true}]
+},
+{
+ "name":"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
+ "fields":[{"name":"producerIndex", "allowUnsafeAccess":true}]
+},
+{
+ "name":"java.lang.Deprecated"
+},
+{
+ "name":"java.lang.Object",
+ "allDeclaredMethods":true,
+ "allPublicMethods":true
+},
+{
+ "name":"java.lang.annotation.Documented"
+},
+{
+ "name":"java.lang.annotation.Inherited"
+},
+{
+ "name":"java.lang.annotation.Retention"
+},
+{
+ "name":"java.lang.annotation.Target"
+},
+{
+ "name":"java.lang.management.ManagementFactory",
+ "methods":[{"name":"getRuntimeMXBean","parameterTypes":[] }]
+},
+{
+ "name":"java.lang.management.RuntimeMXBean",
+ "methods":[{"name":"getName","parameterTypes":[] }]
+},
+{
+ "name":"java.nio.Bits",
+ "methods":[{"name":"unaligned","parameterTypes":[] }]
+},
+{
+ "name":"java.nio.Buffer",
+ "fields":[{"name":"address", "allowUnsafeAccess":true}]
+},
+{
+ "name":"java.nio.DirectByteBuffer",
+ "fields":[{"name":"cleaner", "allowUnsafeAccess":true}],
+ "methods":[{"name":"<init>","parameterTypes":["long","int"] }]
+},
+{
+ "name":"java.security.Principal",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"javax.enterprise.context.control.RequestContextController",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"javax.enterprise.inject.spi.InterceptionFactory",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"javax.enterprise.inject.spi.WithAnnotations",
+ "methods":[{"name":"value","parameterTypes":[] }]
+},
+{
+ "name":"org.apache.peeco.api.HttpServer",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.api.HttpServer$$OwbNormalScopeProxy0",
+ "fields":[{"name":"owbContextualInstanceProvider"}],
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"org.apache.peeco.impl.HttpHandlerInfo",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.impl.PeecoChannelHandler",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.impl.PeecoChannelInitializer",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.impl.PeecoExtension",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.impl.PeecoUtils",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.showcase.Bootstrapper",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.showcase.HelloWorldHandler",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.showcase.HelloWorldHandler$$OwbNormalScopeProxy0",
+ "fields":[{"name":"owbContextualInstanceProvider"}],
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"org.apache.peeco.showcase.HttpServerProducer",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.peeco.showcase.HttpServerProducer$$OwbNormalScopeProxy0",
+ "fields":[{"name":"owbContextualInstanceProvider"}],
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"org.apache.peeco.showcase.proxyGeneration.ProxyGenerator",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.webbeans.conversation.ConversationImpl",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.webbeans.corespi.se.StandaloneContextsService",
+ "methods":[{"name":"<init>","parameterTypes":["org.apache.webbeans.config.WebBeansContext"] }]
+},
+{
+ "name":"org.apache.webbeans.event.EventImpl",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.webbeans.inject.impl.InjectionPointImpl",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.webbeans.inject.instance.InstanceImpl",
+ "allDeclaredFields":true,
+ "allDeclaredMethods":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true
+},
+{
+ "name":"org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler",
+ "methods":[{"name":"<init>","parameterTypes":["javax.enterprise.inject.spi.BeanManager","javax.enterprise.inject.spi.Bean"] }]
+},
+{
+ "name":"org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler",
+ "methods":[{"name":"<init>","parameterTypes":["javax.enterprise.inject.spi.BeanManager","javax.enterprise.inject.spi.Bean"] }]
+},
+{
+ "name":"org.apache.webbeans.lifecycle.StandaloneLifeCycle",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"org.apache.webbeans.service.ClassLoaderProxyService$LoadFirst",
+ "methods":[{"name":"<init>","parameterTypes":["org.apache.webbeans.config.WebBeansContext"] }]
+},
+{
+ "name":"org.apache.webbeans.spi.BeanArchiveService"
+},
+{
+ "name":"org.apache.webbeans.spi.LoaderService"
+},
+{
+ "name":"org.apache.webbeans.spi.ScannerService"
+},
+{
+ "name":"sun.misc.Cleaner",
+ "methods":[{"name":"clean","parameterTypes":[] }]
+},
+{
+ "name":"sun.misc.Unsafe",
+ "fields":[{"name":"theUnsafe"}],
+ "methods":[
+ {"name":"copyMemory","parameterTypes":["java.lang.Object","long","java.lang.Object","long","long"] },
+ {"name":"getAndAddLong","parameterTypes":["java.lang.Object","long","long"] },
+ {"name":"getAndSetObject","parameterTypes":["java.lang.Object","long","java.lang.Object"] }
+ ]
+},
+{
+ "name":"sun.misc.VM",
+ "methods":[{"name":"maxDirectMemory","parameterTypes":[] }]
+},
+{
+ "name":"sun.nio.ch.SelectorImpl",
+ "fields":[
+ {"name":"publicSelectedKeys"},
+ {"name":"selectedKeys"}
+ ]
+}
+]
diff --git a/showcase/src/main/resources/META-INF/native-image/resource-config.json b/showcase/src/main/resources/META-INF/native-image/resource-config.json
new file mode 100644
index 0000000..583fa91
--- /dev/null
+++ b/showcase/src/main/resources/META-INF/native-image/resource-config.json
@@ -0,0 +1,26 @@
+{
+ "resources":[
+ {"pattern":"\\QMETA-INF/beans.xml\\E"},
+ {"pattern":"\\QMETA-INF/openwebbeans/openwebbeans.properties\\E"},
+ {"pattern":"\\QMETA-INF/services/javax.enterprise.inject.se.SeContainerInitializer\\E"},
+ {"pattern":"\\QMETA-INF/services/javax.enterprise.inject.spi.CDIProvider\\E"},
+ {"pattern":"\\QMETA-INF/services/javax.enterprise.inject.spi.Extension\\E"},
+ {"pattern":"\\QMETA-INF/services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory\\E"},
+ {"pattern":"\\QMETA-INF/services/jdk.vm.ci.services.JVMCIServiceLocator\\E"},
+ {"pattern":"\\Qorg/apache/peeco/api/HttpServer.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/impl/HttpHandlerInfo.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/impl/PeecoChannelHandler.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/impl/PeecoChannelInitializer.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/impl/PeecoExtension.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/impl/PeecoUtils.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/Bootstrapper.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/HelloWorldHandler.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/HttpServerProducer.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/proxyGeneration/ProxyGenerator.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/HelloWorldHandler$$OwbNormalScopeProxy0.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/api/HttpServer$$OwbNormalScopeProxy0.class\\E"},
+ {"pattern":"\\Qorg/apache/peeco/showcase/HttpServerProducer$$OwbNormalScopeProxy0.class\\E"},
+ {"pattern":"\\Qorg/apache/webbeans/conversation/ConversationImpl$$OwbNormalScopeProxy0.class\\E"}
+ ],
+ "bundles":[{"name":"openwebbeans/Messages"}]
+}