-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zj/spring custom initializer 1024 (#323)
* add custom initializer and remove some deprecated staff * use spring aware and leave deprecated stuff * small improvements * add code configuration docu * change naming * Update spring-boot.adoc (#327) --------- Co-authored-by: Florian Habermann <[email protected]>
- Loading branch information
1 parent
67f4291
commit b911fd9
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
...org/microstream/spring/boot/example/simple/initializer/StorageContextInitializerImpl.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,38 @@ | ||
package org.microstream.spring.boot.example.simple.initializer; | ||
|
||
/*- | ||
* #%L | ||
* EclipseStore Integrations SpringBoot | ||
* %% | ||
* Copyright (C) 2023 - 2024 MicroStream Software | ||
* %% | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* #L% | ||
*/ | ||
|
||
import org.eclipse.serializer.reference.Lazy; | ||
import org.eclipse.serializer.reference.LazyReferenceManager; | ||
import org.eclipse.store.integrations.spring.boot.types.initializers.StorageContextInitializer; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* This class is for demonstration purposes only. It shows how to execute code before storage is initialized. | ||
* <a href="https://docs.eclipsestore.io/manual/storage/loading-data/lazy-loading/clearing-lazy-references.html">...</a> | ||
*/ | ||
@Component | ||
public class StorageContextInitializerImpl implements StorageContextInitializer | ||
{ | ||
@Override | ||
public void initialize() | ||
{ | ||
LazyReferenceManager.set(LazyReferenceManager.New( | ||
Lazy.Checker( | ||
1_000_000, // timeout of lazy access | ||
0.75 // memory quota | ||
))); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
.../eclipse/store/integrations/spring/boot/types/initializers/StorageContextInitializer.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,29 @@ | ||
package org.eclipse.store.integrations.spring.boot.types.initializers; | ||
|
||
/*- | ||
* #%L | ||
* EclipseStore Integrations SpringBoot | ||
* %% | ||
* Copyright (C) 2023 - 2024 MicroStream Software | ||
* %% | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* #L% | ||
*/ | ||
|
||
/** | ||
* Interface for storage context initializers. | ||
* Implementations of this interface can provide custom initialization logic | ||
* that will be executed before the creation of the storage foundation. | ||
*/ | ||
public interface StorageContextInitializer | ||
{ | ||
/** | ||
* Method to be implemented with custom initialization logic. | ||
* This method will be called immediately before the storage foundation creation process. | ||
*/ | ||
void initialize(); | ||
} |