KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > binder > EmitsportDeployer


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Briclet Frédéric.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.binder;
27
28 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.util.CannotResolveReferenceException;
29 import org.omg.CORBA.Object JavaDoc;
30 import org.omg.Components.AlreadyConnected;
31 import org.omg.Components.CCMObject;
32 import org.omg.Components.EventConsumerBase;
33 import org.omg.Components.InvalidConnection;
34 import org.omg.Components.InvalidName;
35 import org.omg.Components.NoConnection;
36
37 /**
38  * The emitsport deployer is in charge to resolve the emits port
39  * involve in the event connection.
40  *
41  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
42  *
43  * @version 0.1
44  */

45 public class EmitsportDeployer
46        extends EmitsportDeployerContext
47     {
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53
private CCMObject emitter;
54     // ==================================================================
55
//
56
// Constructors.
57
//
58
// ==================================================================
59
// ==================================================================
60
//
61
// Internal methods.
62
//
63
// ==================================================================
64
// ==================================================================
65
//
66
// Public methods.
67
//
68
// ==================================================================
69
/**
70      * This method return the component emitter involve in the event connection.
71      * @return the component emitter
72      * @exception CannotResolveReferenceException is thrown if the emitter is not found
73      */

74     private org.omg.Components.CCMObject
75     getCCMObjectEmitter()
76     throws CannotResolveReferenceException
77     
78     {
79         Object JavaDoc ccm;
80         if(getComponentinstantiationDeployer()!=null)
81              ccm =getComponentinstantiationDeployer().getComponent();
82         else ccm=getFindbyDeployer().resolveReference();
83         
84         return org.omg.Components.
85               CCMObjectHelper.narrow(ccm);
86     }
87     /**
88      * Connect the given @param consumedObject to the current event producer.
89      *
90      * @param consumedObject The consumer object to connect
91      * @throws CannotResolveReferenceException is thrown if the emitter is not found
92      * @throws Invalidname if the precised emiter port name is invalid
93      */

94     public void
95     connectEmiterToConsumer(EventConsumerBase consumedObject)
96     throws CannotResolveReferenceException,
97            InvalidName,
98            AlreadyConnected,
99            InvalidConnection
100     {
101         emitter=getCCMObjectEmitter();
102         emitter.connect_consumer(getEmitsport()
103                                 .getEmitsidentifier()
104                                 .getValue()
105                                  ,consumedObject);
106     }
107     /**
108      * Disconnect the previously connected consumer.
109      *
110      * @throws NoConnection is thrown if the connection is already down
111      */

112     public void
113     disconnectConsumer()
114     throws InvalidName,
115            NoConnection
116     {
117         emitter.disconnect_consumer(getEmitsport()
118         .getEmitsidentifier()
119         .getValue());
120     }
121         
122
123 }
124
Popular Tags