Sling Model 入门

Sling Model的作用

Entirely annotation driven. “Pure” POJOs.
纯注解驱动

Use standard annotations where possible.
尽可能的使用标准注释

Pluggable
可插入的

OOTB, support resource properties (via ValueMap), SlingBindings, OSGi services, request attributes.
支持资源属性(通过ValueMap)、SlingBindings、OSGi服务和请求属性

Adapt multiple objects - minimal required Resource and SlingHttpServletRequest
适应多个对象-最小所需Resource和SlingHttpServletRequest

Client doesn’t know/care that these objects are different than any other adapter factory
客户端不知道/不关心这些对象是否与其他适配器工厂不同

Support both classes and interfaces.
支持类和接口。

Work with existing Sling infrastructure (i.e. not require changes to other bundles).
使用现有Sling基础设施(即不需要更改其他捆绑包)。

基本用法

在最简单的情况下,用@Model和可适应的类对类进行注释。需要注入的字段用@Inject注释:

@Model(adaptables=Resource.class)
public class MyModel {

    @Inject
    private String propertyN
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值