tailieunhanh - Java 2 Bible Enterprise Edition phần 8

Trong một thông cáo trong tương lai của môi trường J2EE, bạn sẽ có thể sử dụng khả năng Java đăng nhập mới có trong J2SE . Điều này sẽ cung cấp cho bạn kiểm soát nhiều hơn về khả năng của bạn đăng nhập. Tuy nhiên, như các bản ghi là các tập tin, | Chapter 20 Why Dream of Jini The Client The Client is just a class for exercising these Calculator services. Its only real method is getAndDisplayResult which takes a Calculator along with the two operands. It then asks the Calculator for the operation name and will get sum if the Calculator is an Adder and difference if the Calculator is a Subtractor. It then gets the results of the calculation and displays them. You can already view Adder and Subtractor as services and see how you could easily extend the application to include other operations. package NonDistributedCalculator public class Client public void getAndDisplayResult Calculator calculator int firstOperand int secondOperand String operationName int operationResult firstOperand secondOperand The operationName of firstOperand and secondOperand is operationResult public static void main String args Client client new Client new Adder 5 6 new Subtractor 24 7 In the next section you ll download and install Jini and get it configured and running. You ll then return to this example and convert it to a set of Jini services and a client. Getting Jini Up and Running You may remember from Chapter 15 that getting all the RMI services running properly is difficult. For the most part the Jini community has addressed that issue by creating a version that is easy to install and to run. Note As with RMI it is a good idea to run these examples on at least two different machines each of which is connected to a network an internal network is fine . You may recall that when you ran RMI examples in which the client and server code were in the same file or even on the same machine shortcuts were taken. If you aren t able to develop on two different machines at least test in such a setup before deploying. Installing Jini Download the latest version of the Jini Technology Starter kit by following the .