View Javadoc

1   /*
2    *  Copyright (c) 2005, 2006 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    */
8   
9   
10  package it.imolinfo.jbi4cics.jbi.xfire;
11  
12  import it.imolinfo.jbi4cics.Logger;
13  import it.imolinfo.jbi4cics.LoggerFactory;
14  import javax.jbi.component.ComponentContext;
15  import org.codehaus.xfire.handler.LocateBindingHandler;
16  import org.codehaus.xfire.service.Service;
17  import org.codehaus.xfire.soap.SoapTransport;
18  import org.codehaus.xfire.soap.handler.SoapBodyHandler;
19  import org.codehaus.xfire.transport.AbstractTransport;
20  import org.codehaus.xfire.transport.Channel;
21  import org.codehaus.xfire.transport.DefaultEndpoint;
22  import org.codehaus.xfire.wsdl11.WSDL11Transport;
23  
24  /**
25   * Simple jbi transport, similar to local transport, but without soap encoding.
26   * #TODO Questa classe dovrebbe sparire se decidono di mettere la classe in
27   * common
28   */
29  public class JbiTransport extends AbstractTransport
30          implements WSDL11Transport, SoapTransport {
31  
32      public static final String JBI_BINDING
33              = "http://java.sun.com/xml/ns/jbi/binding/service+engine";
34  
35      /**
36       * The logger for this class and its instances.
37       */
38      private static final Logger LOG
39              = LoggerFactory.getLogger(JbiTransport.class);
40  
41      private static final String URI_PREFIX = "urn:xfire:transport:jbi:";
42  
43      /**
44       * The hash code value returned by the instances of this class.
45       *
46       * @see #hashCode()
47       */
48      private static final int HASH_CODE = 61;
49  
50      private ComponentContext context;
51  
52      public JbiTransport(ComponentContext context) {
53          addInHandler(new LocateBindingHandler());
54          addInHandler(new SoapBodyHandler());
55          this.context = context;
56      }
57  
58      public String getName() {
59          return "JBI";
60      }
61  
62      public String getServiceURL(Service service) {
63          return "jbi://" + service.getName();
64      }
65  
66      protected Channel createNewChannel(String uri) {
67          JbiChannel c;
68  
69          if (LOG.isDebugEnabled()) {
70              LOG.debug("Creating new channel for uri: " + uri);
71          }
72          c = new JbiChannel(uri, this);
73          c.setEndpoint(new DefaultEndpoint());
74          return c;
75      }
76  
77      protected String getUriPrefix() {
78          return URI_PREFIX;
79      }
80  
81      @Override
82      public String[] getSupportedBindings() {                    // Overridden
83          return new String[] { JBI_BINDING };
84      }
85  
86      public String[] getKnownUriSchemes() {
87          return new String[] { "jbi://" };
88      }
89  
90      public ComponentContext getContext() {
91          return context;
92      }
93  
94      /**
95       * Indicates whether some other object is "equal to" this one.
96       *
97       * @param   obj   the reference object with which to compare.
98       * @return  <code>true</code> if and only if <code>obj</code> is an instance
99       *          of <code>JbiTransport</code> class; <code>false</code>
100      *          otherwise.
101      * @see     #hashCode()
102      */
103     @Override
104     public boolean equals(Object obj) {                         // Overridden
105         return (obj instanceof JbiTransport);
106     }
107 
108     /**
109      * Returns a hash code value for the object.
110      *
111      * @return  a hash code value for this object.
112      * @see     #equals(Object)
113      */
114     @Override
115     public int hashCode() {                                     // Overridden
116         return HASH_CODE;
117     }
118 }