KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > eaio > nativecall > Verifiers


1 /*
2  * Verifiers.java
3  *
4  * Created on 07.09.2004.
5  *
6  * eaio: NativeCall - calling operating system methods from Java
7  * Copyright (c) 2004-2006 Johann Burkard (<mailto:jb@eaio.com>)
8  * <http://eaio.com>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23  * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26  * USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */

29 package com.eaio.nativecall;
30
31 import java.util.Iterator JavaDoc;
32
33 import sun.misc.Service;
34 import sun.misc.ServiceConfigurationError;
35
36 /**
37  * Verifiers instantiates the matching {@link com.eaio.nativecall.Verifier} for
38  * the current operating system.
39  *
40  * @author <a HREF="mailto:jb@eaio.com">Johann Burkard</a>
41  * @version $Id: Verifiers.java,v 1.2 2006/01/06 10:58:33 grnull Exp $
42  */

43 final class Verifiers {
44
45     /**
46      * No instances needed.
47      */

48     private Verifiers() {}
49
50     /**
51      * The Verifier.
52      */

53     private static Verifier v = null;
54
55     /**
56      * Find the matching Verifier.
57      *
58      * @throws ServiceConfigurationError
59      * @throws SecurityException
60      */

61     static void init() throws ServiceConfigurationError, SecurityException JavaDoc {
62         Iterator JavaDoc i =
63             Service.providers(Verifier.class, Verifier.class.getClassLoader());
64         Verifier ver = null;
65         while (i.hasNext()) {
66             ver = (Verifier) i.next();
67             if (ver.supports()) {
68                 v = ver;
69                 break;
70             }
71         }
72     }
73
74     /**
75      * Returns the Verifier.
76      *
77      * @return a Verifier or <code>null</code>
78      */

79     static Verifier getInstance() {
80         return v;
81     }
82
83 }
84
Popular Tags