Migrating basic event API to archiva commons

This commit is contained in:
Martin Stockhammer 2019-10-03 18:30:48 +02:00
parent 7a4bc877e2
commit 405687b120
39 changed files with 132 additions and 56 deletions

View File

@ -51,6 +51,24 @@
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-console-standalone</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,6 +19,8 @@ package org.apache.archiva.repository.events;
* under the License.
*/
import org.apache.archiva.event.Event;
import java.util.EventListener;
/**

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -25,7 +25,8 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class EventManager implements EventSource {
public class EventManager implements EventSource
{
private static final Logger log = LoggerFactory.getLogger(EventManager.class);

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -26,7 +26,7 @@ package org.apache.archiva.repository.events;
*/
public interface EventSource {
<T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);
<T extends Event> void registerEventHandler( EventType<T> type, EventHandler<? super T> eventHandler);
<T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -0,0 +1,46 @@
package org.apache.archiva.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Martin Stockhammer <martin_s@apache.org>
*/
public class EventManagerTest
{
@Test
public void registerEventHandler( )
{
}
@Test
public void unregisterEventHandler( )
{
}
@Test
public void fireEvent( )
{
}
}

View File

@ -36,7 +36,7 @@ import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryProvider;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.event.Event;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;

View File

@ -27,7 +27,7 @@ import org.apache.archiva.metadata.repository.*;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.commons.lang3.StringUtils;

View File

@ -33,7 +33,7 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;

View File

@ -27,11 +27,9 @@ import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang3.time.DateUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

View File

@ -33,7 +33,7 @@ import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -27,7 +27,7 @@ import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import java.nio.file.Files;
import java.nio.file.Path;

View File

@ -28,7 +28,7 @@ import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
@ -57,7 +57,6 @@ import java.util.stream.Collectors;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
*/

View File

@ -27,7 +27,7 @@ import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.custommonkey.xmlunit.XMLAssert;
import org.easymock.EasyMock;

View File

@ -20,9 +20,8 @@ package org.apache.archiva.consumers.core.repository;
*/
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.commons.lang3.time.DateUtils;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Test;

View File

@ -20,7 +20,7 @@ package org.apache.archiva.consumers.core.repository;
*/
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.easymock.EasyMock;
import org.junit.After;

View File

@ -32,8 +32,7 @@ import org.apache.archiva.repository.PasswordCredentials;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.repository.events.RepositoryValueEvent;
import org.apache.archiva.event.Event;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryGroup;
import org.apache.archiva.repository.RepositoryProvider;

View File

@ -32,8 +32,8 @@ import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.events.EventHandler;
import org.apache.archiva.repository.events.RepositoryRegistryEvent;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.event.RepositoryRegistryEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

View File

@ -20,7 +20,7 @@ package org.apache.archiva.repository;
*/
import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.repository.events.EventSource;
import org.apache.archiva.event.EventSource;
import org.apache.archiva.repository.storage.RepositoryStorage;
import org.apache.archiva.repository.features.RepositoryFeature;
import org.apache.archiva.repository.storage.StorageAsset;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.repository;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.repository.events.EventHandler;
import org.apache.archiva.event.EventHandler;
import java.io.IOException;
import java.util.Set;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,6 +19,7 @@ package org.apache.archiva.repository.events;
* under the License.
*/
import org.apache.archiva.event.EventType;
import org.apache.archiva.repository.Repository;
/**

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,13 +19,16 @@ package org.apache.archiva.repository.events;
* under the License.
*/
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventType;
import org.apache.archiva.repository.Repository;
/**
* A repository event is specific to a repository and holds a reference to the repository that
* is related to this event.
*/
public class RepositoryEvent extends Event {
public class RepositoryEvent extends Event
{
private static final long serialVersionUID = 4676673476606414834L;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -20,6 +20,7 @@ package org.apache.archiva.repository.events;
*/
import org.apache.archiva.event.EventType;
import org.apache.archiva.repository.Repository;
import java.net.URI;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,10 +19,14 @@ package org.apache.archiva.repository.events;
* under the License.
*/
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventType;
/**
* Repository registry events are raised by the repository registry itself.
*/
public class RepositoryRegistryEvent extends Event {
public class RepositoryRegistryEvent extends Event
{
private static final long serialVersionUID = -4740127827269612094L;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,6 +19,7 @@ package org.apache.archiva.repository.events;
* under the License.
*/
import org.apache.archiva.event.EventType;
import org.apache.archiva.repository.Repository;
/**

View File

@ -19,8 +19,8 @@ package org.apache.archiva.repository.features;
* under the License.
*/
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.repository.events.EventHandler;
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventHandler;
import java.util.ArrayList;
import java.util.Collection;

View File

@ -21,8 +21,8 @@ package org.apache.archiva.repository.features;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.events.RepositoryIndexEvent;
import org.apache.archiva.repository.events.EventHandler;
import org.apache.archiva.repository.event.RepositoryIndexEvent;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang3.StringUtils;

View File

@ -23,8 +23,12 @@ import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinition;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.event.EventManager;
import org.apache.archiva.event.EventType;
import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.repository.events.*;
import org.apache.archiva.repository.event.*;
import org.apache.archiva.repository.storage.RepositoryStorage;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.features.RepositoryFeature;
@ -40,11 +44,9 @@ import java.net.URI;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.nio.file.CopyOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -341,7 +343,7 @@ public abstract class AbstractRepository implements EditableRepository, EventHan
}
@Override
public <T extends Event> void registerEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) {
public <T extends Event> void registerEventHandler( EventType<T> eventType, EventHandler<? super T> eventHandler) {
if (!EventType.isInstanceOf(eventType, RepositoryEvent.ANY)) {
throw new IllegalArgumentException("Can only register RepositoryEvent Handlers");
}

View File

@ -20,10 +20,14 @@ package org.apache.archiva.repository;
*/
import org.apache.archiva.configuration.*;
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventManager;
import org.apache.archiva.event.EventSource;
import org.apache.archiva.event.EventType;
import org.apache.archiva.indexer.*;
import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.repository.events.*;
import org.apache.archiva.repository.events.EventHandler;
import org.apache.archiva.repository.event.*;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.apache.commons.lang3.StringUtils;
@ -1220,7 +1224,7 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
@Override
public <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) {
public <T extends Event> void registerEventHandler( EventType<T> type, EventHandler<? super T> eventHandler) {
eventManager.registerEventHandler(type, eventHandler);
}

View File

@ -23,8 +23,7 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.repository.events.RepositoryValueEvent;
import org.apache.archiva.event.Event;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;

View File

@ -32,8 +32,7 @@ import org.apache.archiva.repository.PasswordCredentials;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.repository.events.RepositoryValueEvent;
import org.apache.archiva.event.Event;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryGroup;
import org.apache.archiva.repository.RepositoryProvider;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.repository.maven2;
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.configuration.*;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.events.Event;
import org.apache.archiva.event.Event;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;

View File

@ -53,7 +53,7 @@ import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.storage.RepositoryStorage;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;

View File

@ -30,7 +30,7 @@ import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
import org.apache.archiva.xml.XMLException;

View File

@ -30,7 +30,7 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataI
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException;
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.repository.events;
package org.apache.archiva.repository.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -36,7 +36,7 @@ import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.apache.archiva.xml.XMLException;
import java.io.IOException;

View File

@ -26,7 +26,7 @@ import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataException;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.event.RepositoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;