diff options
author | Martin Schreier <martin_s@apache.org> | 2022-02-13 10:27:32 +0100 |
---|---|---|
committer | Martin Schreier <martin_s@apache.org> | 2022-02-13 10:27:32 +0100 |
commit | 0a2dab16770cce10bda6fa2cc2e2d9c7d64c5dbf (patch) | |
tree | 1e633e0ae7fc56a857b5467a12a67adfc017b9e2 /archiva-modules/archiva-base/archiva-event-central | |
parent | 99bd81ac000598105529473a53f62a5b53d885a5 (diff) | |
download | archiva-0a2dab16770cce10bda6fa2cc2e2d9c7d64c5dbf.tar.gz archiva-0a2dab16770cce10bda6fa2cc2e2d9c7d64c5dbf.zip |
Improving event API
Diffstat (limited to 'archiva-modules/archiva-base/archiva-event-central')
3 files changed, 118 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-event-central/pom.xml b/archiva-modules/archiva-base/archiva-event-central/pom.xml new file mode 100644 index 000000000..cd8a5b084 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-event-central/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>archiva-base</artifactId> + <groupId>org.apache.archiva</groupId> + <version>3.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.archiva.event</groupId> + <artifactId>archiva-event-central</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.archiva.event</groupId> + <artifactId>archiva-event-api</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-event-central/src/main/java/org/apache/archiva/event/central/CentralEventManager.java b/archiva-modules/archiva-base/archiva-event-central/src/main/java/org/apache/archiva/event/central/CentralEventManager.java new file mode 100644 index 000000000..44ba9df43 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-event-central/src/main/java/org/apache/archiva/event/central/CentralEventManager.java @@ -0,0 +1,42 @@ +package org.apache.archiva.event.central; +/* + * 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.apache.archiva.event.AbstractEventManager; +import org.apache.archiva.event.Event; +import org.apache.archiva.event.EventHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * Event manager that collects all events from archiva subsystems. + * + * @author Martin Schreier <martin_s@apache.org> + */ +@Service("eventManager#archiva") +public class CentralEventManager extends AbstractEventManager implements EventHandler<Event> +{ + private static final Logger log = LoggerFactory.getLogger( CentralEventManager.class ); + + @Override + public void handle( Event event ) + { + log.info( "Event: type={}, sourceClass={}, source={}", event.getType( ), event.getSource().getClass(), event.getSource() ); + } +} diff --git a/archiva-modules/archiva-base/archiva-event-central/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-event-central/src/main/resources/META-INF/spring-context.xml new file mode 100644 index 000000000..654b2f876 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-event-central/src/main/resources/META-INF/spring-context.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> + +<!-- + ~ 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. + --> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd" + default-lazy-init="true"> + + <context:annotation-config /> + <context:component-scan base-package="org.apache.archiva.event.central"/> + +</beans>
\ No newline at end of file |