Skip to content

Commit

Permalink
Build Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Jun 1, 2024
1 parent 7b9dfb5 commit e0ee5a8
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 206 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/jwebmp/core/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
import net.sf.uadetector.ReadableUserAgent;

import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.logging.Level;

import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_SEMICOLON;
import static com.jwebmp.core.implementations.JWebMPServicesBindings.IPageConfiguratorsKey;

/**
* Top level of any HTML page.
Expand Down Expand Up @@ -531,7 +530,8 @@ private boolean isHeadEmpty()
private void configurePage()
{
@SuppressWarnings("rawtypes")
Set<IPageConfigurator> sortedConfigurators = new LinkedHashSet<>(IGuiceContext.get(IPageConfiguratorsKey));
Set<IPageConfigurator> sortedConfigurators = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(IPageConfigurator.class));
//new LinkedHashSet<>(IGuiceContext.get(IPageConfiguratorsKey));
sortedConfigurators.removeIf(a -> !a.enabled());
for (IPageConfigurator<?> sortedConfigurator : sortedConfigurators)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
package com.jwebmp.core.base.page;

import com.guicedee.client.*;
import com.guicedee.client.IGuiceContext;
import com.jwebmp.core.Page;
import com.jwebmp.core.base.ComponentHierarchyBase;
import com.jwebmp.core.base.html.Paragraph;
import com.jwebmp.core.base.servlets.enumarations.RequirementsPriority;
import com.jwebmp.core.services.*;


import com.jwebmp.core.services.IPage;
import com.jwebmp.core.services.RenderAfterLinks;
import com.jwebmp.core.services.RenderBeforeLinks;
import jakarta.validation.constraints.NotNull;
import java.util.Set;

import static com.jwebmp.core.implementations.JWebMPServicesBindings.*;
import java.util.ServiceLoader;
import java.util.Set;

/**
* Inserts the CSS Links into the page
*/
@SuppressWarnings("unused")
public class CSSLinksInsertPageConfigurator
extends RequirementsPriorityAbstractInsertPageConfigurator<CSSLinksInsertPageConfigurator>
extends RequirementsPriorityAbstractInsertPageConfigurator<CSSLinksInsertPageConfigurator>
{
/**
* Constructor CSSLinksInsertPageConfigurator creates a new CSSLinksInsertPageConfigurator instance.
*/
public CSSLinksInsertPageConfigurator()
{
//No config required
}
/**
* Constructor CSSLinksInsertPageConfigurator creates a new CSSLinksInsertPageConfigurator instance.
*/
public CSSLinksInsertPageConfigurator()
{
//No config required
}

@NotNull
@Override
public Page<?> configure(IPage<?> pager)
{
Page page = (Page)pager;
if (!page.isConfigured() && enabled())
{
renderBeforeLinks(page);
for (RequirementsPriority requirementsPriority : RequirementsPriority.values())
{
page.getHead()
.getChildren()
.addAll(getAllCssLinks(page, requirementsPriority));
}
for (Object o : page.getHead()
.getChildren())
{
ComponentHierarchyBase<?,?,?,?,?> headObject = (ComponentHierarchyBase<?,?,?,?,?>) o;
headObject.preConfigure();
}
renderAfterLinks(page);
}
return page;
}
@NotNull
@Override
public Page<?> configure(IPage<?> pager)
{
Page page = (Page) pager;
if (!page.isConfigured() && enabled())
{
renderBeforeLinks(page);
for (RequirementsPriority requirementsPriority : RequirementsPriority.values())
{
page.getHead()
.getChildren()
.addAll(getAllCssLinks(page, requirementsPriority));
}
for (Object o : page.getHead()
.getChildren())
{
ComponentHierarchyBase<?, ?, ?, ?, ?> headObject = (ComponentHierarchyBase<?, ?, ?, ?, ?>) o;
headObject.preConfigure();
}
renderAfterLinks(page);
}
return page;
}

private void renderBeforeLinks(Page<?> page)
{
Set<RenderBeforeLinks> renderB = IGuiceContext.get(RenderBeforeLinksKey);
Paragraph<?> before = new Paragraph<>().setTextOnly(true);
for (RenderBeforeLinks render : renderB)
{
before.setText(before.getText(0)
.toString() + render.render(page)
.toString());
}
if (before.getText(0)
.toString()
.trim()
.length() > 0)
{
page.getHead()
.add(before);
}
}
private void renderBeforeLinks(Page<?> page)
{
Set<RenderBeforeLinks> renderB = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderBeforeLinks.class));//.get(RenderBeforeLinksKey);
Paragraph<?> before = new Paragraph<>().setTextOnly(true);
for (RenderBeforeLinks render : renderB)
{
before.setText(before.getText(0)
.toString() + render.render(page)
.toString());
}
if (before.getText(0)
.toString()
.trim()
.length() > 0)
{
page.getHead()
.add(before);
}
}

private void renderAfterLinks(Page<?> page)
{
Set<RenderAfterLinks> renderA = IGuiceContext.get(RenderAfterLinksKey);
Paragraph<?> after = new Paragraph<>().setTextOnly(true);
for (RenderAfterLinks render : renderA)
{
after.setText(after.getText(0)
.toString() + render.render(page)
.toString());
}
if (after.getText(0)
.toString()
.trim()
.length() > 0)
{
page.getHead()
.add(after);
}
}
private void renderAfterLinks(Page<?> page)
{
Set<RenderAfterLinks> renderA = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderAfterLinks.class));//.get(RenderAfterLinksKey);
Paragraph<?> after = new Paragraph<>().setTextOnly(true);
for (RenderAfterLinks render : renderA)
{
after.setText(after.getText(0)
.toString() + render.render(page)
.toString());
}
if (after.getText(0)
.toString()
.trim()
.length() > 0)
{
page.getHead()
.add(after);
}
}

@Override
public Integer sortOrder()
{
return Integer.MAX_VALUE - 10;
}
@Override
public Integer sortOrder()
{
return Integer.MAX_VALUE - 10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import java.util.ServiceLoader;
import java.util.Set;

import static com.jwebmp.core.implementations.JWebMPServicesBindings.RenderAfterDynamicScriptsKey;
import static com.jwebmp.core.implementations.JWebMPServicesBindings.RenderBeforeDynamicScriptsKey;

/**
* Configures the dynamic script insertions that run last into the page
*
Expand Down Expand Up @@ -83,7 +80,7 @@ public Page<?> configure(IPage<?> pager)
//Render Before Dynamic Scripts
Paragraph beforeText = new Paragraph().setTextOnly(true);
StringBuilder sbBeforeText = new StringBuilder();
Set<RenderBeforeDynamicScripts> beforeLoader = IGuiceContext.get(RenderBeforeDynamicScriptsKey);
Set<RenderBeforeDynamicScripts> beforeLoader = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderBeforeDynamicScripts.class));// get(RenderBeforeDynamicScriptsKey);
for (RenderBeforeDynamicScripts renderAfterDynamicScripts : beforeLoader)
{
sbBeforeText.append(IGuiceContext.get(renderAfterDynamicScripts.getClass())
Expand Down Expand Up @@ -155,7 +152,7 @@ public Page<?> configure(IPage<?> pager)
//Render After Dynamic Scripts
Paragraph afterText = new Paragraph().setTextOnly(true);
StringBuilder sbAfterText = new StringBuilder();
Set<RenderAfterDynamicScripts> afterLoader = IGuiceContext.get(RenderAfterDynamicScriptsKey);
Set<RenderAfterDynamicScripts> afterLoader = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderAfterDynamicScripts.class));//.get(RenderAfterDynamicScriptsKey);
for (RenderAfterDynamicScripts renderAfterDynamicScripts : afterLoader)
{
sbAfterText.append(IGuiceContext
Expand Down
Loading

0 comments on commit e0ee5a8

Please sign in to comment.