KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > utility > NullSemaphore


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.jdo.spi.persistence.utility;
25
26 import java.util.ResourceBundle JavaDoc;
27 import com.sun.jdo.spi.persistence.utility.logging.Logger;
28
29 /** Implements a simple semaphore that does not do <em>any</em>
30  * semaphore-ing. That is, the methods just immediately return.
31  *
32  * @author Dave Bristor
33  */

34 // db13166: I would rather we use Doug Lea's stuff, but don't want to
35
// introduce that magnitude of change at this point in time.
36
public class NullSemaphore implements Semaphore {
37     /** Where to log messages about locking operations
38      */

39     private static final Logger _logger = LogHelperUtility.getLogger();
40
41     /** For logging, indicates on whose behalf locking is done.
42      */

43     private final String JavaDoc _owner;
44
45     /**
46      * I18N message handler
47      */

48     private final static ResourceBundle JavaDoc messages =
49         I18NHelper.loadBundle(SemaphoreImpl.class);
50
51     public NullSemaphore(String JavaDoc owner) {
52         _owner = owner;
53
54         if (_logger.isLoggable(Logger.FINEST)) {
55             Object JavaDoc[] items = new Object JavaDoc[] {_owner};
56             _logger.finest("utility.nullsemaphore.constructor",items); // NOI18N
57
}
58     }
59
60     /** Does nothing.
61      */

62     public void acquire() {
63
64         if (_logger.isLoggable(Logger.FINEST)) {
65             Object JavaDoc[] items = new Object JavaDoc[] {_owner};
66             _logger.finest("utility.nullsemaphore.acquire",items); // NOI18N
67
}
68     }
69
70     /** Does nothing.
71      */

72     public void release() {
73
74         if (_logger.isLoggable(Logger.FINEST)) {
75             Object JavaDoc[] items = new Object JavaDoc[] {_owner};
76             _logger.finest("utility.nullsemaphore.release",items); // NOI18N
77
}
78     }
79 }
80
Popular Tags