KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > services > daemon > ServiceRecord


1 /*
2
3    Derby - Class org.apache.derby.impl.services.daemon.ServiceRecord
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.services.daemon;
23
24 import org.apache.derby.iapi.services.daemon.Serviceable;
25
26 /** wrapper class for basic daemon's clients */
27 class ServiceRecord
28 {
29     // immutable fields
30
final Serviceable client;
31     private final boolean onDemandOnly;
32     final boolean subscriber;
33
34     // we can tolerate spurrious service, so don't synchronized this
35
private boolean serviceRequest;
36
37     ServiceRecord(Serviceable client, boolean onDemandOnly, boolean subscriber)
38     {
39         this.client = client;
40         this.onDemandOnly = onDemandOnly;
41         this.subscriber = subscriber;
42     }
43
44     final void serviced()
45     {
46         serviceRequest = false;
47     }
48
49     final boolean needImmediateService()
50     {
51         return serviceRequest;
52     }
53
54     final boolean needService()
55     {
56         return serviceRequest || !onDemandOnly;
57     }
58
59
60     final void called()
61     {
62         serviceRequest = true;
63     }
64 }
65
66
67
68
Popular Tags