RE: component deployment
"Guijarro, Julio" <[email protected]>
| Newsgroups | gmane.comp.java.smartfrog.user |
|---|---|
| Message-ID | <8D5B24B83C6A2E4B9E7EE5FA82627DC994A705@sdcexcea01.emea.cpqcorp.net> |
Hi Flavio,
As Patrick said, you get the same component in all the children because you are not copying the "Component description" before deploying it and therefore all the children end up using the same context for their data structures.
There are two very good examples about how to deploy children and applications from inside a component. Check:
- org/smartfrog/examples/spawn
- org/smartfrog/examples/arraycompound
---
Ex from "Spawn"-
if (destination==null) {
p =this.sfCreateNewChild(copyName,(ComponentDescription)offspringDescription.copy(),null);
} else {
--
Ex from ArrayCompoundImpl
private boolean deployTemplate(String hostname) {
Prim p = null;
try {
Context sfHostContext = new ContextImpl();
sfHostContext.sfAddAttribute(SmartFrogCoreKeys.SF_PROCESS_HOST, hostname);
//Create a new copy of the description!
ComponentDescription newcd = (ComponentDescription)((ComponentDescriptionImpl)template).copy();
if (parent == null){
if (sfLog().isDebugEnabled()) {
sfLog().debug("Creating new app: "+ hostname +":'"+parent.sfCompleteName()+"'");
}
p = this.sfCreateNewApp( "app-"+hostname.toString(),newcd , sfHostContext);
} else {
if (sfLog().isDebugEnabled()) {
sfLog().debug("Creating new child: "+ hostname +":'"+parent.sfCompleteName()+"'");
}
p = this.sfCreateNewChild("ch-"+hostname.toString(), parent,newcd, sfHostContext);
}
} catch (Exception e) {
if (sfLog().isErrorEnabled()) {
sfLog().error("deployTemplate: "+hostname, e);
}
return false;
}
return true;
}
---
Julio Guijarro.
> -----Original Message-----
> From: smartfrog-support-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org [mailto:smartfrog-
> [email protected]] On Behalf Of Goldsack, Patrick
> Sent: 16 March 2005 20:42
> To: Flávio Roberto Santos / Projeto Ourgrid
> Cc: Andreas Unterkircher; smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject: Re: [Smartfrog-support] component deployment
>
> All I can think is that you modify the first description to deploy the
> second. If the components are then all local, and you don't copy the
> structure before modification, it is possible that you are changing the
> contexts of all of the components by hidden side-effect. I can't remember
> off the top of my head whether we decided to copy everything just in case
> or
> not - I suspect we went for efficiency...
>
> If this is not the explanation, send me the (hopefully small!) example.
>
> Patrick
>
> ----- Original Message -----
> From: "Flávio Roberto Santos / Projeto Ourgrid" <flaviors-y04Q/[email protected]>
> To: "Goldsack, Patrick" <[email protected]>
> Cc: "Andreas Unterkircher" <[email protected]>;
> <smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Sent: Wednesday, March 16, 2005 6:20 PM
> Subject: Re: [Smartfrog-support] component deployment
>
>
> > Hi Patrick,
> >
> > I have needed something like this: I used the command sfCreateNewChild()
> > to deploy two different components, but I've got some problems to list
> > them.
> >
> > I tried sfChildren() but all the returned components were the same. In
> > other words, the components were with the same attribute values although
> > they've been deployed with different ones.
> >
> > What is happening?
> > If you need, I can send the code to you.
> >
> > Thanks in advance.
> >
> > Flávio Roberto.
> >
> >
> > Goldsack, Patrick wrote:
> >
> >>I presume that you have a ComponentDescriptionImpl instance already
> >>parsed - either by parsing the text (from a string, a file or some input
> >>stream) or by picking up a "LAZY extends" attribute.
> >>
> >>The right model will depend on whether you want the component parented
> >>or not, and by what, and which phase of the lifecycle this parent is in.
> >>
> >>Andreas,
> >>
> >>I will cover a number of possibilities for your current situation:
> >>
> >>1) you are to be the parent, and you are a compound, call the method
> >>sfCreateNewChild(...) on yourself. You can do this as you are in
> >>sfStart, but only after the super call. Had you been in sfDeploy(), you
> >>would have to only partially step through the lifecycle and use the more
> >>basic methods.
> >>
> >>2) you are not the parent but some other compound is - it depends on
> >>whether you where you want this component deployed (near you, near the
> >>parent, or elsewhere). If the location is near the compound - call the
> >>sfCreateNewChild() on that compound passing the
> >>ComponentDescriptionImpl. If the location is not near that compound,
> >>find the process compound of the location (do an sfResolve in the link
> >>"HOST hostame"), and call sfCreateNewChild( ) passing the required
> >>compound as a parent parameter. This will be OK if the parent has been
> >>fully through its lifecycle.
> >>
> >>3) If you want no parent - do as (2) to locate the right process
> >>compound, and use sfCreateNewApp(...).
> >>
> >>In 2 and 3, if the location attributes are set in the component
> >>description, you can always use the local process compound to deploy the
> >>component in the right place.
> >>
> >>Patrick
> >>
> >>-----Original Message-----
> >>From: smartfrog-support-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >>[mailto:smartfrog-support-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
> >>Andreas Unterkircher
> >>Sent: 16 March 2005 13:41
> >>To: smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >>Subject: [Smartfrog-support] component deployment
> >>
> >>
> >>Hello,
> >>
> >>I have a component which should deploy another component if some
> >>condition is met within the sfStart method. What is the right way to do
> >>that in Java ? E.g. I was thinking of something like
> >>
> >>newComponent = new newComponentImpl();
> >>newComponentImpl.sfDeploy();
> >>newComponentImpl.sfStart();
> >>
> >>but I guess this is not right... Do I have to use PrimDeployerImpl ?
> >>Thanks,
> >>Andreas
> >>
> >>--
> >>Andreas Unterkircher
> >>IT Department
> >>CERN
> >>CH-1211 Geneva 23
> >>http://cern.ch/openlab
> >>
> >>
> >>-------------------------------------------------------
> >>SF email is sponsored by - The IT Product Guide
> >>Read honest & candid reviews on hundreds of IT Products from real users.
> >>Discover which products truly live up to the hype. Start reading now.
> >>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> >>_______________________________________________
> >>Smartfrog-support mailing list
> >>Smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >>https://lists.sourceforge.net/lists/listinfo/smartfrog-support
> >>
> >>
> >>-------------------------------------------------------
> >>SF email is sponsored by - The IT Product Guide
> >>Read honest & candid reviews on hundreds of IT Products from real users.
> >>Discover which products truly live up to the hype. Start reading now.
> >>http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
> >>_______________________________________________
> >>Smartfrog-support mailing list
> >>Smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >>https://lists.sourceforge.net/lists/listinfo/smartfrog-support
> >>
> >>
> >
> >
> > --
> >
> > Flavio Roberto Santos
> > Undergraduate Student in Universidade Federal de Campina Grande
> > OurGrid Team Member - www.ourgrid.org
> > Webpage - http://www.dsc.ufcg.edu.br/~flaviors
> >
> > --
> >
> > "As far as the laws of mathematics refer to reality, they are not
> > certain, and as far as they are certain, they do not refer to reality."
> > -- Albert Einstein
> >
> >
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
> _______________________________________________
> Smartfrog-support mailing list
> Smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/smartfrog-support
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click