-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e340937
commit 6a1d115
Showing
12 changed files
with
91 additions
and
34 deletions.
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
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
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
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
12 changes: 12 additions & 0 deletions
12
...j/aspire4j/src/main/java/com/microsoft/aspire/resources/traits/IntrospectiveResource.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 |
---|---|---|
@@ -1,5 +1,17 @@ | ||
package com.microsoft.aspire.resources.traits; | ||
|
||
/** | ||
* Interface for resources that can introspect themselves. This is useful for resources that need to look at the | ||
* environment they are running in to determine their configuration, for example to look at referenced projects, or | ||
* to determine properties from remote resources. | ||
* <p> | ||
* Note that the Aspire App Host never directly calls the introspect() method. Instead, calling the introspect() method | ||
* is the responsibility of the resource creator. This is because the resource creator is the one who knows when the | ||
* resource is ready to be introspected. Introspective resources should implement the appropriate lifecycle methods | ||
* in {@link ResourceWithLifecycle} to ensure that they are introspected at the right time. | ||
* | ||
* @see ResourceWithLifecycle | ||
*/ | ||
public interface IntrospectiveResource { | ||
void introspect(); | ||
} |
46 changes: 46 additions & 0 deletions
46
...j/aspire4j/src/main/java/com/microsoft/aspire/resources/traits/ResourceWithLifecycle.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,46 @@ | ||
package com.microsoft.aspire.resources.traits; | ||
|
||
/** | ||
* All resources have a lifecycle, beginning with creation and ending with the resource being written out to the | ||
* aspire manifest. Within this lifecycle, there are times when the resource should ideally be configured, introspected, | ||
* and then written out. The stages of a resources lifecycle are: | ||
* | ||
* <ol> | ||
* <li>Resource is created - Resource constructor is called.</li> | ||
* <li>Resource is added to the distributed application - onResourceAdded() is called.</li> | ||
* <li>Prior to writing the resource to the aspire manifest, onResourcePrecommit() is called on all resources in the | ||
* order they were added to the distributed application.</li> | ||
* </ol> | ||
* | ||
* <p>The most important point to understand about resource lifecycles is that resources work best when they are | ||
* configured as early as possible, as this allows for other resources to glean more information from them. A resource | ||
* that keeps its cards close to its chest only hurts the resources around it!</p> | ||
* | ||
* @see com.microsoft.aspire.resources.Resource | ||
* @see IntrospectiveResource | ||
*/ | ||
public interface ResourceWithLifecycle { | ||
|
||
/** | ||
* This method is called immediately after the resource is added to the distributed application. It is the earliest | ||
* time that the resource can be configured. | ||
*/ | ||
default void onResourceAdded() { | ||
|
||
} | ||
|
||
/** | ||
* This method is called immediately after the resource is removed from the distributed application. | ||
*/ | ||
default void onResourceRemoved() { | ||
|
||
} | ||
|
||
/** | ||
* Prior to writing the resource to the aspire manifest, onResourcePrecommit() is called on all resources in the | ||
* order they were added to the distributed application. | ||
*/ | ||
default void onResourcePrecommit() { | ||
|
||
} | ||
} |