Skip to content

Commit

Permalink
OWB+Deltaspike configurable waiting time
Browse files Browse the repository at this point in the history
  • Loading branch information
skybber committed Jun 5, 2024
1 parent ea6a4cd commit 3a56b6b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public class DeltaSpikePlugin {

@Init
Scheduler scheduler;
@Init
PluginConfiguration pluginConfiguration;

boolean initialized = false;
int waitOnRedefine = WAIT_ON_REDEFINE;

Map<Object, String> registeredPartialBeans = new WeakHashMap<>();
Map<Object, List<String>> registeredViewConfExtRootClasses = new WeakHashMap<>();
Expand All @@ -84,7 +89,11 @@ public class DeltaSpikePlugin {

@Init
public void init(PluginConfiguration pluginConfiguration) {
LOGGER.info("Deltaspike plugin initialized.");
if (!initialized) {
LOGGER.info("Deltaspike plugin initialized.");
initialized = true;
waitOnRedefine = Integer.valueOf(pluginConfiguration.getProperty("deltaspike.waitOnRedefine", String.valueOf(WAIT_ON_REDEFINE)));
}
}

// ds<1.9
Expand Down Expand Up @@ -145,7 +154,7 @@ private PartialBeanClassRefreshCommand checkRefreshPartialBean(CtClass clazz, Cl
if (partialBean != null) {
String oldSignForProxyCheck = DeltaspikeClassSignatureHelper.getSignaturePartialBeanClass(original);
cmd = new PartialBeanClassRefreshCommand(appClassLoader, partialBean, clazz.getName(), oldSignForProxyCheck, scheduler);
scheduler.scheduleCommand(cmd, WAIT_ON_REDEFINE);
scheduler.scheduleCommand(cmd, waitOnRedefine);
}
return cmd;
}
Expand Down Expand Up @@ -211,7 +220,7 @@ private void checkRefreshViewConfigExtension(CtClass clazz, Class original) {
List<String> rootClassNameList = entry.getValue();
for (String viewConfigClassName: rootClassNameList) {
if (viewConfigClassName.equals(rootClassName)) {
scheduler.scheduleCommand(new ViewConfigReloadCommand(appClassLoader, entry.getKey(), entry.getValue()), WAIT_ON_REDEFINE);
scheduler.scheduleCommand(new ViewConfigReloadCommand(appClassLoader, entry.getKey(), entry.getValue()), waitOnRedefine);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public class OwbJakartaPlugin {
private BeanReloadStrategy beanReloadStrategy;

private Map<URL, URL> registeredArchives = new HashMap<>();
private int waitOnCreate = WAIT_ON_CREATE;
private int waitOnRedefine = WAIT_ON_REDEFINE;

/**
* Plugin initialization, called from archive registration,
Expand All @@ -111,6 +113,8 @@ public void init() {
LOGGER.info("OpenWebBeans plugin initialized.");
initialized = true;
beanReloadStrategy = setBeanReloadStrategy(pluginConfiguration.getProperty("owb.beanReloadStrategy"));
waitOnCreate = Integer.valueOf(pluginConfiguration.getProperty("owb.waitOnCreate", String.valueOf(WAIT_ON_CREATE)));
waitOnRedefine = Integer.valueOf(pluginConfiguration.getProperty("owb.waitOnRedefine", String.valueOf(WAIT_ON_REDEFINE)));
}
}

Expand Down Expand Up @@ -190,7 +194,7 @@ public void onEvent(WatchFileEvent event) {
if (!ClassLoaderHelper.isClassLoaded(appClassLoader, className) || isTestEnvironment) {
// refresh weld only for new classes
LOGGER.trace("register reload command: {} ", className);
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, beanArchiveUrl, event), WAIT_ON_CREATE);
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, beanArchiveUrl, event), waitOnCreate);
}
}
}
Expand Down Expand Up @@ -252,7 +256,7 @@ public void classReload(ClassLoader classLoader, CtClass ctClass, Class<?> origi
oldSignByStrategy,
entry.getValue(),
beanReloadStrategy),
WAIT_ON_REDEFINE
waitOnRedefine
);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class OwbPlugin {

private BeanReloadStrategy beanReloadStrategy;

private int waitOnCreate = WAIT_ON_CREATE;
private int waitOnRedefine = WAIT_ON_REDEFINE;

private Map<URL, URL> registeredArchives = new HashMap<>();

/**
Expand All @@ -111,6 +114,8 @@ public void init() {
LOGGER.info("OpenWebBeans plugin initialized.");
initialized = true;
beanReloadStrategy = setBeanReloadStrategy(pluginConfiguration.getProperty("owb.beanReloadStrategy"));
waitOnCreate = Integer.valueOf(pluginConfiguration.getProperty("owb.waitOnCreate", String.valueOf(WAIT_ON_CREATE)));
waitOnRedefine = Integer.valueOf(pluginConfiguration.getProperty("owb.waitOnRedefine", String.valueOf(WAIT_ON_REDEFINE)));
}
}

Expand Down Expand Up @@ -190,7 +195,7 @@ public void onEvent(WatchFileEvent event) {
if (!ClassLoaderHelper.isClassLoaded(appClassLoader, className) || isTestEnvironment) {
// refresh weld only for new classes
LOGGER.trace("register reload command: {} ", className);
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, beanArchiveUrl, event), WAIT_ON_CREATE);
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, beanArchiveUrl, event), waitOnCreate);
}
}
}
Expand Down Expand Up @@ -252,7 +257,7 @@ public void classReload(ClassLoader classLoader, CtClass ctClass, Class<?> origi
oldSignByStrategy,
entry.getValue(),
beanReloadStrategy),
WAIT_ON_REDEFINE
waitOnRedefine
);
break;
}
Expand Down

0 comments on commit 3a56b6b

Please sign in to comment.