You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2013/10/02 08:34:38 UTC
svn commit: r1528315 - in /tomee/tomee/trunk/server/openejb-cxf-rs/src:
main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java
Author: rmannibucau
Date: Wed Oct 2 06:34:37 2013
New Revision: 1528315
URL: http://svn.apache.org/r1528315
Log:
adding a test on jaxrs jmx mbeans
Added:
tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java
Modified:
tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
Modified: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java?rev=1528315&r1=1528314&r2=1528315&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java (original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java Wed Oct 2 06:34:37 2013
@@ -28,7 +28,6 @@ import org.apache.cxf.jaxrs.model.Method
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
import org.apache.cxf.service.invoker.Invoker;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.apache.cxf.transport.http.HTTPTransportFactory;
@@ -449,13 +448,15 @@ public class CxfRsHttpListener implement
Collections.sort(resourcesToLog);
- for (Logs.LogResourceEndpointInfo resource : resourcesToLog) {
+ for (final Logs.LogResourceEndpointInfo resource : resourcesToLog) {
// Init and register MBeans
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management")
+ .set("j2eeType", "JAX-RS")
.set("J2EEServer", "openejb")
- .set("name", resource.classname)
- .set("j2eeType", "REST-" + resource.type);
+ .set("J2EEApplication", base)
+ .set("EndpointType", resource.type)
+ .set("name", resource.classname);
ObjectName jmxObjectName = jmxName.build();
LocalMBeanServer.registerDynamicWrapperSilently(
@@ -463,7 +464,6 @@ public class CxfRsHttpListener implement
jmxObjectName);
jmxNames.add(jmxObjectName);
- //
LOGGER.info(" Service URI: "
+ Logs.forceLength(resource.address, addressSize, true) + " -> "
@@ -533,9 +533,7 @@ public class CxfRsHttpListener implement
{
final String provider = serviceConfiguration.getProperties().getProperty(PROVIDERS_KEY);
if (provider != null) {
- if (providersConfig == null) {
- providersConfig = new HashSet<String>();
- }
+ providersConfig = new HashSet<String>();
providersConfig.addAll(Arrays.asList(provider.split(",")));
}
@@ -638,20 +636,15 @@ public class CxfRsHttpListener implement
this.address = jmxName.address;
this.classname = jmxName.classname;
- final String[] names = new String[operations.size()];
- final String[] values = new String[operations.size()];
+ final String[] names = new String[jmxName.operations.size()];
+ final String[] values = new String[jmxName.operations.size()];
int idx = 0;
- for (Logs.LogOperationEndpointInfo operation : jmxName.operations) {
- names[idx] = Logs.forceLength(operation.http, jmxName.methodSize, false) + " "
- + Logs.forceLength(operation.address, operation.address.length(), true);
- values[idx] = Logs.forceLength(operation.method, jmxName.methodStrSize, true);
+ for (final Logs.LogOperationEndpointInfo operation : jmxName.operations) {
+ names[idx] = operation.http + " " + operation.address;
+ values[idx] = operation.method;
idx++;
}
- LocalMBeanServer.tabularData(
- "Operations",
- "Operations for this endpoint",
- names, values
- );
+ operations = LocalMBeanServer.tabularData("Operations", "Operations for this endpoint", names, values);
}
@ManagedAttribute
Added: tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java?rev=1528315&view=auto
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java (added)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsJMXTest.java Wed Oct 2 06:34:37 2013
@@ -0,0 +1,71 @@
+/*
+ * 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.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.monitoring.LocalMBeanServer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@EnableServices("jax-rs")
+@RunWith(ApplicationComposer.class)
+public class RsJMXTest {
+ private static ObjectName name;
+
+ @Module
+ @Classes(AnEndpoint.class )
+ public WebApp war() {
+ return new WebApp().contextRoot("app");
+ }
+
+ @BeforeClass
+ public static void before() throws MalformedObjectNameException {
+ name = new ObjectName("openejb.management:j2eeType=JAX-RS,J2EEServer=openejb,J2EEApplication=http_//127.0.0.1_4204/app,EndpointType=Pojo,name=org.apache.openejb.server.cxf.rs.RsJMXTest$AnEndpoint");
+ }
+
+ @Test
+ public void checkServiceWasDeployed() throws Exception {
+ assertTrue(LocalMBeanServer.get().isRegistered(name));
+ }
+
+ @AfterClass
+ public static void after() {
+ assertFalse(LocalMBeanServer.get().isRegistered(name));
+ }
+
+ @Path("/foo")
+ public static class AnEndpoint {
+ @GET
+ public String bar() {
+ return "bar";
+ }
+ }
+}