KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > controller > service > WebServiceImp


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.controller.service;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19
20 import com.jdon.bussinessproxy.TargetMetaDef;
21 import com.jdon.bussinessproxy.meta.MethodMetaArgs;
22 import com.jdon.container.ContainerWrapper;
23 import com.jdon.container.access.TargetMetaRequest;
24 import com.jdon.container.access.UserTargetMetaDefFactory;
25 import com.jdon.container.finder.ContainerCallback;
26 import com.jdon.util.Debug;
27
28 /**
29  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
30  *
31  */

32 public class WebServiceImp implements Service{
33     
34     private final static String JavaDoc module = WebServiceImp.class.getName();
35     private ContainerCallback containerCallback;
36     private WebServiceAccessor webServiceAccessor;
37     
38     public WebServiceImp(WebServiceAccessor webServiceAccessor,
39                           ContainerCallback containerCallback){
40         this.webServiceAccessor = webServiceAccessor;
41         this.containerCallback = containerCallback;
42     }
43     
44     /**
45      * running the service, and return the result
46      */

47     public Object JavaDoc execute(String JavaDoc name,
48             MethodMetaArgs methodMetaArgs,
49             HttpServletRequest JavaDoc request) throws Exception JavaDoc{
50         if ((methodMetaArgs == null) || (methodMetaArgs.getMethodName() == null)){
51             Debug.logWarning(" methodMetaArgs is null. cann't invoke service.execute");
52         }
53         Debug.logVerbose("++++++++++++++++++++++++++++++<begin: invoking from jdonframework.xml", module);
54         Debug.logVerbose("+++++++++++++++execute new service='"+ name + "' method='" + methodMetaArgs.getMethodName() +"'", module);
55         ContainerWrapper cw = containerCallback.getContainerWrapper();
56         TargetMetaDef targetMetaDef = UserTargetMetaDefFactory.getTargetMetaDef(name, cw);
57         if (targetMetaDef == null) return null;
58         Object JavaDoc result = execute(targetMetaDef, methodMetaArgs, request);
59         Debug.logVerbose("+++++++++++++++execute service='"+ name + "' method='" + methodMetaArgs.getMethodName() + "' successfully!", module);
60         Debug.logVerbose("++++++++++++++++++++++++++++++<end:", module);
61         return result;
62     }
63
64     /**
65      * running the service, and return the result
66      */

67     public Object JavaDoc execute( TargetMetaDef targetMetaDef,
68                           MethodMetaArgs methodMetaArgs,
69                           HttpServletRequest JavaDoc request) throws Exception JavaDoc{
70         Debug.logVerbose("[JdonFramework]enter service execution core ", module);
71         TargetMetaRequest targetMetaRequest = UserTargetMetaDefFactory.create(targetMetaDef, request);
72         targetMetaRequest.setMethodMetaArgs(methodMetaArgs);
73         return webServiceAccessor.execute(targetMetaRequest, request);
74     }
75 }
76
Popular Tags