001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: JClassInterceptor.java 2059 2007-11-22 17:22:33Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.deployment.annotations;
025:
026: /**
027: * This class defines a Bean interceptor with the name of the class and the
028: * method which is the interceptor.
029: * @author Florent Benoit
030: */
031: public class JClassInterceptor {
032:
033: /**
034: * String name of the class (internal name) where is the interceptor.
035: */
036: private String className = null;
037:
038: /**
039: * Method with @{@link javax.interceptor.AroundInvoke} annotation.
040: */
041: private JMethod jMethod = null;
042:
043: /**
044: * NO ID.
045: */
046: private static final int NO_ID = -1;
047:
048: /**
049: * Id of this interceptor (0 = no id).
050: */
051: private int id = NO_ID;
052:
053: /**
054: * Constructor.
055: * @param className String name of the class (internal name).
056: * @param jMethod the method with aroundInvoke annotation.
057: * @param id the id of this interceptor
058: */
059: public JClassInterceptor(final String className,
060: final JMethod jMethod, final int id) {
061: this .className = className;
062: this .jMethod = jMethod;
063: this .id = id;
064: }
065:
066: /**
067: * Constructor.
068: * @param className String name of the class (internal name).
069: * @param jMethod the method with aroundInvoke annotation.
070: */
071: public JClassInterceptor(final String className,
072: final JMethod jMethod) {
073: this (className, jMethod, NO_ID);
074: }
075:
076: /**
077: * @return class (internal name) where is the interceptor.
078: */
079: public String getClassName() {
080: return className;
081: }
082:
083: /**
084: * @return Method with @{@link javax.interceptor.AroundInvoke} annotation
085: */
086: public JMethod getJMethod() {
087: return jMethod;
088: }
089:
090: /**
091: * Equals method.
092: * @param another object to compare.
093: * @return true if the objects are the same.
094: */
095: @Override
096: public boolean equals(final Object another) {
097: if (!(another instanceof JClassInterceptor)) {
098: return false;
099: }
100: JClassInterceptor anotherItcp = (JClassInterceptor) another;
101: if (id == NO_ID) {
102: return (anotherItcp.className.equals(className) && anotherItcp.jMethod
103: .equals(jMethod));
104: }
105: return (anotherItcp.className.equals(className)
106: && anotherItcp.jMethod.equals(jMethod) && anotherItcp.id == id);
107: }
108:
109: /**
110: * @return hashCode of the object.
111: */
112: @Override
113: public int hashCode() {
114: return className.hashCode() + jMethod.hashCode();
115: }
116:
117: }
|