Skip to content

Commit

Permalink
#30291: waiting on OSGI to be initiated correctly before registering …
Browse files Browse the repository at this point in the history
…any workflow actionlets (#30531)

To avoid possible race condition, the OSGI actionlets registration is
now preceded by a check that makes sure (after a reasonable number of
tries) that OSGI framework is fully loaded.
  • Loading branch information
victoralfaro-dotcms authored Nov 5, 2024
1 parent 3758dab commit 8077c29
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private void removeReferences() {
Logger.info( this, "Portlets Removed: " + OSGIUtil.getInstance().portletIDsStopped.toString());

//Remove Actionlets in the list
OSGIUtil.getInstance().actionletsStopped.forEach(p -> OSGIUtil.getInstance().workflowOsgiService.removeActionlet(p));
OSGIUtil.getInstance().actionletsStopped.forEach(p -> OSGIUtil.getInstance().getWorkflowOsgiService().removeActionlet(p));
Logger.info( this, "Actionlets Removed: " + OSGIUtil.getInstance().actionletsStopped.toString());

//Cleanup lists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,13 @@
public abstract class GenericBundleActivator implements BundleActivator {

private static final String MANIFEST_HEADER_OVERRIDE_CLASSES = "Override-Classes";

private static final String INIT_PARAM_VIEW_JSP = "view-jsp";
private static final String INIT_PARAM_VIEW_TEMPLATE = "view-template";
public static final String BYTEBUDDY_CLASS_RELOADING_STRATEGY_NOT_SET_JAVA_AGENT_NOT_SET = "bytebuddy ClassReloadingStrategy not set [java agent not set?]";
public static final String COM_LIFERAY_PORTLET_JSPPORTLET = "com.liferay.portlet.JSPPortlet";
public static final String COM_LIFERAY_PORTLET_VELOCITY_PORTLET = "com.liferay.portlet.VelocityPortlet";

private BundleContext context;


private PrimitiveToolboxManager toolboxManager;
private CacheOSGIService cacheOSGIService;
private ConditionletOSGIService conditionletOSGIService;
Expand All @@ -109,7 +106,6 @@ public abstract class GenericBundleActivator implements BundleActivator {
private final Collection<String> postHooks = new ArrayList<>();
private final Collection<String> overriddenClasses = new HashSet<>();


protected ClassLoader getBundleClassloader () {
return this.getClass().getClassLoader();
}
Expand Down Expand Up @@ -563,21 +559,8 @@ protected void addRewriteRule ( String from, String to, String type, String name
* @param context
* @param actionlet
*/
protected void registerActionlet ( BundleContext context, WorkFlowActionlet actionlet ) {

//Getting the service to register our Actionlet
ServiceReference<?> serviceRefSelected = context.getServiceReference( WorkflowAPIOsgiService.class.getName() );
if ( serviceRefSelected == null ) {
return;
}


OSGIUtil.getInstance().workflowOsgiService = (WorkflowAPIOsgiService) context.getService( serviceRefSelected );
OSGIUtil.getInstance().workflowOsgiService.addActionlet( actionlet.getClass() );
actionlets.add( actionlet );

Logger.info( this, "Added actionlet: " + actionlet.getName() );
OSGIUtil.getInstance().actionletsStopped.remove(actionlet.getClass().getCanonicalName());
protected void registerActionlet(final BundleContext context, final WorkFlowActionlet actionlet) {
OSGIUtil.getInstance().registerActionlet(context, actionlet, actionlets);
}

/**
Expand Down Expand Up @@ -831,7 +814,7 @@ protected void unpublishBundleServices () {
*/
protected void unregisterActionlets () {

if (OSGIUtil.getInstance().workflowOsgiService != null) {
if (OSGIUtil.getInstance().getWorkflowOsgiService() != null) {
for ( WorkFlowActionlet actionlet : actionlets ) {
if(!OSGIUtil.getInstance().actionletsStopped.contains(actionlet.getClass().getCanonicalName())){
OSGIUtil.getInstance().actionletsStopped.add(actionlet.getClass().getCanonicalName());
Expand Down
Loading

0 comments on commit 8077c29

Please sign in to comment.