KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > container > visitor > ComponentOriginalVisitor


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.visitor;
17
18 import com.jdon.container.ContainerWrapper;
19 import com.jdon.container.access.TargetMetaRequest;
20 import com.jdon.container.finder.ContainerCallback;
21 import com.jdon.container.visitor.data.SessionContext;
22 import com.jdon.util.Debug;
23
24 /**
25  *
26  * original impleplements for target service components that will be cached
27  *
28  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
29  *
30  */

31 public class ComponentOriginalVisitor implements ComponentVisitor{
32     private final static String JavaDoc module = ComponentOriginalVisitor.class.getName();
33         
34     private ContainerCallback containerCallback;
35     public ComponentOriginalVisitor(ContainerCallback containerCallback) {
36         this.containerCallback = containerCallback;
37     }
38     
39     
40     
41     /**
42      * @return Returns the containerWrapper.
43      */

44     public ContainerWrapper getContainerWrapper() {
45         return containerCallback.getContainerWrapper();
46     }
47     /**
48      * find the visitable component from container,
49      * and execute it's accept method, the return result
50      * is the tager service object.
51      *
52      */

53     public Object JavaDoc visit(TargetMetaRequest targetMetaRequest){
54         Object JavaDoc o = null;
55         try{
56             ContainerWrapper containerWrapper = containerCallback.getContainerWrapper();
57             Debug.logVerbose("[JdonFramework] ComponentOriginalVisitor active:" + targetMetaRequest.getVisitableName(), module);
58             Visitable vo = (Visitable)containerWrapper.lookup(targetMetaRequest.getVisitableName());
59             o = vo.accept(targetMetaRequest);
60         }catch(Exception JavaDoc ex){
61             Debug.logError("[JdonFramework] ComponentOriginalVisitor active error: " + ex);
62         }
63         return o;
64     }
65     
66     public SessionContext visitSessionContext(TargetMetaRequest targetMetaRequest){
67         return (SessionContext)visit(targetMetaRequest);
68     }
69
70 }
71
Popular Tags