-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve Spring To Spring Beans definition compatibility - MEED-…
…7576 - Meeds-io/meeds#2469 This change will enhance Spring contexts Beans sharing by allowing to reference Bean Interface rather than implementation between Spring contexts and without having to define the Interface As Service with Primary annotation in Implementation.
- Loading branch information
Showing
6 changed files
with
217 additions
and
91 deletions.
There are no files selected for viewing
186 changes: 139 additions & 47 deletions
186
component/common/src/main/java/io/meeds/spring/kernel/KernelContainerLifecyclePlugin.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2023 Meeds Association [email protected] | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
|
@@ -18,33 +18,10 @@ | |
*/ | ||
package io.meeds.spring.module.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import org.exoplatform.commons.api.settings.SettingService; | ||
|
||
import io.meeds.spring.module.model.TestModel; | ||
import io.meeds.spring.module.storage.TestStorage; | ||
|
||
@Service | ||
public class TestService { | ||
|
||
// Fake injection from Kernel for Testing Purpose | ||
@Autowired | ||
private SettingService settingService; | ||
|
||
@Autowired | ||
private TestStorage storage; | ||
public interface TestService { | ||
|
||
public TestModel save(TestModel model) { | ||
if (model == null) { | ||
throw new IllegalArgumentException("TestModel is mandatory"); | ||
} | ||
if (settingService == null) { | ||
// Fake exception | ||
throw new IllegalStateException("SettingService is null"); | ||
} | ||
return storage.save(model); | ||
} | ||
TestModel save(TestModel testModel); | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
component/common/src/test/java/io/meeds/spring/module/service/TestServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.spring.module.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import org.exoplatform.commons.api.settings.SettingService; | ||
|
||
import io.meeds.spring.module.model.TestModel; | ||
import io.meeds.spring.module.storage.TestStorage; | ||
|
||
@Service | ||
public class TestServiceImpl implements TestService { | ||
|
||
// Fake injection from Kernel for Testing Purpose | ||
@Autowired | ||
private SettingService settingService; | ||
|
||
@Autowired | ||
private TestStorage storage; | ||
|
||
@Override | ||
public TestModel save(TestModel model) { | ||
if (model == null) { | ||
throw new IllegalArgumentException("TestModel is mandatory"); | ||
} | ||
if (settingService == null) { | ||
// Fake exception | ||
throw new IllegalStateException("SettingService is null"); | ||
} | ||
return storage.save(model); | ||
} | ||
|
||
} |