Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #10437 - Unify Deployer ContextProvider #12583

Open
wants to merge 26 commits into
base: jetty-12.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift click to select a range
8878567
Initial pass at implementation of EnvironmentContextProvider
joakime Nov 22, 2024
3a46e37
Fixing javadoc errors
joakime Nov 22, 2024
c5c07c2
Moving things around
joakime Nov 25, 2024
e0bdeb3
Moving changes back into ContextProvider
joakime Nov 25, 2024
7588d5f
Introducing ContextProvider.configureEnvironment(String name)
joakime Nov 25, 2024
42015b3
Fixing <env>[-zzz].properties sorting
joakime Nov 26, 2024
f9c90ce
Allow an Environment to be removed (needed for testing with Environment)
joakime Nov 26, 2024
83fc5f1
Fixing test cases
joakime Nov 26, 2024
a0c9058
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Nov 27, 2024
249679f
Fix javadoc
joakime Nov 27, 2024
bef04d9
Fix method names
joakime Nov 27, 2024
add337a
Fixing Environment contextClass loading
joakime Nov 27, 2024
2e9660d
Fixing test cases
joakime Nov 27, 2024
9bfab80
Fixing quickstart XML references to provider
joakime Nov 27, 2024
2c651ea
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Dec 2, 2024
0e534f7
Fixing quickstart XML
joakime Dec 2, 2024
43eb679
Fixing deploy containerScanJarPattern for ee9/ee8
joakime Dec 2, 2024
c5a00b8
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Dec 2, 2024
229e358
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Dec 18, 2024
a363189
Changes from reviews. Preparing for BulkListener impl.
joakime Dec 18, 2024
5f6d504
Using BulkListener with sorted paths for alphabetical deployment.
joakime Dec 18, 2024
77c34c2
Changes from review
joakime Dec 18, 2024
5306c3d
More changes from review
joakime Dec 18, 2024
96d5bec
Simplify else
joakime Dec 19, 2024
ee18845
Reworking deploy.createContextHandler to be easier to follow
joakime Dec 20, 2024
e498f2c
Fixing WebAppContext default-context-path mistake
joakime Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 7 additions & 31 deletions jetty-core/jetty-deploy/src/main/config/etc/jetty-core-deploy.xml
Original file line number Diff line number Diff line change
@@ -1,37 1,13 @@
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">

<!-- =============================================================== -->
<!-- Attach the "core" environment app deployment provider -->
<!-- Configure the "core" environment deployment defaults -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call id="DeploymentManager" name="getBean">
<Arg><Call class="java.lang.Class" name="forName"><Arg>org.eclipse.jetty.deploy.DeploymentManager</Arg></Call></Arg>
<Configure id="contextProvider" class="org.eclipse.jetty.deploy.providers.ContextProvider">
<Call name="configureEnvironment">
<Arg>core</Arg>
<Set name="contextHandlerClass">
<Property name="contextHandlerClass" default="org.eclipse.jetty.server.handler.ResourceHandler$ResourceContext" />
</Set>
</Call>
<Ref refid="Environment">
<Call name="setAttribute">
<Arg>contextHandlerClass</Arg>
<Arg><Property name="contextHandlerClass"/></Arg>
</Call>
</Ref>
<Ref refid="DeploymentManager">
<Call name="addAppProvider">
<Arg>
<New id="WebAppProvider-core" class="org.eclipse.jetty.deploy.providers.ContextProvider">
<Set name="EnvironmentName">core</Set>
<Set name="monitoredDirName">
<Call name="resolvePath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.monitoredDir" default="webapps" />
</Arg>
</Call>
</Set>
<Set name="deferInitialScan" property="jetty.deploy.deferInitialScan"/>
<Set name="scanInterval" property="jetty.deploy.scanInterval"/>
</New>
</Arg>
</Call>
</Ref>
</Configure>
49 changes: 25 additions & 24 deletions jetty-core/jetty-deploy/src/main/config/etc/jetty-deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 2,31 @@
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">

<!-- =============================================================== -->
<!-- Create the deployment manager -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The deplyment manager handles the lifecycle of deploying web -->
<!-- applications. Apps are provided by instances of the -->
<!-- AppProvider interface. -->
<!-- Create the monitored directory Context Provider -->
<!-- -->
<!-- The Context Provider is responsible for monitoring a provided -->
<!-- directory for web applications and hot deploying -->
<!-- through the DeploymentManager. -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref refid="Contexts" />
</Set>
<Configure id="contextProvider" class="org.eclipse.jetty.deploy.providers.ContextProvider">
<Set name="monitoredDirName">
<Call name="resolvePath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.monitoredDir" default="webapps" />
</Arg>
</Call>
</Set>
<Set name="deferInitialScan" property="jetty.deploy.deferInitialScan" />
<Set name="scanInterval" property="jetty.deploy.scanInterval" />

<!-- Add a customize step to the deployment lifecycle -->
<!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class
<Call name="insertLifeCycleNode">
<Arg>deployed</Arg>
<Arg>starting</Arg>
<Arg>customise</Arg>
</Call>
-->

</New>
</Arg>
</Call>
<Ref refid="DeploymentManager">
<Call name="addAppProvider">
<Arg>
<Ref refid="contextProvider" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be an error to configure more than one ContextProvider that is scanning the same directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't consider that an error.
Sure, it is a weird configuration.
Plus, I don't want to implement directory scanning lock files to prevent that kind of configuration.

</Arg>
</Call>
</Ref>
</Configure>
Original file line number Diff line number Diff line change
@@ -0,0 1,29 @@
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">

<!-- =============================================================== -->
<!-- Create the deployment manager -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The deployment manager handles the lifecycle of deploying web -->
<!-- applications. Apps are provided by instances of the -->
<!-- AppProvider interface. -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
joakime marked this conversation as resolved.
Show resolved Hide resolved
<Set name="contexts">
<Ref refid="Contexts" />
</Set>

<!-- Add a customize step to the deployment lifecycle -->
<!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class
<Call name="insertLifeCycleNode">
<Arg>deployed</Arg>
<Arg>starting</Arg>
<Arg>customise</Arg>
</Call>
-->
</New>
</Arg>
</Call>
</Configure>
17 changes: 1 addition & 16 deletions jetty-core/jetty-deploy/src/main/config/modules/core-deploy.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 15,6 @@ webapps/
[xml]
etc/jetty-core-deploy.xml

[ini]
contextHandlerClass?=org.eclipse.jetty.server.handler.ResourceHandler$ResourceContext

[ini-template]
## Monitored directory name (relative to $jetty.base)
# jetty.deploy.monitoredDir=webapps

# Defer Initial Scan
# true to have the initial scan deferred until the Server component is started.
# Note: deploy failures do not fail server startup in a deferred initial scan mode.
# false (default) to have initial scan occur as normal.
# jetty.deploy.deferInitialScan=false

## Monitored directory scan period (seconds)
# jetty.deploy.scanInterval=0

## Default ContextHandler class for core deployments
## Default ContextHandler class for "core" environment deployments
# contextHandlerClass=org.eclipse.jetty.server.handler.ResourceHandler$ResourceContext
15 changes: 14 additions & 1 deletion jetty-core/jetty-deploy/src/main/config/modules/deploy.mod
Original file line number Diff line number Diff line change
@@ -1,8 1,9 @@
[description]
This module enables web application deployment from the `$JETTY_BASE/webapps` directory.
This module enables web application context deployment from the `$JETTY_BASE/webapps` directory.

[depend]
server
deployment-manager

[lib]
lib/jetty-deploy-${jetty.version}.jar
Expand All @@ -13,3 14,15 @@ webapps/
[xml]
etc/jetty-deploy.xml

[ini-template]
## Monitored directory name (relative to $jetty.base)
# jetty.deploy.monitoredDir=webapps

# Defer Initial Scan
# true to have the initial scan deferred until the Server component is started.
# Note: deploy failures do not fail server startup in a deferred initial scan mode.
# false (default) to have initial scan occur as normal.
# jetty.deploy.deferInitialScan=false

## Monitored directory scan period (seconds)
# jetty.deploy.scanInterval=0
Original file line number Diff line number Diff line change
@@ -0,0 1,12 @@
[description]
joakime marked this conversation as resolved.
Show resolved Hide resolved
This module enables the DeploymentManager

[depend]
server

[lib]
lib/jetty-deploy-${jetty.version}.jar

[xml]
etc/jetty-deployment-manager.xml

Original file line number Diff line number Diff line change
Expand Up @@ -42,8 42,12 @@ public interface AppProvider extends LifeCycle
ContextHandler createContextHandler(App app) throws Exception;

/**
*
* @return The name of the {@link org.eclipse.jetty.util.component.Environment} this provider is for.
* @deprecated not used by all AppProviders, no generic replacement provided.
*/
String getEnvironmentName();
@Deprecated(forRemoval = true, since = "12.1.0")
default String getEnvironmentName()
{
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 32,7 @@
import org.eclipse.jetty.deploy.graph.Edge;
import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.deploy.graph.Route;
import org.eclipse.jetty.deploy.providers.ContextProvider;
import org.eclipse.jetty.server.Deployable;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
Expand Down Expand Up @@ -132,7 133,9 @@ void setLifeCycleNode(Node node)
* Get the default {@link Environment} name for deployed applications, which is
* the maximal name when using the {@link Deployable#ENVIRONMENT_COMPARATOR}.
* @return The default {@link Environment} name or null.
* @deprecated not used, replacement at {@link ContextProvider#getDefaultEnvironmentName()}
*/
@Deprecated(since = "12.1.0", forRemoval = true)
public String getDefaultEnvironmentName()
{
return _providers.stream()
Expand Down Expand Up @@ -184,6 187,10 @@ public void setAppProviders(Collection<AppProvider> providers)
}
}

/**
* @deprecated No replacement. AppProvider interface no longer has getEnvironmentName.
*/
@Deprecated(since = "12.1.0", forRemoval = true)
public boolean hasAppProviderFor(String environmentName)
{
return environmentName != null && getAppProviders().stream()
Expand Down
Loading
Loading