View Javadoc

1   /*
2    * Copyright (c) 1998-2004 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  package jgroup.test.jini.reggie;
19  
20  import jgroup.core.ConfigManager;
21  import jgroup.jini.LookupManager;
22  import net.jini.core.lookup.ServiceTemplate;
23  
24  import org.apache.log4j.Logger;
25  
26  
27  /**
28   * Simple application to test Reggie.
29   * 
30   * @author Rohnny Moland
31   */
32  public class ReggieHelloClient
33  {
34    ////////////////////////////////////////////////////////////////////////////////////////////
35    // Logger
36    ////////////////////////////////////////////////////////////////////////////////////////////
37  
38    /** Obtain logger for this class */
39    private Logger log = Logger.getLogger(ReggieHelloClient.class);
40  
41  
42    ////////////////////////////////////////////////////////////////////////////////////////////
43    // Fields
44    ////////////////////////////////////////////////////////////////////////////////////////////
45    
46    private ReggieHello reggieHello;
47    
48  
49    ////////////////////////////////////////////////////////////////////////////////////////////
50    // Constructor and main
51    ////////////////////////////////////////////////////////////////////////////////////////////
52  
53    /**
54     *  Instantiates a ReggieHelloClient object.
55     */
56    public static void main(String args[])
57      throws Exception
58    {
59      new ReggieHelloClient();
60  
61      // stay around long enough to receive replies
62      try {
63          Thread.sleep(100000L);
64      } catch(java.lang.InterruptedException e) {
65          // do nothing
66      }
67      
68    }
69    
70    
71    /**
72     *  Constructor invoked by main
73     */
74    public ReggieHelloClient()
75      throws Exception
76    {
77      ConfigManager.init();
78      Class[] types = new Class[] { ReggieHello.class };
79      ServiceTemplate template = new ServiceTemplate(null, types, null);
80      reggieHello = (ReggieHello) LookupManager.lookup(template);
81      
82      log.debug(reggieHello.sayHello());
83    }
84  
85  }