Advanced Java 2 Platform HOW TO PROGRAM phần 8

Khởi động SeminarInfoLeaseService public static void main (chuỗi args []) {/ / thiết lập SecurityManager ( () == null) { (mới RMISecurityManager ());} SeminarInfoLeaseService dịch vụ = new SeminarInfoLeaseService (); | Chapter 22 Jini 1247 113 launch SeminarInfoLeaseService 114 public static void main String args 115 116 set SecurityManager 117 if null 118 new RMISecurityManager 119 120 121 SeminarInfoLeaseService service 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 new SeminarInfoLeaseService Object keepAlive new Object wait on keepAlive Object to keep service running synchronized keepAlive keep application alive try handle exception if wait interrupted catch InterruptedException exception end synchronized block 141 142 end method main Fig. SeminarInfoLeaseService uses class LeaseRenewalManager to manage SeminarInfo service leasing part 4 of 4 . In method discovered lines 69-70 register the SeminarInfo service s ServiceItem with the discovered ServiceRegistrar. Lines 73-74 create a new LeaseRenewalManager which class SeminarInfoLeaseService uses to manage the SeminarInfo service s lease. Lines 77-78 invoke method renewUntil of class LeaseRenewalManager. Method renewUntil takes as its first argument the Lease object to be renewed. In this example we obtain the Lease object by invoking method getLease of class ServiceRegistration. The second argument specifies the desired expiration time in milliseconds for renewed Leases. Line 78 specifies the constant to request a Lease that never expires. This does not guarantee that the lookup service will provide an everlasting Lease the lookup service is free to grant a lease that is shorter than the requested length. The third argument to method renewUntil is the LeaseListener to notify of problems encountered when renewing the Lease. We pass null as the third argument to disregard such notifications. To run the SeminarInfo Jini service with lease management create a new JAR file named . Figure shows the contents of . Note that this JAR

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.