KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > installer > NodeDependencyVisitorDeployer


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.installer;
27
28 import java.util.LinkedList JavaDoc;
29
30 import org.objectweb.openccm.descriptor.softpkg.Dependency;
31 import org.objectweb.openccm.descriptor.softpkg.ccm.CodeDeployer;
32 import org.objectweb.openccm.descriptor.softpkg.ccm.CodeInstallationFailureException;
33 import org.objectweb.openccm.descriptor.softpkg.ccm.DependencyDeployer;
34 import org.objectweb.openccm.descriptor.softpkg.ccm.DependencyResolutionFailureException;
35 import org.omg.Components.ConfigValue;
36 import org.omg.Components.ValueFactoryEntrypoint;
37 import org.omg.Components.valueFactoryEntrypointSeqHelper;
38
39 /**
40  * The NodeDependencyVisitorDeployer implements a visitor able to process
41  * dependency for node target and ECM taget. It also implements a visitor
42  * for the codeDeployer.
43  *
44  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Fr?d?ric</a>
45  *
46  * @version 0.1
47  */

48 public class NodeDependencyVisitorDeployer
49        implements DependencyDeployerVisitor,
50                   CodeDeployerVisitor
51     {
52
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58
private java.util.List JavaDoc config_values;
59     private String JavaDoc entryPoint;
60     // ==================================================================
61
//
62
// Constructors.
63
//
64
// ==================================================================
65
public NodeDependencyVisitorDeployer()
66     {
67         config_values=new LinkedList JavaDoc();
68     }
69     
70     // ==================================================================
71
//
72
// Internal methods.
73
//
74
// ==================================================================
75
// ==================================================================
76
//
77
// Public methods.
78
//
79
// ==================================================================
80
/**
81      * Visitor method for a dependency deployer.
82      *
83      * @param dependencyDeployer the dependency to solve
84      * @throws DependencyResolutionFailureException if the dependency
85      * cannot be solve.
86      */

87     public void
88     visit(DependencyDeployer dependencyDeployer)
89     throws DependencyResolutionFailureException
90     {
91         
92         org.omg.Components.ConfigValue config = null;
93         Dependency dep=dependencyDeployer.getDependency();
94         if ((dep.getAction().compareToIgnoreCase("install") == 0)
95                && (dep.getFileinarchive()!=null)
96                && ((dep.getFileinarchive().getName()!=null)||dep.getFileinarchive().getLink()!=null)
97                /*&& (dep.getName()!=null)
98                && (dep.getName().getValue()!=null)*/

99                )
100                {
101                    // Set up the dependency as config value for home
102
// installation if the dependency is java classes
103
if (dep.getType().trim().
104                        compareToIgnoreCase("Java Class") == 0)
105                    {
106                        config = new org.objectweb.openccm.Components.ConfigValueImpl();
107                        config.name = "load_lib_dependency";
108                        config.value = org.objectweb.openccm.corba.TheORB.getORB().create_any();
109                        config.value.insert_string(/*dep.getName().getValue()*/dep.getFileinarchive().getName());
110                        config_values.add(config);
111                    }
112                }
113             if((dep.getAction().compareToIgnoreCase("install") == 0)
114                &&(dep.getType().compareToIgnoreCase("HOME_CONFIG_VALUE")==0)
115                &&(dep.getName()!=null)
116                &&(dep.getName().getValue()!=null)
117                &&(dep.getName().getValue().indexOf(":")!=-1))
118                {
119                    config = new org.objectweb.openccm.Components.ConfigValueImpl();
120                    String JavaDoc configName=dep.getName()
121                                        .getValue()
122                                        .substring(0,dep.getName()
123                                                        .getValue()
124                                                        .indexOf(":"));
125
126                    String JavaDoc configValue=dep.getName()
127                                          .getValue()
128                                          .substring(dep.getName()
129                                                         .getValue()
130                                                         .indexOf(":")+1,
131                                                         dep.getName().getValue().length());
132
133                    config.name = configName;
134                    config.value = org.objectweb.openccm.corba.TheORB.getORB().create_any();
135                    config.value.insert_string(configValue);
136                    config_values.add(config);
137                }
138                
139                if(dep.getValuetypefactory()!=null&&
140                   dep.getValuetypefactory().getRepid()!=null&&
141                   dep.getValuetypefactory().getValueentrypoint()!=null&&
142                   dep.getValuetypefactory().getFactoryentrypoint()!=null&&
143                   dep.getValuetypefactory().getFileinarchive()!=null)
144                   {
145                    config=new org.objectweb.openccm.Components.ConfigValueImpl();
146                    config.name=org.omg.Components.VALUE_FACTORY_FEATURE_NAME.value;
147                    config.value = org.objectweb.openccm.corba.TheORB.getORB().create_any();
148                    ValueFactoryEntrypoint vtfe=new ValueFactoryEntrypoint();
149                 
150                    vtfe.code_location="fileinarchive:"+dep.getValuetypefactory().getFileinarchive().getName();
151                    vtfe.factory_entrypoint=dep.getValuetypefactory().getFactoryentrypoint();
152                    vtfe.value_entrypoint=dep.getValuetypefactory().getValueentrypoint();
153                    vtfe.repid=dep.getValuetypefactory().getRepid();
154                    
155                    ValueFactoryEntrypoint [] vts=new ValueFactoryEntrypoint[1];
156                    vts[0]=vtfe;
157                    valueFactoryEntrypointSeqHelper.insert(config.value,vts);
158                                
159                    config_values.add(config);
160                   }
161     }
162     /**
163      * Build an return an array of config value relative
164      * to the dependency processing.
165      *
166      * @return the built configvalues
167      */

168     public ConfigValue[]
169     getConfigValue()
170     {
171         return (ConfigValue[])
172                 config_values
173                 .toArray(new ConfigValue[config_values.size()]);
174     }
175     
176     /**
177      * Code visitor to found entrypoint
178      *
179      * @param CodeDeployer the codeDeploye to visit
180      * @throws CodeInstallationFailureException if entrypoint not found
181      */

182     public void
183     visit(CodeDeployer codeDeployer)
184     throws CodeInstallationFailureException
185     {
186         try{
187             entryPoint=codeDeployer.getCode().getEntrypoint().getValue();
188         }
189         catch(Exception JavaDoc e){
190             throw new CodeInstallationFailureException(null,e);
191         }
192     }
193     /**
194      * Return the entryPoint found by the code visitor method.
195      *
196      * @return The entrypoint found
197      */

198     public String JavaDoc
199     getEntryPoint()
200     {
201         return entryPoint;
202     }
203
204
205 }
206
Popular Tags