{"id":295178,"date":"2019-11-25T21:00:15","date_gmt":"2019-11-25T21:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295178"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295178","title":{"rendered":"\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440 (JavaFX+EJB+WildFly)"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477436\/\">\u0418\u0442\u0430\u043a, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0415\u0441\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 (\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435, 4 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b \u0431\u0435\u0437 \u0434\u0440\u043e\u0431\u0435\u0439 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u0441\u0445\u0435\u043c\u0435 [\u043e\u043f\u0435\u0440\u0430\u043d\u04341] [\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440] [\u043e\u043f\u0435\u0440\u0430\u043d\u04342] [\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442]) \u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u042f\u041f (\u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Java, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c WildFly\/JBoss)+\u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u0438\u0435 JavaFX), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<p>  <i>\u042d\u0442\u043e\u0442 \u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RMI (Remote Method Invocation) \u0431\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043b\u0438\u0435\u043d\u0442\u0430 GUI \u0438 EJB, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u043d\u043e \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0430 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/i><\/p>\n<p>  1. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u044b:<br \/>  1.1. JDK, <br \/>  1.2. IDE (\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Java EE),<br \/>  1.3. WildFly (\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f Java),<br \/>  1.4. SceneBuilder (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f GUI).<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JNDI (\u0441\u043b\u0443\u0436\u0431\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f EJB (\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438).<\/p>\n<p>  2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<br \/>  2.1. \u0423\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <a href=\"https:\/\/habr.com\/ru\/users\/remote\/\" class=\"user_link\">Remote<\/a> \u2014 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 EJB \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RMI). <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"java\">package com.calc.server;  import javax.ejb.Remote;  @Remote public interface CalcRemote {     int add(int a, int b);     int sub(int a, int b);     int mul(int a, int b);     int div(int a, int b) throws MyException; } <\/code><\/pre>\n<p><cut\/><br \/>  2.2. \u041a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @Stateless \u2014 \u0441\u0435\u0430\u043d\u0441\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0431\u0435\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f).<\/p>\n<pre><code class=\"java\">package com.calc.server;  import javax.ejb.Stateless;  @Stateless(name = &quot;CalcSessionEJB&quot;) public class CalcSessionBean implements CalcRemote {     public CalcSessionBean() {     }      @Override     public int add(int a, int b) {         return a + b;     }      @Override     public int sub(int a, int b) {         return a - b;     }      @Override     public int mul(int a, int b) {         return a * b;     }      @Override     public int div(int a, int b) throws MyException {         try {             return a \/ b;         } catch (ArithmeticException ex) {             throw new MyException(&quot;Divide by Zero!!!&quot;);         }     } } <\/code><\/pre>\n<p>  2.3. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u043b\u044c \u0438\u043b\u0438 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442.<\/p>\n<pre><code class=\"java\">package com.calc.server;  public class MyException extends Exception {     public MyException(String message) {         super(message);     } } <\/code><\/pre>\n<p>  2.4. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e IDE \u0441\u043e\u0437\u0434\u0430\u0435\u043c ear-\u0444\u0430\u0439\u043b (Enterprise Archive), \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 (\u043c\u043e\u0436\u043d\u043e \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u043e\u0440\u0442\u043e\u043c), \u0434\u0435\u043f\u043b\u043e\u0438\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0438 \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043e, \u0442\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u043e.<\/p>\n<p>  \u041b\u043e\u0433 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"plaintext\">\tjava:global\/Calc_ear_exploded\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote \tjava:app\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote \tjava:module\/CalcSessionEJB!com.calc.server.CalcRemote \tjava:jboss\/exported\/Calc_ear_exploded\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote \tejb:Calc_ear_exploded\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote \tjava:global\/Calc_ear_exploded\/ejb\/CalcSessionEJB \tjava:app\/ejb\/CalcSessionEJB \tjava:module\/CalcSessionEJB <\/code><\/pre>\n<p>  3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<br \/>  3.1. \u0412 SceneBuilder \u043d\u0430\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u043a\u0435\u0442 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430 (main.fxml), css \u043f\u043e\u043a\u0430 \u043d\u0430\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;  &lt;?import javafx.scene.control.*?&gt; &lt;?import javafx.scene.layout.*?&gt;  &lt;AnchorPane id=&quot;AnchorPane&quot; maxHeight=&quot;-Infinity&quot; maxWidth=&quot;-Infinity&quot; minHeight=&quot;-Infinity&quot; minWidth=&quot;-Infinity&quot; prefHeight=&quot;321.0&quot; prefWidth=&quot;231.0&quot; xmlns:fx=&quot;http:\/\/javafx.com\/fxml\/1&quot; xmlns=&quot;http:\/\/javafx.com\/javafx\/2.2&quot; fx:controller=&quot;com.calc.client.impl2.controller.Controller&quot;&gt;   &lt;children&gt;     &lt;Label disable=&quot;false&quot; layoutX=&quot;24.0&quot; layoutY=&quot;15.0&quot; prefHeight=&quot;28.0&quot; prefWidth=&quot;189.0&quot; text=&quot;EJB Calculator&quot; \/&gt;     &lt;TextField fx:id=&quot;displayTextField&quot; layoutX=&quot;24.0&quot; layoutY=&quot;43.0&quot; prefHeight=&quot;56.0&quot; prefWidth=&quot;182.0&quot; \/&gt;     &lt;Button fx:id=&quot;num7Button&quot; layoutX=&quot;24.0&quot; layoutY=&quot;110.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;7&quot; \/&gt;     &lt;Button fx:id=&quot;num8Button&quot; layoutX=&quot;72.0&quot; layoutY=&quot;110.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;8&quot; \/&gt;     &lt;Button fx:id=&quot;num9Button&quot; layoutX=&quot;119.0&quot; layoutY=&quot;110.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;9&quot; \/&gt;     &lt;Button fx:id=&quot;divButton&quot; layoutX=&quot;166.0&quot; layoutY=&quot;110.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;\/&quot; \/&gt;     &lt;Button fx:id=&quot;num4Button&quot; layoutX=&quot;24.0&quot; layoutY=&quot;161.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;4&quot; \/&gt;     &lt;Button fx:id=&quot;num5Button&quot; layoutX=&quot;72.0&quot; layoutY=&quot;161.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;5&quot; \/&gt;     &lt;Button fx:id=&quot;num6Button&quot; layoutX=&quot;119.0&quot; layoutY=&quot;161.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;6&quot; \/&gt;     &lt;Button fx:id=&quot;mulButton&quot; layoutX=&quot;166.0&quot; layoutY=&quot;161.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;*&quot; \/&gt;     &lt;Button fx:id=&quot;num1Button&quot; layoutX=&quot;24.0&quot; layoutY=&quot;209.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;1&quot; \/&gt;     &lt;Button fx:id=&quot;num2Button&quot; layoutX=&quot;72.0&quot; layoutY=&quot;209.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;2&quot; \/&gt;     &lt;Button fx:id=&quot;num3Button&quot; layoutX=&quot;119.0&quot; layoutY=&quot;209.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;3&quot; \/&gt;     &lt;Button fx:id=&quot;subButton&quot; layoutX=&quot;166.0&quot; layoutY=&quot;209.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;-&quot; \/&gt;     &lt;Button fx:id=&quot;num0Button&quot; layoutX=&quot;24.0&quot; layoutY=&quot;259.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;0&quot; \/&gt;     &lt;Button fx:id=&quot;clrButton&quot; layoutX=&quot;72.0&quot; layoutY=&quot;259.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;C&quot; \/&gt;     &lt;Button fx:id=&quot;resButton&quot; layoutX=&quot;119.0&quot; layoutY=&quot;259.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;=&quot; \/&gt;     &lt;Button fx:id=&quot;addButton&quot; layoutX=&quot;166.0&quot; layoutY=&quot;259.0&quot; mnemonicParsing=&quot;false&quot; prefHeight=&quot;39.0&quot; prefWidth=&quot;40.0&quot; text=&quot;+&quot; \/&gt;   &lt;\/children&gt; &lt;\/AnchorPane&gt; <\/code><\/pre>\n<p>  3.2. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043a\u043b\u0430\u0441\u0441 \u043a fxml-\u0444\u043e\u0440\u043c\u0435, \u0434\u043b\u044f \u0430\u043d\u0442\u0438\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 GUI (\u0437\u0430\u043b\u0438\u043f\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b) \u043f\u0440\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &quot;=&quot; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043d\u0438\u0442\u043a\u0443:<\/p>\n<pre><code class=\"java\">package com.calc.client.impl2.controller;  import com.calc.server.CalcRemote; import com.calc.server.MyException; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TextField;  import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Properties;  public class Controller implements Runnable {     private Calculator calculator;     @FXML     private TextField displayTextField;      @FXML     private Button num1Button;      @FXML     private Button num2Button;      @FXML     private Button num3Button;      @FXML     private Button num4Button;      @FXML     private Button num5Button;      @FXML     private Button num6Button;      @FXML     private Button num7Button;      @FXML     private Button num8Button;      @FXML     private Button num9Button;      @FXML     private Button num0Button;      @FXML     private Button addButton;      @FXML     private Button subButton;      @FXML     private Button mulButton;      @FXML     private Button divButton;      @FXML     private Button clrButton;      @FXML     private Button resButton;      @FXML     private void initialize() {         System.out.println(&quot;initialize()&quot;);         calculator = new Calculator();         displayTextField.setText(&quot;0&quot;);          num1Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;1&quot;)));         num2Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;2&quot;)));         num3Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;3&quot;)));         num4Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;4&quot;)));         num5Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;5&quot;)));         num6Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;6&quot;)));         num7Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;7&quot;)));         num8Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;8&quot;)));         num9Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;9&quot;)));         num0Button.setOnAction(event -&gt; displayTextField.setText(calculator.addNumber(&quot;0&quot;)));         addButton.setOnAction(event -&gt; {             calculator.addOperator(&quot;+&quot;);             displayTextField.setText(&quot;&quot;);         });         subButton.setOnAction(event -&gt; {             calculator.addOperator(&quot;-&quot;);             displayTextField.setText(&quot;&quot;);         });         mulButton.setOnAction(event -&gt; {             calculator.addOperator(&quot;*&quot;);             displayTextField.setText(&quot;&quot;);         });         divButton.setOnAction(event -&gt; {             calculator.addOperator(&quot;\/&quot;);             displayTextField.setText(&quot;&quot;);         });         resButton.setOnAction(event -&gt; new Thread(this).start());         clrButton.setOnAction(event -&gt; displayTextField.setText(&quot;&quot;));     }      private void doRequest(String[] data) throws NamingException, MyException {         Properties props = new Properties();         props.put(Context.INITIAL_CONTEXT_FACTORY, &quot;org.wildfly.naming.client.WildFlyInitialContextFactory&quot;); \/\/        props.put(Context.URL_PKG_PREFIXES, &quot;org.jboss.ejb.client.naming&quot;); \/\/        props.put(Context.PROVIDER_URL, &quot;remote+http:\/\/localhost:8080&quot;);         props.put(Context.PROVIDER_URL, &quot;http-remoting:\/\/localhost:8080&quot;); \/\/        props.put(&quot;jboss.naming.client.ejb.context&quot;, &quot;true&quot;); \/\/        props.put(Context.SECURITY_PRINCIPAL, &quot;admin&quot;); \/\/        props.put(Context.SECURITY_CREDENTIALS, &quot;123&quot;);         Context ctx = new InitialContext(props);         \/\/System.out.println(ctx.getEnvironment());          CalcRemote calcRemote = (CalcRemote) ctx.lookup(&quot;Calc_ear_exploded\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote&quot;);    \/\/java:jboss\/exported\/Calc_ear_exploded\/ejb\/CalcSessionEJB!com.calc.server.CalcRemote         String res = Integer.toString(process(calcRemote, data));         displayTextField.setText(res);         System.out.println(res);     }      private int process(CalcRemote calcRemote, String[] resData) throws MyException {         int operand1 = Integer.parseInt(resData[0]);         int operand2 = Integer.parseInt(resData[1]);         String operator = resData[2];         switch (operator) {             case &quot;+&quot;:                 return calcRemote.add(operand1, operand2);             case &quot;-&quot;:                 return calcRemote.sub(operand1, operand2);             case &quot;*&quot;:                 return calcRemote.mul(operand1, operand2);             case &quot;\/&quot;:                 return calcRemote.div(operand1, operand2);         }         return 0;     }      @Override     public void run() {         displayTextField.setText(&quot;WAITING...&quot;);         try {             doRequest(calculator.getResult());         } catch (NamingException ex) {             ex.printStackTrace();         } catch (MyException ex) {             displayTextField.setText(ex.getMessage());         }     } } <\/code><\/pre>\n<p>  3.3. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"java\">package com.calc.client.impl2.controller;  import com.calc.server.MyException;  public class Calculator {     private String buffer = &quot;&quot;, operator, operand1, operand2;     private boolean isOperator = false;      public String addNumber(String value) {         buffer += value;         if (!isOperator) {             operand1 = buffer;         } else {             operand2 = buffer;         }         return buffer;     }      public void addOperator(String value) {         operator = value;         buffer = &quot;&quot;;         isOperator = true;     }      public String[] getResult() throws MyException {         isOperator = false;         buffer = &quot;&quot;;         int check;         try {             check = Integer.parseInt(operand1);             check = Integer.parseInt(operand2);         } catch (NumberFormatException ex) {             throw new MyException(&quot;Wrong format!!!&quot;);         }         return new String[]{operand1, operand2, operator};     } } <\/code><\/pre>\n<p>  3.5. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 WildFly \u044d\u0442\u043e jboss-client.jar), \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c GUI.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432 \u0446\u0438\u0444\u0440\u044b, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 &quot;=&quot; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c (\u0447\u0435\u0440\u0435\u0437 \u0441\u043b\u0443\u0436\u0431\u0443 JNDI), \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u043d\u0430 \u0434\u0438\u0441\u043f\u043b\u0435\u0435 \u00abWAITING&#8230;\u00bb \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u043c \u043f\u0430\u0440\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439: NumberFormatException (\u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435) \u0438 ArithmeticException (\u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430 \u043d\u043e\u043b\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435).<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/477436\/\"> https:\/\/habr.com\/ru\/post\/477436\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477436\/\">\u0418\u0442\u0430\u043a, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0415\u0441\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 (\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435, 4 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b \u0431\u0435\u0437 \u0434\u0440\u043e\u0431\u0435\u0439 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u0441\u0445\u0435\u043c\u0435 [\u043e\u043f\u0435\u0440\u0430\u043d\u04341] [\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440] [\u043e\u043f\u0435\u0440\u0430\u043d\u04342] [\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442]) \u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u042f\u041f (\u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Java, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c WildFly\/JBoss)+\u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u0438\u0435 JavaFX), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<p>  <i>\u042d\u0442\u043e\u0442 \u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RMI (Remote Method Invocation) \u0431\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043b\u0438\u0435\u043d\u0442\u0430 GUI \u0438 EJB, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u043d\u043e \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0430 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/i><\/p>\n<p>  1. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u044b:<br \/>  1.1. JDK, <br \/>  1.2. IDE (\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Java EE),<br \/>  1.3. WildFly (\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f Java),<br \/>  1.4. SceneBuilder (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f GUI).<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JNDI (\u0441\u043b\u0443\u0436\u0431\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f EJB (\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438).<\/p>\n<p>  2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<br \/>  2.1. \u0423\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <a href=\"https:\/\/habr.com\/ru\/users\/remote\/\" class=\"user_link\">Remote<\/a> \u2014 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 EJB \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RMI).   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-295178","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295178"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295178\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}