GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Lean on object service for singleton retrieval · scijava/scijava-common@cbc827c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/main/java/org/scijava/plugin
    • AbstractSingletonService.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/org/scijava/plugin/AbstractSingletonService.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/scijava/plugin/AbstractSingletonService.java
+8-13Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
package org.scijava.plugin;
3333

34-
import java.util.ArrayList;
3534
import java.util.Collections;
3635
import java.util.List;
3736

@@ -58,15 +57,12 @@ public abstract class AbstractSingletonService<PT extends SingletonPlugin>
5857
// TODO: Listen for PluginsAddedEvent and PluginsRemovedEvent
5958
// and update the list of singletons accordingly.
6059

61-
/** List of singleton plugin instances. */
62-
private List<PT> instances;
63-
6460
// -- SingletonService methods --
6561

6662
@Override
6763
public List<PT> getInstances() {
68-
if (instances == null) initInstances();
69-
return instances;
64+
final List<PT> plugins = objectService.getObjects(getPluginType());
65+
return Collections.unmodifiableList(plugins);
7066
}
7167

7268
@Override
@@ -84,7 +80,7 @@ public void initialize() {
8480

8581
@Override
8682
public List<PT> get() {
87-
return new ArrayList<PT>(getInstances());
83+
return createInstances();
8884
}
8985

9086
@Override
@@ -97,15 +93,14 @@ public Class<?> getType() {
9793

9894
// -- Helper methods --
9995

100-
private synchronized void initInstances() {
101-
if (instances != null) return;
102-
103-
instances =
104-
Collections.unmodifiableList(filterInstances(getPluginService()
105-
.createInstancesOfType(getPluginType())));
96+
private List<PT> createInstances() {
97+
final List<PT> instances =
98+
filterInstances(getPluginService().createInstancesOfType(getPluginType()));
10699

107100
log.info("Found " + instances.size() + " " +
108101
getPluginType().getSimpleName() + " plugins.");
102+
103+
return instances;
109104
}
110105

111106
/**

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.