introduce own interfaces for registering the currentTenantKeyGenerator
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Defines the interfaces to register the {@link KeyGenerator} as bean which is
|
||||
* used by spring caching framework to resolve the key-generator. The
|
||||
* key-generator must registered as bean so spring can resolve the key-generator
|
||||
* by its name.
|
||||
*
|
||||
* When using the {@link Service} annotation e.g. by {@link JpaSystemManagement}
|
||||
* the bean registration must be declared by the interface due spring registers
|
||||
* the bean by the implemented interfaces. So introduce a single interface for
|
||||
* the {@link JpaSystemManagement} implementation to allow it to register the
|
||||
* key-generator bean.
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface CurrentTenantCacheKeyGenerator {
|
||||
|
||||
/**
|
||||
* Bean declaration to register a {@code currentTenantKeyGenerator} bean
|
||||
* which is used by the caching framework.
|
||||
*
|
||||
* @return the {@link KeyGenerator} to be used to cache the values of the
|
||||
* current used tenant in the {@link JpaSystemManagement}
|
||||
*/
|
||||
@Bean
|
||||
KeyGenerator currentTenantKeyGenerator();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED)
|
||||
@Validated
|
||||
@Service
|
||||
public class JpaSystemManagement implements SystemManagement {
|
||||
public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, SystemManagement {
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user