~ubuntu-branches/ubuntu/oneiric/libjboss-remoting-java/oneiric

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpHandler.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************
 
2
 *                                     *
 
3
 *  JBoss: The OpenSource J2EE WebOS   *
 
4
 *                                     *
 
5
 *  Distributable under LGPL license.  *
 
6
 *  See terms of license at gnu.org.   *
 
7
 *                                     *
 
8
 ***************************************/
 
9
package org.jboss.test.remoting.performance.spring.http.web;
 
10
 
 
11
import org.jboss.remoting.callback.Callback;
 
12
import org.jboss.remoting.callback.HandleCallbackException;
 
13
import org.jboss.remoting.callback.InvokerCallbackHandler;
 
14
import org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer;
 
15
import org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer;
 
16
import org.springframework.beans.factory.BeanFactory;
 
17
import org.springframework.beans.factory.xml.XmlBeanFactory;
 
18
import org.springframework.core.io.ClassPathResource;
 
19
import org.springframework.core.io.Resource;
 
20
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
 
21
 
 
22
/**
 
23
 * @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
 
24
 */
 
25
public class SpringHttpHandler implements InvokerCallbackHandler
 
26
{
 
27
   private SpringHttpCallbackServer springHttpCallbackServer;
 
28
   private String sessionId;
 
29
 
 
30
   public SpringHttpHandler(String sessionId)
 
31
   {
 
32
      this.sessionId = sessionId;
 
33
   }
 
34
   
 
35
   public void start()
 
36
   {
 
37
//      Resource res = new ClassPathResource("SpringHttpCallbackServerService.xml", SpringHttpHandler.class);
 
38
//      BeanFactory factory = new XmlBeanFactory(res);
 
39
//      springHttpCallbackServer = (SpringHttpCallbackServer)factory.getBean("springHttpCallbackServerService");
 
40
    
 
41
/*
 
42
      Instead of creating callback server proxies by injection, the following xml declaration is
 
43
      replaced by programmatic creation.  Each callback server is registered under a name
 
44
      ending in the sessionId.
 
45
      
 
46
   <bean id="springHttpCallbackServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
 
47
      <property name="serviceUrl" value="rmi://localhost:1299/SpringHttpCallbackServerService"/>
 
48
      <property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer"/>
 
49
   </bean>
 
50
 */
 
51
      
 
52
      RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
 
53
      factory.setServiceUrl("rmi://localhost:1299/SpringHttpCallbackServerService:" + sessionId);
 
54
      factory.setServiceInterface(org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer.class);
 
55
      try
 
56
      {
 
57
         factory.afterPropertiesSet();
 
58
      }
 
59
      catch (Exception e)
 
60
      {
 
61
         System.out.println("unable to create callback proxy");
 
62
         System.out.println(e);
 
63
      }
 
64
      springHttpCallbackServer = (SpringHttpCallbackServer)factory.getObject(); 
 
65
   }
 
66
 
 
67
   public SpringHttpCallbackServer getSpringHttpCallbackServer()
 
68
   {
 
69
      return springHttpCallbackServer;
 
70
   }
 
71
 
 
72
   public void setSpringHttpCallbackServer(SpringHttpCallbackServer springHttpCallbackServer)
 
73
   {
 
74
      this.springHttpCallbackServer = springHttpCallbackServer;
 
75
   }
 
76
 
 
77
   public void handleCallback(Callback callback) throws HandleCallbackException
 
78
   {
 
79
      System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback);
 
80
 
 
81
      try
 
82
      {
 
83
         springHttpCallbackServer.finishedProcessing(callback);
 
84
      }
 
85
      catch(Exception e)
 
86
      {
 
87
         e.printStackTrace();
 
88
         throw new HandleCallbackException(e.getMessage());
 
89
      }
 
90
   }
 
91
}