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.

ConfigurationHandler.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package org.apache.archiva.repository.base;
  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. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.components.registry.RegistryException;
  20. import org.apache.archiva.configuration.ArchivaConfiguration;
  21. import org.apache.archiva.configuration.Configuration;
  22. import org.apache.archiva.configuration.ConfigurationListener;
  23. import org.apache.archiva.configuration.IndeterminateConfigurationException;
  24. import org.springframework.stereotype.Service;
  25. import java.util.concurrent.locks.ReentrantReadWriteLock;
  26. /**
  27. * This is just a simple wrapper to access the archiva configuration used by the registry and associated classes
  28. *
  29. * @author Martin Stockhammer <martin_s@apache.org>
  30. */
  31. @Service("configurationHandler#default")
  32. public class ConfigurationHandler
  33. {
  34. public static final String REGISTRY_EVENT_TAG = "repositoryRegistry";
  35. private ArchivaConfiguration archivaConfiguration;
  36. final ReentrantReadWriteLock lock = new ReentrantReadWriteLock( );
  37. public ConfigurationHandler( ArchivaConfiguration archivaConfiguration ) {
  38. this.archivaConfiguration = archivaConfiguration;
  39. }
  40. public void addListener( ConfigurationListener listener ) {
  41. this.archivaConfiguration.addListener( listener );
  42. }
  43. public ArchivaConfiguration getArchivaConfiguration( )
  44. {
  45. return archivaConfiguration;
  46. }
  47. public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
  48. {
  49. this.archivaConfiguration = archivaConfiguration;
  50. }
  51. public Configuration getBaseConfiguration() {
  52. return archivaConfiguration.getConfiguration( );
  53. }
  54. public void save(Configuration configuration, String eventTag) throws IndeterminateConfigurationException, RegistryException
  55. {
  56. archivaConfiguration.save( configuration, eventTag);
  57. }
  58. public void save(Configuration configuration) throws IndeterminateConfigurationException, RegistryException
  59. {
  60. archivaConfiguration.save( configuration, "" );
  61. }
  62. public ReentrantReadWriteLock getLock() {
  63. return lock;
  64. }
  65. }