[webbeans-commits] Webbeans SVN: r1935 - doc/trunk/reference/zh-CN.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Mar 11 23:20:56 EDT 2009


Author: alartin
Date: 2009-03-11 23:20:56 -0400 (Wed, 11 Mar 2009)
New Revision: 1935

Modified:
   doc/trunk/reference/zh-CN/producermethods.po
Log:


Modified: doc/trunk/reference/zh-CN/producermethods.po
===================================================================
--- doc/trunk/reference/zh-CN/producermethods.po	2009-03-12 01:05:22 UTC (rev 1934)
+++ doc/trunk/reference/zh-CN/producermethods.po	2009-03-12 03:20:56 UTC (rev 1935)
@@ -3,11 +3,11 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: master.xml \n"
+"Project-Id-Version: master.xml\n"
 "Report-Msgid-Bugs-To: http://bugs.kde.org\n"
 "POT-Creation-Date: 2008-12-20 22:08+0000\n"
-"PO-Revision-Date: 2008-12-19 20:26+0000\n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2009-03-12 11:20+0800\n"
+"Last-Translator: Sean Wu <alartin at gmail.com>\n"
 "Language-Team: none\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -17,48 +17,25 @@
 #: producermethods.xml:5
 #, no-c-format
 msgid "Producer methods"
-msgstr ""
+msgstr "生产者方法"
 
 #. Tag: para
 #: producermethods.xml:7
 #, no-c-format
-msgid ""
-"Producer methods let us overcome certain limitations that arise when the Web "
-"Bean manager, instead of the application, is responsible for instantiating "
-"objects. They're also the easiest way to integrate objects which are not Web "
-"Beans into the Web Beans environment. (We'll meet a second approach in <xref "
-"linkend=\"xml\"/>.)"
-msgstr ""
+msgid "Producer methods let us overcome certain limitations that arise when the Web Bean manager, instead of the application, is responsible for instantiating objects. They're also the easiest way to integrate objects which are not Web Beans into the Web Beans environment. (We'll meet a second approach in <xref linkend=\"xml\"/>.)"
+msgstr "生产者方法能够让我们克服使用Web Bean管理器代替应用来负责实例化对象所带来的特定的限制。生产者方法也是将非Web Beans的对象整合到Web Beans环境中的最简单的途径。(我们将在<xref linkend=\"xml\"/>讨论第二种方法)"
 
 #. Tag: para
 #: producermethods.xml:12
 #, no-c-format
 msgid "According to the spec:"
-msgstr ""
+msgstr "根据规范:"
 
 #. Tag: chapter
 #: producermethods.xml:12
 #, no-c-format
 msgid ""
-"<blockquote> <para>A Web Beans producer method acts as a source of objects "
-"to be injected, where:</para> <itemizedlist> <listitem> <para>the objects to "
-"be injected are not required to be instances of Web Beans,</para> </"
-"listitem> <listitem> <para>the concrete type of the objects to be injected "
-"may vary at runtime or</para> </listitem> <listitem> <para>the objects "
-"require some custom initialization that is not performed by the Web Bean "
-"constructor</para> </listitem> </itemizedlist> </blockquote> <para>For "
-"example, producer methods let us:</para> <itemizedlist> <listitem> "
-"<para>expose a JPA entity as a Web Bean,</para> </listitem> <listitem> "
-"<para>expose any JDK class as a Web Bean,</para> </listitem> <listitem> "
-"<para>define multiple Web Beans, with different scopes or initialization, "
-"for the same implementation class, or</para> </listitem> <listitem> "
-"<para>vary the implementation of an API type at runtime.</para> </listitem> "
-"</itemizedlist> <para>In particular, producer methods let us use runtime "
-"polymorphism with Web Beans. As we've seen, deployment types are a powerful "
-"solution to the problem of deployment-time polymorphism. But once the system "
-"is deployed, the Web Bean implementation is fixed. A producer method has no "
-"such limitation:</para> <programlisting role=\"JAVA\"><![CDATA"
-"[@SessionScoped\n"
+"<blockquote> <para>A Web Beans producer method acts as a source of objects to be injected, where:</para> <itemizedlist> <listitem> <para>the objects to be injected are not required to be instances of Web Beans,</para> </listitem> <listitem> <para>the concrete type of the objects to be injected may vary at runtime or</para> </listitem> <listitem> <para>the objects require some custom initialization that is not performed by the Web Bean constructor</para> </listitem> </itemizedlist> </blockquote> <para>For example, producer methods let us:</para> <itemizedlist> <listitem> <para>expose a JPA entity as a Web Bean,</para> </listitem> <listitem> <para>expose any JDK class as a Web Bean,</para> </listitem> <listitem> <para>define multiple Web Beans, with different scopes or initialization, for the same implementation class, or</para> </listitem> <listitem> <para>vary the implementation of an API type at runtime.</para> </listitem> </itemizedlist> <para>In particular, producer met!
 hods let us use runtime polymorphism with Web Beans. As we've seen, deployment types are a powerful solution to the problem of deployment-time polymorphism. But once the system is deployed, the Web Bean implementation is fixed. A producer method has no such limitation:</para> <programlisting role=\"JAVA\"><![CDATA[@SessionScoped\n"
 "public class Preferences {\n"
 "    \n"
 "    private PaymentStrategyType paymentStrategy;\n"
@@ -75,39 +52,44 @@
 "        } \n"
 "    }\n"
 "    \n"
-"}]]></programlisting> <para>Consider an injection point:</para> "
-"<programlisting role=\"JAVA\"><![CDATA[@Preferred PaymentStrategy "
-"paymentStrat;]]></programlisting> <para>This injection point has the same "
-"type and binding annotations as the producer method, so it resolves to the "
-"producer method using the usual Web Beans injection rules. The producer "
-"method will be called by the Web Bean manager to obtain an instance to "
-"service this injection point.</para>."
+"}]]></programlisting> <para>Consider an injection point:</para> <programlisting role=\"JAVA\"><![CDATA[@Preferred PaymentStrategy paymentStrat;]]></programlisting> <para>This injection point has the same type and binding annotations as the producer method, so it resolves to the producer method using the usual Web Beans injection rules. The producer method will be called by the Web Bean manager to obtain an instance to service this injection point.</para>."
 msgstr ""
+"<blockquote> <para>一个Web Bean生产者方法在下列情况下作为注入对象的源:</para> <itemizedlist> <listitem> <para>所要注入的对象并不要求是一个Web Bean的实例,</para> </listitem> <listitem> <para>所要注入的对象的具体类型有可能在运行时变化,或者</para> </listitem> <listitem> <para>对象需要一些Web Bean构造器无法完成的一些自定义的初始化工作</para> </listitem> </itemizedlist> </blockquote> <para>例如,生产者方法能够让我们:</para> <itemizedlist> <listitem> <para>å°†JPA实体作为一个Web Bean暴露出来,</para> </listitem> <listitem> <para>将任何JDK类作为Web Bean暴露出来,</para> </listitem> <listitem> <para>为相同的一个实现类定义多个Web Beans,每个都拥有不同的范围或者初始化,或者</para> </listitem> <listitem> <para>在运行时改变一个接口类型的具体实现。</para> </listitem> </itemizedlist> <para>特别是生产者方æ!
 ³•è®©æˆ‘们能够使用Web Beans实现运行时多态性。就像我们看到的那样,部署类型是解决部署时多态性的解决方案。不过一旦系统被部署之后,Web Bean的实现也就固定了。一个生产者方法并没有这样的限制:</para> <programlisting role=\"JAVA\"><![CDATA[@SessionScoped\n"
+"public class Preferences {\n"
+"    \n"
+"    private PaymentStrategyType paymentStrategy;\n"
+"    \n"
+"    ...\n"
+"    \n"
+"    @Produces @Preferred \n"
+"    public PaymentStrategy getPaymentStrategy() {\n"
+"        switch (paymentStrategy) {\n"
+"            case CREDIT_CARD: return new CreditCardPaymentStrategy();\n"
+"            case CHEQUE: return new ChequePaymentStrategy();\n"
+"            case PAYPAL: return new PayPalPaymentStrategy();\n"
+"            default: return null;\n"
+"        } \n"
+"    }\n"
+"    \n"
+"}]]></programlisting> <para>我们看一下注入点:</para> <programlisting role=\"JAVA\"><![CDATA[@Preferred PaymentStrategy paymentStrat;]]></programlisting> <para>这个注入点和生产者方法拥有相同的类型和绑定注释,所以使用常见的Web Bean注入规则。生产者方法将被Web Bean管理器调用,从而获得一个实例来供给这个注入点。</para>."
 
 #. Tag: title
 #: producermethods.xml:68
 #, no-c-format
 msgid "Scope of a producer method"
-msgstr ""
+msgstr "生产者方法的范围"
 
 #. Tag: para
 #: producermethods.xml:70
 #, no-c-format
-msgid ""
-"The scope of the producer method defaults to <literal>@Dependent</literal>, "
-"and so it will be called <emphasis>every time</emphasis> the Web Bean "
-"manager injects this field or any other field that resolves to the same "
-"producer method. Thus, there could be multiple instances of the "
-"<literal>PaymentStrategy</literal> object for each user session."
-msgstr ""
+msgid "The scope of the producer method defaults to <literal>@Dependent</literal>, and so it will be called <emphasis>every time</emphasis> the Web Bean manager injects this field or any other field that resolves to the same producer method. Thus, there could be multiple instances of the <literal>PaymentStrategy</literal> object for each user session."
+msgstr "默认的生产者方法的范围是 <literal>@Dependent</literal>,所以Web Bean管理器<emphasis>每次</emphasis>注入这个域或者注入任何其他对应改生产者方法的域的时候,这个生产者方法都会被调用。这样,对于每个用户会话,我们有可能有多个<literal>PaymentStrategy</literal>实例。"
 
 #. Tag: para
 #: producermethods.xml:75
 #, no-c-format
-msgid ""
-"To change this behavior, we can add a <literal>@SessionScoped</literal> "
-"annotation to the method."
-msgstr ""
+msgid "To change this behavior, we can add a <literal>@SessionScoped</literal> annotation to the method."
+msgstr "要改变这种行为,我们可以给这个方法添加一个 <literal>@SessionScoped</literal> 注释。"
 
 #. Tag: programlisting
 #: producermethods.xml:78
@@ -118,40 +100,34 @@
 "    ...\n"
 "}]]>"
 msgstr ""
+"<![CDATA[@Produces @Preferred @SessionScoped\n"
+"public PaymentStrategy getPaymentStrategy() {\n"
+"    ...\n"
+"}]]>"
 
 #. Tag: para
 #: producermethods.xml:80
 #, no-c-format
-msgid ""
-"Now, when the producer method is called, the returned "
-"<literal>PaymentStrategy</literal> will be bound to the session context. The "
-"producer method won't be called again in the same session."
-msgstr ""
+msgid "Now, when the producer method is called, the returned <literal>PaymentStrategy</literal> will be bound to the session context. The producer method won't be called again in the same session."
+msgstr "现在,当这个生产者方法被调用时,它返回的 <literal>PaymentStrategy</literal> 对象将被绑定到会话上下文中。这个生产者方法在同一个会话范围中不会被再次调用。"
 
 #. Tag: title
 #: producermethods.xml:87
 #, no-c-format
 msgid "Injection into producer methods"
-msgstr ""
+msgstr "注入到生产者方法中"
 
 #. Tag: para
 #: producermethods.xml:89
 #, no-c-format
-msgid ""
-"There's one potential problem with the code above. The implementations of "
-"<literal>CreditCardPaymentStrategy</literal> are instantiated using the Java "
-"<literal>new</literal> operator. Objects instantiated directly by the "
-"application can't take advantage of dependency injection and don't have "
-"interceptors."
-msgstr ""
+msgid "There's one potential problem with the code above. The implementations of <literal>CreditCardPaymentStrategy</literal> are instantiated using the Java <literal>new</literal> operator. Objects instantiated directly by the application can't take advantage of dependency injection and don't have interceptors."
+msgstr "上面的代码有一个潜在的问题。 <literal>CreditCardPaymentStrategy</literal> 的实现使用Java的 <literal>new</literal> 操作符来实例化。应用直接实例化的对象无法获得依赖注入的好处,也无法获得拦截器。"
 
 #. Tag: para
 #: producermethods.xml:94
 #, no-c-format
-msgid ""
-"If this isn't what we want we can use dependency injection into the producer "
-"method to obtain Web Bean instances:"
-msgstr ""
+msgid "If this isn't what we want we can use dependency injection into the producer method to obtain Web Bean instances:"
+msgstr "如果这不是我们想要的,我们可以对生产者方法使用依赖注入来获得Web Bean实例:"
 
 #. Tag: programlisting
 #: producermethods.xml:97
@@ -169,62 +145,56 @@
 "    } \n"
 "}]]>"
 msgstr ""
+"<![CDATA[@Produces @Preferred @SessionScoped\n"
+"public PaymentStrategy getPaymentStrategy(CreditCardPaymentStrategy ccps,\n"
+"                                          ChequePaymentStrategy cps,\n"
+"                                          PayPalPaymentStrategy ppps) {\n"
+"    switch (paymentStrategy) {\n"
+"        case CREDIT_CARD: return ccps;\n"
+"        case CHEQUE: return cps;\n"
+"        case PAYPAL: return ppps;\n"
+"        default: return null;\n"
+"    } \n"
+"}]]>"
 
 #. Tag: para
 #: producermethods.xml:99
 #, no-c-format
-msgid ""
-"Wait, what if <literal>CreditCardPaymentStrategy</literal> is a request "
-"scoped Web Bean? Then the producer method has the effect of \"promoting\" "
-"the current request scoped instance into session scope. This is almost "
-"certainly a bug! The request scoped object will be destroyed by the Web Bean "
-"manager before the session ends, but the reference to the object will be "
-"left \"hanging\" in the session scope. This error will <emphasis>not</"
-"emphasis> be detected by the Web Bean manager, so please take extra care "
-"when returning Web Bean instances from producer methods!"
-msgstr ""
+msgid "Wait, what if <literal>CreditCardPaymentStrategy</literal> is a request scoped Web Bean? Then the producer method has the effect of \"promoting\" the current request scoped instance into session scope. This is almost certainly a bug! The request scoped object will be destroyed by the Web Bean manager before the session ends, but the reference to the object will be left \"hanging\" in the session scope. This error will <emphasis>not</emphasis> be detected by the Web Bean manager, so please take extra care when returning Web Bean instances from producer methods!"
+msgstr "等一下,如果 <literal>CreditCardPaymentStrategy</literal> 是一个请求范围的Web Bean,那会怎样?生产者方法将会把当前请求范围的实例\"提升\"到会话范围。这近乎是一个Bug!请求范围的对象会在会话结束前被Web Bean管理器销毁,但是这个对象的引用将被 \"悬挂\"在会话范围。Web Bean管理器<emphasis>不会</emphasis>检测到这种错误,因此使用生产者方法返回Web bean实例的时候一定要多加小心!"
 
 #. Tag: para
 #: producermethods.xml:107
 #, no-c-format
-msgid ""
-"There's at least three ways we could go about fixing this bug. We could "
-"change the scope of the <literal>CreditCardPaymentStrategy</literal> "
-"implementation, but this would affect other clients of that Web Bean. A "
-"better option would be to change the scope of the producer method to "
-"<literal>@Dependent</literal> or <literal>@RequestScoped</literal>."
-msgstr ""
+msgid "There's at least three ways we could go about fixing this bug. We could change the scope of the <literal>CreditCardPaymentStrategy</literal> implementation, but this would affect other clients of that Web Bean. A better option would be to change the scope of the producer method to <literal>@Dependent</literal> or <literal>@RequestScoped</literal>."
+msgstr "我们至少有三种方式来解决这个Bug。我们可以改变  <literal>CreditCardPaymentStrategy</literal>实现的范围,但是这种方法将影响到其他使用这个Web Bean的客户。一个更好的选择是将生产者方法的范围更改到 <literal>@Dependent</literal> 或者 <literal>@RequestScoped</literal>。"
 
 #. Tag: para
 #: producermethods.xml:113
 #, no-c-format
-msgid ""
-"But a more common solution is to use the special <literal>@New</literal> "
-"binding annotation."
-msgstr ""
+msgid "But a more common solution is to use the special <literal>@New</literal> binding annotation."
+msgstr "不过更加常用的方法是使用特殊的 <literal>@New</literal> 绑定注释。"
 
 #. Tag: title
 #: producermethods.xml:119
 #, no-c-format
 msgid "Use of <literal>@New</literal> with producer methods"
-msgstr ""
+msgstr "在生产者方法中使用 <literal>@New</literal> "
 
 #. Tag: para
 #: producermethods.xml:121
 #, no-c-format
 msgid "Consider the following producer method:"
-msgstr ""
+msgstr "考虑到下面的生产者方法:"
 
 #. Tag: programlisting
 #: producermethods.xml:123
 #, no-c-format
 msgid ""
 "<![CDATA[@Produces @Preferred @SessionScoped\n"
-"public PaymentStrategy getPaymentStrategy(@New CreditCardPaymentStrategy "
-"ccps,\n"
+"public PaymentStrategy getPaymentStrategy(@New CreditCardPaymentStrategy ccps,\n"
 "                                          @New ChequePaymentStrategy cps,\n"
-"                                          @New PayPalPaymentStrategy ppps) "
-"{\n"
+"                                          @New PayPalPaymentStrategy ppps) {\n"
 "    switch (paymentStrategy) {\n"
 "        case CREDIT_CARD: return ccps;\n"
 "        case CHEQUE: return cps;\n"
@@ -233,15 +203,21 @@
 "    } \n"
 "}]]>"
 msgstr ""
+"<![CDATA[@Produces @Preferred @SessionScoped\n"
+"public PaymentStrategy getPaymentStrategy(@New CreditCardPaymentStrategy ccps,\n"
+"                                          @New ChequePaymentStrategy cps,\n"
+"                                          @New PayPalPaymentStrategy ppps) {\n"
+"    switch (paymentStrategy) {\n"
+"        case CREDIT_CARD: return ccps;\n"
+"        case CHEQUE: return cps;\n"
+"        case PAYPAL: return ppps;\n"
+"        default: return null;\n"
+"    } \n"
+"}]]>"
 
 #. Tag: para
 #: producermethods.xml:125
 #, no-c-format
-msgid ""
-"Then a new <emphasis>dependent</emphasis> instance of "
-"<literal>CreditCardPaymentStrategy</literal> will be created, passed to the "
-"producer method, returned by the producer method and finally bound to the "
-"session context. The dependent object won't be destroyed until the "
-"<literal>Preferences</literal> object is destroyed, at the end of the "
-"session."
-msgstr ""
+msgid "Then a new <emphasis>dependent</emphasis> instance of <literal>CreditCardPaymentStrategy</literal> will be created, passed to the producer method, returned by the producer method and finally bound to the session context. The dependent object won't be destroyed until the <literal>Preferences</literal> object is destroyed, at the end of the session."
+msgstr "一个新的<emphasis>依赖</emphasis>的 <literal>CreditCardPaymentStrategy</literal> 实例将被创建,然后传递给生产者方法,然后生产者方法将其返回,最终这个实例将被绑定到会话上下文。这个依赖对象不会被提前销毁,而是在会话结束时跟随 <literal>Preferences</literal> 一起被销毁。"
+




More information about the weld-commits mailing list