View Javadoc

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