1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.domain.impl;
17
18 import org.acegisecurity.domain.util.ReflectionToStringBuilder;
19
20 import org.apache.commons.beanutils.BeanUtils;
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 import java.io.Serializable;
25
26
27 /***
28 * A business domain object.
29 *
30 * <p>
31 * Only minimal convenience methods are provided by
32 * <code>BusinessObject</code>. Whilst many other methods could easily be
33 * offered (and overridden on an as-required basis) it is felt the default
34 * behaviour of {@link java.lang.Object} is widely understood and an
35 * appropriate default.
36 * </p>
37 *
38 * @author Carlos Sanchez
39 * @author Ben Alex
40 * @author Matthew Porter
41 * @version $Id: BusinessObject.java,v 1.4 2005/11/17 00:55:49 benalex Exp $
42 */
43 public abstract class BusinessObject implements Serializable, Cloneable {
44
45
46 protected final transient Log logger = LogFactory.getLog(getClass());
47
48
49
50 /***
51 * Swallow cloning.
52 *
53 * <p>
54 * This method delegates to BeanUtils.cloneBean().
55 * </p>
56 *
57 * @return a clone of the current instance
58 *
59 * @throws IllegalStateException if there are any problems with swallow
60 * cloning
61 *
62 * @see java.lang.Object#clone()
63 * @see BeanUtils#cloneBean(Object)
64 */
65 public Object clone() throws CloneNotSupportedException {
66 try {
67 return BeanUtils.cloneBean(this);
68 } catch (Exception e) {
69 logger.error(e);
70 throw new CloneNotSupportedException(e.getMessage());
71 }
72 }
73
74 /***
75 * Delegates to {@link CollectionIgnoringReflectionToStringBuilder}.
76 *
77 * @see java.lang.Object#toString()
78 */
79 public String toString() {
80 return new ReflectionToStringBuilder(this).toString();
81 }
82 }