001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@objectweb.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 841 2006-07-12 09:03:06Z benoitf $
023: * --------------------------------------------------------------------------
024: */package com.bm.ejb3metadata.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: * (internal name) where is the interceptor.
078: * @return class (internal name) where is the interceptor.
079: */
080: public String getClassName() {
081: return className;
082: }
083:
084: /**
085: * Method with @{@link javax.interceptor.AroundInvoke} annotation.
086: * @return Method with @{@link javax.interceptor.AroundInvoke} annotation
087: */
088: public JMethod getJMethod() {
089: return jMethod;
090: }
091:
092: /**
093: * Equals method.
094: * @param another object to compare.
095: * @return true if the objects are the same.
096: */
097: @Override
098: public boolean equals(final Object another) {
099: if (!(another instanceof JClassInterceptor)) {
100: return false;
101: }
102: JClassInterceptor anotherItcp = (JClassInterceptor) another;
103: if (id == NO_ID) {
104: return (anotherItcp.className.equals(className) && anotherItcp.jMethod
105: .equals(jMethod));
106: }
107: return (anotherItcp.className.equals(className)
108: && anotherItcp.jMethod.equals(jMethod) && anotherItcp.id == id);
109: }
110:
111: /**
112: * {@inheritDoc}
113: */
114: @Override
115: public int hashCode() {
116: return className.hashCode() + jMethod.hashCode();
117: }
118:
119: }
|