View Javadoc

1   package org.apache.turbine.services.uniqueid;
2   
3   
4   /*
5    * Copyright 2001-2004 The Apache Software Foundation.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License")
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  
21  import org.apache.turbine.services.TurbineServices;
22  
23  /***
24   * This is a facade class for {@link UniqueIdService}.
25   *
26   * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
27   * @version $Id: TurbineUniqueId.java 222043 2004-12-06 17:47:33Z painter $
28   */
29  public abstract class TurbineUniqueId
30  {
31      /***
32       * Utility method for accessing the service
33       * implementation
34       *
35       * @return a UniqueIdService implementation instance
36       */
37      protected static UniqueIdService getService()
38      {
39          return (UniqueIdService) TurbineServices
40                  .getInstance().getService(UniqueIdService.SERVICE_NAME);
41      }
42  
43      /***
44       * <p> Returs an identifer of this Turbine instance that is unique
45       * both on the server and worldwide.
46       *
47       * @return A String with the instance identifier.
48       */
49      public static String getInstanceId()
50      {
51          return getService().getInstanceId();
52      }
53  
54      /***
55       * <p> Returns an identifier that is unique within this turbine
56       * instance, but does not have random-like apearance.
57       *
58       * @return A String with the non-random looking instance
59       * identifier.
60       */
61      public static String getUniqueId()
62      {
63          return getService().getUniqueId();
64      }
65  
66      /***
67       * <p> Returns a unique identifier that looks like random data.
68       *
69       * @return A String with the random looking instance identifier.
70       */
71      public static String getPseudorandomId()
72      {
73          return getService().getPseudorandomId();
74      }
75  }