KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > util > FindbyDeployerContext


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.util;
27
28 import org.objectweb.openccm.descriptor.componentassembly.Findby;
29 import org.objectweb.openccm.descriptor.componentassembly.beans.FindbyBean;
30 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*;
31 import org.omg.Components.HomeFinder;
32 import org.omg.CosNaming.NamingContextExt JavaDoc;
33
34 /**
35  * The findby deployer context defines all the connection requires for
36  * the reference resolution, inluding homefinder service, nameservice...
37  *
38  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
39  *
40  * @version 0.1
41  */

42 public class FindbyDeployerContext
43        extends ChildDeployerContext
44     {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50
private FindbyBean findby;
51     // ==================================================================
52
//
53
// Constructors.
54
//
55
// ==================================================================
56
// ==================================================================
57
//
58
// Internal methods.
59
//
60
// ==================================================================
61
// ==================================================================
62
//
63
// Public methods.
64
//
65
// ==================================================================
66
public void
67     connectFindby(FindbyBean findby)
68     {
69         this.findby=findby;
70         connectDeployerDescription(findby);
71     }
72
73     public Findby
74     getFindby()
75     {
76         return findby;
77     }
78     
79     public NamingContextExt JavaDoc
80     getNamingContextExt()
81     {
82         return getRootDeployerContext().getNamingContextExt();
83     }
84     
85     public HomeFinder
86     getHomeFinder()
87     {
88         return getRootDeployerContext().getHomefinder();
89     }
90     
91     /**
92      * This initialization method is used to check that all the services and
93      * information required to deploy are presents. If all is OK the deployer
94      * is put in inactive deployer state waiting for the deployment processing.
95      *
96      * @exception InitializationError is thrown if a problem is detected
97      */

98     public void
99     initialize()
100     throws InitializationError
101     {
102         if (getFindby() == null)
103             getErrorManager().submitException(
104                 new InitializationError(
105                     this,
106                     "Connection on findby bean is required"
107                         + "check the handler code it must specify this connection"));
108
109         if (getFindby().getHomefinder() != null) {
110             if (getFindby().getHomefinder().getName() == null
111                 || getFindby().getHomefinder().getName().length() == 0)
112                 getErrorManager().submitException(
113                     new InitializationError(
114                         this,
115                         "The name attribute of homefinder element must be"
116                             + "fullfilled check the homefinder element"
117                             + "description\n."
118                             + getStringifiedDeployerDescription()));
119             if (getHomeFinder() == null)
120                 getErrorManager().submitException(
121                     new InitializationError(
122                         this,
123                         "Connection on the current HomeFinder is required to make"
124                             + "HomeFinder lookup, change your findby description if"
125                             + "HomeFinder is not started.\n"
126                             + getStringifiedDeployerDescription()));
127         }
128         if (getFindby().getHomefinder() != null) {
129             if (getFindby().getNamingservice().getName() == null
130                 || getFindby().getNamingservice().getName().length() == 0)
131                 getErrorManager().submitException(
132                     new InitializationError(
133                         this,
134                         "The name attribute of namingservice element must be"
135                             + "fullfilled check the findby element"
136                             + "description\n."
137                             + getStringifiedDeployerDescription()));
138             if (getNamingContextExt() == null)
139                 getErrorManager().submitException(
140                     new InitializationError(
141                         this,
142                         "Connection on the current NameService is required to make"
143                             + "NamingService lookup, change your findby description if"
144                             + "NameService is not started.\n"
145                             + getStringifiedDeployerDescription()));
146         }
147         if (getFindby().getStringifiedobjectref() != null
148             && getFindby().getStringifiedobjectref().getValue().length() == 0)
149             getErrorManager().submitException(
150                 new InitializationError(
151                     this,
152                     "The stringifiedobjectref data must be"
153                         + "fullfilled check the findby element"
154                         + "description\n."
155                         + getStringifiedDeployerDescription()));
156
157         getLifeCycleManager().stepEndedSuccessFully();
158     }
159 }
160
Popular Tags