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.
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:
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.
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.
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() {
}
}
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