Author: asoldano
Date: 2015-03-09 13:39:11 -0400 (Mon, 09 Mar 2015)
New Revision: 19540
Removed:
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointRegistryDeploymentAspect.java
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistry.java
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistryFactory.java
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistry.java
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistryMBean.java
common/trunk/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java
Modified:
common/trunk/src/main/java/org/jboss/ws/common/Loggers.java
common/trunk/src/main/java/org/jboss/ws/common/Messages.java
common/trunk/src/main/java/org/jboss/ws/common/deployment/JAXBIntroDeploymentAspect.java
common/trunk/src/main/java/org/jboss/ws/common/spi/DefaultSPIProvider.java
Log:
[JBWS-3877] EndpointRegistry cleanup
Modified: common/trunk/src/main/java/org/jboss/ws/common/Loggers.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/Loggers.java 2015-03-09 17:38:52 UTC
(rev 19539)
+++ common/trunk/src/main/java/org/jboss/ws/common/Loggers.java 2015-03-09 17:39:11 UTC
(rev 19540)
@@ -95,23 +95,23 @@
@Message(id = 22027, value = "Cannot delete published wsdl document: %s")
void cannotDeletePublishedWsdlDoc(URL url);
- @LogMessage(level = ERROR)
- @Message(id = 22038, value = "Cannot register endpoint %s with JMX
server")
- void cannotRegisterEndpointWithJmxServer(ObjectName endpointName, @Cause Throwable
cause);
+// @LogMessage(level = ERROR)
+// @Message(id = 22038, value = "Cannot register endpoint %s with JMX
server")
+// void cannotRegisterEndpointWithJmxServer(ObjectName endpointName, @Cause Throwable
cause);
+//
+// @LogMessage(level = ERROR)
+// @Message(id = 22039, value = "Cannot unregister endpoint %s with JMX
server")
+// void cannotUnregisterEndpointWithJmxServer(ObjectName endpointName, @Cause
Throwable cause);
+//
+// @LogMessage(level = WARN)
+// @Message(id = 22040, value = "MBeanServer not available, cannot unregister
endpoint with JMX server")
+// void cannotUnregisterDueToMBeanServerUnavailable();
+//
+// @LogMessage(level = DEBUG)
+// @Message(id = 22041, value = "Destroying service endpoint manager")
+// void destroyingServiceEndpointManager();
- @LogMessage(level = ERROR)
- @Message(id = 22039, value = "Cannot unregister endpoint %s with JMX
server")
- void cannotUnregisterEndpointWithJmxServer(ObjectName endpointName, @Cause Throwable
cause);
-
- @LogMessage(level = WARN)
- @Message(id = 22040, value = "MBeanServer not available, cannot unregister
endpoint with JMX server")
- void cannotUnregisterDueToMBeanServerUnavailable();
-
@LogMessage(level = DEBUG)
- @Message(id = 22041, value = "Destroying service endpoint manager")
- void destroyingServiceEndpointManager();
-
- @LogMessage(level = DEBUG)
@Message(id = 22042, value = "Cannot register processor %s with JMX server, will
be trying using the default managed implementation. ")
void cannotRegisterProvidedProcessor(ObjectName processorName, @Cause Throwable
cause);
@@ -123,15 +123,15 @@
@Message(id = 22044, value = "Cannot unregister processor %s with JMX
server")
void cannotUnregisterProcessorWithJmxServer(ObjectName processorName, @Cause
Throwable cause);
- @LogMessage(level = INFO)
- @Message(id = 22050, value = "Endpoint registered: %s")
- void endpointRegistered(ObjectName epName);
+// @LogMessage(level = INFO)
+// @Message(id = 22050, value = "Endpoint registered: %s")
+// void endpointRegistered(ObjectName epName);
+//
+// @LogMessage(level = INFO)
+// @Message(id = 22051, value = "Endpoint unregistered: %s")
+// void endpointUnregistered(ObjectName epName);
@LogMessage(level = INFO)
- @Message(id = 22051, value = "Endpoint unregistered: %s")
- void endpointUnregistered(ObjectName epName);
-
- @LogMessage(level = INFO)
@Message(id = 22052, value = "Starting %s %s")
void startingWSServerConfig(String implTitle, String implVersion);
Modified: common/trunk/src/main/java/org/jboss/ws/common/Messages.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/Messages.java 2015-03-09 17:38:52 UTC
(rev 19539)
+++ common/trunk/src/main/java/org/jboss/ws/common/Messages.java 2015-03-09 17:39:11 UTC
(rev 19540)
@@ -125,21 +125,21 @@
@Message(id = 22037, value = "Annotation class cannot be null")
IllegalArgumentException annotationClassCannotBeNull();
- @Message(id = 22045, value = "Cannot register / unregister null endpoint")
- IllegalArgumentException cannotRegisterUnregisterNullEndpoint();
+// @Message(id = 22045, value = "Cannot register / unregister null
endpoint")
+// IllegalArgumentException cannotRegisterUnregisterNullEndpoint();
+//
+// @Message(id = 22046, value = "Looking for endpoints with null name in the
endpoint registry is not supported")
+// IllegalArgumentException endpointNameCannotBeNull();
+//
+// @Message(id = 22047, value = "Cannot register endpoint with null name:
%s")
+// IllegalArgumentException cannotRegisterEndpointWithNullName(ObjectName epName);
+//
+// @Message(id = 22048, value = "Endpoint already registered: %s")
+// IllegalStateException endpointAlreadyRegistered(ObjectName endpointName);
+//
+// @Message(id = 22049, value = "Endpoint not registered: %s")
+// IllegalStateException endpointNotRegistered(ObjectName endpointName);
- @Message(id = 22046, value = "Looking for endpoints with null name in the
endpoint registry is not supported")
- IllegalArgumentException endpointNameCannotBeNull();
-
- @Message(id = 22047, value = "Cannot register endpoint with null name:
%s")
- IllegalArgumentException cannotRegisterEndpointWithNullName(ObjectName epName);
-
- @Message(id = 22048, value = "Endpoint already registered: %s")
- IllegalStateException endpointAlreadyRegistered(ObjectName endpointName);
-
- @Message(id = 22049, value = "Endpoint not registered: %s")
- IllegalStateException endpointNotRegistered(ObjectName endpointName);
-
@Message(id = 22062, value = "Cannot find attachment %s in webservice deployment
%s")
IllegalStateException cannotFindAttachmentInDeployment(Class<?>
attachmentClass, String dep);
Deleted:
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointRegistryDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointRegistryDeploymentAspect.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointRegistryDeploymentAspect.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.common.deployment;
-
-import org.jboss.ws.common.integration.AbstractDeploymentAspect;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-
-/**
- * A deployer that registers the endpoints
- *
- * @author Thomas.Diesler(a)jboss.com
- */
-public class EndpointRegistryDeploymentAspect extends AbstractDeploymentAspect
-{
- private EndpointRegistryFactory factory;
-
- public void start(Deployment dep)
- {
- if (factory == null) {
- factory = SPIProvider.getInstance().getSPI(EndpointRegistryFactory.class);
- }
- EndpointRegistry registry = factory.getEndpointRegistry();
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- registry.register(ep);
- }
- }
-
- public void stop(Deployment dep)
- {
- if (factory == null) {
- factory = SPIProvider.getInstance().getSPI(EndpointRegistryFactory.class);
- }
- EndpointRegistry registry = factory.getEndpointRegistry();
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- registry.unregister(ep);
- }
- }
-
-}
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/JAXBIntroDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/deployment/JAXBIntroDeploymentAspect.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/deployment/JAXBIntroDeploymentAspect.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -46,6 +46,7 @@
private static final String META_INF_JAXB_INTROS_XML =
"META-INF/jaxb-intros.xml";
private static final String WEB_INF_JAXB_INTROS_XML =
"WEB-INF/jaxb-intros.xml";
+ @SuppressWarnings("unchecked")
public void start(Deployment deployment)
{
// assert ArchiveDeployment
Deleted:
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistry.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistry.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistry.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.common.management;
-
-import static org.jboss.ws.common.Loggers.MANAGEMENT_LOGGER;
-import static org.jboss.ws.common.Messages.MESSAGES;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.ObjectName;
-
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointResolver;
-
-/**
- * A general endpoint registry.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @author alessio.soldano(a)jboss.com
- *
- * @since 20-Apr-2007
- */
-public class DefaultEndpointRegistry implements EndpointRegistry
-{
- private final Map<ObjectName, Endpoint> endpoints = new
ConcurrentHashMap<ObjectName, Endpoint>();
-
- public Endpoint getEndpoint(ObjectName epName)
- {
- if (epName == null)
- throw MESSAGES.endpointNameCannotBeNull();
-
- if (isRegistered(epName) == false)
- throw MESSAGES.endpointNotRegistered(epName);
-
- Endpoint endpoint = endpoints.get(epName);
- return endpoint;
- }
-
- public Endpoint resolve(EndpointResolver resolver)
- {
- return resolver.query(endpoints.values().iterator());
- }
-
- public boolean isRegistered(ObjectName epName)
- {
- if (epName == null)
- throw MESSAGES.endpointNameCannotBeNull();
-
- return endpoints.get(epName) != null;
- }
-
- public Set<ObjectName> getEndpoints()
- {
- return endpoints.keySet();
- }
-
- public void register(Endpoint endpoint)
- {
- if (endpoint == null)
- throw MESSAGES.cannotRegisterUnregisterNullEndpoint();
-
- ObjectName epName = endpoint.getName();
- if (epName == null)
- throw MESSAGES.cannotRegisterEndpointWithNullName(endpoint.getName());
-
- if (isRegistered(epName))
- throw MESSAGES.endpointAlreadyRegistered(epName);
-
- MANAGEMENT_LOGGER.endpointRegistered(epName);
- endpoints.put(epName, endpoint);
- }
-
- public void unregister(Endpoint endpoint)
- {
- if (endpoint == null)
- throw MESSAGES.cannotRegisterUnregisterNullEndpoint();
-
- ObjectName epName = endpoint.getName();
- if (isRegistered(epName) == false)
- throw MESSAGES.endpointNotRegistered(epName);
-
- MANAGEMENT_LOGGER.endpointUnregistered(epName);
- endpoints.remove(epName);
- }
-}
Deleted:
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistryFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistryFactory.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/DefaultEndpointRegistryFactory.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.common.management;
-
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-
-/**
- * Retrieves default registry
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public final class DefaultEndpointRegistryFactory extends EndpointRegistryFactory
-{
-
- private static final EndpointRegistry ENDPOINT_REGISTRY = new
DefaultEndpointRegistry();
-
- public EndpointRegistry getEndpointRegistry()
- {
- return ENDPOINT_REGISTRY;
- }
-
-}
Deleted:
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistry.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistry.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistry.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.common.management;
-
-import static org.jboss.ws.common.Loggers.MANAGEMENT_LOGGER;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-
-import org.jboss.wsf.spi.deployment.Endpoint;
-
-/**
- * A Service Endpoint Registry
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 04-May-2007
- */
-public class ManagedEndpointRegistry extends DefaultEndpointRegistry implements
ManagedEndpointRegistryMBean
-{
- // The MBeanServer
- private volatile MBeanServer mbeanServer;
-
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- @Override
- public void register(Endpoint endpoint)
- {
- super.register(endpoint);
-
- try
- {
- ManagedEndpoint jmxEndpoint = new ManagedEndpoint(endpoint, mbeanServer);
- getMbeanServer().registerMBean(jmxEndpoint, endpoint.getName());
- }
- catch (Exception ex)
- {
- MANAGEMENT_LOGGER.cannotRegisterEndpointWithJmxServer(endpoint.getName(), ex);
- }
- }
-
- @Override
- public void unregister(Endpoint endpoint)
- {
- super.unregister(endpoint);
- try
- {
- if (getMbeanServer() != null)
- getMbeanServer().unregisterMBean(endpoint.getName());
- else
- MANAGEMENT_LOGGER.cannotUnregisterDueToMBeanServerUnavailable();
- }
- catch (JMException ex)
- {
- MANAGEMENT_LOGGER.cannotUnregisterEndpointWithJmxServer(endpoint.getName(),
ex);
- }
- }
-
- public void create() throws Exception
- {
- if (mbeanServer != null)
- {
- getMbeanServer().registerMBean(this, OBJECT_NAME);
- }
- }
-
- public void destroy() throws Exception
- {
- MANAGEMENT_LOGGER.destroyingServiceEndpointManager();
- if (mbeanServer != null)
- {
- getMbeanServer().unregisterMBean(OBJECT_NAME);
- }
- }
-}
Deleted:
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistryMBean.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistryMBean.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/ManagedEndpointRegistryMBean.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.common.management;
-
-import javax.management.ObjectName;
-
-import org.jboss.ws.common.ObjectNameFactory;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-
-/**
- * MBean interface.
- * @since 15-April-2004
- */
-public interface ManagedEndpointRegistryMBean extends EndpointRegistry
-{
- /** The object name in the MBean server */
- ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=EndpointRegistry");
-}
Modified: common/trunk/src/main/java/org/jboss/ws/common/spi/DefaultSPIProvider.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/spi/DefaultSPIProvider.java 2015-03-09
17:38:52 UTC (rev 19539)
+++ common/trunk/src/main/java/org/jboss/ws/common/spi/DefaultSPIProvider.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -26,7 +26,6 @@
import org.jboss.ws.common.deployment.DefaultDeploymentModelFactory;
import org.jboss.ws.common.deployment.DefaultLifecycleHandlerFactory;
import org.jboss.ws.common.management.DefaultEndpointMetricsFactory;
-import org.jboss.ws.common.management.DefaultEndpointRegistryFactory;
import org.jboss.ws.common.management.DefaultJMSEndpointResolver;
import org.jboss.ws.common.security.DefaultSecurityAdapterFactory;
import org.jboss.wsf.spi.SPIProvider;
@@ -34,7 +33,6 @@
import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
import org.jboss.wsf.spi.management.EndpointMetricsFactory;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
import org.jboss.wsf.spi.management.JMSEndpointResolver;
/**
@@ -68,10 +66,6 @@
{
returnType = loadService(spiType, DefaultSecurityAdapterFactory.class, loader);
}
- else if (EndpointRegistryFactory.class.equals(spiType))
- {
- returnType = loadService(spiType, DefaultEndpointRegistryFactory.class,
loader);
- }
else if (JMSEndpointResolver.class.equals(spiType))
{
returnType = loadService(spiType, DefaultJMSEndpointResolver.class, loader);
Deleted:
common/trunk/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java
===================================================================
---
common/trunk/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java 2015-03-09
17:38:52 UTC (rev 19539)
+++
common/trunk/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java 2015-03-09
17:39:11 UTC (rev 19540)
@@ -1,422 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.common.management;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.ObjectName;
-
-import org.jboss.ws.api.monitoring.Record;
-import org.jboss.ws.api.monitoring.RecordProcessor;
-import org.jboss.ws.common.management.DefaultEndpointRegistry;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.EndpointState;
-import org.jboss.wsf.spi.deployment.EndpointType;
-import org.jboss.wsf.spi.deployment.InstanceProvider;
-import org.jboss.wsf.spi.deployment.LifecycleHandler;
-import org.jboss.wsf.spi.deployment.Service;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
-import org.jboss.wsf.spi.invocation.RequestHandler;
-import org.jboss.wsf.spi.management.EndpointMetrics;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.metadata.config.EndpointConfig;
-import org.jboss.wsf.spi.security.SecurityDomainContext;
-
-import junit.framework.TestCase;
-
-/**
- * Test the DefaultEndpointRegistry
- *
- * @author alessio.soldano(a)jboss.com
- * @since 23-Apr-2012
- */
-public class DefaultEndpointRegistryTestCase extends TestCase
-{
- public void testSingleThreadAccess() throws Exception {
- final int MAX = 10;
- DefaultEndpointRegistry reg = new DefaultEndpointRegistry();
- for (int i = 0; i < MAX; i++) {
- Endpoint ep = getTestEndpoint("Foo" + i, "prop",
"v" + i);
- reg.register(ep);
- }
-
- Iterator<ObjectName> it = reg.getEndpoints().iterator();
- checkContents(it, MAX);
-
- reg.register(getTestEndpoint("Foo" + MAX, "prop", "v"
+ MAX));
-
- assertFalse(it.hasNext());
- checkContents(reg.getEndpoints().iterator(), MAX + 1);
- }
-
- public void testConcurrentAccess() throws Exception {
- DefaultEndpointRegistry reg = new DefaultEndpointRegistry();
- reg.register(getTestEndpoint("Test", "prop",
"my-value"));
- ExecutorService es = Executors.newFixedThreadPool(2);
- List<Callable<Boolean>> callables = new
LinkedList<Callable<Boolean>>();
- final int size = 10;
- for (int i = 1; i <= 10; i++) {
- callables.add(new Register(reg, "Foo", i * size, size));
- }
- callables.add(new Reader(reg, "my-value"));
- for (int i = 11; i <= 20; i++) {
- callables.add(new Register(reg, "Foo", i * size, size));
- }
- callables.add(new Reader(reg, "my-value"));
-
- List<Future<Boolean>> results = es.invokeAll(callables);
- for (Future<Boolean> f : results) {
- assertTrue(f.get(10, TimeUnit.SECONDS));
- }
- es.shutdown();
- }
-
- private class Register implements Callable<Boolean> {
- private final EndpointRegistry reg;
- private final String name;
- private final int base;
- private final int n;
-
- public Register(EndpointRegistry reg, String name, int base, int n) {
- this.reg = reg;
- this.name = name;
- this.base = base;
- this.n = n;
- }
-
- @Override
- public Boolean call() throws Exception
- {
- for (int i = base; i < (base + n); i++) {
- try {
- Endpoint ep = getTestEndpoint(name + i, "prop", "v" +
i);
- reg.register(ep);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return true;
- }
- }
-
- private class Reader implements Callable<Boolean> {
- private final EndpointRegistry reg;
- private final String value;
-
- public Reader(EndpointRegistry reg, String value) {
- this.reg = reg;
- this.value = value;
- }
-
- @Override
- public Boolean call() throws Exception
- {
- boolean result = false;
- //below is what org.jboss.wsf.stack.cxf.transport.ServletHelper does for
instance
- for (ObjectName on : reg.getEndpoints()) {
- if (on.getKeyProperty("prop").equalsIgnoreCase(value)) {
- result = true; //do not early exit
- }
- }
- return result;
- }
-
- }
-
- private static void checkContents(Iterator<ObjectName> it, int n) {
- List<String> values = new LinkedList<String>();
- for (int i = 0; i < n; i++) {
- values.add("v" + i);
- }
- while (it.hasNext()) {
- String p = it.next().getKeyProperty("prop");
- if (values.contains(p)) {
- values.remove(p);
- }
- }
- assertTrue("Could not find " + values, values.isEmpty());
- }
-
- private static Endpoint getTestEndpoint(String name, String prop, String value) throws
Exception {
- final ObjectName objName = new ObjectName(name, prop, value);
- return new Endpoint()
- {
-
- @Override
- public void setProperty(String key, Object value)
- {
-
- }
-
- @Override
- public void setProperties(Map<String, Object> props)
- {
-
- }
-
- @Override
- public void removeProperty(String key)
- {
-
- }
-
- @Override
- public <T> T removeAttachment(Class<T> key)
- {
- return null;
- }
-
- @Override
- public Object getProperty(String key)
- {
- return null;
- }
-
- @Override
- public Set<String> getProperties()
- {
- return null;
- }
-
- @Override
- public <T> Collection<T> getAttachments()
- {
- return null;
- }
-
- @Override
- public <T> T getAttachment(Class<T> key)
- {
- return null;
- }
-
- @Override
- public <T> T addAttachment(Class<T> key, Object value)
- {
- return null;
- }
-
- @Override
- public void setType(EndpointType type)
- {
-
- }
-
- @Override
- public void setTargetBeanName(String epImpl)
- {
-
- }
-
- @Override
- public void setState(EndpointState state)
- {
-
- }
-
- @Override
- public void setShortName(String shortName)
- {
-
- }
-
- @Override
- public void setService(Service service)
- {
-
- }
-
- @Override
- public void setSecurityDomainContext(SecurityDomainContext context)
- {
-
- }
-
- @Override
- public void setRequestHandler(RequestHandler handler)
- {
-
- }
-
- @Override
- public void setRecordProcessors(List<RecordProcessor> recordProcessors)
- {
-
- }
-
- @Override
- public void setName(ObjectName epName)
- {
-
- }
-
- @Override
- public void setLifecycleHandler(LifecycleHandler handler)
- {
-
- }
-
- @Override
- public void setInvocationHandler(InvocationHandler invoker)
- {
-
- }
-
- @Override
- public void setInstanceProvider(InstanceProvider provider)
- {
-
- }
-
- @Override
- public void setEndpointMetrics(EndpointMetrics metrics)
- {
-
- }
-
- @Override
- public void setAddress(String address)
- {
-
- }
-
- @Override
- public void processRecord(Record record)
- {
-
- }
-
- @Override
- public EndpointType getType()
- {
- return null;
- }
-
- @Override
- public String getTargetBeanName()
- {
- return null;
- }
-
- @Override
- public Class getTargetBeanClass()
- {
- return null;
- }
-
- @Override
- public EndpointState getState()
- {
- return null;
- }
-
- @Override
- public String getShortName()
- {
- return null;
- }
-
- @Override
- public Service getService()
- {
- return null;
- }
-
- @Override
- public SecurityDomainContext getSecurityDomainContext()
- {
- return null;
- }
-
- @Override
- public RequestHandler getRequestHandler()
- {
- return null;
- }
-
- @Override
- public List<RecordProcessor> getRecordProcessors()
- {
- return null;
- }
-
- @Override
- public ObjectName getName()
- {
- return objName;
- }
-
- @Override
- public LifecycleHandler getLifecycleHandler()
- {
- return null;
- }
-
- @Override
- public InvocationHandler getInvocationHandler()
- {
- return null;
- }
-
- @Override
- public InstanceProvider getInstanceProvider()
- {
- return null;
- }
-
- @Override
- public EndpointMetrics getEndpointMetrics()
- {
- return null;
- }
-
- @Override
- public String getAddress()
- {
- return null;
- }
-
- @Override
- public EndpointConfig getEndpointConfig()
- {
- return null;
- }
-
- @Override
- public void setEndpointConfig(EndpointConfig config)
- {
- // TODO Auto-generated method stub
-
- }
- };
- }
-}