PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/webservices/server-integration/src/main/java/org/jboss/as/webservices/deployers/EndpointRecordProcessorDeploymentAspect.java

#
Java | 80 lines | 45 code | 8 blank | 27 comment | 6 complexity | 79dfc5ba535b48151118ba7b31a9b2f2 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2006, Red Hat Middleware LLC, and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.webservices.deployers;
  23. import java.util.Collections;
  24. import java.util.Iterator;
  25. import java.util.LinkedList;
  26. import java.util.List;
  27. import java.util.ServiceLoader;
  28. import org.jboss.ws.api.monitoring.RecordProcessor;
  29. import org.jboss.ws.api.monitoring.RecordProcessorFactory;
  30. import org.jboss.ws.common.integration.AbstractDeploymentAspect;
  31. import org.jboss.wsf.spi.deployment.Deployment;
  32. import org.jboss.wsf.spi.deployment.Endpoint;
  33. /**
  34. * An aspect that sets the record processors for each endpoint.
  35. *
  36. * @author alessio.soldano@jboss.com
  37. * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
  38. */
  39. public final class EndpointRecordProcessorDeploymentAspect extends AbstractDeploymentAspect {
  40. private List<RecordProcessor> processors = new LinkedList<RecordProcessor>();
  41. public EndpointRecordProcessorDeploymentAspect() {
  42. ServiceLoader<RecordProcessorFactory> loader = ServiceLoader.load(RecordProcessorFactory.class);
  43. Iterator<RecordProcessorFactory> iterator = loader.iterator();
  44. while (iterator.hasNext()) {
  45. RecordProcessorFactory factory = iterator.next();
  46. processors.addAll(factory.newRecordProcessors());
  47. }
  48. }
  49. @Override
  50. public void start(final Deployment dep) {
  51. for (final Endpoint ep : dep.getService().getEndpoints()) {
  52. List<RecordProcessor> processorList = new LinkedList<RecordProcessor>();
  53. if (processors != null) {
  54. for (RecordProcessor pr : processors) {
  55. try {
  56. RecordProcessor clone = (RecordProcessor)pr.clone();
  57. processorList.add(clone);
  58. }
  59. catch (final CloneNotSupportedException ex) {
  60. throw new RuntimeException(ex);
  61. }
  62. }
  63. }
  64. ep.setRecordProcessors(processorList);
  65. }
  66. }
  67. public void stop(final Deployment dep) {
  68. for (final Endpoint ep : dep.getService().getEndpoints()) {
  69. ep.setRecordProcessors(Collections.<RecordProcessor>emptyList());
  70. }
  71. }
  72. }