Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/RuntimeCollective/webapps/bean/Duplicable.java


1   /* $Header: /home/CVS/rjp/src/com/RuntimeCollective/webapps/bean/Duplicable.java,v 1.5 2003/09/30 15:13:09 joe Exp $
2    * $Revision: 1.5 $
3    * $Date: 2003/09/30 15:13:09 $
4    *
5    * ====================================================================
6    *
7    * Josephine : http://www.runtime-collective.com/josephine/index.html
8    *
9    * Copyright (C) 2003 Runtime Collective
10   * 
11   * This product includes software developed by the
12   * Apache Software Foundation (http://www.apache.org/).
13   *
14   * This library is free software; you can redistribute it and/or
15   * modify it under the terms of the GNU Lesser General Public
16   * License as published by the Free Software Foundation; either
17   * version 2.1 of the License, or (at your option) any later version.
18   *
19   * This library is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   * Lesser General Public License for more details.
23   *
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this library; if not, write to the Free Software
26   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27   *
28   */
29  
30  package com.RuntimeCollective.webapps.bean;
31  
32  import com.RuntimeCollective.webapps.bean.EntityBean;
33  
34  /**
35   * Interface to implement if you want an EntityBean to be duplicable, that is,
36   * to make it possible to duplicate a bean into a new one, with the same properties,
37   * but a new id.
38   *
39   * @version $Id: Duplicable.java,v 1.5 2003/09/30 15:13:09 joe Exp $
40   */
41  public interface Duplicable extends EntityBean {
42  
43      /** Not sure we need this, but EBS complains otherwise */
44      public static String DATABASE_TABLE = "global_object";
45  
46      /**
47       * The method to call when you want to create (and save) the duplicate of an object.
48       * <p>
49       * This will call makeDuplicate(int) with a fresh new id.
50       *
51       * @return an object of the same class, with the same properties, but with a new id.
52       */
53      public Duplicable makeDuplicate();
54  
55      /**
56       * The method to call when you want to create (and save) the duplicate of an object,
57       * while expliciting the id you want for the duplicate.
58       * <p>
59       * To use with care, as obviously the bean using that id will be overwritten. It is
60       * "recommended" that the overwritten bean be of the same type as the object being
61       * duplicated.
62       * <p>
63       * Implementation-wise, this method will make a raw duplicate (ie clone itself
64       * by changing its own id), and then call
65       * the customiseDuplicate() method where class-specific code should reside.
66       *
67       * @param id, the id to be used for the duplicate
68       * @return an object of the same class, with the same properties, but with a new id.
69       */
70      public Duplicable makeDuplicate(int duplicateId);
71  
72      /**
73       * A method to customise (and save) a "raw" Duplicate, usually not called directly,
74       * but used by makeDuplicate(int).
75       * <p>
76       * This method will do additional processing of a "raw" Duplicate. This is most
77       * useful for class-specific logic, such as creating Duplicates of composed
78       * objects, and assigning those Duplicates to the "raw" Duplicate.
79       * <p>
80       * When subclassing a Duplicable class, you should override this method only,
81       * <b>without</b> changing the makeDuplicate methods.
82       *
83       * @param duplicate, the "raw" duplicate
84       * @return the "complete" duplicate
85       */
86      public Duplicable customiseDuplicate(Duplicable duplicate);
87  }
88  
89  
90  
91