This is an automated email from the ASF dual-hosted git repository.
dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push:
new ac14585 [TOMEE-2669] [DOC] [Translation] Translate async-methods
example to Spanish
new 48b0c9b Merge pull request #556 from cchacin/TOMEE-2669
ac14585 is described below
commit ac145855b74dcefe3d75a72c6832fb15fb651bcc
Author: Carlos Chacin <[email protected]>
AuthorDate: Sat Sep 7 10:12:04 2019 -0700
[TOMEE-2669] [DOC] [Translation] Translate async-methods example to Spanish
---
examples/async-methods/README.adoc | 23 ++--
.../async-methods/{README.adoc => README_es.adoc} | 153 +++++++++------------
examples/async-methods/README_pt.adoc | 24 ++--
3 files changed, 91 insertions(+), 109 deletions(-)
diff --git a/examples/async-methods/README.adoc
b/examples/async-methods/README.adoc
index 04be7ac..3f942a0 100644
--- a/examples/async-methods/README.adoc
+++ b/examples/async-methods/README.adoc
@@ -24,14 +24,14 @@ next statement,
`final Future<String> orange = processor.addJob("orange");`
-without waiting for the addJob() method to complete. And later we could
+without waiting for the `addJob()` method to complete. And later we could
ask for the result using the `Future<?>.get()` method like
`assertEquals("blue", blue.get());`
It waits for the processing to complete (if its not completed already)
and gets the result. If you did not care about the result, you could
-simply have your asynchronous method as a void method.
+simply have your asynchronous method as a `void` method.
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html[Future]
Object from docs,
@@ -52,7 +52,8 @@ ____
== The code
-....
+[source,java]
+----
@Singleton
public class JobProcessor {
@Asynchronous
@@ -76,11 +77,12 @@ private void doSomeHeavyLifting() {
}
}
}
-....
+----
== Test
-....
+[source,java]
+----
public class JobProcessorTest extends TestCase {
public void test() throws Exception {
@@ -112,15 +114,16 @@ public void test() throws Exception {
// Execution should be around 9 - 21 seconds
// The execution time depends on the number of threads available for
asynchronous execution.
- // In the best case it is 10s plus some minimal processing time.
+ // In the best case it is 10s plus some minimal processing time.
assertTrue("Expected > 9 but was: " + total, total > 9);
assertTrue("Expected < 21 but was: " + total, total < 21);
}
}
-....
+----
-....
+[source,java]
+----
-------------------------------------------------------
T E S T S
-------------------------------------------------------
@@ -172,7 +175,7 @@ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time
elapsed: 23.491 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-....
+----
== How it works under the covers
@@ -208,7 +211,7 @@
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicI
to the `@Asynchronous` method and have the bean code periodically update
it with the percent complete.
-#Related Examples
+== Related Examples
For complex asynchronous processing, JavaEE’s answer is
`@MessageDrivenBean`. Have a look at the
diff --git a/examples/async-methods/README.adoc
b/examples/async-methods/README_es.adoc
similarity index 55%
copy from examples/async-methods/README.adoc
copy to examples/async-methods/README_es.adoc
index 04be7ac..8f9d078 100644
--- a/examples/async-methods/README.adoc
+++ b/examples/async-methods/README_es.adoc
@@ -1,58 +1,54 @@
:index-group: EJB
:jbake-type: page
:jbake-status: status=published
-= @Asynchronous Methods
+= Métodos @Asynchronous
-The @Asynchronous annotation was introduced in EJB 3.1 as a simple way
-of creating asynchronous processing.
+La annotación @Asynchronous fue introducida en EJB 3.1 como una manera simple
+de crear procesamiento asíncrono.
-Every time a method annotated `@Asynchronous` is invoked by anyone it
-will immediately return regardless of how long the method actually
-takes. Each invocation returns a
+Cada vez que un método anotado con `@Asynchronous` es invocado por cualquiera
+retornará inmediatamentesin importar cuanto tarda en realidad el método. Cada
+invocación retorna un objeto
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html[Future]
-object that essentially starts out _empty_ and will later have its value
-filled in by the container when the related method call actually
-completes. Returning a `Future` object is not required and
-`@Asynchronous` methods can of course return `void`.
+que esencialmente inicia _vacío_ y luego se llenará con su valor por el
+contenedor cuando la llamada al metodo relacionado se ejecute en realidad.
+Retornar un objeto `Future` no es requerido y un método `@Asynchronous` puede
+por supuesto retornar `void`.
-== Example
+== Ejemplo
-Here, in `JobProcessorTest`,
+Aquí, en `JobProcessorTest`,
-`final Future<String> red = processor.addJob("red");` proceeds to the
-next statement,
+`final Future<String> red = processor.addJob("red");` procede a la siguiente
sentencia,
`final Future<String> orange = processor.addJob("orange");`
-without waiting for the addJob() method to complete. And later we could
-ask for the result using the `Future<?>.get()` method like
+sin esperar por a que método `addJob()` se complete. Y luego podríamos
+preguntar por el resultado usando el método `Future<?>.get()` como sigue
`assertEquals("blue", blue.get());`
-It waits for the processing to complete (if its not completed already)
-and gets the result. If you did not care about the result, you could
-simply have your asynchronous method as a void method.
+Espera a que el procesamiento de complete (si no se a completado aún) y
+obtiene el resultado. Si no te importa el resultado, podrías simplemente tener
tu método asíncrono como un método `void`.
-http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html[Future]
-Object from docs,
+Desde la documentación del Objeto
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html[Future],
____
-A Future represents the result of an asynchronous computation. Methods
-are provided to check if the computation is complete, to wait for its
-completion, and to retrieve the result of the computation. The result
-can only be retrieved using method get when the computation has
-completed, blocking if necessary until it is ready. Cancellation is
-performed by the cancel method. Additional methods are provided to
-determine if the task completed normally or was cancelled. Once a
-computation has completed, the computation cannot be cancelled. If you
-would like to use a Future for the sake of cancellability but not
-provide a usable result, you can declare types of the form Future<?> and
-return null as a result of the underlying task
+Un Future representa el resultado de un cómputo asíncrono. Se proporcionan
métodos para chequear si el cómputo está completo, esperar por que se complete,
+y para obtener el resultado del cómputo. El resultado solo puede ser obtenido
+usando el método get cuando el cómputo se ha completado, bloqueando si es
+necesario hasta que está listo. La cancelación es ejecutada por el método
+cancel. Métodos adicionales son proporcionados para determinarsi la tarea se
+completó normalmente o fue cancelada. Una vez que un cómputo se ha completado,
+el cómputo no puede ser cancelado. Si quieres usar un Future solo por que se
+puede cancelar pero sin proveer un resultado usable, puedes declarar tipos de
+la forma Future<?> y retornar null como un resultado de la tarea subyacente
____
-== The code
+== El código
-....
+[source,java]
+----
@Singleton
public class JobProcessor {
@Asynchronous
@@ -60,10 +56,10 @@ public class JobProcessor {
@AccessTimeout(-1)
public Future<String> addJob(String jobName) {
- // Pretend this job takes a while
+ // Pretendamos que esta tarea tarda un tiempo
doSomeHeavyLifting();
- // Return our result
+ // Retorna nuestro resultado
return new AsyncResult<String>(jobName);
}
@@ -76,11 +72,12 @@ private void doSomeHeavyLifting() {
}
}
}
-....
+----
-== Test
+== Prueba
-....
+[source,java]
+----
public class JobProcessorTest extends TestCase {
public void test() throws Exception {
@@ -91,7 +88,7 @@ public void test() throws Exception {
final long start = System.nanoTime();
- // Queue up a bunch of work
+ // Encola mucho trabajo
final Future<String> red = processor.addJob("red");
final Future<String> orange = processor.addJob("orange");
final Future<String> yellow = processor.addJob("yellow");
@@ -99,7 +96,7 @@ public void test() throws Exception {
final Future<String> blue = processor.addJob("blue");
final Future<String> violet = processor.addJob("violet");
- // Wait for the result -- 1 minute worth of work
+ // Espera por el resultado -- 1 minuto de trabajo
assertEquals("blue", blue.get());
assertEquals("orange", orange.get());
assertEquals("green", green.get());
@@ -107,20 +104,21 @@ public void test() throws Exception {
assertEquals("yellow", yellow.get());
assertEquals("violet", violet.get());
- // How long did it take?
+ // Cuanto tiempo tardó?
final long total = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() -
start);
- // Execution should be around 9 - 21 seconds
- // The execution time depends on the number of threads available for
asynchronous execution.
- // In the best case it is 10s plus some minimal processing time.
+ // Una ejecución debería tardar entre 9 y 21 seconds
+ // El tiempo de ejecución dependen en el número de threads disponibles
para la ejecucion asíncrona.
+ // En el mejor de los casos son 10s mas un tiempo mínimo
assertTrue("Expected > 9 but was: " + total, total > 9);
assertTrue("Expected < 21 but was: " + total, total < 21);
}
}
-....
+----
-....
+[source,java]
+----
-------------------------------------------------------
T E S T S
-------------------------------------------------------
@@ -172,44 +170,23 @@ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time
elapsed: 23.491 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-....
-
-== How it works under the covers
-
-Under the covers what makes this work is:
-
-* The `JobProcessor` the caller sees is not actually an instance of
-`JobProcessor`. Rather it’s a subclass or proxy that has all the methods
-overridden. Methods that are supposed to be asynchronous are handled
-differently.
-* Calls to an asynchronous method simply result in a `Runnable` being
-created that wraps the method and parameters you gave. This runnable is
-given to an
-http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html[Executor]
-which is simply a work queue attached to a thread pool.
-* After adding the work to the queue, the proxied version of the method
-returns an implementation of `Future` that is linked to the `Runnable`
-which is now waiting on the queue.
-* When the `Runnable` finally executes the method on the _real_
-`JobProcessor` instance, it will take the return value and set it into
-the `Future` making it available to the caller.
-
-Important to note that the `AsyncResult` object the `JobProcessor`
-returns is not the same `Future` object the caller is holding. It would
-have been neat if the real `JobProcessor` could just return `String` and
-the caller’s version of `JobProcessor` could return `Future<String>`,
-but we didn’t see any way to do that without adding more complexity. So
-the `AsyncResult` is a simple wrapper object. The container will pull
-the `String` out, throw the `AsyncResult` away, then put the `String` in
-the _real_ `Future` that the caller is holding.
-
-To get progress along the way, simply pass a thread-safe object like
-http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html[AtomicInteger]
-to the `@Asynchronous` method and have the bean code periodically update
-it with the percent complete.
-
-#Related Examples
-
-For complex asynchronous processing, JavaEE’s answer is
-`@MessageDrivenBean`. Have a look at the
-link:../simple-mdb/README.html[simple-mdb] example
+----
+
+== Como funciona esto detrás de escena
+
+Lo que lo hace trabajar detrás de escena es:
+
+* El `JobProcessor` quien es el llamador ve que no es de hecho una instancia
de `JobProcessor`. Por el contrario es una subclase o proxy que tiene todos los
métodos sobrescritos. Métodos que deben ser asíncronos son tratados distinto.
+* Llamadas a un método asíncrono simplemente retornan un `Runnable` siendo
creado que envuelve el método y parámetros que tu pasaste. Este runnable es
pasado a un
+http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html[Executor]
quien es simplemente una cola de trabajo adjuntada al conjunto de hilos
(thread pool).
+* Después de añadir el trabajo a la cola, la versión proxeada del método
retorna una implementation de `Future` que es enlazada a el `Runnable` quien
está ahora esperando en la cola.
+* Cuando el `Runnable` finalmente ejecuta el método sobre la instancia _real_
del `JobProcessor`, tomará el valor de retorno y lo asignará dentro del
`Future` haciendolo disponible a el que llama.
+
+Importante notar que el objeto `AsyncResult` que `JobProcessor` retorna no es
el mismo objeto `Future` que el que llama contiene. Sería genial si el
`JobProcessor` real pudiera retornar `String` y que el que la versión de
`JobProcessor` del que llama pudiera retornar `Future<String>`, pero no
encontramos una manera de hacer eso sin añadir mas complejidad. Entonces el
`AsyncResult` es un simple objeto envoltorio. El contenedor sacará el `String`,
descartará el `AsyncResult`, entonces pond [...]
+
+Para obtener status del proceso, simplemente pasa un objeto thread-safe como
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html[AtomicInteger]
a el método `@Asynchronous` y has que el código lo actualice periodicamente
con el porcentaje completado.
+
+== Ejemplos Relacionados
+
+Para procesamiento asíncrono complejo, la respuesta de JavaEE’s es
`@MessageDrivenBean`. Échale una mirada al ejemplo
+link:../simple-mdb/README.html[simple-mdb]
diff --git a/examples/async-methods/README_pt.adoc
b/examples/async-methods/README_pt.adoc
index 81e0ae0..df59fed 100644
--- a/examples/async-methods/README_pt.adoc
+++ b/examples/async-methods/README_pt.adoc
@@ -3,14 +3,14 @@
:jbake-status: status=published
= Métodos Assíncronos
-A anotação @Asynchronous foi introduzida no EJB 3.1 como um simples meio
+A anotação `@Asynchronous` foi introduzida no EJB 3.1 como um simples meio
de criar processamento assícrono.
Toda vez que um método anotado com `@Asynchronous` é invocado por qualquer um
que
vai imediatamente retornar independentemente de quanto tempo o método
realmente leva.
-
+
Cada invocação retorna um objeto
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html[Future]
-que essencialmente inicia _vazio_ e terá mais tarde o seu valor preenchido
pelo contêiner quando o método relacionado é chamado concluir.
+que essencialmente inicia _vazio_ e terá mais tarde o seu valor preenchido
pelo contêiner quando o método relacionado é chamado concluir.
Retornar um objeto `Future` não é necessário e os métodos `@ Asynchronous`
podem retornar `void`.
@@ -23,7 +23,7 @@ próxima declaração,
`final Future<String> orange = processor.addJob("orange");`
-sem aguardar pelo método addJob() para completar. E depois poderíamos
+sem aguardar pelo método `addJob()` para completar. E depois poderíamos
perguntar pelo resultado usando o método `Future <?>. get ()` como
`assertEquals("blue", blue.get());`
@@ -50,7 +50,8 @@ ____
== O código
-....
+[source,java]
+----
@Singleton
public class JobProcessor {
@Asynchronous
@@ -74,7 +75,7 @@ private void doSomeHeavyLifting() {
}
}
}
-....
+----
== Teste
@@ -110,15 +111,16 @@ public void test() throws Exception {
// A execução deve ser em torno de 9 a 21 segundos
// O tempo de execução depende do número de encadeamentos disponíveis para
execução assíncrona.
- //No melhor dos casos, é 10s mais algum tempo de processamento mínimo.
+ //No melhor dos casos, é 10s mais algum tempo de processamento mínimo.
assertTrue("Expected > 9 but was: " + total, total > 9);
assertTrue("Expected < 21 but was: " + total, total < 21);
}
}
-....
+----
-....
+[source,java]
+----
-------------------------------------------------------
T E S T S
-------------------------------------------------------
@@ -170,7 +172,7 @@ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time
elapsed: 23.491 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-....
+----
== Como funciona debaixo dos panos
@@ -196,7 +198,7 @@ retornado não é o mesmo objeto `Future` que o chamador está
segurando.
Seria legal se o `JobProcessor` real pudesse retornar` String` e
a versão do chamador de `JobProcessor` poderia retornar` Future <String> `,
-mas nós não vimos nenhuma maneira de fazer isso sem adicionar mais
complexidade.
+mas nós não vimos nenhuma maneira de fazer isso sem adicionar mais
complexidade.
Então o `AsyncResult` é um simples objeto wrapper. O contêiner vai puxar
o `String` para fora, lançar o ` AsyncResult`, então colocar o `String` em