-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: b=main,r=48e6a2cb8a9170eb249958cf3b58a4b58ffecbac,t=2024-05…
…-03-1242-44277
- Loading branch information
1 parent
7b08c2f
commit 18d4727
Showing
39 changed files
with
596 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ore/src/main/java/org/sonatype/nexus/internal/script/groovy/GroovyScriptEngineLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.internal.script.groovy; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import javax.script.ScriptEngineManager; | ||
|
||
import org.sonatype.nexus.common.app.ApplicationDirectories; | ||
import org.sonatype.nexus.common.app.ManagedLifecycle; | ||
import org.sonatype.nexus.common.stateguard.StateGuardLifecycleSupport; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
import static org.sonatype.nexus.common.app.ManagedLifecycle.Phase.SERVICES; | ||
|
||
/** | ||
* Groovy script engine loader. Is used to run groovy scripts. | ||
*/ | ||
@Named | ||
@Singleton | ||
@ManagedLifecycle(phase = SERVICES) | ||
public class GroovyScriptEngineLoader | ||
extends StateGuardLifecycleSupport | ||
{ | ||
private final ClassLoader classLoader; | ||
|
||
private final ApplicationDirectories applicationDirectories; | ||
|
||
private final ScriptEngineManager scriptEngineManager; | ||
|
||
@Inject | ||
public GroovyScriptEngineLoader( | ||
final @Named("nexus-uber") ClassLoader classLoader, | ||
final ApplicationDirectories applicationDirectories, | ||
final ScriptEngineManager scriptEngineManager) | ||
{ | ||
this.classLoader = checkNotNull(classLoader); | ||
this.applicationDirectories = checkNotNull(applicationDirectories); | ||
this.scriptEngineManager = checkNotNull(scriptEngineManager); | ||
} | ||
|
||
@Override | ||
protected void doStart() throws Exception { | ||
GroovyScriptEngineFactory groovyEngineFactory = new GroovyScriptEngineFactory(classLoader, applicationDirectories); | ||
log.debug("Registering engine-factory: {}", groovyEngineFactory); | ||
groovyEngineFactory.getNames().forEach(name -> scriptEngineManager.registerEngineName(name, groovyEngineFactory)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.