KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > container > config > aspect > AopInterceptorsXmlLoader


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

16     package com.jdon.container.config.aspect;
17     
18     import java.util.Iterator JavaDoc;
19     import java.util.List JavaDoc;
20     import java.util.Map JavaDoc;
21     
22     import org.jdom.Element;
23     
24 import com.jdon.container.config.ComponentMetaDef;
25     import com.jdon.controller.config.XmlParser;
26     import com.jdon.util.Debug;
27     
28     /**
29      * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
30      *
31      */

32     public class AopInterceptorsXmlLoader extends XmlParser {
33         
34         public final static String JavaDoc module = AopInterceptorsXmlLoader.class.getName();
35     
36         public void parse(Element root, Map JavaDoc mps) throws Exception JavaDoc {
37             List JavaDoc interceptors = root.getChildren("interceptor");
38             Debug.logVerbose("[JdonFramework] found interceptor size:" + interceptors.size(), module);
39             Iterator JavaDoc iter = interceptors.iterator();
40             
41             ComponentMetaDef componentMetaDef;
42             
43             while (iter.hasNext()) {
44               Element component = (Element) iter.next();
45               String JavaDoc name = component.getAttributeValue("name");
46               Debug.logVerbose("[JdonFramework] found interceptor name:" + name, module);
47               String JavaDoc className = component.getAttributeValue("class");
48               String JavaDoc pointcut = component.getAttributeValue("pointcut");
49               List JavaDoc mappings = component.getChildren("constructor");
50               String JavaDoc[] constructors = null;
51               if ((mappings != null) && (mappings.size() != 0)) {
52                   constructors = new String JavaDoc[mappings.size()];
53                   int j = 0;
54                   Iterator JavaDoc i = mappings.iterator();
55                   while (i.hasNext()) {
56                     Element constructor = (Element) i.next();
57                     String JavaDoc value = constructor.getAttributeValue("value");
58                     Debug.logVerbose("[JdonFramework] interceptor "+ name + "constructor=" + value, module);
59                     constructors[j] = value;
60                     j++;
61                   }
62                 }
63     
64               if (constructors != null)
65                   componentMetaDef = new AspectComponentsMetaDef(name, className, constructors, pointcut);
66               else
67                   componentMetaDef = new AspectComponentsMetaDef(name, className, pointcut);
68               
69               mps.put(name, componentMetaDef);
70             }
71           }
72         
73       
74     }
75
Popular Tags