2 * Copyright © 2020 Bell Canada.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.core.listeners
19 import org.onap.ccsdk.cds.blueprintsprocessor.core.cluster.BlueprintClusterTopic
20 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterMessage
21 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService
22 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterMessageListener
23 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.ClusterJoinedEvent
24 import org.onap.ccsdk.cds.controllerblueprints.core.logger
25 import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintCompileCache
26 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
27 import org.springframework.context.event.EventListener
28 import org.springframework.stereotype.Component
31 @ConditionalOnProperty("CLUSTER_ENABLED", havingValue = "true")
32 open class BlueprintCompilerCacheMessageListener(private val clusterService: BlueprintClusterService) : BlueprintClusterMessageListener<String> {
33 private val log = logger(BlueprintCompilerCacheMessageListener::class)
35 @EventListener(ClusterJoinedEvent::class)
37 log.info("Registering BlueprintCompilerCacheMessageListener")
38 clusterService.addBlueprintClusterMessageListener(BlueprintClusterTopic.BLUEPRINT_CLEAN_COMPILER_CACHE, this)
41 override fun onMessage(message: BlueprintClusterMessage<String>?) {
43 log.info("Received ClusterMessage - Cleaning compile cache for blueprint (${it.payload})")
44 BlueprintCompileCache.cleanClassLoader(it.payload)