KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > instrument > JoinpointClassification


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.aop.instrument;
23
24
25 /**
26  * This class represents the classification of a joinpoint.
27  * <code>JoinpointClassification</code> is an implementation of the
28  * Enum Type Pattern, described by Joshua Block on his
29  * book entitled "Effective Java Programming Language Guide".
30  * @author Flavia Rainone
31  */

32 public final class JoinpointClassification
33 {
34    /**
35     * Indicates that the joinpoint mustn't be instrumented.
36     */

37    public static JoinpointClassification NOT_INSTRUMENTED = new JoinpointClassification("not instrumented");
38    
39    /**
40     * Indicates that the joinpoint must be prepared for runtime wrapping.
41     */

42    public static JoinpointClassification PREPARED = new JoinpointClassification("prepared");
43    
44    /**
45     * Indicates that the joinpoint must be wrapped inside a code block for interception.
46     */

47    public static JoinpointClassification WRAPPED = new JoinpointClassification("wrapped");
48    
49    /**
50     * Indicates that the joinpoint must be wrapped inside a code block for interception due
51     * only to dynamic bindings.
52     * This status is necessary to diferentatiate from WRAPPED.
53     * When a joinpoint will be wrapped due to a dynamic aop operation, considering
54     * the class containing the joinpoint is being loaded after the dynamic operation was
55     * performed, and the joinpoint is, for example, a field read, we know we will have to
56     * replace fiel reads in classes already loaded by the field read wrapper. So, this
57     * status is a flag telling: "you may have to replace the joinpoint executions by the
58     * joinpoint wrappers in already loaded classes (only in hot swap enabled case).
59     */

60    public static JoinpointClassification DYNAMICALY_WRAPPED = new JoinpointClassification(WRAPPED, "dynamicaly wrapped");
61
62
63    /** The classification description */
64    private String JavaDoc description;
65    private boolean dynamicAop;
66    private JoinpointClassification counterPart;
67    
68    /**
69     * Private constructor (singleton class).
70     * @param description classification description.
71     */

72    private JoinpointClassification(String JavaDoc description) {
73       this.description = description;
74       this.dynamicAop = false;
75    }
76
77    /**
78     * Private constructor (singleton class).
79     * @param description classification description.
80     */

81    private JoinpointClassification(JoinpointClassification counterpart, String JavaDoc description) {
82       this(description);
83       this.counterPart = counterpart;
84       this.dynamicAop = true;
85    }
86    
87    /**
88     * Returns a description of the joinpoint classification.
89     */

90    public String JavaDoc toString() {
91       return this.description;
92    }
93    
94    public boolean equals(Object JavaDoc other)
95    {
96       if (other == counterPart)
97       {
98          return true;
99       }
100       return super.equals(other);
101    }
102 }
Popular Tags