View Javadoc

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