01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.woody.binding;
18:
19: import org.apache.cocoon.woody.binding.JXPathBindingManager.Assistant;
20: import org.apache.cocoon.woody.util.DomHelper;
21: import org.w3c.dom.Element;
22:
23: /**
24: * InsertBeanJXPathBindingBuilder provides a helper class for the Factory
25: * implemented in {@link JXPathBindingManager} that helps construct the
26: * actual {@link InsertBeanJXPathBinding} out of the configuration in the
27: * provided configElement which looks like:
28: * <pre><code>
29: * <wb:insert-bean classname="..child-bean-class.." addmethod="..method-to-add.."/>
30: * </code></pre>
31: *
32: * @version CVS $Id: InsertBeanJXPathBindingBuilder.java 433543 2006-08-22 06:22:54Z crossley $
33: */
34: public class InsertBeanJXPathBindingBuilder extends
35: JXPathBindingBuilderBase {
36:
37: /**
38: * Creates an instance of {@link InsertBeanJXPathBinding} configured
39: * with the nested template of the bindingElm.
40: */
41: public JXPathBindingBase buildBinding(Element bindingElm,
42: Assistant assistant) throws BindingException {
43:
44: try {
45: CommonAttributes commonAtts = JXPathBindingBuilderBase
46: .getCommonAttributes(bindingElm);
47:
48: String className = DomHelper.getAttribute(bindingElm,
49: "classname");
50: String addMethod = DomHelper.getAttribute(bindingElm,
51: "addmethod");
52:
53: return new InsertBeanJXPathBinding(commonAtts, className,
54: addMethod);
55: } catch (BindingException e) {
56: throw e;
57: } catch (Exception e) {
58: throw new BindingException(
59: "Error building a insert-bean binding defined at "
60: + DomHelper.getLocation(bindingElm), e);
61: }
62: }
63: }
|