KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > binding > InsertBeanJXPathBindingBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.woody.binding;
17
18 import org.apache.cocoon.woody.binding.JXPathBindingManager.Assistant;
19 import org.apache.cocoon.woody.util.DomHelper;
20 import org.w3c.dom.Element JavaDoc;
21
22 /**
23  * InsertBeanJXPathBindingBuilder provides a helper class for the Factory
24  * implemented in {@link JXPathBindingManager} that helps construct the
25  * actual {@link InsertBeanJXPathBinding} out of the configuration in the
26  * provided configElement which looks like:
27  * <pre><code>
28  * &lt;wb:insert-bean classname="..child-bean-class.." addmethod="..method-to-add.."/&gt;
29  * </code></pre>
30  *
31  * @version CVS $Id: InsertBeanJXPathBindingBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
32  */

33 public class InsertBeanJXPathBindingBuilder extends JXPathBindingBuilderBase {
34
35     /**
36      * Creates an instance of {@link InsertBeanJXPathBinding} configured
37      * with the nested template of the bindingElm.
38      */

39     public JXPathBindingBase buildBinding(Element JavaDoc bindingElm, Assistant assistant) throws BindingException {
40
41         try {
42             CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
43
44             String JavaDoc className =
45                 DomHelper.getAttribute(bindingElm, "classname");
46             String JavaDoc addMethod =
47                 DomHelper.getAttribute(bindingElm, "addmethod");
48
49             return new InsertBeanJXPathBinding(commonAtts, className, addMethod);
50         } catch (BindingException e) {
51             throw e;
52         } catch (Exception JavaDoc e) {
53             throw new BindingException("Error building a insert-bean binding defined at " + DomHelper.getLocation(bindingElm), e);
54         }
55     }
56 }
57
Popular Tags