KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > body > jini > ProActiveJiniMetaObjectFactory


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.core.body.jini;
32
33 import org.objectweb.proactive.core.ProActiveException;
34 import org.objectweb.proactive.core.ProActiveRuntimeException;
35 import org.objectweb.proactive.core.body.ProActiveMetaObjectFactory;
36 import org.objectweb.proactive.core.body.RemoteBodyFactory;
37 import org.objectweb.proactive.core.body.UniversalBody;
38
39
40 /**
41  * <p>
42  * This class provides singleton instances of all default factories
43  * creating MetaObjects used in the Body.
44  * </p>
45  * <p>
46  * One can inherit from this class in order to provide custom implementation
47  * of one or several factories. This class provide a default implementation that
48  * makes the factories a singleton. One instance of each mata object factory is
49  * created when this object is built and the same instance is returned each time
50  * somebody ask for an instance.
51  * </p>
52  * <p>
53  * In order to change one meta object factory following that singleton pattern,
54  * only the protected method <code>newXXXSingleton</code> has to be overwritten.
55  * The method <code>newXXXSingleton</code> is guarantee to be called only once at
56  * construction time of this object.
57  * </p>
58  * <p>
59  * In order to change one meta object factory that does not follow the singleton
60  * pattern, the public method <code>newXXX</code> has to be overwritten in order
61  * to return a new instance of the factory each time. The default implementation
62  * of each <code>newXXX</code> method if to return the singleton instance of the
63  * factory created from <code>newXXXSingleton</code> method call.
64  * </p>
65  * <p>
66  * Each sub class of this class should be implemented as a singleton and provide
67  * a static method <code>newInstance</code> for this purpose.
68  * </p>
69  *
70  * @author ProActive Team
71  * @version 1.0, 2002/05
72  * @since ProActive 0.9.2
73  */

74 public class ProActiveJiniMetaObjectFactory extends ProActiveMetaObjectFactory implements java.io.Serializable JavaDoc {
75
76   //
77
// -- PRIVATE MEMBERS -----------------------------------------------
78
//
79

80   
81
82   //
83
// -- PROTECTED MEMBERS -----------------------------------------------
84
//
85

86
87   
88   //
89
// -- CONSTRUCTORS -----------------------------------------------
90
//
91

92
93
94   //
95
// -- PUBLICS METHODS -----------------------------------------------
96
//
97

98
99
100   //
101
// -- PROTECTED METHODS -----------------------------------------------
102
//
103

104
105
106   protected RemoteBodyFactory newRemoteBodyFactorySingleton() {
107     return new RemoteJiniBodyFactoryImpl();
108   }
109
110
111
112   //
113
// -- INNER CLASSES -----------------------------------------------
114
//
115

116
117
118   protected static class RemoteJiniBodyFactoryImpl implements RemoteBodyFactory, java.io.Serializable JavaDoc {
119     public UniversalBody newRemoteBody(UniversalBody body) {
120       try {
121      // System.out.println("Creating ibis remote body adapter");
122
return new JiniBodyAdapter(body);
123       } catch (ProActiveException e) {
124           throw new ProActiveRuntimeException("Cannot create Jini Remote body adapter ", e);
125       }
126     }
127   } // end inner class RemoteBodyFactoryImpl
128

129
130
131
132 }
133
Popular Tags