View Javadoc

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