Projects tigase _server server-core Issues #381
vHostManager has not yet been set when a component's start() method is called (#381)
Gabriel Rossetti opened 1 decade ago

When calling getDefVHostItem() from a component's start() method you get the real hostname instead due to the fact that the vHostManager has not been set yet:

public class MyComponent extends AbstractMessageReceiver {

@Override

public void start() {

super.start();  

log.debug("addrs is: {}", getDefVHostItem().toString()); // this will print the real hostname instead of the virtual hostname

}

}

When you initialize/start a componenet this should already be set since the server has already parsed init.properties at this point.

Please see here for more info: https://projects.tigase.org/boards/4/topics/3364?r=3377

Artur Hefczyc commented 1 decade ago

The start() method is called only to start/initialize components' own data and mechanisms. All components start/can start at the same time concurrently, so there can be no dependency on any other component or assumption that something else is already initialized.

If you need to do something when the whole server started up and all other components are initialized, you can use initializationCompleted() method, which is called when the server is basically ready to process user's data. There are 2 remarks for this however:

  1. The method initializationCompleted() really means that initialization is completed, even for your component. This really means that at this point the component must be ready to accept data for processing. Therefore, this method can be only used for some "post-initialization" actions or initialization of elements on which stanza processing does not depends.

  2. The getDefVHostItem() is actually different from everything else.Hostname information is taken from DNS system which may take long time. It is executed on a separate thread, so the time when the real hostname is available to the system depends how quickly DNS system can obtain this information.

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
2423
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#381
Please wait...
Page is in error, reload to recover