Skip to content

Commit

Permalink
WELD-2771 Update Weld SE Numberguess example and related documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Apr 22, 2024
1 parent f8024df commit b5e095e
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 73 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
57 changes: 0 additions & 57 deletions docs/reference/src/main/asciidoc/weldexamples.asciidoc
Expand Up @@ -336,63 +336,6 @@ Swing application with no EJB or servlet dependencies. This example can
be found in the `examples/se/numberguess` folder of the Weld
distribution.

==== Creating the Eclipse project

To use the Weld SE numberguess example in Eclipse, you can either import
it as a Maven project if you have the
http://m2eclipse.sonatype.org/[m2eclipse plugin] installed, or generate
an Eclipse project and import it.

With m2eclipse installed, you can open any Maven project directly. From
within Eclipse, select _File \-> Import... \-> Existing Maven Projects_.
Then, browse to the location of the Weld SE numberguess example. You
should see that Eclipse recognizes the Maven project.

Without m2eclipse plugin, you first have to generate an Eclipse project.
Switch into the Weld SE numberguess example folder, then execute the
Maven Eclipse plugin, as follows:

[source, console]
-----------------------------------------------------------------------------------
mvn eclipse:configure-workspace -Declipse.workspace=/path/to/your/eclipse/workspace
-----------------------------------------------------------------------------------

and then

[source, console]
-------------------
mvn eclipse:eclipse
-------------------

Then from within Eclipse, select _File \-> Import... \-> Existing Projects
into Workspace_ and browse to the location of the Weld SE numberguess
example.

In both cases, you should now see a project in your workspace called
`weld-se-numberguess`.

It's time to get the example running!

==== Running the example from Eclipse

Disable m2eclipse's _Workspace Resolution_, to make sure that Eclipse
can find `StartMain`. Right click on the project, and choose _Properties
\-> Maven_, and uncheck _Resolve dependencies from Workspace projects_:

image:images/weld-se-numberguess-m2eclipse-1.png[image]

Right click on the project, and choose _Run As \-> Java Application_:

image:images/weld-se-numberguess-m2eclipse-2.png[image]

Locate the `StartMain` class:

image:images/weld-se-numberguess-m2eclipse-3.png[image]

The application should now launch!

image:images/weld-se-numberguess-m2eclipse-4.png[image]

==== Running the example from the command line

* Ensure that Maven 3 is installed and in your PATH
Expand Down
16 changes: 4 additions & 12 deletions examples/se/numberguess/README.md
Expand Up @@ -7,12 +7,7 @@ To start this Weld SE application you can either choose to start it with `org.jb
The former is a well known default which attempts to discover beans on classpath and then boots the application.
The latter is a synthetic archive which has defined components and disables discovery leading to a minimal, quickly booting application.
Of course you will need all of the relevant jar dependencies
on your classpath, which is most easily done by loading the project into your
favourite Maven-capable IDE and running it from there.

If you are using m2eclipse, and the application won't start, make sure you uncheck
"Resolve dependencies from Workspace projects" in the Maven properties panel. Then
run a full build to ensure all classes are in the right place.
on your classpath, which is most easily done by loading the project into your favourite Maven-capable IDE and running it from there.

To run this example using Maven directly:

Expand Down Expand Up @@ -55,9 +50,8 @@ This profile provides the capability to package the artifact in a fat-jar (singl

Swing Example: Number Guess
---------------------------
Here's an example of a Swing application, Number Guess, similar to the example in chapter 7.
This example shows how to use the Weld SE extension in a Java SE based Swing application
with no EJB or servlet dependencies.
Here's an example of a Swing application, Number Guess, similar to the example in chapter 6.
This example shows how to use the Weld SE extension in a Java SE based Swing application with no EJB or servlet dependencies.

In the Number Guess application you are given 10 attempts to guess a number between 1 and 100. After each attempt, you will be told whether you are too high, or too low.

Expand All @@ -68,9 +62,7 @@ The game's main logic is located in `Game.java`. In this example, it differs fro

* Notice that the bean is not named, since it doesn't need to be accessed via EL.

* In Java SE there is no JSF `FacesContext` to which messages can be added. Instead
the Game class provides additional information about the state of the current game
including:
* In Java SE there is no JSF `FacesContext` to which messages can be added. Instead, the Game class provides additional information about the state of the current game including:

* if the game has been won or lost,

Expand Down
8 changes: 4 additions & 4 deletions examples/se/numberguess/pom.xml
Expand Up @@ -106,7 +106,7 @@
<id>jandex</id>
<dependencies>
<dependency>
<groupId>org.jboss</groupId>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
</dependency>
</dependencies>
Expand All @@ -119,9 +119,9 @@
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<groupId>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.2.3</version>
<version>${jandex.version}</version>
<executions>
<execution>
<id>make-index</id>
Expand All @@ -136,7 +136,7 @@
</executions>
<dependencies>
<dependency>
<groupId>org.jboss</groupId>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
<version>${jandex.version}</version>
</dependency>
Expand Down

0 comments on commit b5e095e

Please sign in to comment.