KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > injection > WebServiceRefInjector


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.injection;
23
24 // $Id: WebServiceRefInjector.java 57934 2006-10-31 02:49:01Z scott.stark@jboss.org $
25

26 import javax.naming.Context JavaDoc;
27 import javax.xml.ws.WebServiceException;
28 import javax.xml.ws.WebServiceRef;
29
30 import org.jboss.logging.Logger;
31 import org.jboss.metamodel.descriptor.ServiceRef;
32 import org.jboss.ws.jaxws.injection.WebServiceRefDeployer;
33
34 /**
35  * Inject a jaxws web service ref.
36  *
37  * @author Thomas.Diesler@jboss.com
38  * @version $Revision: 57934 $
39  */

40 public class WebServiceRefInjector implements EncInjector
41 {
42    private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
43
44    private Context JavaDoc ctx;
45    private String JavaDoc name;
46    private Class JavaDoc refType;
47    private String JavaDoc refTypeName;
48    private WebServiceRef wsref;
49    private ServiceRef sref;
50
51    public WebServiceRefInjector(Context JavaDoc ctx, String JavaDoc name, Class JavaDoc refType, WebServiceRef wsref, ServiceRef sref)
52    {
53       this.ctx = ctx;
54       this.name = name;
55       this.refType = refType;
56       this.wsref = wsref;
57       this.sref = sref;
58       this.refTypeName = (refType != null ? refType.getName() : null);
59    }
60
61    public void inject(InjectionContainer container)
62    {
63       try
64       {
65          WebServiceRefDeployer.setupWebServiceRef(ctx, name, refType, wsref, getAdaptedServiceRef());
66          log.debug("@WebServiceRef bound [env=" + name + ",ref=" + refTypeName + "]");
67       }
68       catch (Exception JavaDoc e)
69       {
70          throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + ",type=" + refTypeName + "]", e);
71       }
72    }
73
74    private org.jboss.ws.jaxws.injection.ServiceRef getAdaptedServiceRef()
75    {
76       org.jboss.ws.jaxws.injection.ServiceRef newRef = new org.jboss.ws.jaxws.injection.ServiceRef();
77       newRef.setEncName(sref.getEncName());
78       newRef.setWsdlLocation(sref.getWsdlLocation());
79       newRef.setConfigName(sref.getConfigName());
80       newRef.setConfigFile(sref.getConfigFile());
81       return newRef;
82    }
83
84    public String JavaDoc toString()
85    {
86       return super.toString() + "{enc=" + name + ",type=" + refTypeName + "}";
87    }
88 }
89
Popular Tags