tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tveron...@apache.org
Subject tomee git commit: applying changes from https://github.com/apache/tomee/pull/135
Date Tue, 17 Jul 2018 10:18:54 GMT
Repository: tomee
Updated Branches:
  refs/heads/fb_tomee8 44a99613d -> bf929780a


applying changes from https://github.com/apache/tomee/pull/135


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bf929780
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bf929780
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bf929780

Branch: refs/heads/fb_tomee8
Commit: bf929780ae384de305388594c7227c73a3193f9a
Parents: 44a9961
Author: Thiago Veronezi <thiago@veronezi.org>
Authored: Tue Jul 17 06:09:13 2018 -0400
Committer: Thiago Veronezi <thiago@veronezi.org>
Committed: Tue Jul 17 06:09:13 2018 -0400

----------------------------------------------------------------------
 .../assembler/classic/JndiEncBuilder.java       |  4 +-
 .../core/ivm/naming/MapObjectReference.java     |  6 +-
 .../apache/openejb/server/cxf/rs/Contexts.java  |  3 +
 .../cxf/rs/ApplicationRsInjectionTest.java      | 65 ++++++++++++++++++++
 4 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bf929780/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
index 53bcac8..3c287f9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
@@ -73,6 +73,7 @@ import javax.transaction.UserTransaction;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 import javax.ws.rs.container.ResourceContext;
+import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Configuration;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Request;
@@ -341,10 +342,11 @@ public class JndiEncBuilder {
                     reference = new ObjectReference(ThreadLocalContextManager.RESOURCE_CONTEXT);
                 } else if (Configuration.class.equals(type)) {
                     reference = new ObjectReference(ThreadLocalContextManager.CONFIGURATION);
+                } else if (Application.class.equals(type)) {
+                    reference = new ObjectReference(ThreadLocalContextManager.APPLICATION);
                 } else {
                     reference = new MapObjectReference(ThreadLocalContextManager.OTHERS,
referenceInfo.referenceType);
                 }
-
                 bindings.put(normalize(referenceInfo.referenceName), reference);
             }
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/bf929780/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/MapObjectReference.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/MapObjectReference.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/MapObjectReference.java
index bbca666..4cf14f4 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/MapObjectReference.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/MapObjectReference.java
@@ -31,6 +31,10 @@ public class MapObjectReference extends Reference {
     }
 
     public Object getObject() throws NamingException {
-        return obj.get().get(key);
+        final Map<String, Object> theMap = obj.get();
+        if (theMap == null) {
+            return null;
+        }
+        return theMap.get(key);
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/bf929780/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/Contexts.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/Contexts.java
b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/Contexts.java
index e1a5411..4fc3211 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/Contexts.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/Contexts.java
@@ -178,6 +178,9 @@ public final class Contexts {
             } else if (ResourceContext.class.equals(type)) {
                 final ResourceContext config = JAXRSUtils.createContextValue(exchange.getInMessage(),
null, ResourceContext.class);
                 ThreadLocalContextManager.RESOURCE_CONTEXT.set(config);
+            } else if (Application.class.equals(type)) {
+                final Application config = JAXRSUtils.createContextValue(exchange.getInMessage(),
null, Application.class);
+                ThreadLocalContextManager.APPLICATION.set(config);
             } else {
                 final Message message = exchange.getInMessage();
                 final ContextProvider<?> provider = ProviderFactory.getInstance(message).createContextProvider(type,
message);

http://git-wip-us.apache.org/repos/asf/tomee/blob/bf929780/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationRsInjectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationRsInjectionTest.java
b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationRsInjectionTest.java
new file mode 100644
index 0000000..8db7068
--- /dev/null
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationRsInjectionTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.openejb.server.cxf.rs;
+
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.RandomPort;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@Classes(innerClassesAsBean = true)
+@EnableServices("jaxrs")
+@RunWith(ApplicationComposer.class)
+public class ApplicationRsInjectionTest {
+    @RandomPort("http")
+    private URL root;
+
+    @Test
+    public void run() {
+        assertEquals("false", ClientBuilder.newClient().target(root.toExternalForm()).path("/openejb/applicationTest").request().get(String.class));
+    }
+
+    @Path("applicationTest")
+    public static class Dummy {
+
+        // This was null. It should be injected here
+        // https://issues.apache.org/jira/browse/TOMEE-2201
+        @Context
+        private Application application;
+
+        @GET
+        @Produces(MediaType.TEXT_PLAIN)
+        public Response touch() {
+            return Response.ok().entity(this.application == null).type(MediaType.TEXT_PLAIN).build();
+        }
+    }
+
+}


Mime
View raw message