Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
christofluethi authored and g1raffi committed Nov 15, 2023
1 parent 9be0dfc commit a2b0b8f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 45 deletions.
21 changes: 4 additions & 17 deletions content/en/docs/01.0/13_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ Each extension is able to provide custom information shown on the dev ui. Extens
* Custom pages with or without actions to interact the application
* If you are using Flyway you may for example clean and migrate your database using the Dev UI

Example of an ChaosMonkey extension which allows to inject random errors in your rest endpoints.

![Quarkus Dev UI](../dev-ui-monkeys.png)

With the provided Configuration tool, you are able to change the runtime config for example the quarkus log level
Expand All @@ -265,11 +267,12 @@ On Windows using Powershell:
iex "& { $(iwr https://ps.jbang.dev) } app install --fresh --force quarkus@quarkusio"
```

If jbang has already been installed, you can it directly:
If jbang has already been installed, you can install it directly:

```s
# This can also be used to update to the latest version
jbang app install --fresh --force quarkus@quarkusio
# Use the latest (or locally built) snapshot (with qss as an alias)
jbang app install --force --name qss ~/.m2/repository/io/quarkus/quarkus-cli/999-SNAPSHOT/quarkus-cli-999-SNAPSHOT-runner.jar
```
Expand All @@ -289,7 +292,6 @@ Check out `quarkus --help` to get a help information with all the available comm
To create a new Quarkus project simply run the `create` command of the CLI:

```s
quarkus create app test-name
-----------
Expand All @@ -308,7 +310,6 @@ applying codestarts...
--> <pwd>/test-name
-----------
Navigate into this directory and get started: quarkus dev
```

To check out the options for project creation see `quarkus create app --help`.
Expand All @@ -320,7 +321,6 @@ The Quarkus CLI will give you quality of life features when working with extensi
You can list your installed extensions in a Quarkus project by invoking

```s
quarkus ext ls
Looking for the newly published extensions in registry.quarkus.io
Expand All @@ -329,13 +329,11 @@ Current Quarkus extensions installed:
quarkus-resteasy
To get more information, append `--full` to your command line.
```

When looking for new extensions to install you can use the `--installable / -i` option. This will simply list all extensions available. You can also filter your query by using the `--search / -s <key>` for the keyword `<key>`.

```s
quarkus ext ls -is openshift
Current Quarkus extensions installable:
Expand All @@ -347,27 +345,22 @@ To get more information, append `--full` to your command line.
To list only extensions from specific category, append `--category "categoryId"` to your command line.
Add an extension to your project by adding the dependency to your pom.xml or use `quarkus extension add "artifactId"`
```

When you have found your desired extension you can add the extension with

```s
quarkus ext add smallrye-health
[SUCCESS] ✅ Extension io.quarkus:quarkus-smallrye-health has been installed
```

Or to remove extensions use

```s
quarkus ext rm smallrye-health
[SUCCESS] ✅ Extension io.quarkus:quarkus-smallrye-health has been uninstalled
```


Expand All @@ -376,27 +369,21 @@ quarkus ext rm smallrye-health
Building your project with the Quarkus CLI is as simple as:

```s
quarkus build
```

To start up your application in dev mode you can use:

```s
quarkus dev
```

{{% details title="Hint" %}}

They say cool kids use:

```s
alias q=quarkus
```

{{% /details %}}
8 changes: 0 additions & 8 deletions content/en/docs/01.0/15_vertx.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ Vert.x provides multiple APIs. For starters we are going to take a look at the '
Due to the reactive nature of Vert.x, the API contains mostly asynchronous methods. They follow all a similar syntax:

```java

public void doSomething(param1, param2, Handler<AsyncResult<T>> handler) {
// ...
}

```

Interesting here is the last parameter of the `doSomething` method. It is a function that will be used as a callback whenever the opertion succeeds or fails. Let's look at the example here:

```java

vertx.fileSystem()
.readFile("my-file.txt", ar -> {
if (ar.failed()) {
Expand All @@ -36,7 +33,6 @@ vertx.fileSystem()
System.out.println("File content is: " + ar.result());
}
});

```

The code reads a file as an asynchronous operation and invokes the callback when the file is read. The `Handler<AsyncResult<T>>` handles the file read and provides methods (`cause()`, `failed()`, `result()`) to compute the file read.
Expand All @@ -61,7 +57,6 @@ Mutiny defines two reactive types:
Their usages might look like this:

```java

Multi.createFrom().items("a", "b", "c")
.onItem().transform(String::toUpperCase)
.subscribe().with(
Expand All @@ -75,17 +70,14 @@ Uni.createFrom().item("a")
item -> System.out.println("Received: " + item),
failure -> System.out.println("Failed with " + failure)
);

```

The transformed code example from above to Mutiny will look like this:

```java

Uni<Buffer> uni = vertx.fileSystem().readFile("my-file.txt");
uni.subscribe()
.with(it -> System.out.println("File content is: " + it));

```

To dive further into the Mutiny framework consider checking their [documentation](https://smallrye.io/smallrye-mutiny/guides).
20 changes: 0 additions & 20 deletions content/en/docs/01.0/17_cdi.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ As a developer we can focus ourselves on the business logic rather than troublyi
We are going to write and define several beans in the following excercises, an example of a bean might look like this:

```java

@ApplicationScoped
public class DummyService {

Expand All @@ -28,15 +27,13 @@ public class DummyService {
return "dummy";
}
}

```

This example defines a `DummyService` bean. The annotation `@ApplicationScoped` tells the container to create a single bean instance for the application and will be used by all other beans that inject `DummyService`.

The CDI process of matching beans to injection points is type-safe. Each bean defines set of bean types. In our example the defined `DummyService` has two types: `DummyService` and `java.lang.Object`. Exactly one bean must be assignable to the injection point, otherwise your build will fail with an `UnsatisfiedResolutionException` when none are assignable and with `AmbiguousResolutionException` when multiple are assignable. You can use the `jakarta.enterprise.inject.Instance` to resolve ambiguities at runtime and iterate over all beans implementing a given type:

```java

public class Translator {

@Inject
Expand All @@ -48,7 +45,6 @@ public class Translator {
}
}
}

```


Expand All @@ -62,7 +58,6 @@ You have several possibilities available to inject your beans into your classes.
You can inject your beans with the field injection. This is the most used and most straight forward method for injection:

```java

@ApplicationScoped
public class DummyService {

Expand All @@ -71,7 +66,6 @@ public class DummyService {

//...
}

```


Expand All @@ -80,7 +74,6 @@ public class DummyService {
The constructor injection defines the injectable beans as injectable parameters in the constructor of your class. It is not necessary to use the `@Inject` annotation if your definition only has one no-args constructor defined.

```java

@ApplicationScoped
public class DummyService {

Expand All @@ -92,7 +85,6 @@ public class DummyService {

//...
}

```


Expand All @@ -101,7 +93,6 @@ public class DummyService {
The third option is using the setter injection. Instead of defining your dependencies in the class as `@Injected` fields you can annotate a method which sets your dependencies.

```java

@ApplicationScoped
public class DummyService {

Expand All @@ -114,7 +105,6 @@ public class DummyService {

//...
}

```


Expand Down Expand Up @@ -147,7 +137,6 @@ Synthetic beans are not going to be covered in this lab.
But let's take a look at producers. Producer methods and field are useful if you need more control over the instantiation of a bean. They are also useful when integrating third-party libraries where you don’t control the class source and may not add additional annotations etc.

```java

@ApplicationScoped
public class Producers {

Expand Down Expand Up @@ -175,7 +164,6 @@ public class Consumer {

// ...
}

```


Expand All @@ -189,7 +177,6 @@ So far we have seen that we can inject our beans into classes and do not need to
A bean class may declare lifecylce callbacks: `@PostConstruct` and `@PreDestroy`. With these two annotations the lifecycle of the bean can be altered and controlled. The `@PostConstruct` annotated callback is invoked before the bean is put into service and can be used to do initializing work. The `@PreDestroy` callback is invoked before a bean is destroyed to do cleanup tasks.

```java

import jakarta.annotation.PostConstruct;;
import jakarta.annotation.PreDestroy;

Expand All @@ -206,7 +193,6 @@ public class Translator {
// ...
}
}

```


Expand All @@ -217,20 +203,17 @@ Interceptors are a helpful tool to separate cross-cutting concerns from business
For demonstration purposes we can check out a small example. We create the annotation `@Logged` as an `@InterceptorBinding` which should indicate that some logging will be done at invokation time.

```java

@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({METHOD, TYPE})
public @interface Logged {
}

```

Then we can create the interceptor:

```java

@Logged
@Interceptor
public class LoggedInterceptor implements Serializable {
Expand All @@ -248,7 +231,6 @@ public class LoggedInterceptor implements Serializable {
return invocationContext.proceed();
}
}

```


Expand All @@ -259,7 +241,6 @@ Beans may also produce and consume events to interact in a completely decoupled
For example you can control behaviour at startup times by observing the `StartupEvent`.

```java

@ApplicationScoped
public class DummyService {

Expand All @@ -268,5 +249,4 @@ public class DummyService {
}

}

```

0 comments on commit a2b0b8f

Please sign in to comment.