"Stephen McConnell" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED]
> Eike Stepper wrote:
> > hi,
> >
> > i have a component that should be instantiated with
> > each service lookup (a channel). but instead it seems
> > that the second channel is being re-used.
>
> No possible.
>
> > it took me a
> > while, because it changed its state silently.
> >
> > i use the following code:
> >
> >   protected Channel createChannel() throws Exception, AssemblyException
> >   {
> >
> >     short channelId = findFreeChannelId();
> >     if (getLogger().isDebugEnabled())
> >     {
> >       getLogger().debug("creating new channel with id: " + channelId);
> >     }
> >
> >     ReferenceDescriptor reference = new 
> > ReferenceDescriptor(Channel.class.getName());
> >     DeploymentModel component = (DeploymentModel) model.getModel(reference);
> >     component.commission();
> >
> >     Channel channel = (Channel) component.resolve();
>
> At this point you have a brand-new instance.
> Basically the code get to the following in DefaultAppliance:
>
>     m_lifestyle.resolve();
>
> WHich invokes resolve in the transient lifestyle handler which in turn
> established and returns an instance by direct incarnation:
>
>     Object instance = getComponentFactory().incarnate();
>
>
> >     channel.setId(channelId);
> >     channel.setConnector(this);
> >     channels.set(channelId, channel);
> >     return channel;
> >   }
> >
> > the following lines in the log show, that a channel that had already
> > been initialized with a connector + id receives a new id:
> >
> > [DEBUG  ] (app.Client1): creating new channel with id: 1
> > [DEBUG  ] (app.net4j.Channel.CLIENT-0:0): received id: 1
>
> Can you post the snippet of code that is generating the log message?

you have already seen it! the first lien comes from the above logger
call and the second one comes from within Channel.setId:

  public void setId(short id)
  {
    this.id = id;

    if (getLogger().isDebugEnabled())
    {
      getLogger().debug("received id: " + id);
    }

    changeLoggingCategory();
  }


the changeLoggingCategory() call appends the internal name of the
connector ("CLIENT-0") plus the channel id to the logging category.

as you can see that particular channel had already changed its category when
it receives a second id (now 1)!

somehow i got the feeling, that my containers are not set up
correctly/appropriately - but no concrete idea...

/eike





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to