• Keine Ergebnisse gefunden

Exercise2MobileCodewithRMI Exercise1RMIChatsystem PracticeSheet12 AdvancedAspectsofObject-OrientedProgramming(SS2015)

N/A
N/A
Protected

Academic year: 2022

Aktie "Exercise2MobileCodewithRMI Exercise1RMIChatsystem PracticeSheet12 AdvancedAspectsofObject-OrientedProgramming(SS2015)"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. Dr. A. Poetzsch-Heffter Mathias Weber, M.Sc.

University of Kaiserslautern Department of Computer Science Software Technology Group

Advanced Aspects of Object-Oriented Programming (SS 2015) Practice Sheet 12

Date of Issue: 08.07.15

Deadline: 14.07.15 (before the lecture as PDF via E-Mail)

Exercise 1 RMI Chatsystem

In the lecture a chatsystem that runs in a single JavaVM was presented. We want to distribute it according to the following picture.

Concepts and Approach JCoBox: The Language Implementation

Example: Simple Chat Application

Server Session

Session Client

Client GUI

GUI

interface Client4Session{ void onChatMsg(Msg m);

}

interface Client4GUI{

void publishMsg(String m);

}

interface Server{

Session connect(Client c);

}

interface Session{ void publish(Msg m);

void close();

}

Jan Sch¨afer, Arnd Poetzsch-Heffter JCoBox 18

Java VM 3

Java VM 2 Java VM 1

The communication between the different Java VMs shall be done by RMI. The implementation should be done in plain Java instead of JCoBox.

Implement the complete system. You can use the interfaces definitions presented in the JCoBox slides as a starting point. The GUI should consist of an area the chat is shown in and an input field to enter the message to send. As in the exercises before, the server part of your system shall be able to handle an arbitrary number of clients, which may connect and disconnect at any time, and it shall support the.byeand.history ncommands.

Exercise 2 Mobile Code with RMI

Mobile code gives to possibility to transfer code from one machine to the other and execute it.

a) Download the mobile code project from the lecture homepage and try to get the server to run using the ant com- mandant runServeron a console in theserverdirectory.

b) In thesrcfolder in theclientfolder you find the needed interfacesIServerandTask. The RMI registry gets started on the server and an instance of the classServergets registered under the nameServer. Implement a client that runs the following tasks on the server:

• Read the content of filesecret.txtin the server directory and print the content to the client console.

• Write a fileoutput.txtin the server directory with the content "Hello from Client".

• Delete the filesecret.txtin the server directory.

Hint: Inform yourself about thecodebaseproperty and how to use it to download code to the server. If the client and the server run on the same machine you can use thefile:protocol in the codebase attribute.

(2)

Exercise 3 Swing

As the Swing-Framework is not thread-safe, two rules apply to each swing-application (from the javadoc):

• Time-consuming tasks should not be run on the Event Dispatch Thread. Otherwise the application becomes unresponsive.

• Swing components should be accessed on the Event Dispatch Thread only.

a) Download the fileworker_JCoBox.zipfrom the lecture homepage and unpack it. Implement a CoBoxFactorizeWorker

that performs the actual work of factorizing a given number and notifies theControllerabout the intermediate re- sults. The CoBox must at least understand the messagesvoid execute()andvoid cancel()and it must have a constructor that takes aControllerand the number of typelongto factorize.

Hint: The annotation@Swingon theControllerCoBox has the result that all asynchronous calls on theController

box are executed in the Swing Event Dispatch Thread.

b) SwingWorkeris designed for situations where you need to have a long running task run in a background thread and provide updates to the UI either when done, or while processing.

Rewrite the program in Java and use aSwingWorkerto perform the factorization.

c) Which threads are involved in the execution of aSwingWorker? What is the interface between the GUI and the worker?

Referenzen

ÄHNLICHE DOKUMENTE

Typically, the interface between the worker and the GUI is very broad: The process() method, which is part of the worker and updates the state of the GUI, will access most of

occurs.. The red line, region one, is one of the outermost zones in our domain. This region consists out of a mixture of newly accreted matter and traces of the ashes of the last

We applied ACO to the PVRPTW in two different ways: first, to solve the pricing subproblem of a column generation approach that provides lower bounds for the LP-relaxed PVRPTW

Third, I estimate the combined effect of invention and spread on the timing of adoption, and find that one extra standard deviation of temperature seasonality is associated

The progressive tax system and progressive taxation in general relates to a situation in which the proportion of income earned through taxation (tax rate) increases with

(angelehnt an: Niveaubestimmende Aufgaben für die Grundschule, Englisch, URL: https://back.bildung-lsa.de/pool/RRL_Lehrplaene/nivgsengl.pdf). mobile number

Just like the multilevel system of governance that is at the heart of the three papers, the papers themselves consider the different levels: the first paper focuses on the direct

The Teutonic prosecutor brought about the faking of bulla which put an end to the Prussian Association connected with Poland.15 This was convergent with the policy of Calixtus III