├── .gitignore ├── README.md └── code ├── chapter10 ├── javaee7-ws-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter10 │ │ │ │ └── ws │ │ │ │ ├── Account.java │ │ │ │ ├── AccountManager.java │ │ │ │ ├── AccountWS.java │ │ │ │ └── AccountWSItf.java │ │ ├── resources │ │ │ └── META-INF │ │ │ │ ├── MANIFEST.MF │ │ │ │ └── persistence.xml │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ └── web.xml │ │ │ └── index.jsp │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter10 │ │ └── test │ │ └── TestWS.java └── javaee7-ws-handler │ ├── README.md │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter10 │ │ │ ├── handler │ │ │ ├── SampleLogicalHandler.java │ │ │ └── SampleSOAPHandler.java │ │ │ └── ws │ │ │ ├── Account.java │ │ │ ├── AccountManager.java │ │ │ ├── AccountWS.java │ │ │ └── AccountWSItf.java │ ├── resources │ │ ├── META-INF │ │ │ ├── MANIFEST.MF │ │ │ └── persistence.xml │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter10 │ │ │ └── ws │ │ │ └── handlers.xml │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp │ └── test │ └── java │ └── com │ └── itbuzzpress │ └── chapter10 │ └── test │ └── TestWS.java ├── chapter11 ├── javaee7-rest-aysnc │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter11 │ │ │ │ ├── activator │ │ │ │ └── JaxRsActivator.java │ │ │ │ ├── ejb │ │ │ │ └── DataList.java │ │ │ │ ├── handler │ │ │ │ └── MyTimeoutHandler.java │ │ │ │ ├── model │ │ │ │ └── SimpleProperty.java │ │ │ │ └── service │ │ │ │ └── ParamRESTService.java │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter11 │ │ └── test │ │ ├── TestAsyncClient.java │ │ └── TestSyncClient.java ├── javaee7-rest-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter11 │ │ │ ├── activator │ │ │ └── JaxRsActivator.java │ │ │ ├── ejb │ │ │ └── DataList.java │ │ │ ├── model │ │ │ └── SimpleProperty.java │ │ │ └── service │ │ │ ├── ParamRESTService.java │ │ │ └── SimpleRESTService.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp ├── javaee7-rest-client │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter11 │ │ │ │ ├── activator │ │ │ │ └── JaxRsActivator.java │ │ │ │ ├── ejb │ │ │ │ └── DataList.java │ │ │ │ ├── model │ │ │ │ └── SimpleProperty.java │ │ │ │ └── service │ │ │ │ ├── ParamRESTService.java │ │ │ │ └── SimpleRESTService.java │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter11 │ │ └── test │ │ └── TestClient.java ├── javaee7-rest-filters │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter11 │ │ │ │ ├── filter │ │ │ │ ├── CachingFilter.java │ │ │ │ └── LoggingFilter.java │ │ │ │ ├── model │ │ │ │ ├── JaxRsActivator.java │ │ │ │ └── SimpleProperty.java │ │ │ │ └── service │ │ │ │ └── SimpleRESTService.java │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter11 │ │ └── test │ │ ├── TestClient.java │ │ └── filter │ │ └── ClientFilter.java ├── javaee7-rest-interceptors │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter11 │ │ │ │ ├── interceptor │ │ │ │ ├── ZipReaderInterceptor.java │ │ │ │ └── ZipWriterInterceptor.java │ │ │ │ ├── model │ │ │ │ ├── JaxRsActivator.java │ │ │ │ └── SimpleProperty.java │ │ │ │ └── service │ │ │ │ └── SimpleRESTService.java │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter11 │ │ └── test │ │ └── TestClient.java └── javaee8-rest-sse │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter11 │ │ ├── SseResource.java │ │ ├── activator │ │ └── JaxRsActivator.java │ │ └── client │ │ └── SSEClient.java │ └── webapp │ ├── broadcast.jsp │ └── index.html ├── chapter12 ├── javaee7-jms-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter12 │ │ │ ├── controller │ │ │ └── MessageSender.java │ │ │ └── mdb │ │ │ └── MDBSample.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.xhtml └── javaee7-jms-client │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── itbuzzpress │ └── chapter12 │ ├── HelloWorldJMSClient.java │ └── JMSClient.java ├── chapter13 ├── javaee7-json │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── sample │ │ │ ├── objectmodel │ │ │ ├── ParseJSON.java │ │ │ ├── ProduceJSON.java │ │ │ └── ProduceJSONArray.java │ │ │ └── streaming │ │ │ ├── ConsumeJSONStream.java │ │ │ └── ProduceJSONStream.java │ │ ├── resources │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── data.json │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp └── javaee8-jsonb │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── json │ │ ├── activator │ │ └── JaxRsActivator.java │ │ ├── model │ │ └── Person.java │ │ └── service │ │ └── JsonService.java │ └── webapp │ └── index.jsp ├── chapter14 ├── javaee7-batch-batchlet │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter14 │ │ │ ├── batchlet │ │ │ └── DatabaseBatchlet.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── servlet │ │ │ └── TestBatchlet.java │ │ ├── resources │ │ └── META-INF │ │ │ ├── batch-jobs │ │ │ └── simplebatchlet.xml │ │ │ └── persistence.xml │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.jsp ├── javaee7-batch-chunk-checkpoint │ ├── README.md │ ├── input.csv │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter14 │ │ │ ├── chunk │ │ │ ├── BatchCheckpointAlgorithm.java │ │ │ ├── BatchItemProcessor.java │ │ │ ├── BatchItemReader.java │ │ │ └── BatchItemWriter.java │ │ │ ├── ejb │ │ │ └── EJBSingleton.java │ │ │ ├── exception │ │ │ └── IllegalItemException.java │ │ │ └── servlet │ │ │ └── TestChunk.java │ │ ├── resources │ │ └── META-INF │ │ │ ├── batch-jobs │ │ │ └── simplejob.xml │ │ │ ├── create.sql │ │ │ └── drop.sql │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.jsp ├── javaee7-batch-chunk │ ├── README.md │ ├── input.csv │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter14 │ │ │ ├── chunk │ │ │ ├── BatchItemProcessor.java │ │ │ ├── BatchItemReader.java │ │ │ └── BatchItemWriter.java │ │ │ ├── exception │ │ │ └── IllegalItemException.java │ │ │ └── servlet │ │ │ └── TestChunk.java │ │ ├── resources │ │ └── META-INF │ │ │ ├── batch-jobs │ │ │ └── simplejob.xml │ │ │ ├── create.sql │ │ │ └── drop.sql │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.jsp ├── javaee7-batch-decision │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter14 │ │ │ ├── batchlet │ │ │ └── SimpleBatchlet.java │ │ │ ├── decision │ │ │ └── DecisionNode.java │ │ │ └── servlet │ │ │ └── TestDecision.java │ │ ├── resources │ │ └── META-INF │ │ │ └── batch-jobs │ │ │ └── decision.xml │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.jsp ├── javaee7-batch-exception │ ├── README.md │ ├── input.csv │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter14 │ │ │ ├── chunk │ │ │ ├── BatchItemProcessor.java │ │ │ ├── BatchItemReader.java │ │ │ └── BatchItemWriter.java │ │ │ ├── exception │ │ │ └── IllegalItemException.java │ │ │ ├── listener │ │ │ └── ChunkSkipWriteListener.java │ │ │ └── servlet │ │ │ └── TestChunk.java │ │ ├── resources │ │ └── META-INF │ │ │ ├── batch-jobs │ │ │ └── simplejobexception.xml │ │ │ ├── create.sql │ │ │ └── drop.sql │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.jsp └── javaee7-batch-listeners │ ├── README.md │ ├── input.csv │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter14 │ │ ├── chunk │ │ ├── BatchItemProcessor.java │ │ ├── BatchItemReader.java │ │ └── BatchItemWriter.java │ │ ├── exception │ │ └── IllegalItemException.java │ │ ├── listener │ │ ├── BatchItemProcessListener.java │ │ ├── BatchItemReadListener.java │ │ └── BatchItemWriteListener.java │ │ └── servlet │ │ └── TestListener.java │ ├── resources │ └── META-INF │ │ ├── batch-jobs │ │ └── listener.xml │ │ ├── create.sql │ │ └── drop.sql │ └── webapp │ ├── WEB-INF │ ├── beans.xml │ └── web.xml │ └── index.jsp ├── chapter15 ├── javaee7-managedcontextual │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter15 │ │ │ ├── ejb │ │ │ └── ContextExecutorEJB.java │ │ │ ├── job │ │ │ └── CallableTask.java │ │ │ └── servlet │ │ │ └── ExecutorServlet.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp ├── javaee7-managedexecutor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter15 │ │ │ ├── ejb │ │ │ └── SimpleEJB.java │ │ │ ├── job │ │ │ ├── CallableTask.java │ │ │ ├── SimpleTask.java │ │ │ └── TxCallableTask.java │ │ │ └── servlet │ │ │ ├── CallableExecutorServlet.java │ │ │ ├── ExecutorServlet.java │ │ │ └── TxCallableExecutorServlet.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp ├── javaee7-managedfactoryexecutor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter15 │ │ │ ├── job │ │ │ ├── CallableTask.java │ │ │ └── SimpleTask.java │ │ │ └── servlet │ │ │ ├── FactoryExecutorServiceServlet.java │ │ │ ├── FactoryExecutorServlet.java │ │ │ └── PoolExecutorEJB.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp └── javaee7-managedscheduledexecutor │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter15 │ │ ├── job │ │ ├── CallableTask.java │ │ └── SimpleTask.java │ │ └── servlet │ │ ├── ScheduledCallableExecutorServlet.java │ │ └── ScheduledExecutor.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.jsp ├── chapter16 ├── https │ ├── README.md │ ├── client.cer │ ├── client.keystore │ ├── client.truststore │ ├── generatekeys.sh │ ├── script.cli │ ├── server.cer │ ├── server.keystore │ └── server.truststore ├── javaee7-ejb-elytron-ssl │ ├── README.md │ ├── client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter16 │ │ │ │ └── client │ │ │ │ └── RemoteEJBClient.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ └── wildfly-config.xml │ │ │ ├── client.keystore │ │ │ └── client.truststore │ ├── script.cli │ ├── server │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter16 │ │ │ ├── ejb │ │ │ ├── Account.java │ │ │ ├── AccountEJB.java │ │ │ ├── Calculator.java │ │ │ └── CalculatorEJB.java │ │ │ └── exception │ │ │ └── InsufficientFundsException.java │ └── ssl │ │ ├── client.cer │ │ ├── client.keystore │ │ ├── client.truststore │ │ ├── generatekeys.sh │ │ ├── keys.cli │ │ ├── server.cer │ │ ├── server.keystore │ │ └── server.truststore ├── javaee7-ejb-elytron │ ├── README.md │ ├── client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter16 │ │ │ │ └── client │ │ │ │ └── RemoteEJBClient.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── wildfly-config.xml │ ├── script.cli │ └── server │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter16 │ │ ├── ejb │ │ ├── Account.java │ │ ├── AccountEJB.java │ │ ├── Calculator.java │ │ └── CalculatorEJB.java │ │ └── exception │ │ └── InsufficientFundsException.java ├── javaee7-security-elytron │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── security │ │ │ └── SecuredServlet.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── jboss-web.xml │ │ └── web.xml │ │ └── index.html └── legacy │ ├── README.md │ ├── javaee7-ejb-ssl │ ├── javaee7-ejb-client-ssl │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter16 │ │ │ │ └── client │ │ │ │ └── RemoteEJBClient.java │ │ │ └── resources │ │ │ └── jboss-ejb-client.properties │ ├── javaee7-ejb-server-ssl │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter16 │ │ │ │ ├── ejb │ │ │ │ ├── Account.java │ │ │ │ ├── AccountEJB.java │ │ │ │ ├── Calculator.java │ │ │ │ └── CalculatorEJB.java │ │ │ │ └── exception │ │ │ │ └── InsufficientFundsException.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ ├── MANIFEST.MF │ │ │ └── beans.xml │ └── ssl │ │ ├── client.cer │ │ ├── client.keystore │ │ ├── client.truststore │ │ ├── generatekeys.sh │ │ ├── script.cli │ │ ├── server.cer │ │ ├── server.keystore │ │ └── server.truststore │ └── javaee7-security-jaas │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter16 │ │ └── servlet │ │ └── SecureServlet.java │ ├── resources │ └── META-INF │ │ └── MANIFEST.MF │ └── webapp │ ├── WEB-INF │ ├── jboss-web.xml │ └── web.xml │ └── index.jsp ├── chapter3 ├── javaee7-async-servlet │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter3 │ │ │ └── servlet │ │ │ └── async │ │ │ ├── AsyncService.java │ │ │ ├── AsyncServlet.java │ │ │ └── ExampleAsyncListener.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── beans.xml │ │ └── index.jsp ├── javaee7-noblock-servlet │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter3 │ │ │ └── servlet │ │ │ └── async │ │ │ ├── ExampleReadListener.java │ │ │ └── NonBlockingServlet.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── beans.xml │ │ └── index.jsp └── javaee8-servlet-push │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter3 │ │ └── servlet │ │ └── push │ │ ├── PushImage.java │ │ └── PushResources.java │ └── webapp │ ├── WEB-INF │ └── beans.xml │ ├── css │ ├── myscript.js │ └── style.css │ ├── images │ └── duke.png │ └── index.jsp ├── chapter4 ├── async │ ├── javaee7-ejb-client-async │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter4 │ │ │ │ └── client │ │ │ │ └── RemoteEJBClient.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── wildfly-config.xml │ └── javaee7-ejb-server-async │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter4 │ │ │ ├── ejb │ │ │ ├── Account.java │ │ │ ├── AccountEJB.java │ │ │ ├── Calculator.java │ │ │ └── CalculatorEJB.java │ │ │ └── exception │ │ │ └── InsufficientFundsException.java │ │ └── resources │ │ └── META-INF │ │ ├── MANIFEST.MF │ │ └── beans.xml ├── basic │ ├── javaee7-ejb-client-basic │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter4 │ │ │ │ └── client │ │ │ │ └── RemoteEJBClient.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── wildfly-config.xml │ └── javaee7-ejb-server-basic │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter4 │ │ │ ├── ejb │ │ │ ├── Account.java │ │ │ ├── AccountEJB.java │ │ │ ├── Calculator.java │ │ │ └── CalculatorEJB.java │ │ │ └── exception │ │ │ └── InsufficientFundsException.java │ │ └── resources │ │ └── META-INF │ │ ├── MANIFEST.MF │ │ └── beans.xml └── timer │ ├── javaee7-ejb-client-timer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter4 │ │ │ └── client │ │ │ └── RemoteEJBClient.java │ │ └── resources │ │ └── META-INF │ │ └── wildfly-config.xml │ └── javaee7-ejb-server-timer │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter4 │ │ ├── ejb │ │ ├── Account.java │ │ ├── AccountEJB.java │ │ ├── Calculator.java │ │ ├── CalculatorEJB.java │ │ └── UserRegistry.java │ │ └── exception │ │ └── InsufficientFundsException.java │ └── resources │ └── META-INF │ ├── MANIFEST.MF │ └── beans.xml ├── chapter5 ├── cdi-j2se │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── itbuzzpress │ │ │ │ └── chapter5 │ │ │ │ ├── App.java │ │ │ │ ├── CDI2Demo.java │ │ │ │ ├── Hello.java │ │ │ │ ├── SimpleEvent.java │ │ │ │ └── SimpleService.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── beans.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── itbuzzpress │ │ └── chapter5 │ │ └── test │ │ └── AppTest.java ├── javaee7-cdi-alternative │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ ├── Hard.java │ │ │ ├── Player.java │ │ │ ├── Rules.java │ │ │ └── Simple.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ └── Anagram.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee7-cdi-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ └── Player.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ └── Anagram.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee7-cdi-decorator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ └── Player.java │ │ │ ├── decorator │ │ │ ├── PlayerDecorator.java │ │ │ └── PlayerItf.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ └── Anagram.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee7-cdi-event │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ ├── Player.java │ │ │ └── WordInventory.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ └── Anagram.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee7-cdi-interceptor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ └── Player.java │ │ │ ├── interceptors │ │ │ └── AuditInterceptor.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ ├── Anagram.java │ │ │ └── Auditing.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee7-cdi-qualifier │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter5 │ │ │ ├── bean │ │ │ ├── GenerateWord.java │ │ │ └── Player.java │ │ │ ├── enums │ │ │ └── Language.java │ │ │ ├── model │ │ │ └── Word.java │ │ │ └── qualifier │ │ │ └── Anagram.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ └── index.xhtml └── javaee8-cdi-producerfactory │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter5 │ │ ├── bean │ │ ├── GenerateWord.java │ │ ├── Player.java │ │ └── WordInterceptor.java │ │ ├── model │ │ └── Word.java │ │ └── qualifier │ │ ├── Anagram.java │ │ └── AnagramInterceptor.java │ └── webapp │ ├── WEB-INF │ ├── beans.xml │ ├── faces-config.xml │ └── web.xml │ └── index.xhtml ├── chapter6 ├── javaee7-jsf-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ ├── bean │ │ │ ├── Manager.java │ │ │ └── SingletonBean.java │ │ │ └── model │ │ │ └── User.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ ├── index.xhtml │ │ └── resources │ │ └── style.css ├── javaee7-jsf-composite │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ ├── bean │ │ │ ├── Manager.java │ │ │ └── SingletonBean.java │ │ │ └── model │ │ │ └── User.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ ├── index.xhtml │ │ ├── resources │ │ ├── mycomponents │ │ │ └── signup.xhtml │ │ └── style.css │ │ └── templates │ │ ├── footer.xhtml │ │ ├── header.xhtml │ │ └── template.xhtml ├── javaee7-jsf-contracts │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ ├── bean │ │ │ ├── Manager.java │ │ │ ├── SingletonBean.java │ │ │ └── TemplateBean.java │ │ │ └── model │ │ │ └── User.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ ├── admin │ │ └── index.xhtml │ │ ├── contracts │ │ ├── black │ │ │ ├── style.css │ │ │ └── template.xhtml │ │ └── color │ │ │ ├── style.css │ │ │ └── template.xhtml │ │ └── index.xhtml ├── javaee7-jsf-flow │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ └── flow │ │ │ └── SignupBean.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ ├── index.xhtml │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── javaee7 │ │ │ └── jsf │ │ │ └── flow │ │ │ ├── Flow1.java │ │ │ └── Flow1Bean.java │ │ └── signup │ │ ├── signup-flow.xml │ │ ├── signup.xhtml │ │ ├── signup2.xhtml │ │ └── signup3.xhtml ├── javaee7-jsf-multipleflow │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ └── flow │ │ │ ├── ConfirmBean.java │ │ │ └── SignupBean.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ ├── confirm │ │ ├── confirm-flow.xml │ │ ├── confirm.xhtml │ │ └── confirm2.xhtml │ │ ├── index.xhtml │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── javaee7 │ │ │ └── jsf │ │ │ └── flow │ │ │ ├── Flow1.java │ │ │ └── Flow1Bean.java │ │ └── signup │ │ ├── signup-flow.xml │ │ ├── signup.xhtml │ │ ├── signup2.xhtml │ │ └── signup3.xhtml ├── javaee8-jsf-commandscript │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ └── bean │ │ │ └── CounterBean.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee8-jsf-datatablemap │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ └── beans │ │ │ ├── Country.java │ │ │ └── CountryBean.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ └── web.xml │ │ └── index.xhtml ├── javaee8-jsf-validatewholebean │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter6 │ │ │ └── validator │ │ │ ├── Customer.java │ │ │ ├── CustomerGroup.java │ │ │ ├── CustomerValidator.java │ │ │ └── ValidCustomer.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ ├── index.xhtml │ │ └── register.xhtml └── javaee8-jsf-websocket │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter6 │ │ └── beans │ │ └── HelperBean.java │ └── webapp │ ├── WEB-INF │ ├── beans.xml │ ├── faces-config.xml │ └── web.xml │ └── index.xhtml ├── chapter7 └── javaee7-jpa-basic │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter7 │ │ ├── ejb │ │ └── ManagerEJB.java │ │ └── entity │ │ ├── Customer.java │ │ └── Request.java │ ├── resources │ └── META-INF │ │ ├── MANIFEST.MF │ │ ├── create.sql │ │ ├── drop.sql │ │ └── persistence.xml │ └── webapp │ └── WEB-INF │ └── web.xml ├── chapter8 └── javaee7-test │ ├── README.md │ ├── nohup.out │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter8 │ │ │ ├── ejb │ │ │ └── ManagerEJB.java │ │ │ └── entity │ │ │ ├── Customer.java │ │ │ └── Request.java │ ├── resources │ │ └── META-INF │ │ │ ├── MANIFEST.MF │ │ │ ├── create.sql │ │ │ ├── drop.sql │ │ │ └── persistence.xml │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── angular.html │ └── test │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter8 │ │ └── test │ │ └── TestJPA.java │ └── resources │ └── arquillian.xml ├── chapter9 ├── javaee7-websocket-async │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter9 │ │ │ ├── endpoint │ │ │ ├── HelloWorldEndpoint.java │ │ │ └── WebSocketEndpoint.java │ │ │ └── servlet │ │ │ └── ServletClient.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp ├── javaee7-websocket-basic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter9 │ │ │ └── endpoint │ │ │ └── HelloWorldEndpoint.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.html ├── javaee7-websocket-binary │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter9 │ │ │ └── endpoint │ │ │ └── HelloWorldBinaryEndpoint.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.html ├── javaee7-websocket-client │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── itbuzzpress │ │ │ └── chapter9 │ │ │ ├── endpoint │ │ │ ├── HelloWorldEndpoint.java │ │ │ └── WebSocketEndpoint.java │ │ │ └── servlet │ │ │ └── ServletClient.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp └── javaee7-websocket-encdec │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── itbuzzpress │ │ └── chapter9 │ │ ├── decoder │ │ └── MessageDecoder.java │ │ ├── encoder │ │ └── MessageEncoder.java │ │ ├── endpoint │ │ ├── HelloWorldEncodedEndpoint.java │ │ └── WebSocketEncodedEndpoint.java │ │ ├── model │ │ └── User.java │ │ └── servlet │ │ └── ServletClient.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.jsp └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build 3 | target 4 | .DS_Store 5 | bin 6 | .openshift 7 | */.gitignore 8 | .gitkeep 9 | /helloworld-jsp 10 | README.html 11 | SERVICES.html 12 | CHANGES.html 13 | CONTRIBUTING.html 14 | RELEASE_PROCEDURE.html 15 | out 16 | nb-configuration.xml 17 | nbactions.xml 18 | .idea 19 | *.ipr 20 | *.iws 21 | *.iml 22 | atlassian-ide-plugin.xml 23 | .checkstyle 24 | .classpath 25 | .project 26 | .settings 27 | .metadata 28 | .factorypath 29 | .nbattrs 30 | *.log 31 | build.metadata 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Practical Enterprise & Microsevices development 2 | ===================================== 3 | 4 | This is the old repository for Java EE 8 examples to be deployed on WildFly Application Server 5 | 6 | Latest repository is available here: https://github.com/fmarchioni/practical-enterprise-development 7 | 8 | 9 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/README.md: -------------------------------------------------------------------------------- 1 | SOAP Web services basic example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of JAX-WS Web services 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/src/main/java/com/itbuzzpress/chapter10/ws/AccountWSItf.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter10.ws; 2 | 3 | import javax.jws.WebMethod; 4 | import javax.jws.WebService; 5 | @WebService 6 | public interface AccountWSItf { 7 | @WebMethod 8 | public void newAccount( String name); 9 | 10 | @WebMethod 11 | public void withdraw(String name, long amount) throws RuntimeException; 12 | 13 | @WebMethod 14 | public void deposit(String name, long amount); 15 | 16 | @WebMethod 17 | public Account findAccountByName(String name); 18 | } 19 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter10/javaee7-ws-basic/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | java:jboss/datasources/ExampleDS 11 | 12 | 13 | 14 | 16 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-basic/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/README.md: -------------------------------------------------------------------------------- 1 | SOAP Web services with Handlers example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of JAX-WS Web services using Handlers 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/java/com/itbuzzpress/chapter10/ws/AccountWSItf.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter10.ws; 2 | 3 | import javax.jws.WebMethod; 4 | import javax.jws.WebParam; 5 | import javax.jws.WebService; 6 | @WebService 7 | public interface AccountWSItf { 8 | @WebMethod 9 | public void newAccount( String name); 10 | 11 | @WebMethod 12 | public void withdraw(String name, long amount) throws RuntimeException; 13 | 14 | @WebMethod 15 | public void deposit(String name, long amount); 16 | 17 | @WebMethod 18 | public Account findAccountByName(String name); 19 | } 20 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter10/javaee7-ws-handler/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | java:jboss/datasources/ExampleDS 11 | 12 | 13 | 14 | 16 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/resources/com/itbuzzpress/chapter10/ws/handlers.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | com.itbuzzpress.chapter10.handler.SampleSOAPHandler 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter10/javaee7-ws-handler/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-aysnc/README.md: -------------------------------------------------------------------------------- 1 | Asynchronous REST Web services example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Asynchronous REST Web services 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-aysnc/src/main/java/com/itbuzzpress/chapter11/activator/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.activator; 2 | 3 | 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | import javax.ws.rs.core.Application; 7 | 8 | /** 9 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 10 | * "no XML" approach to activating JAX-RS. 11 | * 12 | *

13 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 14 | * annotation. 15 | *

16 | */ 17 | @ApplicationPath("/rest") 18 | public class JaxRsActivator extends Application { 19 | /* class body intentionally left blank */ 20 | } 21 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-aysnc/src/main/java/com/itbuzzpress/chapter11/handler/MyTimeoutHandler.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.handler; 2 | 3 | import java.net.HttpURLConnection; 4 | 5 | import javax.ws.rs.container.AsyncResponse; 6 | import javax.ws.rs.container.TimeoutHandler; 7 | import javax.ws.rs.core.Response; 8 | 9 | import com.itbuzzpress.chapter11.model.SimpleProperty; 10 | 11 | public class MyTimeoutHandler implements TimeoutHandler { 12 | 13 | @Override 14 | public void handleTimeout(AsyncResponse asyncResp) { 15 | Response r = Response.serverError().status( HttpURLConnection.HTTP_UNAVAILABLE).build( ); 16 | asyncResp.resume( r ); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-aysnc/src/main/java/com/itbuzzpress/chapter11/model/SimpleProperty.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class SimpleProperty { 7 | @Override 8 | public String toString() { 9 | return "SimpleProperty [key=" + key + ", value=" + value + "]"; 10 | } 11 | public SimpleProperty() { 12 | 13 | } 14 | 15 | 16 | private String key; 17 | private String value; 18 | public String getKey() { 19 | return key; 20 | } 21 | public void setKey(String key) { 22 | this.key = key; 23 | } 24 | public SimpleProperty( String key, String value) { 25 | super(); 26 | 27 | this.key = key; 28 | this.value = value; 29 | } 30 | public String getValue() { 31 | return value; 32 | } 33 | public void setValue(String value) { 34 | this.value = value; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-aysnc/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-basic/README.md: -------------------------------------------------------------------------------- 1 | Basic REST Web services example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of REST Web services 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-rest-basic/ 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-basic/src/main/java/com/itbuzzpress/chapter11/activator/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.activator; 2 | 3 | 4 | 5 | 6 | import javax.ws.rs.ApplicationPath; 7 | import javax.ws.rs.core.Application; 8 | 9 | /** 10 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 11 | * "no XML" approach to activating JAX-RS. 12 | * 13 | *

14 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 15 | * annotation. 16 | *

17 | */ 18 | @ApplicationPath("/rest") 19 | public class JaxRsActivator extends Application { 20 | /* class body intentionally left blank */ 21 | } 22 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-basic/src/main/java/com/itbuzzpress/chapter11/ejb/DataList.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.ejb; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import javax.annotation.PostConstruct; 8 | 9 | import javax.ejb.Singleton; 10 | import javax.enterprise.context.SessionScoped; 11 | import javax.inject.Named; 12 | 13 | import com.itbuzzpress.chapter11.model.SimpleProperty; 14 | 15 | @Singleton 16 | @Named 17 | public class DataList implements Serializable { 18 | private List list; 19 | 20 | @PostConstruct 21 | public void init() { 22 | list = new ArrayList(); 23 | 24 | } 25 | public List getList() { 26 | return list; 27 | } 28 | 29 | public void setList(List list) { 30 | this.list = list; 31 | } 32 | public int addToList(String key, String value) { 33 | list.add(new SimpleProperty(key,value)); 34 | return list.size(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-basic/src/main/java/com/itbuzzpress/chapter11/model/SimpleProperty.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class SimpleProperty { 7 | public SimpleProperty() { 8 | 9 | } 10 | 11 | private String key; 12 | private String value; 13 | public String getKey() { 14 | return key; 15 | } 16 | public void setKey(String key) { 17 | this.key = key; 18 | } 19 | public SimpleProperty(String key, String value) { 20 | super(); 21 | this.key = key; 22 | this.value = value; 23 | } 24 | public String getValue() { 25 | return value; 26 | } 27 | public void setValue(String value) { 28 | this.value = value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-client/README.md: -------------------------------------------------------------------------------- 1 | REST Web services with Java Client example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of REST Web services Client API 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-client/src/main/java/com/itbuzzpress/chapter11/activator/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.activator; 2 | 3 | 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | import javax.ws.rs.core.Application; 7 | 8 | /** 9 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 10 | * "no XML" approach to activating JAX-RS. 11 | * 12 | *

13 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 14 | * annotation. 15 | *

16 | */ 17 | @ApplicationPath("/rest") 18 | public class JaxRsActivator extends Application { 19 | /* class body intentionally left blank */ 20 | } 21 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-client/src/main/java/com/itbuzzpress/chapter11/model/SimpleProperty.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class SimpleProperty { 7 | public SimpleProperty() { 8 | 9 | } 10 | 11 | 12 | private String key; 13 | private String value; 14 | public String getKey() { 15 | return key; 16 | } 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | public SimpleProperty( String key, String value) { 21 | super(); 22 | 23 | this.key = key; 24 | this.value = value; 25 | } 26 | public String getValue() { 27 | return value; 28 | } 29 | public void setValue(String value) { 30 | this.value = value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-client/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/README.md: -------------------------------------------------------------------------------- 1 | REST Web services with Filters example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of REST Web services Filters API 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/src/main/java/com/itbuzzpress/chapter11/filter/CachingFilter.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.ws.rs.container.ContainerRequestContext; 6 | import javax.ws.rs.container.ContainerResponseContext; 7 | import javax.ws.rs.container.ContainerResponseFilter; 8 | import javax.ws.rs.ext.Provider; 9 | 10 | @Provider 11 | public class CachingFilter implements ContainerResponseFilter { 12 | 13 | @Override 14 | public void filter(ContainerRequestContext crc, ContainerResponseContext crc1) throws IOException { 15 | System.out.println("[Caching filter] Running"); 16 | if (crc.getMethod().equals("GET")) { 17 | crc.getHeaders().add("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); 18 | crc.getHeaders().add("Expires", "-1"); 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/src/main/java/com/itbuzzpress/chapter11/filter/LoggingFilter.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.ws.rs.container.ContainerRequestContext; 6 | import javax.ws.rs.container.ContainerRequestFilter; 7 | import javax.ws.rs.ext.Provider; 8 | 9 | @Provider 10 | public class LoggingFilter implements ContainerRequestFilter { 11 | 12 | public void filter(ContainerRequestContext crc) throws IOException { 13 | 14 | System.out.println(crc.getMethod() + " " + crc.getUriInfo().getAbsolutePath()); 15 | for (String key : crc.getHeaders().keySet()) { 16 | System.out.println("[Logging Filter] " +key + ": " + crc.getHeaders().get(key)); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/src/main/java/com/itbuzzpress/chapter11/model/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | import javax.ws.rs.core.Application; 7 | 8 | /** 9 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 10 | * "no XML" approach to activating JAX-RS. 11 | * 12 | *

13 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 14 | * annotation. 15 | *

16 | */ 17 | @ApplicationPath("/rest") 18 | public class JaxRsActivator extends Application { 19 | /* class body intentionally left blank */ 20 | } 21 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/src/main/java/com/itbuzzpress/chapter11/model/SimpleProperty.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class SimpleProperty { 7 | public SimpleProperty() { 8 | 9 | } 10 | 11 | 12 | private String key; 13 | private String value; 14 | public String getKey() { 15 | return key; 16 | } 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | public SimpleProperty( String key, String value) { 21 | super(); 22 | 23 | this.key = key; 24 | this.value = value; 25 | } 26 | public String getValue() { 27 | return value; 28 | } 29 | public void setValue(String value) { 30 | this.value = value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-filters/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-interceptors/README.md: -------------------------------------------------------------------------------- 1 | REST Web services with Interceptors example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of REST Web services Interceptors API 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy -DskipTests=true 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | mvn test 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-interceptors/src/main/java/com/itbuzzpress/chapter11/model/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | import javax.ws.rs.core.Application; 7 | 8 | /** 9 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 10 | * "no XML" approach to activating JAX-RS. 11 | * 12 | *

13 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 14 | * annotation. 15 | *

16 | */ 17 | @ApplicationPath("/rest") 18 | public class JaxRsActivator extends Application { 19 | /* class body intentionally left blank */ 20 | } 21 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-interceptors/src/main/java/com/itbuzzpress/chapter11/model/SimpleProperty.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class SimpleProperty { 7 | public SimpleProperty() { 8 | 9 | } 10 | 11 | 12 | private String key; 13 | private String value; 14 | public String getKey() { 15 | return key; 16 | } 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | public SimpleProperty( String key, String value) { 21 | super(); 22 | 23 | this.key = key; 24 | this.value = value; 25 | } 26 | public String getValue() { 27 | return value; 28 | } 29 | public void setValue(String value) { 30 | this.value = value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-interceptors/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/chapter11/javaee7-rest-interceptors/src/test/java/com/itbuzzpress/chapter11/test/TestClient.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.test; 2 | 3 | 4 | 5 | import javax.ws.rs.client.Client; 6 | import javax.ws.rs.client.ClientBuilder; 7 | 8 | 9 | import org.junit.Test; 10 | 11 | 12 | 13 | public class TestClient { 14 | String BASE_URL ="http://localhost:8080/javaee7-rest-interceptors/rest"; 15 | @Test 16 | public void test() { 17 | Client client = ClientBuilder.newClient(); 18 | 19 | String hello = client 20 | .target(BASE_URL +"/simple/text") 21 | .request() 22 | .get(String.class); 23 | // Return value is zipped 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /code/chapter11/javaee8-rest-sse/src/main/java/com/itbuzzpress/chapter11/activator/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter11.activator; 2 | 3 | import javax.ws.rs.ApplicationPath; 4 | import javax.ws.rs.core.Application; 5 | 6 | 7 | @ApplicationPath("/rest") 8 | public class JaxRsActivator extends Application { 9 | /* class body intentionally left blank */ 10 | } -------------------------------------------------------------------------------- /code/chapter11/javaee8-rest-sse/src/main/webapp/broadcast.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 |
11 | 12 | " 13 |
14 | 15 | -------------------------------------------------------------------------------- /code/chapter12/javaee7-jms-basic/README.md: -------------------------------------------------------------------------------- 1 | Basic JMS example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of a JMS 2.0 application 6 | 7 | ###### Pre-requisites: 8 | You need the following Queue Definition in a full/full-ha profile: 9 | 10 | ```shell 11 | 12 | ``` 13 | 14 | ###### Build and Deploy 15 | ```shell 16 | mvn clean install wildfly:deploy 17 | ``` 18 | 19 | ###### Test 20 | ```shell 21 | http://localhost:8080/javaee7-jms-basic 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /code/chapter12/javaee7-jms-basic/src/main/java/com/itbuzzpress/chapter12/mdb/MDBSample.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter12.mdb; 2 | 3 | import javax.ejb.ActivationConfigProperty; 4 | import javax.ejb.MessageDriven; 5 | import javax.jms.JMSException; 6 | import javax.jms.Message; 7 | import javax.jms.MessageListener; 8 | import javax.jms.TextMessage; 9 | 10 | @MessageDriven(activationConfig = { 11 | @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/queue/exampleQueue"), 12 | @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), }) 13 | public class MDBSample implements MessageListener { 14 | 15 | public void onMessage(Message message) { 16 | try { 17 | TextMessage tm = (TextMessage) message; 18 | System.out.println("Message received : " + tm.getText()); 19 | } catch (JMSException ex) { 20 | ex.printStackTrace(); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /code/chapter12/javaee7-jms-basic/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter12/javaee7-jms-basic/src/main/webapp/WEB-INF/beans.xml -------------------------------------------------------------------------------- /code/chapter12/javaee7-jms-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.sun.faces.enableRestoreView11Compatibility 4 | true 5 | 6 | 7 | Faces Servlet 8 | javax.faces.webapp.FacesServlet 9 | 1 10 | 11 | 12 | Faces Servlet 13 | *.xhtml 14 | 15 | 16 | index.xhtml 17 | 18 | -------------------------------------------------------------------------------- /code/chapter13/javaee7-json/README.md: -------------------------------------------------------------------------------- 1 | Java EE 7 examples using JSON API 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of JSON API 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-json/ 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /code/chapter13/javaee7-json/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter13/javaee7-json/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter13/javaee7-json/src/main/resources/data.json: -------------------------------------------------------------------------------- 1 | [{"name":"Nicolas","surname":"Cage"},{"name":"John","surname":"Travolta"}] -------------------------------------------------------------------------------- /code/chapter13/javaee7-json/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter13/javaee7-json/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test JSON API 8 | 9 |

Test JSON API

10 |
11 |
12 |

Object Model API

13 | Parse JSON Example
Produce JSON Example
Produce JSON with Array Example

16 |

Streaming API

17 | Consume JSON Example
Produce JSON Example
19 |
20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /code/chapter13/javaee8-jsonb/README.md: -------------------------------------------------------------------------------- 1 | Java EE 8 examples using JSON API 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of JSON-B API 6 | 7 | ###### Start a Java EE 8 profile 8 | ```shell 9 | ./standalone.sh -c standalone-ee8.xml 10 | ``` 11 | 12 | ###### Build and Deploy 13 | ```shell 14 | mvn clean install wildfly:deploy 15 | ``` 16 | 17 | ###### Test 18 | ```shell 19 | http://localhost:8080/javaee8-jsonb/ 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /code/chapter13/javaee8-jsonb/src/main/java/com/itbuzzpress/json/activator/JaxRsActivator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.itbuzzpress.json.activator; 7 | 8 | import java.util.Set; 9 | import javax.ws.rs.core.Application; 10 | 11 | import javax.ws.rs.ApplicationPath; 12 | import javax.ws.rs.core.Application; 13 | 14 | /** 15 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 16 | * "no XML" approach to activating JAX-RS. 17 | * 18 | *

19 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath} 20 | * annotation. 21 | *

22 | */ 23 | @ApplicationPath("/rest") 24 | public class JaxRsActivator extends Application { 25 | /* class body intentionally left blank */ 26 | } -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/README.md: -------------------------------------------------------------------------------- 1 | Basic Batchlet example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a Batchlet example 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-batch-batchlet/ 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/src/main/resources/META-INF/batch-jobs/simplebatchlet.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | java:jboss/datasources/ExampleDS 11 | 12 | 13 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-batchlet/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Simple Batchlet 9 | 10 |

Test Simple Batchlet

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/README.md: -------------------------------------------------------------------------------- 1 | Basic Chunk job example with checkpoint class 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a Chunk job example with checkpoint class 6 | 7 | ###### Install the CSV file in the location specified by your job.xml (in this example /tmp) 8 | ```shell 9 | cp input.csv /tmp 10 | ``` 11 | 12 | ###### Build and Deploy 13 | ```shell 14 | mvn clean install wildfly:deploy 15 | ``` 16 | 17 | ###### Test 18 | ```shell 19 | http://localhost:8080/javaee7-batch-chunk-checkpoint/ 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/input.csv: -------------------------------------------------------------------------------- 1 | John,Smith,45 2 | Mark,Twain,32 3 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/java/com/itbuzzpress/chapter14/chunk/BatchCheckpointAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.chunk; 2 | 3 | import javax.batch.api.chunk.AbstractCheckpointAlgorithm; 4 | import javax.batch.runtime.context.JobContext; 5 | import javax.inject.Inject; 6 | import javax.inject.Named; 7 | 8 | import com.itbuzzpress.chapter14.ejb.EJBSingleton; 9 | 10 | 11 | @Named 12 | public class BatchCheckpointAlgorithm extends AbstractCheckpointAlgorithm { 13 | 14 | @Inject 15 | private JobContext jobContext; 16 | 17 | @Inject 18 | private EJBSingleton ejb; 19 | 20 | @Override 21 | public boolean isReadyToCheckpoint() throws Exception { 22 | Integer counter = ejb.getCounter(jobContext.getExecutionId()); 23 | return counter % 3 == 0; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/java/com/itbuzzpress/chapter14/ejb/EJBSingleton.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.ejb; 2 | 3 | import java.util.HashMap; 4 | 5 | import javax.ejb.Singleton; 6 | 7 | @Singleton 8 | public class EJBSingleton { 9 | private HashMap map = new HashMap(); 10 | 11 | public void setCounter(Long key, Integer i) { 12 | map.put(key, i); 13 | } 14 | 15 | public Integer getCounter(Long key) { 16 | return map.get(key); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/java/com/itbuzzpress/chapter14/exception/IllegalItemException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.exception; 2 | 3 | public class IllegalItemException extends IllegalArgumentException { 4 | public int getItem() { 5 | return item; 6 | } 7 | int item; 8 | public IllegalItemException(String error, int item) { 9 | super(error); 10 | this.item = item; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/resources/META-INF/batch-jobs/simplejob.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CHUNK_CSV_DATABASE ("NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null) -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE CHUNK_CSV_DATABASE -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk-checkpoint/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Chunk Job with Checkpoint 9 | 10 |

Chunk Job with Checkpoint

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/README.md: -------------------------------------------------------------------------------- 1 | Basic Chunk job example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a Chunk job example 6 | ###### Install the CSV file in the location specified by your simplejob.xml (in this example /tmp) 7 | ```shell 8 | cp input.csv /tmp 9 | ``` 10 | 11 | ###### Build and Deploy 12 | ```shell 13 | mvn clean install wildfly:deploy 14 | ``` 15 | 16 | ###### Test 17 | ```shell 18 | http://localhost:8080/javaee7-batch-chunk/ 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/input.csv: -------------------------------------------------------------------------------- 1 | John,Smith,45 2 | Mark,Twain,32 3 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/java/com/itbuzzpress/chapter14/exception/IllegalItemException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.exception; 2 | 3 | public class IllegalItemException extends IllegalArgumentException { 4 | public int getItem() { 5 | return item; 6 | } 7 | int item; 8 | public IllegalItemException(String error, int item) { 9 | super(error); 10 | this.item = item; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/resources/META-INF/batch-jobs/simplejob.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CHUNK_CSV_DATABASE ("NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null) -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE CHUNK_CSV_DATABASE -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-chunk/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Your First Batch Job 9 | 10 |

Your First Batch Job

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-decision/README.md: -------------------------------------------------------------------------------- 1 | Basic job example with Decision 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a with Decision class 6 | 7 | ###### Configure in the decision.xml file the FS Path to be scanned: 8 | ```xml 9 | 10 | 11 | 12 | ``` 13 | 14 | ###### Build and Deploy 15 | ```shell 16 | mvn clean install wildfly:deploy 17 | ``` 18 | 19 | ###### Test 20 | ```shell 21 | http://localhost:8080/javaee7-batch-decision/ 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-decision/src/main/resources/META-INF/batch-jobs/decision.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-decision/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-decision/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-decision/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Decision Node 9 | 10 |

Test Decision Node

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/README.md: -------------------------------------------------------------------------------- 1 | Basic job example with Exception Listener 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a with a Skippable exception listener class 6 | 7 | ###### Install the CSV file in the location specified by your job.xml (in this example /tmp) 8 | ```shell 9 | cp input.csv /tmp 10 | ``` 11 | 12 | ###### Build and Deploy 13 | ```shell 14 | mvn clean install wildfly:deploy 15 | ``` 16 | 17 | ###### Test 18 | ```shell 19 | http://localhost:8080/javaee7-batch-exception/ 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/input.csv: -------------------------------------------------------------------------------- 1 | John,Smith,45 2 | Mark,Twain,32 3 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/java/com/itbuzzpress/chapter14/exception/IllegalItemException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.exception; 2 | 3 | public class IllegalItemException extends IllegalArgumentException { 4 | 5 | private int item; 6 | public IllegalItemException(String error, int id) { 7 | super(error); 8 | this.item = id; 9 | } 10 | public int getItem() { 11 | 12 | return item; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/resources/META-INF/batch-jobs/simplejobexception.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CHUNK_CSV_DATABASE ("NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null) -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE CHUNK_CSV_DATABASE -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-exception/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Chunk Job with Exception Listener 9 | 10 |

Test Chunk Job with Exception Listener

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/README.md: -------------------------------------------------------------------------------- 1 | Basic job example with listeners 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Batch API with a with a listener class 6 | 7 | ###### Install the CSV file in the location specified by your job.xml (in this example /tmp) 8 | ```shell 9 | cp input.csv /tmp 10 | ``` 11 | 12 | ###### Build and Deploy 13 | ```shell 14 | mvn clean install wildfly:deploy 15 | ``` 16 | 17 | ###### Test 18 | ```shell 19 | http://localhost:8080/javaee7-batch-listeners/ 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/input.csv: -------------------------------------------------------------------------------- 1 | John,Smith,45 2 | Mark,Twain,32 3 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/java/com/itbuzzpress/chapter14/exception/IllegalItemException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.exception; 2 | 3 | public class IllegalItemException extends IllegalArgumentException { 4 | public int getItem() { 5 | return item; 6 | } 7 | int item; 8 | public IllegalItemException(String error, int item) { 9 | super(error); 10 | this.item = item; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/java/com/itbuzzpress/chapter14/listener/BatchItemReadListener.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter14.listener; 2 | 3 | import javax.batch.api.chunk.listener.AbstractItemReadListener; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | public class BatchItemReadListener extends AbstractItemReadListener { 8 | 9 | @Override 10 | public void beforeRead() throws Exception { 11 | System.out.println("BatchItemReadListener.beforeRead"); 12 | } 13 | 14 | @Override 15 | public void afterRead(Object item) throws Exception { 16 | System.out.println("BatchItemReadListener.afterRead: " + item); 17 | } 18 | 19 | @Override 20 | public void onReadError(Exception ex) throws Exception { 21 | System.out.println("BatchItemReadListener.onReadError: " + ex.getMessage()); 22 | } 23 | } -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/resources/META-INF/batch-jobs/listener.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CHUNK_CSV_DATABASE ("NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null) -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE CHUNK_CSV_DATABASE -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter14/javaee7-batch-listeners/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Batch Job with Listeners 9 | 10 |

Batch Job with Listeners

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedcontextual/README.md: -------------------------------------------------------------------------------- 1 | Java EE Concurrency example with Contextual instance example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Java EE Concurrency with a Contextual instance 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-managedcontextual/ 14 | ``` 15 | **Note** In order to propagate the Principal identity in the Proxy, it would be necessary to include a Security context in this application 16 | 17 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedcontextual/src/main/java/com/itbuzzpress/chapter15/job/CallableTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | import java.security.AccessController; 4 | import java.util.concurrent.Callable; 5 | 6 | import javax.security.auth.Subject; 7 | 8 | public class CallableTask implements Callable { 9 | private int id; 10 | 11 | public CallableTask(int id) { 12 | this.id = id; 13 | } 14 | 15 | public Long call() { 16 | long summation = 0; 17 | for (int i = 1; i <= id; i++) { 18 | summation += i; 19 | } 20 | Subject subject = Subject.getSubject(AccessController.getContext()); 21 | 22 | logInfo(subject, summation); 23 | return new Long(summation); 24 | } 25 | 26 | private void logInfo(Subject subject, long summation) { 27 | System.out.println("Subject is " + subject); 28 | if (subject != null) 29 | System.out.println("Subject is " + subject.getPrincipals()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedcontextual/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedcontextual/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Contextual instance 9 | 10 |

Java EE Test Contextual instance

11 |
12 |
13 | Test Servlet

14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/README.md: -------------------------------------------------------------------------------- 1 | Java EE Concurrency examples 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Java EE Concurrency with Runnable, Callable tasks and in a tx-context 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-managedexecutor/ 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/src/main/java/com/itbuzzpress/chapter15/ejb/SimpleEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.ejb; 2 | 3 | import javax.ejb.Stateless; 4 | 5 | @Stateless 6 | public class SimpleEJB { 7 | 8 | public long calculate(long id) { 9 | long summation = 0; 10 | for (int i = 1; i <= id; i++) { 11 | summation += i; 12 | } 13 | 14 | return new Long(summation); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/src/main/java/com/itbuzzpress/chapter15/job/CallableTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.Callable; 5 | 6 | 7 | 8 | public class CallableTask implements Callable { 9 | private int id; 10 | 11 | public CallableTask(int id) { 12 | this.id = id; 13 | } 14 | 15 | public Long call() { 16 | long summation = 0; 17 | for (int i = 1; i <= id; i++) { 18 | summation += i; 19 | } 20 | 21 | return new Long(summation); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/src/main/java/com/itbuzzpress/chapter15/job/SimpleTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | public class SimpleTask implements Runnable { 4 | 5 | @Override 6 | public void run() { 7 | System.out.println("Thread started."); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | concurrent/myExecutor 9 | 10 | 11 | javax.enterprise.concurrent.ManagedExecutorService 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedexecutor/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Concurrency Utilities 9 | 10 |

Java EE Test Concurrency Utilities

11 |
12 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedfactoryexecutor/README.md: -------------------------------------------------------------------------------- 1 | Java EE Concurrency examples with Thread Factory 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Java EE Concurrency with a Factory to create Threads 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-managedfactoryexecutor/ 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedfactoryexecutor/src/main/java/com/itbuzzpress/chapter15/job/CallableTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.Callable; 5 | 6 | 7 | 8 | public class CallableTask implements Callable { 9 | private long id; 10 | 11 | public CallableTask(long id) { 12 | this.id = id; 13 | } 14 | 15 | public Long call() { 16 | long summation = 0; 17 | for (int i = 1; i <= id; i++) { 18 | summation += i; 19 | } 20 | 21 | return new Long(summation); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedfactoryexecutor/src/main/java/com/itbuzzpress/chapter15/job/SimpleTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | public class SimpleTask implements Runnable { 4 | 5 | @Override 6 | public void run() { 7 | System.out.println("Simple Task Started."); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedfactoryexecutor/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | concurrent/myExecutor 9 | 10 | 11 | javax.enterprise.concurrent.ManagedExecutorService 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedfactoryexecutor/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Concurrency Utilities 9 | 10 |

Java EE Test Concurrency Utilities

11 |
12 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedscheduledexecutor/README.md: -------------------------------------------------------------------------------- 1 | Java EE Concurrency examples with a Scheduled Executor 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Java EE Concurrency with a Scheduled Executor 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-managedscheduledexecutor/ 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedscheduledexecutor/src/main/java/com/itbuzzpress/chapter15/job/CallableTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.Callable; 5 | 6 | 7 | 8 | public class CallableTask implements Callable { 9 | private long id; 10 | 11 | public CallableTask(long id) { 12 | this.id = id; 13 | } 14 | 15 | public Long call() { 16 | long summation = 0; 17 | for (int i = 1; i <= id; i++) { 18 | summation += i; 19 | } 20 | 21 | return new Long(summation); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedscheduledexecutor/src/main/java/com/itbuzzpress/chapter15/job/SimpleTask.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter15.job; 2 | 3 | public class SimpleTask implements Runnable { 4 | 5 | @Override 6 | public void run() { 7 | System.out.println("Thread started."); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedscheduledexecutor/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | concurrent/myExecutor 9 | 10 | 11 | javax.enterprise.concurrent.ManagedExecutorService 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/chapter15/javaee7-managedscheduledexecutor/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Concurrency Utilities 9 | 10 |

Java EE Test Concurrency Utilities

11 |
12 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /code/chapter16/https/README.md: -------------------------------------------------------------------------------- 1 | Securing WildFly with SSL 2 | ===================================== 3 | 4 | This folder contains the script generatekeys.sh to generate client/server keystores and trustores 5 | 6 | ###### Generate keys 7 | 8 | ```shell 9 | ./generatekeys.sh 10 | ``` 11 | 12 | Then copy the keystores and trustores in the $JBOSS_HOME/standalone/configuration folder 13 | 14 | ```shell 15 | cp *.keystore $JBOSS_HOME/standalone/configuration 16 | 17 | cp *.truststore $JBOSS_HOME/standalone/configuration 18 | ``` 19 | 20 | 21 | ###### Install keys on the application server 22 | 23 | ```shell 24 | /bin/jboss-cli.sh --file=script.cli 25 | ``` 26 | -------------------------------------------------------------------------------- /code/chapter16/https/client.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/client.cer -------------------------------------------------------------------------------- /code/chapter16/https/client.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/client.keystore -------------------------------------------------------------------------------- /code/chapter16/https/client.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/client.truststore -------------------------------------------------------------------------------- /code/chapter16/https/script.cli: -------------------------------------------------------------------------------- 1 | connect 2 | batch 3 | # Configure Server Keystore 4 | /subsystem=elytron/key-store=demoKeyStore:add(path=server.keystore,relative-to=jboss.server.config.dir, credential-reference={clear-text=123456},type=JKS) 5 | # Server Keystore credentials 6 | /subsystem=elytron/key-manager=demoKeyManager:add(key-store=demoKeyStore,credential-reference={clear-text=123456}) 7 | # Server keystore Protocols 8 | /subsystem=elytron/server-ssl-context=demoSSLContext:add(key-manager=demoKeyManager,protocols=["TLSv1.2"]) 9 | # This is only needed if WildFly uses by default the Legacy security realm 10 | /subsystem=undertow/server=default-server/https-listener=https:undefine-attribute(name=security-realm) 11 | # Store SSL Context information in undertow 12 | /subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=ssl-context,value=demoSSLContext) 13 | run-batch 14 | reload 15 | -------------------------------------------------------------------------------- /code/chapter16/https/server.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/server.cer -------------------------------------------------------------------------------- /code/chapter16/https/server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/server.keystore -------------------------------------------------------------------------------- /code/chapter16/https/server.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/https/server.truststore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/client/src/main/resources/client.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/client/src/main/resources/client.keystore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/client/src/main/resources/client.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/client/src/main/resources/client.truststore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/server/src/main/java/com/itbuzzpress/chapter16/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import com.itbuzzpress.chapter16.exception.InsufficientFundsException; 4 | 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public void createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/server/src/main/java/com/itbuzzpress/chapter16/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | 5 | public interface Calculator { 6 | 7 | public float calculateInterest(long money); 8 | 9 | } -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/server/src/main/java/com/itbuzzpress/chapter16/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | import java.util.Timer; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.annotation.Resource; 8 | import javax.annotation.security.RolesAllowed; 9 | import javax.ejb.EJB; 10 | import javax.ejb.Remote; 11 | import javax.ejb.Stateless; 12 | import javax.ejb.Timeout; 13 | import javax.ejb.TimerConfig; 14 | import javax.ejb.TimerService; 15 | 16 | @Stateless 17 | @Remote(Calculator.class) 18 | @RolesAllowed("employee") 19 | @org.jboss.ejb3.annotation.SecurityDomain("other") 20 | public class CalculatorEJB implements Calculator { 21 | 22 | float interest=5; 23 | 24 | @Override 25 | public float calculateInterest(long money) { 26 | 27 | return money * (1+ (interest/100)); 28 | 29 | 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/server/src/main/java/com/itbuzzpress/chapter16/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.cer -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.keystore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/client.truststore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.cer -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.keystore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/javaee7-ejb-elytron-ssl/ssl/server.truststore -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron/README.md: -------------------------------------------------------------------------------- 1 | ## Example how to invoke EJBs which are using a Security Domain 2 | 3 | ### Configure Elytron subsystem: 4 | 5 | This is needed to configure elytron subsystem: 6 | ```shell 7 | /bin/jboss-cli.sh --file=script.cli 8 | ``` 9 | 10 | ### Compile and deploy the server application 11 | ``` 12 | cd server 13 | 14 | mvn clean install wildfly:deploy 15 | ``` 16 | 17 | ### Compile and execute the client application 18 | ``` 19 | cd client 20 | 21 | mvn clean install exec:exec 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron/server/src/main/java/com/itbuzzpress/chapter16/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import com.itbuzzpress.chapter16.exception.InsufficientFundsException; 4 | 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public void createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron/server/src/main/java/com/itbuzzpress/chapter16/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | 5 | public interface Calculator { 6 | 7 | public float calculateInterest(long money); 8 | 9 | } -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron/server/src/main/java/com/itbuzzpress/chapter16/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | import java.util.Timer; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.annotation.Resource; 8 | import javax.annotation.security.RolesAllowed; 9 | import javax.ejb.EJB; 10 | import javax.ejb.Remote; 11 | import javax.ejb.Stateless; 12 | import javax.ejb.Timeout; 13 | import javax.ejb.TimerConfig; 14 | import javax.ejb.TimerService; 15 | 16 | @Stateless 17 | @Remote(Calculator.class) 18 | @RolesAllowed("employee") 19 | @org.jboss.ejb3.annotation.SecurityDomain("other") 20 | public class CalculatorEJB implements Calculator { 21 | 22 | float interest=5; 23 | 24 | @Override 25 | public float calculateInterest(long money) { 26 | 27 | return money * (1+ (interest/100)); 28 | 29 | 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-ejb-elytron/server/src/main/java/com/itbuzzpress/chapter16/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-security-elytron/README.md: -------------------------------------------------------------------------------- 1 | ## Example of a secured Web application 2 | 3 | 4 | 1. You need to Define a Security Domain in your WildFly configuration matching with the information in jboss-web.xml: 5 | ```xml 6 | 10 | 11 | httpFsSD 12 | 13 | ``` 14 | Check this CLI script to create an example FileSystem realm: https://github.com/fmarchioni/wildfly-admin-guide/blob/master/chapter15/fsrealm.cli 15 | 16 | ###### Compile and deploy 17 | 18 | ```shell 19 | mvn clean install wildfly:deploy 20 | ``` 21 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-security-elytron/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | httpFsSD 10 | 11 | -------------------------------------------------------------------------------- /code/chapter16/javaee7-security-elytron/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | BASIC 9 | RealmUsersRoles 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /code/chapter16/legacy/README.md: -------------------------------------------------------------------------------- 1 | WildFly Legacy Security 2 | ===================================== 3 | 4 | The examples in this folder are part of the older version of the book [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) which used the legacy security subsystem 5 | 6 | ###### javaee7-ejb-ssl 7 | 8 | This is an example of an EJB secured with SSL and a Security Domain for Authentication/Authorization 9 | 10 | ###### javaee7-security-jaas 11 | 12 | This is an example of a a Web application secured with BASIC Authentication 13 | 14 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-client-ssl/README.md: -------------------------------------------------------------------------------- 1 | Remote EJB Client SSL example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the secure usage of a remote EJB application secured with SSL 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install exec:exec 9 | ``` 10 | **Note** In order to run this example you need at first to generate Key pairs and install on the server. Next you have to configure the application server to use the https connector. Read through chapter 16 for information about it. 11 | 12 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/README.md: -------------------------------------------------------------------------------- 1 | Remote EJB with SSL example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the secure usage on an EJB application 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/java/com/itbuzzpress/chapter16/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import com.itbuzzpress.chapter16.exception.InsufficientFundsException; 4 | 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public void createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/java/com/itbuzzpress/chapter16/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | 5 | public interface Calculator { 6 | 7 | public float calculateInterest(long money); 8 | 9 | } -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/java/com/itbuzzpress/chapter16/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.ejb; 2 | 3 | import java.util.List; 4 | import java.util.Timer; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.annotation.Resource; 8 | import javax.annotation.security.RolesAllowed; 9 | import javax.ejb.EJB; 10 | import javax.ejb.Remote; 11 | import javax.ejb.Stateless; 12 | import javax.ejb.Timeout; 13 | import javax.ejb.TimerConfig; 14 | import javax.ejb.TimerService; 15 | 16 | @Stateless 17 | @Remote(Calculator.class) 18 | @RolesAllowed("employee") 19 | @org.jboss.ejb3.annotation.SecurityDomain("other") 20 | public class CalculatorEJB implements Calculator { 21 | 22 | float interest=5; 23 | 24 | @Override 25 | public float calculateInterest(long money) { 26 | 27 | return money * (1+ (interest/100)); 28 | 29 | 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/java/com/itbuzzpress/chapter16/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter16.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/javaee7-ejb-server-ssl/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.cer -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.keystore -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/client.truststore -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.cer -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.keystore -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.truststore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-ejb-ssl/ssl/server.truststore -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-security-jaas/README.md: -------------------------------------------------------------------------------- 1 | Java EE Security example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic security patterns in a Web application 6 | ###### Build and Deploy 7 | ```shell 8 | mvn clean install wildfly:deploy 9 | ``` 10 | 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-security-jaas/ 14 | ``` 15 | **Note** This application requires configuring a **Security Domain** as described in chapter 16 16 | 17 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-security-jaas/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter16/legacy/javaee7-security-jaas/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-security-jaas/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | other 3 | -------------------------------------------------------------------------------- /code/chapter16/legacy/javaee7-security-jaas/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 |

Hello from secure application

3 | 4 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-async-servlet/README.md: -------------------------------------------------------------------------------- 1 | Asynchronous Servlet example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Asynchronous Servlet in a Java EE 7 Environment. 6 | 7 | ###### Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-async-servlet 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-async-servlet/src/main/java/com/itbuzzpress/chapter3/servlet/async/AsyncService.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter3.servlet.async; 2 | import java.io.IOException; 3 | import java.io.PrintWriter; 4 | 5 | import javax.servlet.AsyncContext; 6 | 7 | public class AsyncService implements Runnable { 8 | AsyncContext ac; 9 | 10 | public AsyncService(AsyncContext ac) { 11 | this.ac = ac; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | 17 | try { 18 | Thread.sleep(2000); 19 | } catch (InterruptedException e) { 20 | e.printStackTrace(); 21 | } 22 | try { 23 | PrintWriter out = ac.getResponse().getWriter(); 24 | out.write("AsyncService completed processing!"); 25 | } catch (IOException e) { 26 | e.printStackTrace(); 27 | } 28 | //complete the processing 29 | ac.complete(); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-async-servlet/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-async-servlet/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test Async Servlet 9 | 10 |

Test Async Servlet

11 |
12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-noblock-servlet/README.md: -------------------------------------------------------------------------------- 1 | Non Blocking I/O Asynchronous Servlet example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Non Blocking I/O Asynchronous Servlet in a Java EE 7 Environment. 6 | 7 | ###### Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee7-noblock-servlet 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-noblock-servlet/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter3/javaee7-noblock-servlet/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test Non Blocking IO Servlet 8 | 9 |

Test Non Blocking IO Servlet

10 |
11 |
12 |
13 |
14 |
15 | 16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/README.md: -------------------------------------------------------------------------------- 1 | Servlet Push Example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of a ServletPush feature in a Java EE 8 Environment. 6 | 7 | ###### Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | ###### Test 12 | ```shell 13 | http://localhost:8080/javaee8-servlet-push 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/src/main/webapp/css/myscript.js: -------------------------------------------------------------------------------- 1 | function hello() { 2 | alert("load new content"); 3 | document.open(); 4 | document.write("

Out with the old - in with the new!

"); 5 | document.close(); 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/src/main/webapp/css/style.css: -------------------------------------------------------------------------------- 1 | body {background-color: coral;} -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/src/main/webapp/images/duke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter3/javaee8-servlet-push/src/main/webapp/images/duke.png -------------------------------------------------------------------------------- /code/chapter3/javaee8-servlet-push/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Servlet Push Example 9 | 10 |

Servlet 4.0 Push Example

11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-client-async/README.md: -------------------------------------------------------------------------------- 1 | Remote Client for Asynchronous EJB example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Remote Client EJB in a Java EE 7 Environment. 6 | 7 | ###### Test 8 | ```shell 9 | mvn clean install exec:exec 10 | ``` 11 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/README.md: -------------------------------------------------------------------------------- 1 | Asynchronous EJB example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Asynchronous Remote EJB a Java EE 7 Environment. 6 | 7 | ###### Create User 8 | 9 | Add user to WildFly with this command: bin/add-user.sh -a -u ejbuser -p password123 10 | 11 | ###### Deploy 12 | ```shell 13 | mvn clean install wildfly:deploy 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/java/com/itbuzzpress/chapter4/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import com.itbuzzpress.chapter4.exception.InsufficientFundsException; 4 | import java.util.concurrent.Future; 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public Future createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/java/com/itbuzzpress/chapter4/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import java.util.List; 4 | 5 | public interface Calculator { 6 | 7 | public float calculateInterest(long money); 8 | 9 | } -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/java/com/itbuzzpress/chapter4/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import javax.ejb.Remote; 4 | import javax.ejb.Stateless; 5 | 6 | @Stateless 7 | @Remote(Calculator.class) 8 | public class CalculatorEJB implements Calculator { 9 | 10 | float interest=5; 11 | 12 | @Override 13 | public float calculateInterest(long money) { 14 | 15 | return money * (1+ (interest/100)); 16 | 17 | 18 | } 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/java/com/itbuzzpress/chapter4/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /code/chapter4/async/javaee7-ejb-server-async/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-client-basic/README.md: -------------------------------------------------------------------------------- 1 | Remote Client EJB example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Remote Client EJB in a Java EE 7 Environment. 6 | 7 | ###### Test 8 | ```shell 9 | mvn clean install exec:exec 10 | ``` 11 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/README.md: -------------------------------------------------------------------------------- 1 | Remote EJB example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Remote EJB 3.2 a Java EE 7 Environment. 6 | 7 | ###### Create User 8 | 9 | Add user to WildFly with this command: bin/add-user.sh -a -u ejbuser -p password123 10 | 11 | ###### Deploy 12 | ```shell 13 | mvn clean install wildfly:deploy 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/java/com/itbuzzpress/chapter4/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import com.itbuzzpress.chapter4.exception.InsufficientFundsException; 4 | 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public void createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/java/com/itbuzzpress/chapter4/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | 4 | public interface Calculator { 5 | 6 | public float calculateInterest(long money); 7 | 8 | } -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/java/com/itbuzzpress/chapter4/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import javax.ejb.Remote; 4 | import javax.ejb.Stateless; 5 | 6 | @Stateless 7 | @Remote(Calculator.class) 8 | public class CalculatorEJB implements Calculator { 9 | 10 | float interest=5; 11 | 12 | @Override 13 | public float calculateInterest(long money) { 14 | 15 | return money * (1+ (interest/100)); 16 | 17 | 18 | } 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/java/com/itbuzzpress/chapter4/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /code/chapter4/basic/javaee7-ejb-server-basic/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-client-timer/README.md: -------------------------------------------------------------------------------- 1 | Remote Client EJB Timer example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Remote Client EJB in a Java EE 7 Environment. 6 | 7 | ###### Test 8 | ```shell 9 | mvn clean install exec:exec 10 | ``` 11 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/README.md: -------------------------------------------------------------------------------- 1 | Timer EJB example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of Timer EJB 3 in a Java EE 7 Environment. 6 | 7 | ###### Create User 8 | 9 | Add user to WildFly with this command: bin/add-user.sh -a -u ejbuser -p password123 10 | 11 | ###### Deploy 12 | ```shell 13 | mvn clean install wildfly:deploy 14 | ``` 15 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/java/com/itbuzzpress/chapter4/ejb/Account.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import com.itbuzzpress.chapter4.exception.InsufficientFundsException; 4 | 5 | 6 | public interface Account { 7 | 8 | 9 | public void deposit(long amount); 10 | public void withdraw(long amount) throws InsufficientFundsException; 11 | 12 | public long getMoney(); 13 | public void createAccount(long amount); 14 | } -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/java/com/itbuzzpress/chapter4/ejb/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | 4 | public interface Calculator { 5 | 6 | public float calculateInterest(long money); 7 | 8 | } -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/java/com/itbuzzpress/chapter4/ejb/CalculatorEJB.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.ejb; 2 | 3 | import javax.ejb.Remote; 4 | import javax.ejb.Stateless; 5 | 6 | @Stateless 7 | @Remote(Calculator.class) 8 | public class CalculatorEJB implements Calculator { 9 | 10 | float interest=5; 11 | 12 | @Override 13 | public float calculateInterest(long money) { 14 | 15 | return money * (1+ (interest/100)); 16 | 17 | 18 | } 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/java/com/itbuzzpress/chapter4/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter4.exception; 2 | 3 | import javax.ejb.EJBException; 4 | 5 | public class InsufficientFundsException extends Exception { 6 | public InsufficientFundsException(String mess){ 7 | super(mess); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /code/chapter4/timer/javaee7-ejb-server-timer/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/README.md: -------------------------------------------------------------------------------- 1 | CDI J2SE example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates using CDI 2.0 in a Standalone Java application 6 | 7 | ###### Build and Test 8 | ```shell 9 | mvn clean install exec:exec 10 | ``` 11 | 12 | 13 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/java/com/itbuzzpress/chapter5/App.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5; 2 | 3 | import javax.enterprise.event.*; 4 | 5 | 6 | public class App { 7 | public void onEvent(@Observes SimpleEvent ignored, SimpleService service) { 8 | service.greet(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/java/com/itbuzzpress/chapter5/CDI2Demo.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5; 2 | 3 | 4 | import javax.enterprise.inject.se.*; 5 | 6 | public class CDI2Demo { 7 | public static void main(String... args) { 8 | 9 | SeContainerInitializer containerInit = SeContainerInitializer.newInstance(); 10 | SeContainer container = containerInit.initialize(); 11 | // retrieve a bean and do work with it 12 | Hello myBean = container.select(Hello.class).get(); 13 | myBean.greet(); 14 | 15 | // Fire synchronous event that triggers the code in App class. 16 | container.getBeanManager().fireEvent(new SimpleEvent()); 17 | // when done 18 | container.close(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/java/com/itbuzzpress/chapter5/Hello.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5; 2 | 3 | public class Hello { 4 | 5 | public void greet() { 6 | System.out.println("Hello World!"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/java/com/itbuzzpress/chapter5/SimpleEvent.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5; 2 | 3 | public class SimpleEvent { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/java/com/itbuzzpress/chapter5/SimpleService.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5; 2 | 3 | import javax.inject.*; 4 | 5 | public class SimpleService { 6 | @Inject 7 | private Hello greeter; 8 | 9 | public void greet() 10 | { 11 | greeter.greet(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /code/chapter5/cdi-j2se/src/test/java/com/itbuzzpress/chapter5/test/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.test; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/README.md: -------------------------------------------------------------------------------- 1 | CDI example using Alternatives 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the usage of *@Alternative* annotation with a CDI application 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-cdi-alternative 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/java/com/itbuzzpress/chapter5/bean/Hard.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.bean; 2 | 3 | import javax.enterprise.inject.Alternative; 4 | 5 | @Alternative 6 | public class Hard implements Rules { 7 | private int maxAttempts = 3; 8 | 9 | public int getMaxAttempts() { 10 | return maxAttempts; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/java/com/itbuzzpress/chapter5/bean/Rules.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.inject.Named; 6 | 7 | 8 | @Named 9 | public interface Rules extends Serializable{ 10 | public int getMaxAttempts(); 11 | } 12 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/java/com/itbuzzpress/chapter5/bean/Simple.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.bean; 2 | 3 | import javax.enterprise.inject.Alternative; 4 | 5 | @Alternative 6 | public class Simple implements Rules { 7 | private int maxAttempts = 6; 8 | 9 | public int getMaxAttempts() { 10 | return maxAttempts; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | com.itbuzzpress.chapter5.bean.Hard 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-alternative/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-basic/README.md: -------------------------------------------------------------------------------- 1 | CDI example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF + CDI application 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-cdi-basic 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-basic/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-basic/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-basic/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/README.md: -------------------------------------------------------------------------------- 1 | CDI example with Decorator 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF + CDI application with *Decorator* 6 | 7 | The decorator will turn the guess into Uppercase making impossible to guess the words which are lowercase. 8 | 9 | ###### Build and Deploy 10 | ```shell 11 | mvn clean install wildfly:deploy 12 | ``` 13 | 14 | ###### Test 15 | ```shell 16 | http://localhost:8080/javaee7-cdi-decorator 17 | ``` 18 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/java/com/itbuzzpress/chapter5/decorator/PlayerDecorator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.decorator; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.decorator.Decorator; 6 | import javax.decorator.Delegate; 7 | import javax.inject.Inject; 8 | 9 | 10 | @Decorator 11 | public class PlayerDecorator implements PlayerItf,Serializable { 12 | 13 | 14 | @Inject @Delegate PlayerItf player; 15 | 16 | 17 | public void check() { 18 | System.out.println("[Decorator] User check with "+player.getGuess()); 19 | player.check(); 20 | 21 | } 22 | public String getGuess() { 23 | return player.getGuess(); 24 | } 25 | public void setGuess(String guess) { 26 | player.setGuess(guess.toUpperCase()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/java/com/itbuzzpress/chapter5/decorator/PlayerItf.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.decorator; 2 | 3 | 4 | 5 | public interface PlayerItf { 6 | public void check(); 7 | 8 | public String getGuess(); 9 | public void setGuess(String guess); 10 | } 11 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | com.itbuzzpress.chapter5.decorator.PlayerDecorator 11 | 12 | 13 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-decorator/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/README.md: -------------------------------------------------------------------------------- 1 | CDI example with Event 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF + CDI application with *Event* 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-cdi-event 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/src/main/java/com/itbuzzpress/chapter5/bean/WordInventory.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.enterprise.event.Observes; 8 | 9 | import com.itbuzzpress.chapter5.model.Word; 10 | 11 | @ApplicationScoped 12 | public class WordInventory { 13 | 14 | private List listWords = new ArrayList(); 15 | 16 | public void addWord(@Observes Word word) { 17 | System.out.println("Added new anagram " + word.getAnagram()); 18 | 19 | listWords.add(word); 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-event/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/README.md: -------------------------------------------------------------------------------- 1 | CDI example with Interceptors 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF + CDI application with *Interceptor* 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-cdi-interceptor 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/java/com/itbuzzpress/chapter5/interceptors/AuditInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.interceptors; 2 | 3 | 4 | import java.io.Serializable; 5 | 6 | import javax.interceptor.AroundInvoke; 7 | import javax.interceptor.Interceptor; 8 | import javax.interceptor.InvocationContext; 9 | 10 | import com.itbuzzpress.chapter5.qualifier.Auditing; 11 | 12 | 13 | 14 | @Interceptor 15 | @Auditing 16 | public class AuditInterceptor implements Serializable { 17 | 18 | 19 | @AroundInvoke 20 | public Object logMethodEntry(InvocationContext ctx) throws Exception { 21 | System.out.println("Before entering method:" + ctx.getMethod().getName()); 22 | return ctx.proceed(); 23 | } 24 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/java/com/itbuzzpress/chapter5/qualifier/Auditing.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.qualifier; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | 14 | 15 | import javax.inject.Qualifier; 16 | import javax.interceptor.InterceptorBinding; 17 | 18 | @InterceptorBinding 19 | @Retention(RUNTIME) 20 | @Target({TYPE, METHOD, FIELD}) 21 | @Qualifier 22 | 23 | public @interface Auditing { 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | com.itbuzzpress.chapter5.interceptors.AuditInterceptor 9 | 10 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-interceptor/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/README.md: -------------------------------------------------------------------------------- 1 | CDI example with Qualifier 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF + CDI application with *Qualifier* 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-cdi-qualifier 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/src/main/java/com/itbuzzpress/chapter5/enums/Language.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.enums; 2 | 3 | public enum Language { 4 | ENGLISH, ITALIAN 5 | } 6 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | private String solution; 7 | private String anagram; 8 | public Word(String original, String anagram){ 9 | 10 | this.solution = original; 11 | this.anagram = anagram; 12 | } 13 | public String getSolution() { 14 | return solution; 15 | } 16 | public void setSolution(String original) { 17 | this.solution = original; 18 | } 19 | public String getAnagram() { 20 | return anagram; 21 | } 22 | public void setAnagram(String anagram) { 23 | this.anagram = anagram; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import javax.inject.Qualifier; 14 | 15 | import com.itbuzzpress.chapter5.enums.Language; 16 | 17 | @Qualifier 18 | @Retention(RUNTIME) 19 | @Target({ FIELD, TYPE, METHOD }) 20 | 21 | public @interface Anagram { 22 | Language value(); 23 | 24 | } -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter5/javaee7-cdi-qualifier/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter5/javaee8-cdi-producerfactory/README.md: -------------------------------------------------------------------------------- 1 | CDI Producer Factory example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a JSF + CDI application using the CDI Producer Factory feature (Java EE 8) 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee8-cdi-producerfactory 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter5/javaee8-cdi-producerfactory/src/main/java/com/itbuzzpress/chapter5/model/Word.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter5.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Word implements Serializable{ 6 | public Word() { 7 | 8 | } 9 | private String solution; 10 | private String anagram; 11 | public Word(String original, String anagram){ 12 | 13 | this.solution = original; 14 | this.anagram = anagram; 15 | } 16 | public String getSolution() { 17 | return solution; 18 | } 19 | public void setSolution(String original) { 20 | this.solution = original; 21 | } 22 | public String getAnagram() { 23 | return anagram; 24 | } 25 | public void setAnagram(String anagram) { 26 | this.anagram = anagram; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /code/chapter5/javaee8-cdi-producerfactory/src/main/java/com/itbuzzpress/chapter5/qualifier/Anagram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.itbuzzpress.chapter5.qualifier; 4 | 5 | import static java.lang.annotation.ElementType.FIELD; 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.PARAMETER; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | import javax.inject.Qualifier; 16 | 17 | @Target( { TYPE, METHOD, PARAMETER, FIELD }) 18 | @Retention(RUNTIME) 19 | @Documented 20 | @Qualifier 21 | public @interface Anagram { 22 | 23 | } -------------------------------------------------------------------------------- /code/chapter5/javaee8-cdi-producerfactory/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter5/javaee8-cdi-producerfactory/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.sun.faces.enableRestoreView11Compatibility 6 | true 7 | 8 | 9 | Faces Servlet 10 | javax.faces.webapp.FacesServlet 11 | 1 12 | 13 | 14 | Faces Servlet 15 | *.xhtml 16 | 17 | 18 | index.xhtml 19 | 20 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-basic/README.md: -------------------------------------------------------------------------------- 1 | JSF basic application 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF application 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-jsf-basic 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-basic/src/main/java/com/itbuzzpress/chapter6/bean/SingletonBean.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.ejb.Singleton; 8 | 9 | import com.itbuzzpress.chapter6.model.User; 10 | 11 | 12 | 13 | @Singleton 14 | public class SingletonBean { 15 | List listUsers; 16 | 17 | @PostConstruct 18 | public void init() { 19 | listUsers = new ArrayList(); 20 | } 21 | public void put(User user) { 22 | this.listUsers.add(user); 23 | 24 | } 25 | public void delete(User user) { 26 | listUsers.remove(user); 27 | 28 | } 29 | public List getListUsers() { 30 | return listUsers; 31 | } 32 | public void setListUsers(List listUsers) { 33 | this.listUsers = listUsers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-basic/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-basic/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-basic/src/main/webapp/resources/style.css: -------------------------------------------------------------------------------- 1 | .default { 2 | padding: 5px; 3 | text-align: left; 4 | font-family: Arial, Verdana, sans-serif; 5 | border: 1px solid #000; 6 | border-bottom: 1; 7 | } 8 | 9 | .buttons { 10 | padding: 5px; 11 | text-align: left; 12 | font-family: Arial, Verdana, sans-serif; 13 | margin-top: 0; 14 | margin-left: 0; 15 | margin-right: 0; 16 | margin-bottom: 0; 17 | } 18 | 19 | .table-header { 20 | text-align: center; 21 | background: none repeat scroll 0 0 #E5E5E5; 22 | border-bottom: 1px solid #BBBBBB; 23 | padding: 16px; 24 | } 25 | 26 | .table-odd-row { 27 | text-align: center; 28 | background: none repeat scroll 0 0 #FFFFFFF; 29 | border-top: 1px solid #BBBBBB; 30 | } 31 | 32 | .table-even-row { 33 | text-align: center; 34 | background: none repeat scroll 0 0 #E5E5E5; 35 | border-top: 1px solid #BBBBBB; 36 | } -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/README.md: -------------------------------------------------------------------------------- 1 | JSF application using Composite components 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF application using Facelets and Composite components 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-jsf-composite 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/java/com/itbuzzpress/chapter6/bean/SingletonBean.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.ejb.Singleton; 8 | 9 | import com.itbuzzpress.chapter6.model.User; 10 | 11 | 12 | 13 | @Singleton 14 | public class SingletonBean { 15 | List listUsers; 16 | 17 | @PostConstruct 18 | public void init() { 19 | listUsers = new ArrayList(); 20 | } 21 | public void put(User user) { 22 | this.listUsers.add(user); 23 | 24 | } 25 | public void delete(User user) { 26 | listUsers.remove(user); 27 | 28 | } 29 | public List getListUsers() { 30 | return listUsers; 31 | } 32 | public void setListUsers(List listUsers) { 33 | this.listUsers = listUsers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/java/com/itbuzzpress/chapter6/model/User.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | 7 | private String name; 8 | 9 | private String surname; 10 | 11 | private String email; 12 | 13 | public String getEmail() { 14 | return email; 15 | } 16 | 17 | public void setEmail(String email) { 18 | this.email = email; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getSurname() { 30 | return surname; 31 | } 32 | 33 | public void setSurname(String surname) { 34 | this.surname = surname; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/webapp/resources/style.css: -------------------------------------------------------------------------------- 1 | .default { 2 | padding: 5px; 3 | text-align: left; 4 | font-family: Arial, Verdana, sans-serif; 5 | border: 1px solid #000; 6 | border-bottom: 1; 7 | } 8 | 9 | .buttons { 10 | padding: 5px; 11 | text-align: left; 12 | font-family: Arial, Verdana, sans-serif; 13 | margin-top: 0; 14 | margin-left: 0; 15 | margin-right: 0; 16 | margin-bottom: 0; 17 | } 18 | 19 | .table-header { 20 | text-align: center; 21 | background: none repeat scroll 0 0 #E5E5E5; 22 | border-bottom: 1px solid #BBBBBB; 23 | padding: 16px; 24 | } 25 | 26 | .table-odd-row { 27 | text-align: center; 28 | background: none repeat scroll 0 0 #FFFFFFF; 29 | border-top: 1px solid #BBBBBB; 30 | } 31 | 32 | .table-even-row { 33 | text-align: center; 34 | background: none repeat scroll 0 0 #E5E5E5; 35 | border-top: 1px solid #BBBBBB; 36 | } -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/webapp/templates/footer.xhtml: -------------------------------------------------------------------------------- 1 | 6 |

7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/webapp/templates/header.xhtml: -------------------------------------------------------------------------------- 1 | 6 |

7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-composite/src/main/webapp/templates/template.xhtml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 |
19 | 20 |
21 | 22 | Default Content 23 | 24 |
25 | 28 |
29 | 30 |
31 | 32 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/README.md: -------------------------------------------------------------------------------- 1 | JSF application using Resource Library Contracts 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF application using Resource Library Contracts 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-jsf-contracts 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/java/com/itbuzzpress/chapter6/bean/SingletonBean.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.ejb.Singleton; 8 | 9 | import com.itbuzzpress.chapter6.model.User; 10 | 11 | 12 | 13 | @Singleton 14 | public class SingletonBean { 15 | List listUsers; 16 | 17 | @PostConstruct 18 | public void init() { 19 | listUsers = new ArrayList(); 20 | } 21 | public void put(User user) { 22 | this.listUsers.add(user); 23 | 24 | } 25 | public void delete(User user) { 26 | listUsers.remove(user); 27 | 28 | } 29 | public List getListUsers() { 30 | return listUsers; 31 | } 32 | public void setListUsers(List listUsers) { 33 | this.listUsers = listUsers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/java/com/itbuzzpress/chapter6/bean/TemplateBean.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.bean; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | 7 | 8 | @Named 9 | @SessionScoped 10 | public class TemplateBean implements Serializable { 11 | 12 | String contract = "black"; 13 | 14 | public String getContract() { 15 | return contract; 16 | } 17 | 18 | public void setContract(String contract) { 19 | this.contract = contract; 20 | } 21 | 22 | public String change(String s) { 23 | System.out.println("Change to "+s); 24 | this.contract=s; 25 | return "index"; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/java/com/itbuzzpress/chapter6/model/User.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | 7 | 8 | private String name; 9 | 10 | private String surname; 11 | 12 | private String email; 13 | 14 | 15 | public String getEmail() { 16 | return email; 17 | } 18 | public void setEmail(String email) { 19 | this.email = email; 20 | } 21 | public String getName() { 22 | return name; 23 | } 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | public String getSurname() { 28 | return surname; 29 | } 30 | public void setSurname(String surname) { 31 | this.surname = surname; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | /admin/* 12 | black 13 | 14 | 15 | * 16 | color 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/contracts/black/style.css: -------------------------------------------------------------------------------- 1 | .default { 2 | padding: 5px; 3 | text-align: left; 4 | font-family: Arial, Verdana, sans-serif; 5 | border: 1px solid #000; 6 | border-bottom: 1; 7 | } 8 | 9 | .buttons { 10 | padding: 5px; 11 | text-align: left; 12 | font-family: Arial, Verdana, sans-serif; 13 | margin-top: 0; 14 | margin-left: 0; 15 | margin-right: 0; 16 | margin-bottom: 0; 17 | } 18 | 19 | .table-header { 20 | text-align: center; 21 | background: none repeat scroll 0 0 #E5E5E5; 22 | border-bottom: 1px solid #000000; 23 | padding: 16px; 24 | } 25 | 26 | .table-odd-row { 27 | text-align: center; 28 | background: none repeat scroll 0 0 #FFFFFFF; 29 | border-top: 1px solid #FFFFFF; 30 | } 31 | 32 | .table-even-row { 33 | text-align: center; 34 | background: none repeat scroll 0 0 #9F9A9A; 35 | border-top: 1px solid #C0C0C0; 36 | } -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/contracts/black/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | JSF 2.2 Example of Resource Library Contract 12 | 13 | 14 | 15 | 16 |
17 |

Black Theme

18 |
19 | 20 |
21 | Content 22 |
23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/contracts/color/style.css: -------------------------------------------------------------------------------- 1 | .default { 2 | padding: 5px; 3 | text-align: left; 4 | font-family: Arial, Verdana, sans-serif; 5 | border: 1px solid #000; 6 | border-bottom: 1; 7 | background: #26EE72; 8 | } 9 | 10 | .buttons { 11 | padding: 5px; 12 | text-align: left; 13 | font-family: Arial, Verdana, sans-serif; 14 | margin-top: 0; 15 | margin-left: 0; 16 | margin-right: 0; 17 | margin-bottom: 0; 18 | } 19 | 20 | .table-header { 21 | text-align: center; 22 | background: none repeat scroll 0 0 #FF0000; 23 | border-bottom: 1px solid #BBBBBB; 24 | padding: 16px; 25 | } 26 | 27 | .table-odd-row { 28 | text-align: center; 29 | background: none repeat scroll 0 0 #FFFFFFF; 30 | border-top: 1px solid #26EE72; 31 | } 32 | 33 | .table-even-row { 34 | text-align: center; 35 | background: none repeat scroll 0 0 #9F9A9A; 36 | border-top: 1px solid #00FF00; 37 | } -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-contracts/src/main/webapp/contracts/color/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | JSF 2.2 Example of Resource Library Contract 12 | 13 | 14 | 15 | 16 |
17 |

Color Theme

18 |
19 | 20 |
21 | Content 22 |
23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/README.md: -------------------------------------------------------------------------------- 1 | JSF application using a JSF flow 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF application using a single JSF flow 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-jsf-flow 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 |

Faces Flow Demo

9 |

Click Signup User to Start Flow

10 | 11 |

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/main/java/org/javaee7/jsf/flow/Flow1.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.jsf.flow; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.inject.Produces; 5 | import javax.faces.flow.Flow; 6 | import javax.faces.flow.builder.FlowBuilder; 7 | import javax.faces.flow.builder.FlowBuilderParameter; 8 | import javax.faces.flow.builder.FlowDefinition; 9 | 10 | public class Flow1 implements Serializable { 11 | 12 | private static final long serialVersionUID = -7623501087369765218L; 13 | 14 | // @Produces @FlowDefinition 15 | // public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) { 16 | // String flowId = "flow1"; 17 | // flowBuilder.id("", flowId); 18 | // flowBuilder.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode(); 19 | // 20 | // return flowBuilder.getFlow(); 21 | // } 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/main/java/org/javaee7/jsf/flow/Flow1Bean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.jsf.flow; 2 | 3 | 4 | import java.io.Serializable; 5 | import javax.faces.flow.FlowScoped; 6 | import javax.inject.Named; 7 | 8 | 9 | @Named 10 | @FlowScoped("flow1") 11 | public class Flow1Bean implements Serializable { 12 | 13 | public Flow1Bean() { 14 | } 15 | 16 | public String getName() { 17 | return this.getClass().getSimpleName(); 18 | } 19 | 20 | public String getHomeAction() { 21 | return "/index"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/signup/signup-flow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | #{signupBean.homeAction} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/signup/signup.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | Signup account 9 | 10 | 11 | 12 |

Signup Account

13 | Name:
14 |
15 | Surname:
16 |
17 | Email:
18 |
19 | 20 | 21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-flow/src/main/webapp/signup/signup3.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | Last page in the flow 11 | 12 | 13 | 14 |

Registration completed!

15 |

Name: #{flowScope.name}

16 |

Surname: #{flowScope.surname}

17 | 18 | 19 |

20 |

21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/README.md: -------------------------------------------------------------------------------- 1 | JSF application using multiple JSF flow 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JSF application using multiple JSF flows 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-jsf-multipleflow 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/confirm/confirm-flow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | #{confirmBean.homeAction} 12 | 13 | 14 | 15 | paramFromSignup 16 | #{flowScope.param1Value} 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/confirm/confirm.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | Confirm Email 9 | 10 | 11 | 12 |

Confirm Email

13 |

An email with a secret key has been sent to: #{flowScope.param1Value}

14 | 15 |

Enter key

16 | 17 |

18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/confirm/confirm2.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | Confirm Email 9 | 10 | 11 | 12 |

Congratulations you have completed the Registration

13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 |

Faces Flow Demo

9 |

Click Signup User to Start Flow

10 | 11 |

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/main/java/org/javaee7/jsf/flow/Flow1.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.jsf.flow; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.inject.Produces; 5 | import javax.faces.flow.Flow; 6 | import javax.faces.flow.builder.FlowBuilder; 7 | import javax.faces.flow.builder.FlowBuilderParameter; 8 | import javax.faces.flow.builder.FlowDefinition; 9 | 10 | 11 | public class Flow1 implements Serializable { 12 | 13 | private static final long serialVersionUID = -7623501087369765218L; 14 | 15 | // @Produces @FlowDefinition 16 | // public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) { 17 | // String flowId = "flow1"; 18 | // flowBuilder.id("", flowId); 19 | // flowBuilder.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode(); 20 | // 21 | // return flowBuilder.getFlow(); 22 | // } 23 | } 24 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/main/java/org/javaee7/jsf/flow/Flow1Bean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.jsf.flow; 2 | 3 | 4 | import java.io.Serializable; 5 | import javax.faces.flow.FlowScoped; 6 | import javax.inject.Named; 7 | 8 | 9 | @Named 10 | @FlowScoped("flow1") 11 | public class Flow1Bean implements Serializable { 12 | 13 | public Flow1Bean() { 14 | } 15 | 16 | public String getName() { 17 | return this.getClass().getSimpleName(); 18 | } 19 | 20 | public String getHomeAction() { 21 | return "/index"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/signup/signup-flow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | #{signupBean.homeAction} 12 | 13 | 14 | 15 | 16 | 17 | 18 | confirm 19 | 20 | 21 | 22 | 23 | paramFromSignup 24 | #{flowScope.email} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/signup/signup.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | Signup account 9 | 10 | 11 | 12 |

Signup Account

13 | Name:
14 |
15 | Surname:
16 |
17 | Email:
18 |
19 | 20 | 21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /code/chapter6/javaee7-jsf-multipleflow/src/main/webapp/signup/signup3.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | Last page in the flow 11 | 12 | 13 | 14 |

Registration completed!

15 |

Name: #{flowScope.name}

16 |

Surname: #{flowScope.surname}

17 | 18 | 19 |

20 |

21 |

22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-commandscript/README.md: -------------------------------------------------------------------------------- 1 | JSF Command Script 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the JSF 2.3 CommandScript feature to enable javascript call the server-side via Ajax 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee8-jsf-commandscript 15 | ``` 16 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-commandscript/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-datatablemap/README.md: -------------------------------------------------------------------------------- 1 | JSF Datatable Map example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates using a Datatable backed by a java.util.HashMap 6 | 7 | Requires JSF 2.3 8 | 9 | ###### Build and Deploy 10 | ```shell 11 | mvn clean install wildfly:deploy 12 | ``` 13 | 14 | ###### Test 15 | ```shell 16 | http://localhost:8080/javaee8-jsf-datatablemap 17 | ``` 18 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-datatablemap/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/README.md: -------------------------------------------------------------------------------- 1 | JSF ValidateWholeBean example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a JSF2.3 features which enables a centralized validation of all Bean properties using 6 | 7 | Requires JSF 2.3 8 | 9 | ###### Build and Deploy 10 | ```shell 11 | mvn clean install wildfly:deploy 12 | ``` 13 | 14 | ###### Test 15 | ```shell 16 | http://localhost:8080/javaee8-jsf-validatewholebean 17 | ``` 18 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/java/com/itbuzzpress/chapter6/validator/CustomerGroup.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.validator; 2 | 3 | public interface CustomerGroup { 4 | 5 | } -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/java/com/itbuzzpress/chapter6/validator/CustomerValidator.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.validator; 2 | 3 | 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | 7 | public class CustomerValidator implements ConstraintValidator { 8 | 9 | @Override 10 | public void initialize(ValidCustomer constraintAnnotation) { 11 | 12 | } 13 | 14 | @Override 15 | public boolean isValid(Customer value, ConstraintValidatorContext context) { 16 | if (value.getEmail().endsWith(".com") && (value.getAge() < 50)) 17 | return true; 18 | else 19 | return false; 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/java/com/itbuzzpress/chapter6/validator/ValidCustomer.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter6.validator; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.Target; 9 | 10 | import javax.validation.Constraint; 11 | import javax.validation.Payload; 12 | 13 | @Constraint(validatedBy = {CustomerValidator.class}) 14 | @Documented 15 | @Target(TYPE) 16 | @Retention(RUNTIME) 17 | public @interface ValidCustomer { 18 | 19 | String message() default "This customer does not meet our requirements!"; 20 | Class[] groups() default {}; 21 | Class[] payload() default {}; 22 | } 23 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-validatewholebean/src/main/webapp/register.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 |

Customer registered

8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-websocket/README.md: -------------------------------------------------------------------------------- 1 | JSF WebSocket example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a JSF2.3 features which enables using WebSockets in a JSF application 6 | 7 | Requires JSF 2.3 8 | 9 | ###### Build and Deploy 10 | ```shell 11 | mvn clean install wildfly:deploy 12 | ``` 13 | 14 | ###### Test 15 | ```shell 16 | http://localhost:8080/javaee8-jsf-websocket 17 | ``` 18 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-websocket/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter6/javaee8-jsf-websocket/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /code/chapter7/javaee7-jpa-basic/README.md: -------------------------------------------------------------------------------- 1 | JPA application 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates a basic JPA application 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | A test JPA application is included in chapter 8 14 | 15 | Todo: Include Testing Servlets for several JPA use cases 16 | -------------------------------------------------------------------------------- /code/chapter7/javaee7-jpa-basic/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter7/javaee7-jpa-basic/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter7/javaee7-jpa-basic/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE customer ( id BIGINT(20) NOT NULL AUTO_INCREMENT, address VARCHAR(255) NULL DEFAULT NULL, email VARCHAR(255) NULL DEFAULT NULL, name VARCHAR(255) NULL DEFAULT NULL, phone_number VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (id)) 2 | CREATE TABLE request ( id BIGINT(20) NOT NULL AUTO_INCREMENT, quantity INT(11) NULL DEFAULT NULL, id_customer BIGINT(20) NULL DEFAULT NULL, PRIMARY KEY (id), INDEX (id_customer),CONSTRAINT FOREIGN KEY (id_customer) REFERENCES customer (id)) -------------------------------------------------------------------------------- /code/chapter7/javaee7-jpa-basic/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | drop table customer 2 | drop table request 3 | -------------------------------------------------------------------------------- /code/chapter7/javaee7-jpa-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/README.md: -------------------------------------------------------------------------------- 1 | Arquillian example application 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates how to test a basic JPA application using Arquillian 6 | 7 | ###### Build 8 | ```shell 9 | mvn clean install 10 | ``` 11 | 12 | ###### Managed Test 13 | 14 | Configure src/test/resources/arquillian.xml in to point to your Wildfly installation. Ex: 15 | ```xml 16 | 17 | /home/francesco/jboss/wildfly-12.0.0.Final 18 | 9990 19 | localhost 20 | 21 | ``` 22 | ```shell 23 | mvn test -Parq-wildfly-managed 24 | ``` 25 | 26 | ###### Remote Test 27 | ```shell 28 | mvn test -Parq-wildfly-remote 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/nohup.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter8/javaee7-test/nohup.out -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarchioni/practical-javaee7-development-wildfly/e310f6f3251e01b92fbb086063d0a4ff09e25965/code/chapter8/javaee7-test/src/main/resources/META-INF/MANIFEST.MF -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE customer ( id BIGINT(20) NOT NULL AUTO_INCREMENT, address VARCHAR(255) NULL DEFAULT NULL, email VARCHAR(255) NULL DEFAULT NULL, name VARCHAR(255) NULL DEFAULT NULL, phone_number VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (id)) 2 | CREATE TABLE request ( id BIGINT(20) NOT NULL AUTO_INCREMENT, quantity INT(11) NULL DEFAULT NULL, id_customer BIGINT(20) NULL DEFAULT NULL, PRIMARY KEY (id), INDEX (id_customer),CONSTRAINT FOREIGN KEY (id_customer) REFERENCES customer (id)) -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | drop table customer 2 | drop table request 3 | -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter8/javaee7-test/src/main/webapp/angular.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 |
11 |

Hello {{yourName}}!

12 |
13 | 14 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-async/README.md: -------------------------------------------------------------------------------- 1 | Asynchronous Web sockets example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates how to test Asynchronous Web sockets communication 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-websocket-async/ 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-async/src/main/java/com/itbuzzpress/chapter9/endpoint/HelloWorldEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter9.endpoint; 2 | 3 | 4 | import javax.websocket.*; 5 | import javax.websocket.server.ServerEndpoint; 6 | 7 | 8 | @ServerEndpoint(value="/hello") 9 | 10 | 11 | 12 | public class HelloWorldEndpoint { 13 | @OnMessage 14 | public String hello(String message) { 15 | System.out.println("Received : "+ message); 16 | return "Hello from HelloWorldEndpoint"; 17 | } 18 | @OnOpen 19 | public void myOnOpen(Session session) { 20 | System.out.println("WebSocket opened: " + session.getId()); 21 | } 22 | @OnClose 23 | public void myOnClose(CloseReason reason) { 24 | System.out.println("Closing a due to " + reason.getReasonPhrase()); 25 | } 26 | @OnError 27 | public void error(Throwable t) { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-async/src/main/java/com/itbuzzpress/chapter9/endpoint/WebSocketEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter9.endpoint; 2 | 3 | 4 | 5 | 6 | import javax.websocket.CloseReason; 7 | 8 | import javax.websocket.OnClose; 9 | import javax.websocket.OnMessage; 10 | import javax.websocket.OnOpen; 11 | import javax.websocket.Session; 12 | 13 | 14 | 15 | @javax.websocket.ClientEndpoint() 16 | public class WebSocketEndpoint { 17 | 18 | 19 | 20 | @OnOpen 21 | public void onOpen(Session session) { 22 | 23 | 24 | 25 | } 26 | @OnClose 27 | public void onClose(Session userSession, CloseReason reason) { 28 | 29 | System.out.println("Session closed!"); 30 | } 31 | @OnMessage 32 | public void onMessage(String message) { 33 | System.out.println("Received message: " + message); 34 | 35 | } 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-async/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | index.jsp 6 | 7 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-async/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-basic/README.md: -------------------------------------------------------------------------------- 1 | Basic Web sockets example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Web sockets communication using a Java EE endpoint and a Javascript client 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-websocket-basic 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-basic/src/main/java/com/itbuzzpress/chapter9/endpoint/HelloWorldEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter9.endpoint; 2 | 3 | 4 | import javax.websocket.*; 5 | import javax.websocket.server.ServerEndpoint; 6 | 7 | 8 | @ServerEndpoint(value="/hello") 9 | 10 | 11 | 12 | public class HelloWorldEndpoint { 13 | @OnMessage 14 | public String hello(String message) { 15 | System.out.println("Received : "+ message); 16 | return "Hello form the Server!"; 17 | } 18 | @OnOpen 19 | public void myOnOpen(Session session) { 20 | System.out.println("WebSocket opened: " + session.getId()); 21 | } 22 | @OnClose 23 | public void myOnClose(CloseReason reason) { 24 | System.out.println("Closing a due to " + reason.getReasonPhrase()); 25 | } 26 | @OnError 27 | public void error(Throwable t) { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-binary/README.md: -------------------------------------------------------------------------------- 1 | Binary Web sockets example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Web sockets binary communication using a Java EE endpoint and a Javascript client 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-websocket-binary 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-binary/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-client/README.md: -------------------------------------------------------------------------------- 1 | Web sockets client example 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Web sockets communication using a Java EE endpoint and a Java client 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-websocket-client 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-client/src/main/java/com/itbuzzpress/chapter9/endpoint/HelloWorldEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter9.endpoint; 2 | 3 | 4 | import javax.websocket.*; 5 | import javax.websocket.server.ServerEndpoint; 6 | 7 | 8 | @ServerEndpoint(value="/hello") 9 | 10 | 11 | 12 | public class HelloWorldEndpoint { 13 | @OnMessage 14 | public String hello(String message) { 15 | System.out.println("Received : "+ message); 16 | return "Hello from HelloWorldEndpoint"; 17 | } 18 | @OnOpen 19 | public void myOnOpen(Session session) { 20 | System.out.println("WebSocket opened: " + session.getId()); 21 | } 22 | @OnClose 23 | public void myOnClose(CloseReason reason) { 24 | } 25 | @OnError 26 | public void error(Throwable t) { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-client/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | index.jsp 6 | 7 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-client/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-encdec/README.md: -------------------------------------------------------------------------------- 1 | Web sockets example Encoders & Decoders 2 | ===================================== 3 | Example taken from [Practical Java EE 7 Development using WildFly application server](http://www.itbuzzpress.com/ebooks/java-ee-7-development-on-wildfly.html) 4 | 5 | This example demonstrates the basic usage of Web sockets communication using Encoders & Decoders 6 | 7 | ###### Build and Deploy 8 | ```shell 9 | mvn clean install wildfly:deploy 10 | ``` 11 | 12 | ###### Test 13 | ```shell 14 | http://localhost:8080/javaee7-websocket-encdec 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-encdec/src/main/java/com/itbuzzpress/chapter9/model/User.java: -------------------------------------------------------------------------------- 1 | package com.itbuzzpress.chapter9.model; 2 | import javax.xml.bind.annotation.*; 3 | 4 | @XmlRootElement 5 | public class User { 6 | String name; 7 | String surname; 8 | String email; 9 | boolean registered; 10 | 11 | public boolean isRegistered() { 12 | return registered; 13 | } 14 | public void setRegistered(boolean registered) { 15 | this.registered = registered; 16 | } 17 | public String getName() { 18 | return name; 19 | } 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | public String getSurname() { 24 | return surname; 25 | } 26 | public void setSurname(String surname) { 27 | this.surname = surname; 28 | } 29 | public String getEmail() { 30 | return email; 31 | } 32 | public void setEmail(String email) { 33 | this.email = email; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-encdec/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /code/chapter9/javaee7-websocket-encdec/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------