Skip to content

Instantly share code, notes, and snippets.

@binarycrayon
Created August 4, 2011 04:23
Show Gist options
  • Save binarycrayon/1124504 to your computer and use it in GitHub Desktop.
Save binarycrayon/1124504 to your computer and use it in GitHub Desktop.
Lookup.Template example
// interface class, String ID of implementer class, testImpl is an alternative implementation of PreviewController
Lookup.Template template = new Lookup.Template(PreviewController.class, "org.gephi.preview.testImpl", null);
Result result = Lookup.getDefault().lookup(template);
Lookup.Item it=Lookup.getDefault().lookupItem(template);
PreviewController instance = it.getInstance();
System.out.println("the instance is: " + instance.toString());
// output: the instance is org.gephi.preview.testImpl@69fe571f
template = new Lookup.Template(PreviewController.class, "org.gephi.preview.PreviewControllerImpl", null);
it=Lookup.getDefault().lookupItem(template);
instance = it.getInstance();
System.out.println("the instance is: " + instance.toString());
//output: the instance is org.gephi.preview.PreviewControllerImpl@3909ea96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment