最新版本:5.7.0
這是Holon平台的核心模塊,代表平台基礎,提供了整體體系結構,基礎結構和API的定義。
模塊的亮點是:
Context資源Property模型和Datastore APIJWT )支持有關詳細信息,請參見模塊文檔。
就像任何其他平台模塊一樣,此工件也是Holon平台生態系統的一部分,但也可以用作獨立庫。
有關更多詳細信息,請參見入門和平台文檔。
屬性模型定義:
public interface Subject {
static NumericProperty < Long > ID = NumericProperty . longType ( "id" );
static StringProperty NAME = StringProperty . create ( "name" );
static StringProperty SURNAME = StringProperty . create ( "surname" );
static TemporalProperty < LocalDate > BIRTH = TemporalProperty . localDate ( "birth" );
static BooleanProperty ACTIVE = BooleanProperty . create ( "active" );
static VirtualProperty < String > FULL_NAME = VirtualProperty . create ( String . class ,
propertyBox -> propertyBox . getValue ( NAME ) + " " + propertyBox . getValue ( SURNAME ));
static PropertySet <?> SUBJECT = PropertySet . of ( ID , NAME , SURNAME , BIRTH , ACTIVE , FULL_NAME );
}屬性配置:
static StringProperty NAME = StringProperty . create ( "name" ). message ( "Name" ). messageCode ( "localization.name" )
. withConfiguration ( "my-config" , "my-value" );屬性值轉換器:
static StringProperty INTEGER_MODEL = StringProperty . create ( "integer_value" ). converter ( Integer . class ,
integer -> String . valueOf ( integer ), string -> Integer . valueOf ( string ));物業驗證者:
static StringProperty NAME = StringProperty . create ( "name" )
. withValidator ( Validator . notBlank ()). withValidator ( Validator . max ( 50 ));財產主持人和渲染器:
String value = NAME . present ( "A value" );
MyType myType = NAME . render ( MyType . class );屬性箱:
PropertyBox propertyBox = PropertyBox . create ( SUBJECT );
String name = propertyBox . getValue ( NAME );
Optional < String > oname = propertyBox . getValueIfPresent ( NAME );
propertyBox . setValue ( NAME , "John" );
propertyBox . propertyValues (). forEach ( propertyValue -> {
Property <?> property = propertyValue . getProperty ();
Object value = propertyValue . getValue ();
});數據存儲:
DataTarget <?> TARGET = DataTarget . named ( "subjects" );
Datastore datastore = getDatastore ();
Stream < PropertyBox > results = datastore . query (). target ( TARGET )
. filter ( NAME . contains ( "a" ). and ( SURNAME . isNotNull ())). sort ( BIRTH . desc ()). stream ( SUBJECT );
Stream < String > names = datastore . query ( TARGET ). aggregate ( SURNAME ). stream ( NAME . max ());
Optional < String > name = datastore . query ( TARGET ). filter ( ID . eq ( 1L )). findOne ( NAME );
datastore . insert ( TARGET , PropertyBox . builder ( SUBJECT ). set ( ID , 1L ). set ( NAME , "John" ). set ( ACTIVE , true ). build ());
datastore . bulkUpdate ( TARGET ). set ( ACTIVE , true ). filter ( BIRTH . lt ( LocalDate . now ())). execute ();
datastore . query ( TARGET ). filter ( ID . eq ( 1L )). findOne ( SUBJECT ). ifPresent ( subject -> datastore . delete ( TARGET , subject ));Bean PropertySet和數據存儲:
class MyBean {
private @ NotNull Long id ;
private @ Caption ( "The name" ) String name ;
private @ Caption ( "The surname" ) String surname ;
/* getters and setters omitted */
}
BeanPropertySet < MyBean > propertySet = BeanPropertySet . create ( MyBean . class );
PathProperty <?> name = propertySet . property ( "name" );
PathProperty < String > typedName = propertySet . property ( "name" , String . class );
BeanDatastore datastore = BeanDatastore . of ( getDatastore ());
Stream < MyBean > results = datastore . query ( MyBean . class ). filter ( propertySet . property ( "name" ). eq ( "John" )). stream ();
datastore . save ( new MyBean ());領域:
Realm realm = Realm . builder (). withAuthenticator ( Authenticator . create ( MyAuthenticationToken . class , token -> {
if ( "test" . equals ( token . getPrincipal ())) {
return Authentication . builder ( "test" ). withPermission ( "ROLE1" ). build ();
}
throw new UnknownAccountException ();
}))
. withDefaultAuthorizer (). build ();
Realm . builder (). withAuthenticator ( Account . authenticator ( id -> Optional . of ( Account . builder ( id ). build ()))). build ();authcontext:
AuthContext context = AuthContext . create ( realm );
context . authenticate ( AuthenticationToken . accountCredentials ( "test" , "pwd" ));
Optional < Authentication > authentication = context . getAuthentication ();
boolean permitted = context . isPermitted ( "ROLE1" , "ROLE2" );RESTClient:
RestClient client = RestClient . forTarget ( "https://rest.api.example" );
ResponseEntity < TestData > response = client . request ()
. path ( "test/{id}" ). resolve ( "id" , 123 )
. accept ( MediaType . APPLICATION_JSON )
. header ( "MY_HEADER" , "my-value" )
. authorizationBearer ( "An389fz56xsr7" )
. get ( TestData . class );
HttpStatus status = response . getStatus ();
Optional < TestData > payload = response . getPayload ();
Optional < TestData > data = client . request (). path ( "test/{id}" ). resolve ( "id" , 123 )
. getForEntity ( TestData . class );
List < TestData > results = client . request (). path ( "test" ). getAsList ( TestData . class );
client . request (). path ( "test" ). post ( RequestEntity . json ( new TestData ()));
Optional < PropertyBox > propertyBox = client . request (). path ( "test2" )
. propertySet ( PROPERTIES ). getForEntity ( PropertyBox . class ); bertization -context:
LocalizationContext localizationContext = LocalizationContext . builder ()
. withMessageProvider ( MessageProvider . fromProperties ( "messages" ). build ())
. withDefaultDateTemporalFormat ( TemporalFormat . MEDIUM )
. withInitialLocale ( Locale . US )
. build ();
localizationContext . localize ( Locale . ITALY );
String localized = localizationContext . getMessage ( "message.code" , "Default message" );
String formatted = localizationContext . format ( LocalDate . now ());
formatted = localizationContext . format ( 123.4d );
Optional < LocalizationContext > current = LocalizationContext . getCurrent ();請參閱“用戶指南”和“完整示例”的模塊文檔。
請參閱Holon平台代碼結構和約定,以了解開發和組織項目代碼庫的“真正的Java API”理念。
Holon平台是使用Java 11構建的,因此您需要JRE/JDK版本11或更高版本才能使用平台工件。
有關可用發行版,請參見發行版。每個版本標籤都提供了封閉問題的鏈接。
Holon平台是開源的,並根據Apache 2.0許可證獲得許可。 Maven Central存儲庫都可以使用所有工件(包括二進製文件,來源和Javadocs)。
該模塊的Maven組ID是com.holon-platform.core 。
Maven bom:
< dependencyManagement >
< dependency >
< groupId >com.holon-platform.core</ groupId >
< artifactId >holon-bom</ artifactId >
< version >5.7.0</ version >
< type >pom</ type >
< scope >import</ scope >
</ dependency >
</ dependencyManagement >有關此模塊可用偽像的列表,請參見“文物”列表。
Holon平台提供了整體的BOM(材料清單) ,以輕鬆獲取所有可用的平台文物:
平台Maven bom:
< dependencyManagement >
< dependency >
< groupId >com.holon-platform</ groupId >
< artifactId >bom</ artifactId >
< version >${platform-version}</ version >
< type >pom</ type >
< scope >import</ scope >
</ dependency >
</ dependencyManagement >有關此模塊可用偽像的列表,請參見“文物”列表。
您可以使用Maven(建議使用3.3.x版或更高版本)來構建來源:
mvn clean install
檢查平台文檔或特定模塊文檔。
在堆棧溢出方面詢問一個問題。我們監視holon-platform標籤。
報告一個問題。
也提供商業支持。
有關一組示例項目,請參見Holon平台示例存儲庫。
參見為Holon平台做出貢獻。
加入任何問題的貢獻室,並與我們聯繫。
所有Holon平台模塊都是在Apache 2.0許可證下發布的開源軟件。
Maven組ID : com.holon-platform.core
| 文物ID | 描述 |
|---|---|
holon-core | 平台核心組件,服務和API |
holon-http | HTTP消息支持 |
holon-async-http | 異步HTTP消息支持 |
holon-async-datastore | 異步數據存儲API |
holon-auth | 身份驗證和授權 |
holon-auth-jwt | JSON網絡令牌支持 |
holon-spring | 春季整合 |
holon-spring-security | 春季安全集成 |
holon-spring-boot | 春季啟動集成 |
holon-starter | 基本彈簧靴啟動器 |
holon-starter-security | 帶有彈簧安全集成的基本彈簧啟動器 |
holon-starter-test | 基本彈簧啟動器用於單位測試 |
holon-bom | 材料清單 |
holon-bom-platform | 包括外部依賴的材料清單 |
documentation-core | 文件 |