zoukankan      html  css  js  c++  java
  • Tapestry5的注解之@Inject

    @Inject

    Tapestry5中有好多个有用的注解,今天记录些@Inject相关的东西。

    Injection is Tapestry's way of making a dependency – such as a resource, asset, component, block or service – available in a page, component, mixin or service class.

    Injection是Tapestry中定义从属关系的方式 - 例如,resource, asset, component, block or service - 在page,component,mixin或者服务类中都可以定义。

    胡乱翻译的。

    1 Block Injection 插入一个块儿。。。

    @Inject
    private Block foo; //默认id为foo的
    
    或者
    @Inject @Id(
    "bar") private Block barBlock; //id已经被指定

    2 Resource Injection 资源插入

    • java.util.Locale – The locale for the component (all components within a page use the same locale).
    • org.slf4j.Logger – A Logger instance configured for the component, based on the component's class name. SLF4J is a wrapper around Log4J or other logging toolkits.
    • org.apache.tapestry5.ComponentResources – The resources for the component, often used to generate links related to the component.
    • org.apache.tapestry5.ioc.Messages – The component message catalog for the component, from which localized messages can be generated.
    @Inject
    private ComponentResources resources;

    3 Asset Injection class或者src什么的

    @Inject
    @Path("context:images/top_banner.png")
    private Asset banner;

    4 Service Injection

    这个比较普遍。。。

    5 Request Injection

    这个目前只见过,request.isXHR() ? someZone.getBody() : null;这一种情况。。。

  • 相关阅读:
    使用没有初始化变量很危险
    openssl动态库编译
    数据库水平切分及问题
    用dpkg命令制作deb包方法总结
    centOS安装mysql---glibc方式
    RabbitMQ常用命令
    shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory
    mysql主从复制实现数据库同步
    CentOS 7.0下使用yum安装MySQL
    RabbitMQ的远程Web管理与监控工具
  • 原文地址:https://www.cnblogs.com/voctrals/p/2972255.html
Copyright © 2011-2022 走看看