KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > jtests > conform > basic > server > BasicMultiObject


1 /**
2  * Copyright (C) 2002,2005 - INRIA (www.inria.fr)
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
5  *
6  * This library is developed inside the ObjectWeb Consortium,
7  * http://www.objectweb.org
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  *
24  * --------------------------------------------------------------------------
25  * $Id: BasicMultiObject.java,v 1.5 2005/02/11 11:02:51 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.jtests.conform.basic.server;
29
30 import java.rmi.RemoteException JavaDoc;
31
32 import javax.naming.InitialContext JavaDoc;
33 import javax.rmi.PortableRemoteObject JavaDoc;
34
35 /**
36  * Class <code>BasicMultiObject</code> is a basic remote object with reference
37  * to another object
38  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
39  */

40 public class BasicMultiObject extends PortableRemoteObject JavaDoc implements BasicMultiObjectItf {
41
42     /**
43      * Constructor
44      * @throws RemoteException (super constructor)
45      */

46     public BasicMultiObject() throws RemoteException JavaDoc {
47         super();
48     }
49
50     /**
51      * Basic multi method this method get the name for the BasicObjectItf from
52      * jndi and return the result of getSting added with a multi
53      * @return String "string"
54      * @throws RemoteException if lookup/narrow fails
55      */

56     public String JavaDoc getMultiString() throws RemoteException JavaDoc {
57         try {
58             // set the object name
59
String JavaDoc basicName = "basicname";
60             InitialContext JavaDoc ic = new InitialContext JavaDoc();
61             BasicObjectItf ob = (BasicObjectItf) PortableRemoteObject
62                     .narrow(ic.lookup(basicName), BasicObjectItf.class);
63
64             return "multi string call: " + ob.getString();
65         } catch (Exception JavaDoc e) {
66             e.printStackTrace();
67             throw new RemoteException JavaDoc("" + e);
68         }
69     }
70
71     /**
72      * Basic multi method this method get the BasicObjectItf stub
73      * @return BasicObjectItf
74      * @throws RemoteException if lookup/narrow fails
75      */

76     public BasicObjectItf getBasicObject() throws RemoteException JavaDoc {
77         try {
78             // set the object name
79
String JavaDoc basicName = "basicname";
80             InitialContext JavaDoc ic = new InitialContext JavaDoc();
81             return (BasicObjectItf) PortableRemoteObject.narrow(ic.lookup(basicName), BasicObjectItf.class);
82
83         } catch (Exception JavaDoc e) {
84             e.printStackTrace();
85             throw new RemoteException JavaDoc("" + e);
86         }
87     }
88
89     /**
90      * Basic Ref String, method this method get the BasicObjectItf stub
91      * @return String of the reference
92      * @throws RemoteException if lookup/narrow fails
93      */

94     public String JavaDoc getBasicRefString() throws RemoteException JavaDoc {
95         try {
96             // set the object name
97
String JavaDoc basicRefName = "basicrefname";
98             InitialContext JavaDoc ic = new InitialContext JavaDoc();
99             return ((BasicObjectRef) PortableRemoteObject.narrow(ic.lookup(basicRefName), BasicObjectRef.class))
100                     .toString();
101         } catch (Exception JavaDoc e) {
102             throw new RemoteException JavaDoc("" + e);
103         }
104     }
105
106 }
Popular Tags