⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 events.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 2 页
字号:
#. Tag: para#: events.xml:93#, no-c-formatmsgid """Essentially all of the methods of the <literal>Session</literal> interface ""correlate to an event. You have a <literal>LoadEvent</literal>, a ""<literal>FlushEvent</literal>, etc (consult the XML configuration-file DTD ""or the <literal>org.hibernate.event</literal> package for the full list of ""defined event types). When a request is made of one of these methods, the ""Hibernate <literal>Session</literal> generates an appropriate event and ""passes it to the configured event listeners for that type. Out-of-the-box, ""these listeners implement the same processing in which those methods always ""resulted. However, you are free to implement a customization of one of the ""listener interfaces (i.e., the <literal>LoadEvent</literal> is processed by ""the registered implemenation of the <literal>LoadEventListener</literal> ""interface), in which case their implementation would be responsible for ""processing any <literal>load()</literal> requests made of the ""<literal>Session</literal>."msgstr """基本上,<literal>Session</literal>接口的每个方法都有相对应的事件。比如 ""<literal>LoadEvent</literal>,<literal>FlushEvent</literal>,等等(查阅XML配""置文件 的DTD,以及<literal>org.hibernate.event</literal>包来获得所有已定义的""事件的列表)。当某个方 法被调用时,Hibernate <literal>Session</literal>会生成""一个相对应的事件并激活所 有配置好的事件监听器。系统预设的监听器实现的处理过程""就是被监听的方法要做的(被监听的方法所做的其实仅仅是激活监听器, “实际”的工作""是由监听器完成的)。不过,你可以自由地选择实现 一个自己定制的监听器(比如,实""现并注册用来处理处理<literal>LoadEvent</literal>的""<literal>LoadEventListener</literal>接口), 来负责处理所有的调用""<literal>Session</literal>的<literal>load()</literal>方法的请求。"#. Tag: para#: events.xml:108#, no-c-formatmsgid """The listeners should be considered effectively singletons; meaning, they are ""shared between requests, and thus should not save any state as instance ""variables."msgstr """监听器应该被看作是单例(singleton)对象,也就是说,所有同类型的事件的处理共享同""一个监听器实例,因此监听器 不应该保存任何状态(也就是不应该使用成员变量)。"#. Tag: para#: events.xml:113#, no-c-formatmsgid """A custom listener should implement the appropriate interface for the event ""it wants to process and/or extend one of the convenience base classes (or ""even the default event listeners used by Hibernate out-of-the-box as these ""are declared non-final for this purpose). Custom listeners can either be ""registered programmatically through the <literal>Configuration</literal> ""object, or specified in the Hibernate configuration XML (declarative ""configuration through the properties file is not supported). Here's an ""example of a custom load event listener:"msgstr """用户定制的监听器应该实现与所要处理的事件相对应的接口,或者从一个合适的基类继""承(甚至是从Hibernate自带的默认事件监听器类继承, 为了方便你这样做,这些类都""被声明成non-final的了)。用户定制的监听器可以通过编程使用""<literal>Configuration</literal>对象 来注册,也可以在Hibernate的XML格式的配置""文件中进行声明(不支持在Properties格式的配置文件声明监听器)。 下面是一个用户""定制的加载事件(load event)的监听器:"#. Tag: programlisting#: events.xml:123#, no-c-formatmsgid """<![CDATA[public class MyLoadListener implements LoadEventListener {\n""    // this is the single method defined by the LoadEventListener interface\n""    public void onLoad(LoadEvent event, LoadEventListener.LoadType ""loadType)\n""            throws HibernateException {\n""        if ( !MySecurity.isAuthorized( event.getEntityClassName(), event.""getEntityId() ) ) {\n""            throw MySecurityException(\"Unauthorized access\");\n""        }\n""    }\n""}]]>"msgstr ""#. Tag: para#: events.xml:125#, no-c-formatmsgid """You also need a configuration entry telling Hibernate to use the listener in ""addition to the default listener:"msgstr """你还需要修改一处配置,来告诉Hibernate,除了默认的监听器,还要附加选定的监听""器。"#. Tag: programlisting#: events.xml:130#, no-c-formatmsgid """<![CDATA[<hibernate-configuration>\n""    <session-factory>\n""        ...\n""        <event type=\"load\">\n""            <listener class=\"com.eg.MyLoadListener\"/>\n""            <listener class=\"org.hibernate.event.def.""DefaultLoadEventListener\"/>\n""        </event>\n""    </session-factory>\n""</hibernate-configuration>]]>"msgstr ""#. Tag: para#: events.xml:132#, no-c-formatmsgid "Instead, you may register it programmatically:"msgstr "看看用另一种方式,通过编程的方式来注册它。"#. Tag: programlisting#: events.xml:136#, no-c-formatmsgid """<![CDATA[Configuration cfg = new Configuration();\n""LoadEventListener[] stack = { new MyLoadListener(), new ""DefaultLoadEventListener() };\n""cfg.EventListeners().setLoadEventListeners(stack);]]>"msgstr ""#. Tag: para#: events.xml:138#, no-c-formatmsgid """Listeners registered declaratively cannot share instances. If the same class ""name is used in multiple <literal>&lt;listener/&gt;</literal> elements, each ""reference will result in a separate instance of that class. If you need the ""capability to share listener instances between listener types you must use ""the programmatic registration approach."msgstr """通过在XML配置文件声明而注册的监听器不能共享实例。如果在多个<literal>&lt;""listener/&gt;</literal>节点中使用 了相同的类的名字,则每一个引用都将会产生一""个独立的实例。如果你需要在多个监听器类型之间共享 监听器的实例,则你必须使用编""程的方式来进行注册。"#. Tag: para#: events.xml:146#, no-c-formatmsgid """Why implement an interface and define the specific type during ""configuration? Well, a listener implementation could implement multiple ""event listener interfaces. Having the type additionally defined during ""registration makes it easier to turn custom listeners on or off during ""configuration."msgstr """为什么我们实现了特定监听器的接口,在注册的时候还要明确指出我们要注册哪个事件""的监听器呢? 这是因为一个类可能实现多个监听器的接口。在注册的时候明确指定要监""听的事件,可以让启用或者禁用对某个事件的监听的配置工作简单些。"#. Tag: title#: events.xml:156#, no-c-formatmsgid "Hibernate declarative security"msgstr "Hibernate的声明式安全机制"#. Tag: para#: events.xml:157#, no-c-formatmsgid """Usually, declarative security in Hibernate applications is managed in a ""session facade layer. Now, Hibernate3 allows certain actions to be ""permissioned via JACC, and authorized via JAAS. This is optional ""functionality built on top of the event architecture."msgstr """通常,Hibernate应用程序的声明式安全机制由会话外观层(session facade)所管理。 ""现在,Hibernate3允许某些特定的行为由JACC进行许可管理,由JAAS进行授权管理。 本""功能是一个建立在事件框架之上的可选的功能。"#. Tag: para#: events.xml:163#, no-c-formatmsgid """First, you must configure the appropriate event listeners, to enable the use ""of JAAS authorization."msgstr """首先,你必须要配置适当的事件监听器(event listener),来激活使用JAAS管理授权""的功能。"#. Tag: programlisting#: events.xml:168#, no-c-formatmsgid """<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure.""JACCPreDeleteEventListener\"/>\n""<listener type=\"pre-update\" class=\"org.hibernate.secure.""JACCPreUpdateEventListener\"/>\n""<listener type=\"pre-insert\" class=\"org.hibernate.secure.""JACCPreInsertEventListener\"/>\n""<listener type=\"pre-load\" class=\"org.hibernate.secure.""JACCPreLoadEventListener\"/>]]>"msgstr ""#. Tag: para#: events.xml:170#, no-c-formatmsgid """Note that <literal>&lt;listener type=\"...\" class=\"...\"/&gt;</literal> is ""just a shorthand for <literal>&lt;event type=\"...\"&gt;&lt;listener class=""\"...\"/&gt;&lt;/event&gt;</literal> when there is exactly one listener for ""a particular event type."msgstr """注意,<literal>&lt;listener type=\"...\" class=\"...\"/&gt;</literal>只是""<literal>&lt;event type=\"...\"&gt;&lt;listener class=\"...\"/&gt;&lt;/""event&gt;</literal>的简写,对每一个事件类型都必须严格的有一个监听器与之对应。"#. Tag: para#: events.xml:176#, no-c-formatmsgid """Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to ""roles:"msgstr """接下来,仍然在<literal>hibernate.cfg.xml</literal>文件中,绑定角色的权限:"#. Tag: programlisting#: events.xml:180#, no-c-formatmsgid """<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,""read\"/>\n""<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"msgstr ""#. Tag: para#: events.xml:182#, no-c-formatmsgid "The role names are the roles understood by your JACC provider."msgstr "这些角色的名字就是你的JACC provider所定义的角色的名字。"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -