KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > beans > metadata > plugins > AbstractDependencyMetaData


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.beans.metadata.plugins;
23
24 import java.util.Iterator JavaDoc;
25
26 import org.jboss.beans.metadata.spi.DependencyMetaData;
27 import org.jboss.beans.metadata.spi.MetaDataVisitor;
28 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
29 import org.jboss.dependency.plugins.AbstractDependencyItem;
30 import org.jboss.dependency.spi.ControllerState;
31 import org.jboss.dependency.spi.DependencyItem;
32 import org.jboss.kernel.spi.dependency.KernelControllerContext;
33 import org.jboss.util.JBossObject;
34 import org.jboss.util.JBossStringBuilder;
35
36 /**
37  * A dependency.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 56022 $
41  */

42 public class AbstractDependencyMetaData extends JBossObject implements DependencyMetaData
43 {
44    /** The dependency */
45    protected Object JavaDoc dependency;
46
47    /**
48     * Create a new dependency
49     */

50    public AbstractDependencyMetaData()
51    {
52    }
53
54    /**
55     * Create a new dependency
56     *
57     * @param dependency the dependency
58     */

59    public AbstractDependencyMetaData(Object JavaDoc dependency)
60    {
61       this.dependency = dependency;
62    }
63    
64    /**
65     * Set the dependency
66     *
67     * @param dependency the dependency
68     */

69    public void setDependency(Object JavaDoc dependency)
70    {
71       this.dependency = dependency;
72       flushJBossObjectCache();
73    }
74
75    public Object JavaDoc getDependency()
76    {
77       return dependency;
78    }
79
80    public void initialVisit(MetaDataVisitor visitor)
81    {
82       KernelControllerContext context = visitor.getControllerContext();
83       DependencyItem item = new LifecycleDependencyItem(context.getName(), ControllerState.CREATE);
84       visitor.addDependency(item);
85       item = new LifecycleDependencyItem(context.getName(), ControllerState.START);
86       visitor.addDependency(item);
87
88       visitor.initialVisit(this);
89    }
90
91    public void describeVisit(MetaDataVisitor vistor)
92    {
93       vistor.describeVisit(this);
94    }
95
96    public Iterator JavaDoc<? extends MetaDataVisitorNode> getChildren()
97    {
98       return null;
99    }
100    
101    public void toString(JBossStringBuilder buffer)
102    {
103       buffer.append("dependency=").append(dependency);
104    }
105    
106    public void toShortString(JBossStringBuilder buffer)
107    {
108       buffer.append(dependency);
109    }
110    
111    /**
112     * A LifecycleDependencyItem.
113     */

114    public class LifecycleDependencyItem extends AbstractDependencyItem
115    {
116       /**
117        * Create a new LifecycleDependencyItem.
118        *
119        * @param name the name
120        * @param state the state
121        */

122       public LifecycleDependencyItem(Object JavaDoc name, ControllerState state)
123       {
124          super(name, dependency, state, state);
125       }
126    }
127 }
128
Popular Tags