I am setting up basic environment for learning CDI in JavaEE7. I have the following code for starting Weld
. Just a startup and shutdown.
package
Running Java EE application requires an Application server (or container). This container makes your life far simple regarding the integration of different services (security, messaging, transaction, etc...) needed to run an enterprise application.
If you don't use an application server (like you are doing in your example) you have to make this integration yourself (i.e build your own server). That's a very hard and useless task since servers exist.
The code you show in your question is how you can use the proprietary part of Weld to start a CDI container by hand when you don't want or can use a container.
If you read carefully Antonio's book, you'll see that on page xxxiv in section 'Download and Running the Code' it is stated that you need to deploy your code on Glassfish 4, one of the open source Java EE 7 server (the other being JBoss Wildfly)
Appendix A of the book (page 539) describe in a very precise way how to set up your environment to run book examples and simple Java EE applications. Please follow instruction in this part and you'll see that developing and deploying Java EE 7 application si very simple.