KickJava   Java API By Example, From Geeks To Geeks.

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


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.Cookie;
33 import org.omg.Components.CookieRequired;
34 import org.omg.Components.ExceededConnectionLimit;
35 import org.omg.Components.InvalidConnection;
36 import org.omg.Components.InvalidName;
37 import org.omg.Components.NoConnection;
38
39 /**
40  * The usesportDeployer is used to resolve a usesport and to establish
41  * the connection with the user.
42  *
43  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
44  *
45  * @version 0.1
46  */

47 public class UsesportDeployer
48        extends UsesportDeployerContext
49     {
50     // ==================================================================
51
//
52
// Internal state.
53
//
54
// ==================================================================
55
private Cookie cookie;
56     private CCMObject user;
57     // ==================================================================
58
//
59
// Constructors.
60
//
61
// ==================================================================
62
// ==================================================================
63
//
64
// Internal methods.
65
//
66
// ==================================================================
67
// ==================================================================
68
//
69
// Public methods.
70
//
71
// ==================================================================
72
/**
73      * The getCCMObjectUser is used to resolve the CCMobject which
74      * have the usesport to connect.
75      *
76      * @return the CCMObject which got the precised usesport
77      * @throws CannotResolveReferenceException if the CCMObject is not founded
78      */

79     public org.omg.Components.CCMObject
80     getCCMobjectUser ()
81     throws CannotResolveReferenceException
82
83      {
84          if(getComponentinstantiationDeployer()!=null)
85              return getComponentinstantiationDeployer().getComponent();
86          return org.omg.Components.
87              CCMObjectHelper.narrow(getFindbyDeployer().resolveReference());
88      }
89      
90     /**
91      * The establishConnection method is used to establish the connection
92      * between the usesport an the provided object
93      *
94      * @return The cookie connection
95      * @throws CannotResolveReferenceException if the CCMObject user is not founded
96      * @throws InvalidName if the precised usesport name is invalid
97      * @throws InvalidConnection if the given providedObject is invalid
98      * @throws AlreadyConnect if the usesport is a simple connection and
99      * it is already connected.
100      * @throws ExceededConnectionLimit if the connection is multiple and have aleady
101      * too many active connections.
102      */

103     public Cookie
104     establishConnection(Object JavaDoc providedObject)
105     throws CannotResolveReferenceException,
106            InvalidName,
107            InvalidConnection,
108            AlreadyConnected,
109            ExceededConnectionLimit
110     {
111         user=getCCMobjectUser();
112         cookie=user.connect(getUsesport().getUsesidentifier().getValue(),providedObject);
113         getLifeCycleManager().stepEndedSuccessFully();
114         return cookie;
115     }
116     
117     /**
118      * Break the current establishes connection.
119      *
120      * @throws InvalidName if the usesport name precised is invalid
121      * @throws InvalidConnection If conenction is invalid
122      * @throws CookieRequired if the cookie given is not valid
123      * @throws NoConnection if there is no connection established.
124      */

125     public void
126     breakConnection()
127     throws InvalidName,
128            InvalidConnection,
129            CookieRequired,
130            NoConnection
131     {
132         user.disconnect(getUsesport().getUsesidentifier().getValue(),cookie);
133         getLifeCycleManager().stepEndedSuccessFully();
134     }
135 }
136
Popular Tags