You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/09/02 20:13:01 UTC
[2/2] tomee git commit: applying changes from
https://github.com/apache/tomee/pull/135
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/d2ac6243
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d2ac6243
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d2ac6243
Branch: refs/heads/tomee-7.1.x
Commit: d2ac6243cf365dcd3f56c88fb8f58e60c7ec9dbc
Parents: c353207
Author: Thiago Veronezi <th...@veronezi.org>
Authored: Tue Jul 17 06:09:13 2018 -0400
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Sun Sep 2 21:12:43 2018 +0100
----------------------------------------------------------------------
.../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/d2ac6243/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/d2ac6243/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/d2ac6243/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/d2ac6243/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();
+ }
+ }
+
+}