You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractMonitoredConsumer.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package org.apache.archiva.consumers;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.common.FileTypeUtils;
  21. import java.util.HashSet;
  22. import java.util.Iterator;
  23. import java.util.List;
  24. import java.util.Set;
  25. /**
  26. * AbstractMonitoredConsumer
  27. *
  28. *
  29. */
  30. public abstract class AbstractMonitoredConsumer
  31. implements Consumer
  32. {
  33. private Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>();
  34. public void addConsumerMonitor( ConsumerMonitor monitor )
  35. {
  36. monitors.add( monitor );
  37. }
  38. public void removeConsumerMonitor( ConsumerMonitor monitor )
  39. {
  40. monitors.remove( monitor );
  41. }
  42. protected void triggerConsumerError( String type, String message )
  43. {
  44. for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); )
  45. {
  46. ConsumerMonitor monitor = itmonitors.next();
  47. try
  48. {
  49. monitor.consumerError( this, type, message );
  50. }
  51. catch ( Throwable t )
  52. {
  53. /* discard error */
  54. }
  55. }
  56. }
  57. protected void triggerConsumerWarning( String type, String message )
  58. {
  59. for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); )
  60. {
  61. ConsumerMonitor monitor = itmonitors.next();
  62. try
  63. {
  64. monitor.consumerWarning( this, type, message );
  65. }
  66. catch ( Throwable t )
  67. {
  68. /* discard error */
  69. }
  70. }
  71. }
  72. protected void triggerConsumerInfo( String message )
  73. {
  74. for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); )
  75. {
  76. ConsumerMonitor monitor = itmonitors.next();
  77. try
  78. {
  79. monitor.consumerInfo( this, message );
  80. }
  81. catch ( Throwable t )
  82. {
  83. /* discard error */
  84. }
  85. }
  86. }
  87. public boolean isProcessUnmodified()
  88. {
  89. return false;
  90. }
  91. protected List<String> getDefaultArtifactExclusions()
  92. {
  93. return FileTypeUtils.DEFAULT_EXCLUSIONS;
  94. }
  95. }