KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > advice > AspectDefinition


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.advice;
23
24 /**
25  * Contains definition of aspect or interceptor
26  * Scope defaults to PER_VM if it is null.
27  *
28  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
29  * @version $Revision: 42524 $
30  */

31 public class AspectDefinition
32 {
33    protected String JavaDoc name;
34    protected Scope scope = Scope.PER_VM;
35    protected AspectFactory factory;
36    protected boolean deployed = true;
37
38    /**
39     * @param name
40     * @param scope defaults to PER_VM if null
41     * @param factory
42     */

43    public AspectDefinition(String JavaDoc name, Scope scope, AspectFactory factory)
44    {
45
46       this.name = name;
47       this.scope = scope;
48       this.factory = factory;
49       if (this.scope == null) this.scope = Scope.PER_VM;
50       if (this.name == null) this.name = this.factory.getName();
51    }
52
53    public AspectDefinition() {}
54
55    public void undeploy()
56    {
57       this.deployed = false;
58    }
59
60    public boolean isDeployed()
61    {
62       return deployed;
63    }
64
65    public void setName(String JavaDoc name)
66    {
67       this.name = name;
68    }
69
70    public void setScope(Scope scope)
71    {
72       this.scope = scope;
73    }
74
75    public void setFactory(AspectFactory factory)
76    {
77       this.factory = factory;
78    }
79
80    public AspectFactory getFactory()
81    {
82       return factory;
83    }
84
85    public String JavaDoc getName()
86    {
87       return name;
88    }
89
90    public Scope getScope()
91    {
92       return scope;
93    }
94
95    public int hashCode()
96    {
97       return name.hashCode();
98    }
99
100    public boolean equals(Object JavaDoc obj)
101    {
102       if (obj == this) return true;
103       if (!(obj instanceof AspectDefinition)) return false;
104       return name.equals(((AspectDefinition) obj).name);
105    }
106 }
107
Popular Tags