001package org.apache.turbine.services.uniqueid;
002
003
004/*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements.  See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership.  The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License.  You may obtain a copy of the License at
012 *
013 *   http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied.  See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024import org.apache.turbine.services.TurbineServices;
025
026/**
027 * This is a facade class for {@link UniqueIdService}.
028 *
029 * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
030 * @version $Id: TurbineUniqueId.java 615328 2008-01-25 20:25:05Z tv $
031 */
032public abstract class TurbineUniqueId
033{
034    /**
035     * Utility method for accessing the service
036     * implementation
037     *
038     * @return a UniqueIdService implementation instance
039     */
040    protected static UniqueIdService getService()
041    {
042        return (UniqueIdService) TurbineServices
043                .getInstance().getService(UniqueIdService.SERVICE_NAME);
044    }
045
046    /**
047     * <p> Returs an identifer of this Turbine instance that is unique
048     * both on the server and worldwide.
049     *
050     * @return A String with the instance identifier.
051     */
052    public static String getInstanceId()
053    {
054        return getService().getInstanceId();
055    }
056
057    /**
058     * <p> Returns an identifier that is unique within this turbine
059     * instance, but does not have random-like apearance.
060     *
061     * @return A String with the non-random looking instance
062     * identifier.
063     */
064    public static String getUniqueId()
065    {
066        return getService().getUniqueId();
067    }
068
069    /**
070     * <p> Returns a unique identifier that looks like random data.
071     *
072     * @return A String with the random looking instance identifier.
073     */
074    public static String getPseudorandomId()
075    {
076        return getService().getPseudorandomId();
077    }
078}