From e659e2d1b5ccd68d87e2cbf8e50a049412e13651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Op=C3=A1lka?= Date: Thu, 29 Nov 2018 11:54:01 +0100 Subject: [PATCH] [WFLY-11440] Refactoring - removing deprecated EJBUtilities class. --- .../jboss/as/ejb3/component/EJBComponent.java | 9 +- .../component/EJBComponentCreateService.java | 15 +- .../jboss/as/ejb3/component/EJBUtilities.java | 201 ------------------ .../MessageDrivenComponentCreateService.java | 140 ++++++++++-- .../MessageDrivenComponentDescription.java | 10 +- .../as/ejb3/inflow/EndpointDeployer.java | 54 ----- .../as/ejb3/subsystem/EJB3SubsystemAdd.java | 11 +- .../as/ejb3/subsystem/EJBStatistics.java | 47 ++++ .../StatisticsEnabledWriteHandler.java | 10 +- 9 files changed, 184 insertions(+), 313 deletions(-) delete mode 100644 ejb3/src/main/java/org/jboss/as/ejb3/component/EJBUtilities.java delete mode 100644 ejb3/src/main/java/org/jboss/as/ejb3/inflow/EndpointDeployer.java create mode 100644 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBStatistics.java diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponent.java b/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponent.java index c2508446b529..8596a208246e 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponent.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponent.java @@ -63,6 +63,7 @@ import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.security.EJBSecurityMetaData; import org.jboss.as.ejb3.security.JaccInterceptor; +import org.jboss.as.ejb3.subsystem.EJBStatistics; import org.jboss.as.ejb3.suspend.EJBSuspendHandlerService; import org.jboss.as.ejb3.timerservice.TimerServiceImpl; import org.jboss.as.ejb3.tx.ApplicationExceptionDetails; @@ -89,6 +90,7 @@ /** * @author Carlo de Wolf + * @author Richard Opalka */ public abstract class EJBComponent extends BasicComponent implements ServerActivityCallback { @@ -98,7 +100,6 @@ public abstract class EJBComponent extends BasicComponent implements ServerActiv private final Map txTimeouts; private final Map txExplicitAttrs; - private final EJBUtilities utilities; private final boolean isBeanManagedTransaction; private final Map, ApplicationExceptionDetails> applicationExceptions; private final EJBSecurityMetaData securityMetaData; @@ -145,11 +146,7 @@ public Principal run() { */ protected EJBComponent(final EJBComponentCreateService ejbComponentCreateService) { super(ejbComponentCreateService); - - this.applicationExceptions = Collections.unmodifiableMap(ejbComponentCreateService.getApplicationExceptions().getApplicationExceptions()); - - this.utilities = ejbComponentCreateService.getEJBUtilities(); final Map txAttrs = ejbComponentCreateService.getTxAttrs(); if (txAttrs == null || txAttrs.isEmpty()) { this.txAttrs = Collections.emptyMap(); @@ -468,7 +465,7 @@ public boolean isCallerInRole(final String roleName) throws IllegalStateExceptio } public boolean isStatisticsEnabled() { - return utilities.isStatisticsEnabled(); + return EJBStatistics.getInstance().isEnabled(); } public Object lookup(String name) throws IllegalArgumentException { diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponentCreateService.java b/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponentCreateService.java index 7f1ac2237833..e31291b7f454 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponentCreateService.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBComponentCreateService.java @@ -50,12 +50,10 @@ import org.jboss.as.ejb3.security.EJBSecurityMetaData; import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService.ApplicationSecurityDomain; import org.jboss.as.ejb3.suspend.EJBSuspendHandlerService; -import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.invocation.InterceptorFactory; import org.jboss.invocation.Interceptors; import org.jboss.invocation.proxy.MethodIdentifier; import org.jboss.msc.inject.Injector; -import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.value.InjectedValue; import org.wildfly.extension.requestcontroller.ControlPoint; @@ -64,6 +62,7 @@ /** * @author Jaikiran Pai + * @author Richard Opalka */ public class EJBComponentCreateService extends BasicComponentCreateService { @@ -233,18 +232,6 @@ private static Method getComponentMethod(final ComponentConfiguration componentC } } - /** - * @return - * @deprecated {@link EJBUtilities} is deprecated post 7.2.0.Final version. - */ - @Deprecated - protected EJBUtilities getEJBUtilities() { - // constructs - final DeploymentUnit deploymentUnit = getDeploymentUnitInjector().getValue(); - final ServiceController serviceController = (ServiceController) deploymentUnit.getServiceRegistry().getRequiredService(EJBUtilities.SERVICE_NAME); - return serviceController.getValue(); - } - Map getTxAttrs() { return txAttrs; } diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBUtilities.java b/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBUtilities.java deleted file mode 100644 index 2a34df0af93e..000000000000 --- a/ejb3/src/main/java/org/jboss/as/ejb3/component/EJBUtilities.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright (c) 2011, Red Hat, Inc., 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.as.ejb3.component; - -import java.beans.IntrospectionException; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import javax.resource.ResourceException; -import javax.resource.spi.ActivationSpec; - -import org.jboss.as.connector.util.ConnectorServices; -import org.jboss.as.ejb3.inflow.EndpointDeployer; -import org.jboss.as.ejb3.logging.EjbLogger; -import org.jboss.common.beans.property.BeanUtils; -import org.jboss.jca.core.spi.rar.Activation; -import org.jboss.jca.core.spi.rar.Endpoint; -import org.jboss.jca.core.spi.rar.MessageListener; -import org.jboss.jca.core.spi.rar.NotFoundException; -import org.jboss.jca.core.spi.rar.ResourceAdapterRepository; -import org.jboss.msc.inject.Injector; -import org.jboss.msc.service.Service; -import org.jboss.msc.service.ServiceName; -import org.jboss.msc.service.StartContext; -import org.jboss.msc.service.StartException; -import org.jboss.msc.service.StopContext; -import org.jboss.msc.value.InjectedValue; - -/** - * The gas, water & energy for the EJB subsystem. - * - * @author Carlo de Wolf - * @author Jaikiran Pai - * @deprecated Deprecated post 7.2.x version. Services/Components which depended on this service for getting access to various other services are expected to directly depend on the relevant services themselves. - */ -@Deprecated -public class EJBUtilities implements EndpointDeployer, Service { - - - public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb", "utilities"); - - private final InjectedValue resourceAdapterRepositoryValue = new InjectedValue(); - - private volatile boolean statisticsEnabled = false; - - public ActivationSpec createActivationSpecs(final String resourceAdapterName, final Class messageListenerInterface, - final Properties activationConfigProperties, final ClassLoader classLoader) { - try { - // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the - // ra name - final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName); - if (raIdentifier == null) { - throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName); - } - final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository(); - if (resourceAdapterRepository == null) { - throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable(); - } - // now get the message listeners for this specific ra identifier - final List messageListeners = resourceAdapterRepository.getMessageListeners(raIdentifier); - if (messageListeners == null || messageListeners.isEmpty()) { - throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName); - } - MessageListener requiredMessageListener = null; - // now find the expected message listener from the list of message listeners for this resource adapter - for (final MessageListener messageListener : messageListeners) { - if (messageListenerInterface.equals(messageListener.getType())) { - requiredMessageListener = messageListener; - break; - } - } - if (requiredMessageListener == null) { - throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName); - } - // found the message listener, now finally create the activation spec - final Activation activation = requiredMessageListener.getActivation(); - // filter out the activation config properties, specified on the MDB, which aren't accepted by the resource - // adaptor - final Properties validActivationConfigProps = this.filterUnknownActivationConfigProperties(resourceAdapterName, activation, activationConfigProperties); - // now set the activation config properties on the ActivationSpec - final ActivationSpec activationSpec = activation.createInstance(); - BeanUtils.mapJavaBeanProperties(activationSpec, validActivationConfigProps); - - return activationSpec; - - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (ResourceException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (NotFoundException e) { - throw new RuntimeException(e); - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - } - - /** - * Returns the {@link org.jboss.jca.core.spi.rar.Endpoint} corresponding to the passed resourceAdapterName - * - * @param resourceAdapterName The resource adapter name - * @return - */ - public Endpoint getEndpoint(final String resourceAdapterName) { - // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the - // ra name - final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName); - if (raIdentifier == null) { - throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName); - } - final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository(); - if (resourceAdapterRepository == null) { - throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable(); - } - try { - return resourceAdapterRepository.getEndpoint(raIdentifier); - } catch (NotFoundException nfe) { - throw EjbLogger.ROOT_LOGGER.noSuchEndpointException(resourceAdapterName, nfe); - } - } - - public ResourceAdapterRepository getResourceAdapterRepository() { - return resourceAdapterRepositoryValue.getOptionalValue(); - } - - public Injector getResourceAdapterRepositoryInjector() { - return resourceAdapterRepositoryValue; - } - - @Override - public EJBUtilities getValue() throws IllegalStateException, IllegalArgumentException { - return this; - } - public boolean isStatisticsEnabled() { - return statisticsEnabled; - } - - public void setStatisticsEnabled(final boolean b) { - this.statisticsEnabled = b; - } - - @Override - public void start(StartContext context) throws StartException { - } - - @Override - public void stop(StopContext context) { - } - - /** - * Removes activation config properties which aren't recognized by the resource adapter activation, from the - * passed activationConfigProps and returns only those Properties which are valid. - * - * @param resourceAdapterName The resource adapter name - * @param activation {@link Activation} - * @param activationConfigProps Activation config properties which will be checked for validity - * @return - */ - private Properties filterUnknownActivationConfigProperties(final String resourceAdapterName, final Activation activation, final Properties activationConfigProps) { - if (activationConfigProps == null) { - return null; - } - final Map> raActivationConfigProps = activation.getConfigProperties(); - final Set raRequiredConfigProps = activation.getRequiredConfigProperties(); - final Enumeration propNames = activationConfigProps.propertyNames(); - final Properties validActivationConfigProps = new Properties(); - // initialize to all the activation config properties that have been set on the MDB - validActivationConfigProps.putAll(activationConfigProps); - while (propNames.hasMoreElements()) { - final Object propName = propNames.nextElement(); - if (raActivationConfigProps.containsKey(propName) == false && raRequiredConfigProps.contains(propName) == false) { - // not a valid activation config property, so log a WARN and filter it out from the valid activation config properties - validActivationConfigProps.remove(propName); - EjbLogger.ROOT_LOGGER.activationConfigPropertyIgnored(propName, resourceAdapterName); - } - } - return validActivationConfigProps; - } -} diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentCreateService.java b/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentCreateService.java index eeb1c335e716..76ef43cba9c5 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentCreateService.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentCreateService.java @@ -22,8 +22,14 @@ package org.jboss.as.ejb3.component.messagedriven; +import java.beans.IntrospectionException; +import java.util.Enumeration; +import java.util.Map; +import java.util.Set; +import java.util.List; import java.util.Properties; +import javax.resource.ResourceException; import javax.resource.spi.ActivationSpec; import javax.resource.spi.ResourceAdapter; @@ -32,13 +38,15 @@ import org.jboss.as.ee.component.ComponentConfiguration; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.component.EJBComponentCreateService; -import org.jboss.as.ejb3.component.EJBUtilities; import org.jboss.as.ejb3.component.pool.PoolConfig; import org.jboss.as.ejb3.deployment.ApplicationExceptions; -import org.jboss.as.ejb3.inflow.EndpointDeployer; import org.jboss.as.server.suspend.SuspendController; +import org.jboss.common.beans.property.BeanUtils; +import org.jboss.jca.core.spi.rar.Activation; import org.jboss.jca.core.spi.rar.Endpoint; -import org.jboss.msc.inject.Injector; +import org.jboss.jca.core.spi.rar.MessageListener; +import org.jboss.jca.core.spi.rar.NotFoundException; +import org.jboss.jca.core.spi.rar.ResourceAdapterRepository; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; @@ -46,6 +54,7 @@ /** * @author Stuart Douglas + * @author Richard Opalka */ public class MessageDrivenComponentCreateService extends EJBComponentCreateService { @@ -54,9 +63,9 @@ public class MessageDrivenComponentCreateService extends EJBComponentCreateServi private final String resourceAdapterName; private final boolean deliveryActive; private final ServiceName deliveryControllerName; + private final InjectedValue resourceAdapterRepositoryInjectedValue = new InjectedValue(); private final InjectedValue resourceAdapterInjectedValue = new InjectedValue(); private final InjectedValue poolConfig = new InjectedValue(); - private final InjectedValue ejbUtilitiesInjectedValue = new InjectedValue(); private final InjectedValue suspendControllerInjectedValue = new InjectedValue<>(); private final ClassLoader moduleClassLoader; @@ -93,18 +102,125 @@ protected BasicComponent createComponent() { // Match configured value to the actual RA names final String activeResourceAdapterName = searchActiveResourceAdapterName(configuredResourceAdapterName); - - final ActivationSpec activationSpec = getEndpointDeployer().createActivationSpecs(activeResourceAdapterName, messageListenerInterface, activationProps, getDeploymentClassLoader()); + final ActivationSpec activationSpec = createActivationSpecs(activeResourceAdapterName, messageListenerInterface, activationProps, getDeploymentClassLoader()); final MessageDrivenComponent component = new MessageDrivenComponent(this, messageListenerInterface, activationSpec, deliveryActive, deliveryControllerName, activeResourceAdapterName); // set the endpoint - final EJBUtilities ejbUtilities = this.ejbUtilitiesInjectedValue.getValue(); - final Endpoint endpoint = ejbUtilities.getEndpoint(activeResourceAdapterName); + final Endpoint endpoint = getEndpoint(activeResourceAdapterName); component.setEndpoint(endpoint); return component; } + private ActivationSpec createActivationSpecs(final String resourceAdapterName, final Class messageListenerInterface, + final Properties activationConfigProperties, final ClassLoader classLoader) { + try { + // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the + // ra name + final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName); + if (raIdentifier == null) { + throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName); + } + final ResourceAdapterRepository resourceAdapterRepository = resourceAdapterRepositoryInjectedValue.getValue(); + if (resourceAdapterRepository == null) { + throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable(); + } + // now get the message listeners for this specific ra identifier + final List messageListeners = resourceAdapterRepository.getMessageListeners(raIdentifier); + if (messageListeners == null || messageListeners.isEmpty()) { + throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName); + } + MessageListener requiredMessageListener = null; + // now find the expected message listener from the list of message listeners for this resource adapter + for (final MessageListener messageListener : messageListeners) { + if (messageListenerInterface.equals(messageListener.getType())) { + requiredMessageListener = messageListener; + break; + } + } + if (requiredMessageListener == null) { + throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName); + } + // found the message listener, now finally create the activation spec + final Activation activation = requiredMessageListener.getActivation(); + // filter out the activation config properties, specified on the MDB, which aren't accepted by the resource + // adaptor + final Properties validActivationConfigProps = this.filterUnknownActivationConfigProperties(resourceAdapterName, activation, activationConfigProperties); + // now set the activation config properties on the ActivationSpec + final ActivationSpec activationSpec = activation.createInstance(); + BeanUtils.mapJavaBeanProperties(activationSpec, validActivationConfigProps); + + return activationSpec; + + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (ResourceException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (NotFoundException e) { + throw new RuntimeException(e); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + /** + * Removes activation config properties which aren't recognized by the resource adapter activation, from the + * passed activationConfigProps and returns only those Properties which are valid. + * + * @param resourceAdapterName The resource adapter name + * @param activation {@link Activation} + * @param activationConfigProps Activation config properties which will be checked for validity + * @return + */ + private Properties filterUnknownActivationConfigProperties(final String resourceAdapterName, final Activation activation, final Properties activationConfigProps) { + if (activationConfigProps == null) { + return null; + } + final Map> raActivationConfigProps = activation.getConfigProperties(); + final Set raRequiredConfigProps = activation.getRequiredConfigProperties(); + final Enumeration propNames = activationConfigProps.propertyNames(); + final Properties validActivationConfigProps = new Properties(); + // initialize to all the activation config properties that have been set on the MDB + validActivationConfigProps.putAll(activationConfigProps); + while (propNames.hasMoreElements()) { + final Object propName = propNames.nextElement(); + if (raActivationConfigProps.containsKey(propName) == false && raRequiredConfigProps.contains(propName) == false) { + // not a valid activation config property, so log a WARN and filter it out from the valid activation config properties + validActivationConfigProps.remove(propName); + EjbLogger.ROOT_LOGGER.activationConfigPropertyIgnored(propName, resourceAdapterName); + } + } + return validActivationConfigProps; + } + + + /** + * Returns the {@link org.jboss.jca.core.spi.rar.Endpoint} corresponding to the passed resourceAdapterName + * + * @param resourceAdapterName The resource adapter name + * @return + */ + private Endpoint getEndpoint(final String resourceAdapterName) { + // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the + // ra name + final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName); + if (raIdentifier == null) { + throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName); + } + final ResourceAdapterRepository resourceAdapterRepository = resourceAdapterRepositoryInjectedValue.getValue(); + if (resourceAdapterRepository == null) { + throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable(); + } + try { + return resourceAdapterRepository.getEndpoint(raIdentifier); + } catch (NotFoundException nfe) { + throw EjbLogger.ROOT_LOGGER.noSuchEndpointException(resourceAdapterName, nfe); + } + } + + private String searchActiveResourceAdapterName(String configuredResourceAdapterName) { // Use the configured value unless it doesn't match and some variant of it does String result = configuredResourceAdapterName; @@ -135,18 +251,14 @@ private ClassLoader getDeploymentClassLoader() { return getComponentClass().getClassLoader(); } - private EndpointDeployer getEndpointDeployer() { - return getEJBUtilities(); + public InjectedValue getResourceAdapterRepositoryInjector() { + return this.resourceAdapterRepositoryInjectedValue; } public InjectedValue getResourceAdapterInjector() { return this.resourceAdapterInjectedValue; } - public Injector getEJBUtilitiesInjector() { - return this.ejbUtilitiesInjectedValue; - } - public ClassLoader getModuleClassLoader() { return moduleClassLoader; } diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentDescription.java b/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentDescription.java index 7c3efc5db2fc..918215f6068d 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentDescription.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/component/messagedriven/MessageDrivenComponentDescription.java @@ -21,7 +21,6 @@ */ package org.jboss.as.ejb3.component.messagedriven; - import java.util.Properties; import javax.ejb.MessageDrivenBean; @@ -45,7 +44,6 @@ import org.jboss.as.ee.metadata.MetadataCompleteMarker; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.component.EJBComponentDescription; -import org.jboss.as.ejb3.component.EJBUtilities; import org.jboss.as.ejb3.component.EJBViewDescription; import org.jboss.as.ejb3.component.MethodIntf; import org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor; @@ -63,6 +61,7 @@ import org.jboss.invocation.ImmediateInterceptorFactory; import org.jboss.invocation.Interceptor; import org.jboss.invocation.InterceptorContext; +import org.jboss.jca.core.spi.rar.ResourceAdapterRepository; import org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData; import org.jboss.modules.ModuleLoader; import org.jboss.msc.service.Service; @@ -71,6 +70,7 @@ /** * @author Carlo de Wolf + * @author Richard Opalka */ public class MessageDrivenComponentDescription extends EJBComponentDescription { private final Properties activationProps; @@ -105,8 +105,6 @@ public MessageDrivenComponentDescription(final String componentName, final Strin this.activationProps = activationProps; this.messageListenerInterfaceName = messageListenerInterfaceName; this.defaultMdbPoolAvailable = defaultMdbPoolAvailable; - // setup a dependency on the EJBUtilities service - this.addDependency(EJBUtilities.SERVICE_NAME); registerView(getEJBClassName(), MethodIntf.MESSAGE_ENDPOINT); // add the interceptor which will invoke the setMessageDrivenContext() method on a MDB which implements @@ -142,7 +140,6 @@ public ComponentConfiguration createConfiguration(final ClassReflectionIndex cla mdbComponentConfiguration.getCreateDependencies().add(new DependencyConfigurator() { @Override public void configureDependency(final ServiceBuilder serviceBuilder, final MessageDrivenComponentCreateService mdbComponentCreateService) throws DeploymentUnitProcessingException { - serviceBuilder.addDependency(EJBUtilities.SERVICE_NAME, EJBUtilities.class, mdbComponentCreateService.getEJBUtilitiesInjector()); serviceBuilder.addDependency(SuspendController.SERVICE_NAME, SuspendController.class, mdbComponentCreateService.getSuspendControllerInjectedValue()); } }); @@ -348,10 +345,11 @@ public void configureDependency(ServiceBuilder serviceBuilder, Service { @Override - public void configureDependency(ServiceBuilder serviceBuilder, MessageDrivenComponentCreateService service) throws DeploymentUnitProcessingException { + public void configureDependency(ServiceBuilder serviceBuilder, MessageDrivenComponentCreateService service) { final ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(MessageDrivenComponentDescription.this.resourceAdapterName); // add the dependency on the RA service + serviceBuilder.addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, service.getResourceAdapterRepositoryInjector()); serviceBuilder.addDependency(raServiceName, ResourceAdapter.class, service.getResourceAdapterInjector()); } } diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/inflow/EndpointDeployer.java b/ejb3/src/main/java/org/jboss/as/ejb3/inflow/EndpointDeployer.java deleted file mode 100644 index 3e2d116fb0aa..000000000000 --- a/ejb3/src/main/java/org/jboss/as/ejb3/inflow/EndpointDeployer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright (c) 2011, Red Hat, Inc., 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.as.ejb3.inflow; - -import javax.resource.spi.ActivationSpec; -import java.util.Properties; - -/** - * Connector 1.6 13.4.3 Endpoint Deployer - * The endpoint deployer is a human who has the responsibility to deploy the message - * endpoint, or application, on an application server. The deployer is expected to know - * the requirements of the application and be aware of the details of the runtime - * environment in which the application will be deployed. - * - * In JBoss we have automated the endpoint deployer. :-) - * - * @author Carlo de Wolf - */ -public interface EndpointDeployer { - /** - * The deployer configures an ActivationSpec JavaBean instance based on the - * information provided by the application developer or assembler, which is contained - * in the endpoint deployment descriptor or by way of metadata annotations described - * in Section 18.7, “@Activation” on page 18-14. The deployer may also use additional - * message provider-specific information to configure the ActivationSpec JavaBean - * instance. - * - * @param resourceAdapterName the name of the resource adapter to use - * @param messageListenerInterface the listener interface of the endpoint - * @param beanProps the standard and provider-specific information for configuring the activation spec - * @param classLoader the class loader which holds the activation spec class - * @return - */ - ActivationSpec createActivationSpecs(String resourceAdapterName, Class messageListenerInterface, Properties beanProps, ClassLoader classLoader); -} diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemAdd.java b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemAdd.java index 2d0aca744b61..098e619bc22e 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemAdd.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemAdd.java @@ -39,7 +39,6 @@ import java.net.URI; import java.util.function.Supplier; -import org.jboss.as.connector.util.ConnectorServices; import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; @@ -49,7 +48,6 @@ import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.clustering.SingletonBarrierService; -import org.jboss.as.ejb3.component.EJBUtilities; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.as.ejb3.deployment.DeploymentRepositoryService; import org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor; @@ -135,7 +133,6 @@ import org.jboss.dmr.ModelNode; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.javax.rmi.RemoteObjectSubstitutionManager; -import org.jboss.jca.core.spi.rar.ResourceAdapterRepository; import org.jboss.metadata.ejb.spec.EjbJarMetaData; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; @@ -156,6 +153,7 @@ * Add operation handler for the EJB3 subsystem. * * @author Emanuel Muckenhuber + * @author Richard Opalka */ class EJB3SubsystemAdd extends AbstractBoottimeAddStepHandler { @@ -414,13 +412,6 @@ protected void execute(DeploymentProcessorTarget processorTarget) { .install(); if (!appclient) { - final EJBUtilities utilities = new EJBUtilities(); - ServiceBuilder ejbUtilsBuilder = serviceTarget.addService(EJBUtilities.SERVICE_NAME, utilities) - .addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, utilities.getResourceAdapterRepositoryInjector()) - .setInitialMode(ServiceController.Mode.PASSIVE); - ejbUtilsBuilder.install(); - - // create the POA Registry use by iiop final POARegistry poaRegistry = new POARegistry(); context.getServiceTarget().addService(POARegistry.SERVICE_NAME, poaRegistry) diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBStatistics.java b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBStatistics.java new file mode 100644 index 000000000000..eb4a96e29bac --- /dev/null +++ b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBStatistics.java @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright (c) 2018, Red Hat, Inc., 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.as.ejb3.subsystem; + +/** + * @author Richard Opalka + */ +public final class EJBStatistics { + + private static final EJBStatistics INSTANCE = new EJBStatistics(); + private volatile boolean enabled; + + private EJBStatistics() {} + + public boolean isEnabled() { + return enabled; + } + + void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + public static EJBStatistics getInstance() { + return INSTANCE; + } + +} diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatisticsEnabledWriteHandler.java b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatisticsEnabledWriteHandler.java index 886ca8ec0900..caa52c2e4148 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatisticsEnabledWriteHandler.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatisticsEnabledWriteHandler.java @@ -25,14 +25,13 @@ import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; -import org.jboss.as.ejb3.component.EJBUtilities; import org.jboss.dmr.ModelNode; -import org.jboss.msc.service.ServiceRegistry; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.STATISTICS_ENABLED; /** * @author Carlo de Wolf + * @author Richard Opalka */ class StatisticsEnabledWriteHandler extends AbstractWriteAttributeHandler { static StatisticsEnabledWriteHandler INSTANCE = new StatisticsEnabledWriteHandler(); @@ -57,11 +56,6 @@ protected void revertUpdateToRuntime(final OperationContext context, final Model void updateToRuntime(final OperationContext context, final ModelNode model) throws OperationFailedException { final boolean statisticsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean(); - utilities(context).setStatisticsEnabled(statisticsEnabled); - } - - private static EJBUtilities utilities(final OperationContext context) { - final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); - return (EJBUtilities) serviceRegistry.getRequiredService(EJBUtilities.SERVICE_NAME).getValue(); + EJBStatistics.getInstance().setEnabled(statisticsEnabled); } }