#How does the following initialization work?

14 messages · Page 1 of 1 (latest)

long flint
#
public class VizController implements VisualizationController {

    private static VizController instance;

...

    public VizController() {
    }

    public synchronized static VizController getInstance() {
        if (instance == null) {
            instance = (VizController) Lookup.getDefault().lookup(VisualizationController.class);
            instance.initInstances();
        }
        return instance;
    }

How exactly is instantiation working here? Lookup comes from org.openide.util.Lookup, which is part of the Netbeans API, but I'm not understanding how it can create an instance without calling the new keyword.

Here's the source, if anyone is interested: https://github.com/gephi/gephi/blob/master/modules/VisualizationImpl/src/main/java/org/gephi/visualization/VizController.java

GitHub

Gephi - The Open Graph Viz Platform. Contribute to gephi/gephi development by creating an account on GitHub.

sour caveBOT
#

This post has been reserved for your question.

Hey @long flint! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

late sinew
#

That is a very big source code xd

long flint
#

yeah heheh

#

have been digging through it for two days now

late sinew
long flint
#

yeah

late sinew
#

If so you can simply use an IDE towards the method definition of .lookup()

#

from what I can see from the imports, the Lookup class is in a package named org.openide.util.Lookup

#

I tried searching for a class named Lookup using the Github search feature but wasn't able to find it, so it is probably a class from a dependency of the project

long flint
#

I'll see if I can find it in the dependencies

#

thanks for the help btw!

sour caveBOT
# long flint thanks for the help btw!

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.