最新版本: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 | 文档 |