KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > system > metadata > ServiceAttributeMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, 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.system.metadata;
23
24 import java.util.Set JavaDoc;
25
26 import org.jboss.dependency.spi.ControllerState;
27 import org.jboss.deployment.DeploymentException;
28 import org.jboss.util.UnreachableStatementException;
29
30 /**
31  * ServiceAttributeMetaData.
32  *
33  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
34  * @version $Revision: 1.1 $
35  */

36 public class ServiceAttributeMetaData extends AbstractMetaDataVisitorNode
37 {
38    /** The attribute name */
39    private String JavaDoc name;
40    
41    /** Whether to trim the value */
42    private boolean trim;
43    
44    /** Whether to do property replacement */
45    private boolean replace;
46    
47    /** The value */
48    private ServiceValueMetaData value;
49
50    /**
51     * Get the name.
52     *
53     * @return the name.
54     */

55    public String JavaDoc getName()
56    {
57       return name;
58    }
59
60    /**
61     * Set the name.
62     *
63     * @param name the name.
64     */

65    public void setName(String JavaDoc name)
66    {
67       if (name == null)
68          throw new IllegalArgumentException JavaDoc("Null name");
69       this.name = name;
70    }
71
72    /**
73     * Get the replace.
74     *
75     * @return the replace.
76     */

77    public boolean isReplace()
78    {
79       return replace;
80    }
81
82    /**
83     * Set the replace.
84     *
85     * @param replace the replace.
86     */

87    public void setReplace(boolean replace)
88    {
89       this.replace = replace;
90    }
91
92    /**
93     * Get the trim.
94     *
95     * @return the trim.
96     */

97    public boolean isTrim()
98    {
99       return trim;
100    }
101
102    /**
103     * Set the trim.
104     *
105     * @param trim the trim.
106     */

107    public void setTrim(boolean trim)
108    {
109       this.trim = trim;
110    }
111
112    /**
113     * Get the value.
114     *
115     * @return the value.
116     */

117    public ServiceValueMetaData getValue()
118    {
119       return value;
120    }
121
122    /**
123     * Set the value.
124     *
125     * @param value the value.
126     */

127    public void setValue(ServiceValueMetaData value)
128    {
129       if (value == null)
130          throw new IllegalArgumentException JavaDoc("Null value");
131       this.value = value;
132    }
133    
134    /**
135     * Get the value
136     *
137     * @param valueContext the value context
138     * @return the value
139     * @throws Exception for any error
140     */

141    public Object JavaDoc getValue(ServiceValueContext valueContext) throws Exception JavaDoc
142    {
143       valueContext.setTrim(isTrim());
144       valueContext.setReplace(isReplace());
145       try
146       {
147          return value.getValue(valueContext);
148       }
149       catch (Throwable JavaDoc t)
150       {
151          DeploymentException.rethrowAsDeploymentException("Error configuring attribute " + name, t);
152          throw new UnreachableStatementException();
153       }
154    }
155    
156    public void visit(ServiceMetaDataVisitor visitor)
157    {
158       visitor.setContextState(ControllerState.CONFIGURED);
159       visitor.visit(this);
160    }
161
162    protected void addChildren(Set JavaDoc<ServiceMetaDataVisitorNode> children)
163    {
164       children.add(value);
165    }
166 }
167
Popular Tags