Return-Path: X-Original-To: apmail-tomee-commits-archive@www.apache.org Delivered-To: apmail-tomee-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 16AA61041B for ; Wed, 2 Oct 2013 06:35:11 +0000 (UTC) Received: (qmail 26750 invoked by uid 500); 2 Oct 2013 06:35:10 -0000 Delivered-To: apmail-tomee-commits-archive@tomee.apache.org Received: (qmail 26691 invoked by uid 500); 2 Oct 2013 06:35:04 -0000 Mailing-List: contact commits-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tomee.apache.org Delivered-To: mailing list commits@tomee.apache.org Received: (qmail 26678 invoked by uid 99); 2 Oct 2013 06:35:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 06:35:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 06:34:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7337623889FA; Wed, 2 Oct 2013 06:34:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Wed, 02 Oct 2013 06:34:38 -0000 To: commits@tomee.apache.org From: rmannibucau@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131002063438.7337623889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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(); - } + providersConfig = new HashSet(); 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"; + } + } +}