View Javadoc

    1   /* Copyright 2004, 2005 Acegi Technology Pty Limited
    2    *
    3    * Licensed under the Apache License, Version 2.0 (the "License");
    4    * you may not use this file except in compliance with the License.
    5    * You may obtain a copy of the License at
    6    *
    7    *     http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    * Unless required by applicable law or agreed to in writing, software
    10   * distributed under the License is distributed on an "AS IS" BASIS,
    11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12   * See the License for the specific language governing permissions and
    13   * limitations under the License.
    14   */
    15
    16  package org.acegisecurity.domain;
    17
    18  import java.io.Serializable;
    19
    20
    21  /***
    22   * An interface that indicates an object is a <i>persistable entity</i>.
    23   *
    24   * <p>
    25   * A persistable entity is any object that is capable of being persisted,
    26   * typically via a {@link org.acegisecurity.domain.dao.Dao} implementation.
    27   * </p>
    28   *
    29   * @author Ben Alex
    30   * @version $Id: PersistableEntity.java,v 1.2 2005/11/17 00:56:47 benalex Exp $
    31   */
    32  public interface PersistableEntity {
    33      //~ Methods ================================================================
    34
    35      /***
    36       * Provides a common getter for the persistence layer to obtain an
    37       * identity, irrespective of the actual type of identity used.
    38       *
    39       * <p>
    40       * Typically a subclass will delegate to a <code>public
    41       * SomePrimitiveWrapper getId()</code> method. The necessity for the
    42       * <code>getInternalId()</code> abstract method is solely  because the
    43       * persistence layer needs a way of obtaining the identity irrespective of
    44       * the actual identity implementation choice.
    45       * </p>
    46       *
    47       * <p>
    48       * Returning <code>null</code> from this method will indicate the object
    49       * has never been saved. This will likely be relied on by some
    50       * <code>Dao</code> implementations.
    51       * </p>
    52       *
    53       * @return the persistence identity of this instance
    54       */
    55      abstract Serializable getInternalId();
    56  }