KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > xfire > transport > MuleLocalTransport


1 /*
2  * $Id: MuleLocalTransport.java 3937 2006-11-20 16:04:25Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.soap.xfire.transport;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.codehaus.xfire.service.Service;
16 import org.codehaus.xfire.soap.SoapTransport;
17 import org.codehaus.xfire.soap.SoapTransportHelper;
18 import org.codehaus.xfire.transport.AbstractTransport;
19 import org.codehaus.xfire.transport.Channel;
20 import org.codehaus.xfire.transport.DefaultEndpoint;
21 import org.codehaus.xfire.transport.MapSession;
22 import org.codehaus.xfire.transport.Session;
23 import org.codehaus.xfire.wsdl11.WSDL11Transport;
24 import org.mule.providers.soap.xfire.MuleInvoker;
25 import org.mule.umo.manager.UMOWorkManager;
26
27 /**
28  * TODO document
29  */

30 public class MuleLocalTransport extends AbstractTransport implements SoapTransport, WSDL11Transport
31 {
32     public static final String JavaDoc BINDING_ID = "urn:xfire:transport:local";
33     public static final String JavaDoc URI_PREFIX = "xfire.local://";
34
35     /**
36      * logger used by this class
37      */

38     protected transient Log logger = LogFactory.getLog(getClass());
39
40     private Session session;
41     private boolean maintainSession;
42     protected final UMOWorkManager workManager;
43
44     public MuleLocalTransport(UMOWorkManager workManager)
45     {
46         super();
47         SoapTransportHelper.createSoapTransport(this);
48         this.workManager = workManager;
49     }
50
51     public String JavaDoc getServiceURL(Service service)
52     {
53         String JavaDoc ep = ((MuleInvoker)service.getInvoker()).getEndpoint().getEndpointURI().getAddress();
54         return ep + "/" + service.getSimpleName();
55     }
56
57     protected Channel createNewChannel(String JavaDoc uri)
58     {
59         logger.debug("Creating new channel for uri: " + uri);
60
61         MuleLocalChannel c = new MuleLocalChannel(uri, this, session);
62         c.setWorkManager(workManager);
63         c.setEndpoint(new DefaultEndpoint());
64
65         return c;
66     }
67
68     public void setMaintainSession(boolean maintainSession)
69     {
70         this.maintainSession = maintainSession;
71         resetSession();
72     }
73
74     public void resetSession()
75     {
76         if (maintainSession)
77         {
78             session = new MapSession();
79         }
80         else
81         {
82             session = null;
83         }
84     }
85
86     protected String JavaDoc getUriPrefix()
87     {
88         return URI_PREFIX;
89     }
90
91     public String JavaDoc[] getSupportedBindings()
92     {
93         return new String JavaDoc[]{BINDING_ID};
94     }
95
96     public String JavaDoc[] getKnownUriSchemes()
97     {
98         return new String JavaDoc[]{URI_PREFIX};
99     }
100
101     public String JavaDoc getName()
102     {
103         return "Local";
104     }
105
106     public String JavaDoc[] getSoapTransportIds()
107     {
108         return new String JavaDoc[]{BINDING_ID};
109     }
110 }
111
Popular Tags