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

Draft
wants to merge 52 commits into
base: jetty-12.1.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 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
2b0741b
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Jan 2, 2025
9d9267d
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Jan 14, 2025
cf69f26
Introducing DeploymentUnit to simplify added/changed/removed update b…
joakime Jan 15, 2025
4fd255b
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Jan 15, 2025
1ebdd10
Fix deprecation warnings
joakime Jan 16, 2025
d5def4c
Introduce ChangeSetListener in Scanner
joakime Jan 16, 2025
54960bd
Changes from review
joakime Jan 16, 2025
c16fdf7
Changes from review
joakime Jan 16, 2025
bc1b50f
Adding environment configuration hotreload ability
joakime Jan 17, 2025
24eb791
Correct syntax
joakime Jan 17, 2025
4d286d7
Updating Unit.calcState javadoc and unit tests.
joakime Jan 20, 2025
40052bd
Use new Unit.getLivePaths() impl
joakime Jan 20, 2025
6806b58
Isolate and cleanup deploy test that manipulate the Environment singl…
joakime Jan 21, 2025
8f32176
Merge remote-tracking branch 'origin/jetty-12.1.x' into fix/12.1.x/un…
joakime Jan 21, 2025
f92901d
Correct XML from merge
joakime Jan 21, 2025
c7fdc92
Debug for failing `JettyWebSocketTest` on CI
joakime Jan 21, 2025
745f4fe
Issue warning for overlap on reserved env configuration names in the …
joakime Jan 22, 2025
456132f
Rollback DEBUG logging
joakime Jan 22, 2025
dfd741b
Use new war filenames properly
joakime Jan 22, 2025
72c7304
Overhaul based on last PR review
joakime Jan 23, 2025
fbedd51
Fixing compilation on OSGI modules
joakime Jan 23, 2025
4bb0850
Fixing deployer XML id
joakime Jan 23, 2025
1e29659
Fixing null OSGiApp.properties
joakime Jan 23, 2025
2acf58e
More work on test stability
joakime Jan 23, 2025
7b5cd4e
Fix directory deployment issue
joakime Jan 23, 2025
318ab9e
Fixing "core" deployments
joakime Jan 24, 2025
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
31 changes: 31 additions & 0 deletions jetty-core/jetty-deploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
<artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- Using as ZIP to avoid having classes and dependencies live in test classloader -->
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-test-core-example-webapp</artifactId>
<version>${project.version}</version>
<classifier>core-webapp</classifier>
<type>zip</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
Expand All @@ -53,6 +62,28 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-core-webapps</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<includeClassifiers>core-webapp</includeClassifiers>
<includeTypes>zip</includeTypes>
<outputDirectory>${project.build.directory}/core-webapps/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<stripClassifier>true</stripClassifier>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Expand Down
37 changes: 0 additions & 37 deletions jetty-core/jetty-deploy/src/main/config/etc/jetty-core-deploy.xml

This file was deleted.

57 changes: 35 additions & 22 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,43 @@
<!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 Default Deployment Provider -->
<!-- -->
<!-- The Default Deployment Provider is responsible for monitoring -->
<!-- provided directories for web applications and hot deploying -->
<!-- through the DeploymentManager. -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Configure id="defaultDeployer" class="org.eclipse.jetty.deploy.providers.DefaultProvider">
<Call name="addMonitoredDirectory">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<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>
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.monitoredDir" default="webapps" />
</Arg>
</Call>
</Arg>
</Call>
<Set name="environmentsDirectory">
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.environmentsDir" default="environments" />
</Arg>
</Call>
</Set>
<Set name="deferInitialScan" property="jetty.deploy.deferInitialScan" />
<Set name="scanInterval" property="jetty.deploy.scanInterval" />

<Ref refid="DeploymentManager">
<Call name="addAppProvider">
<Arg>
<Ref refid="defaultDeployer" />
</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>
35 changes: 0 additions & 35 deletions jetty-core/jetty-deploy/src/main/config/modules/core-deploy.mod

This file was deleted.

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 @@ -13,136 +13,24 @@

package org.eclipse.jetty.deploy;

import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.eclipse.jetty.server.Deployable;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.FileID;

/**
* The information about an App that is managed by the {@link DeploymentManager}.
* An abstract App, the component that moves through the DeploymentManager.
*/
public class App
public interface App
{
private final DeploymentManager _manager;
private final AppProvider _provider;
private final Path _path;
private final Map<String, String> _properties = new HashMap<>();
private ContextHandler _context;

/**
* Create an App with specified Origin ID and archivePath
* <p>
* Any properties file that exists with the same {@link FileID#getBasename(Path)} as the
* filename passed will be used to initialize the properties returned by {@link #getProperties()}.
* @param manager the deployment manager
* @param provider the app provider
* @param path the path to the application directory, war file or XML descriptor
* @see App#getContextPath()
*/
public App(DeploymentManager manager, AppProvider provider, Path path)
{
_manager = manager;
_provider = provider;
_path = path;

try
{
String basename = FileID.getBasename(path);
Path properties = path.getParent().resolve(basename + ".properties");
if (Files.exists(properties))
{
try (InputStream stream = Files.newInputStream(properties))
{
Properties p = new Properties();
p.load(stream);
p.stringPropertyNames().forEach(k -> _properties.put(k, p.getProperty(k)));
}
}
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}

/**
* @return The deployment manager
*/
public DeploymentManager getDeploymentManager()
{
return _manager;
}

/**
* @return The AppProvider
*/
public AppProvider getAppProvider()
{
return _provider;
}

public Map<String, String> getProperties()
{
return _properties;
}

/**
* Get ContextHandler for the App.
*
* Create it if needed.
* The application name.
*
* @return the {@link ContextHandler} to use for the App when fully started.
* (Portions of which might be ignored when App is not yet
* {@link AppLifeCycle#DEPLOYED} or {@link AppLifeCycle#STARTED})
* @throws Exception if unable to get the context handler
* @return the application name.
*/
public ContextHandler getContextHandler() throws Exception
{
if (_context == null)
_context = getAppProvider().createContextHandler(this);
return _context;
}
String getName();

/**
* The context path {@link App} relating to how it is installed on the
* jetty server side.
* Get the active ContextHandler for this App.
*
* @return the contextPath for the App
*/
public String getContextPath()
{
return _context == null ? null : _context.getContextPath();
}

/**
* Get the environment name.
* @return The {@link org.eclipse.jetty.util.component.Environment} name for the application
* if set with the {@link Deployable#ENVIRONMENT} property, else null.
* @return the ContextHandler for the App. null means the ContextHandler hasn't been created yet.
*/
public String getEnvironmentName()
{
return getProperties().get(Deployable.ENVIRONMENT);
}

/**
* The origin of this {@link App} as specified by the {@link AppProvider}
*
* @return String representing the origin of this app.
*/
public Path getPath()
{
return _path;
}

@Override
public String toString()
{
return "App@%x[%s,%s,%s]".formatted(hashCode(), getEnvironmentName(), _context, _path);
}
ContextHandler getContextHandler();
}
Loading
Loading