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

Payara 1529 #1505

Merged
merged 5 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Portions Copyright [2016] [Payara Foundation and/or its affiliates]
<jmx-connector port="8686" address="0.0.0.0" security-enabled="false" auth-realm-name="admin-realm" name="system" enabled="false"></jmx-connector>
<das-config></das-config>
</admin-service>
<connector-service shutdown-timeout-in-seconds="30">
<connector-service class-loading-policy="global" shutdown-timeout-in-seconds="30">
</connector-service>
<ejb-container steady-pool-size="0" max-pool-size="32" session-store="${com.sun.aas.instanceRoot}/session-store" pool-resize-quantity="8">
<ejb-timer-service ejb-timer-service="Hazelcast"></ejb-timer-service>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# File of asadmin commands to run after all deployments
# don't add asadmin onto the command line for example
# generate-jvm-report
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
package fish.payara.micro.boot.runtime;

import com.hazelcast.logging.Logger;
import java.util.logging.Level;
import org.glassfish.embeddable.CommandResult;
import org.glassfish.embeddable.CommandResult.ExitStatus;
import org.glassfish.embeddable.CommandRunner;
Expand All @@ -62,6 +64,7 @@ public boolean execute(CommandRunner runner) {
boolean result = true;
CommandResult asadminResult = runner.run(command, arguments);
if (asadminResult.getExitStatus().equals(ExitStatus.FAILURE)) {
Logger.getLogger(BootCommand.class).log(Level.WARNING, "Boot Command " + command + " failed " + asadminResult.getOutput());
result = false;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public GlassFish newGlassFish(GlassFishProperties glassfishProperties) throws Gl
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(context));
config.commit();
registry.populateServiceLocator("default", habitat, Arrays.asList(new EmbeddedInhabitantsParser(), new DuplicatePostProcessor()));
registry.populateServiceLocator("default", habitat, Arrays.asList(new PayaraMicroInhabitantsParser(), new EmbeddedInhabitantsParser(), new DuplicatePostProcessor()));
registry.populateConfig(habitat);
ModuleStartup kernel = habitat.getService(ModuleStartup.class);
gf = new MicroGlassFish(kernel, habitat, glassfishProperties.getProperties());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.micro.boot.runtime;

import org.glassfish.hk2.api.PopulatorPostProcessor;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.DescriptorImpl;

/**
* Payara Micro HK2 Service post processor
* @author Steve Millidge (Payara Foundation)
*/
public class PayaraMicroInhabitantsParser implements PopulatorPostProcessor {

@Override
public DescriptorImpl process(ServiceLocator sl, DescriptorImpl di) {
if ("org.glassfish.ejb.persistent.timer.DistributedEJBTimerService".equals(di.getImplementation())) {
return null;
}
return di;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @author steve
*/
public enum RUNTIME_OPTION {
nocluster(false), deploydir(true, new DirectoryValidator(true, true, false)), deploy(true, new FileSystemItemValidator(true, true, false, true, true)), port(true, new PortValidator()), sslport(true, new PortValidator()), name(true), instancegroup(true), group(true), mcaddress(true, new MulticastValidator()), mcport(true, new PortValidator()), clustername(true), clusterpassword(true), hostaware(false), startport(true, new PortValidator()), rootdir(true, new DirectoryValidator(true, true, true)), deploymentdir(true, new DirectoryValidator(true, true, false)), domainconfig(true, new FileValidator(true, true, true)), minhttpthreads(true, new IntegerValidator(1, Integer.MAX_VALUE)), maxhttpthreads(true, new IntegerValidator(2, Integer.MAX_VALUE)), hzconfigfile(true, new FileValidator(true, true, false)), autobindhttp(false), autobindssl(false), autobindrange(true, new IntegerValidator(1, 100000)), lite(false), enablehealthcheck(true), logo(false), deployfromgav(true), additionalrepository(true), outputuberjar(true, new FileValidator(false, false, false)), systemproperties(true, new FileValidator(true, true, false)), disablephonehome(false), version(false), logtofile(true, new FileValidator(false, false, false)), logproperties(true, new FileValidator(true, true, false)), accesslog(true, new DirectoryValidator(true, true, true)), accesslogformat(true), enablerequesttracing(false), requesttracingthresholdunit(true), requesttracingthresholdvalue(true), prebootcommandfile(true, new FileValidator(true, true, false)), postbootcommandfile(true, new FileValidator(true, true, false)), nested(false), unpackdir(true, new DirectoryValidator(true, true, true)), help(false);
nocluster(false), deploydir(true, new DirectoryValidator(true, true, false)), deploy(true, new FileSystemItemValidator(true, true, false, true, true)), port(true, new PortValidator()), sslport(true, new PortValidator()), name(true), instancegroup(true), group(true), mcaddress(true, new MulticastValidator()), mcport(true, new PortValidator()), clustername(true), clusterpassword(true), hostaware(false), startport(true, new PortValidator()), rootdir(true, new DirectoryValidator(true, true, true)), deploymentdir(true, new DirectoryValidator(true, true, false)), domainconfig(true, new FileValidator(true, true, true)), minhttpthreads(true, new IntegerValidator(1, Integer.MAX_VALUE)), maxhttpthreads(true, new IntegerValidator(2, Integer.MAX_VALUE)), hzconfigfile(true, new FileValidator(true, true, false)), autobindhttp(false), autobindssl(false), autobindrange(true, new IntegerValidator(1, 100000)), lite(false), enablehealthcheck(true), logo(false), deployfromgav(true), additionalrepository(true), outputuberjar(true, new FileValidator(false, false, false)), systemproperties(true, new FileValidator(true, true, false)), disablephonehome(false), version(false), logtofile(true, new FileValidator(false, false, false)), logproperties(true, new FileValidator(true, true, false)), accesslog(true, new DirectoryValidator(true, true, true)), accesslogformat(true), enablerequesttracing(false), requesttracingthresholdunit(true), requesttracingthresholdvalue(true), prebootcommandfile(true, new FileValidator(true, true, false)), postbootcommandfile(true, new FileValidator(true, true, false)), postdeploycommandfile(true, new FileValidator(true,true,false)), nested(false), unpackdir(true, new DirectoryValidator(true, true, true)), help(false);

private RUNTIME_OPTION(boolean value) {
this(value, new Validator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public class PayaraMicroImpl implements PayaraMicroBoot {
private final short defaultHttpsPort = 8181;
private BootCommands preBootCommands;
private BootCommands postBootCommands;
private BootCommands postDeployCommands;
private String userLogFile = "payara-server%u.log";
private String userAccessLogDirectory = "";
private String accessLogFormat = "%client.name% %auth-user-name% %datetime% %request% %status% %response.length%";
Expand All @@ -157,6 +158,7 @@ public class PayaraMicroImpl implements PayaraMicroBoot {
private String instanceGroup;
private String preBootFileName;
private String postBootFileName;
private String postDeployFileName;
private RuntimeDirectory runtimeDir = null;

/**
Expand Down Expand Up @@ -981,6 +983,7 @@ public PayaraMicroRuntime bootStrap() throws BootstrapException {
deployAll();

postBootActions();
postDeployCommands.executeCommands(gf.getCommandRunner());

long end = System.currentTimeMillis();
dumpFinalStatus(end - start);
Expand Down Expand Up @@ -1025,6 +1028,7 @@ private PayaraMicroImpl() {
repositoryURLs = new LinkedList<>();
preBootCommands = new BootCommands();
postBootCommands = new BootCommands();
postDeployCommands = new BootCommands();
try {
repositoryURLs.add(new URL(defaultMavenRepository));
} catch (MalformedURLException ex) {
Expand Down Expand Up @@ -1264,6 +1268,9 @@ else if (requestTracing[0].matches("\\D+")) {
case prebootcommandfile:
preBootFileName = value;
break;
case postdeploycommandfile:
postDeployFileName = value;
break;
default:
break;
}
Expand Down Expand Up @@ -1297,9 +1304,53 @@ private void setSystemProperties(File propertiesFile) throws IllegalArgumentExce
}

private void deployAll() throws GlassFishException {
// Deploy explicit wars first.

// Deploy from within the jar first.
int deploymentCount = 0;
Deployer deployer = gf.getDeployer();
Deployer deployer = gf.getDeployer();
// search MICRO-INF/deploy for deployments
// if there is a deployment called ROOT deploy to the root context /
URL url = this.getClass().getClassLoader().getResource("MICRO-INF/deploy");
if (url != null) {
String entryName = "";
try {
List<String> entriesToDeploy = new LinkedList<>();
JarURLConnection urlcon = (JarURLConnection) url.openConnection();
JarFile jFile = urlcon.getJarFile();
Enumeration<JarEntry> entries = jFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
entryName = entry.getName();
if (!entry.isDirectory() && !entryName.endsWith(".properties") && !entryName.endsWith(".xml") && !entryName.endsWith(".gitkeep") && entryName.startsWith("MICRO-INF/deploy")) {
entriesToDeploy.add(entryName);
}
}

for (String entry : entriesToDeploy) {
File file = new File(entry);
String contextRoot = file.getName();
String name = contextRoot.substring(0, contextRoot.length() - 4);
if (contextRoot.endsWith(".ear") || contextRoot.endsWith(".war") || contextRoot.endsWith(".jar") || contextRoot.endsWith(".rar")) {
contextRoot = name;
}

if (contextRoot.equals("ROOT")) {
contextRoot = "/";
}

deployer.deploy(this.getClass().getClassLoader().getResourceAsStream(entry), "--availabilityenabled",
"true", "--contextroot",
contextRoot, "--name", name, "--force","true");
deploymentCount++;
}
} catch (IOException ioe) {
LOGGER.log(Level.WARNING, "Could not deploy jar entry {0}",
entryName);
}
} else {
LOGGER.info("No META-INF/deploy directory");
}

if (deployments != null) {
for (File war : deployments) {
if (war.exists() && war.canRead()) {
Expand Down Expand Up @@ -1355,48 +1406,6 @@ private void deployAll() throws GlassFishException {
}
}

// search MICRO-INF/deploy for deployments
// if there is a deployment called ROOT deploy to the root context /
URL url = this.getClass().getClassLoader().getResource("MICRO-INF/deploy");
if (url != null) {
String entryName = "";
try {
HashSet<String> entriesToDeploy = new HashSet<>();
JarURLConnection urlcon = (JarURLConnection) url.openConnection();
JarFile jFile = urlcon.getJarFile();
Enumeration<JarEntry> entries = jFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
entryName = entry.getName();
if (!entry.isDirectory() && !entryName.endsWith(".properties") && !entryName.endsWith(".xml") && !entryName.endsWith(".gitkeep") && entryName.startsWith("MICRO-INF/deploy")) {
entriesToDeploy.add(entryName);
}
}

for (String entry : entriesToDeploy) {
File file = new File(entry);
String contextRoot = file.getName();
if (contextRoot.endsWith(".ear") || contextRoot.endsWith(".war") || contextRoot.endsWith(".jar") || contextRoot.endsWith(".rar")) {
contextRoot = contextRoot.substring(0, contextRoot.length() - 4);
}

if (contextRoot.equals("ROOT")) {
contextRoot = "/";
}

deployer.deploy(this.getClass().getClassLoader().getResourceAsStream(entry), "--availabilityenabled",
"true", "--contextroot",
contextRoot, "--name", file.getName(), "--force","true");
deploymentCount++;
}
} catch (IOException ioe) {
LOGGER.log(Level.WARNING, "Could not deploy jar entry {0}",
entryName);
}
} else {
LOGGER.info("No META-INF/deploy directory");
}

LOGGER.log(Level.INFO, "Deployed {0} archive(s)", deploymentCount);
}

Expand Down Expand Up @@ -1519,6 +1528,15 @@ private void configureCommandFiles() throws IOException {
if (postBootFileName != null) {
postBootCommands.parseCommandScript(new File(postBootFileName));
}

scriptURL = Thread.currentThread().getContextClassLoader().getResource("MICRO-INF/post-deploy-commands.txt");
if (scriptURL != null) {
postDeployCommands.parseCommandScript(scriptURL);
}

if (postDeployFileName != null) {
postDeployCommands.parseCommandScript(new File(postDeployFileName));
}
}

private void configureAccessLogging() {
Expand Down Expand Up @@ -1928,6 +1946,10 @@ private void packageUberJar() {
if (preBootFileName != null) {
creator.setPreBootCommands(new File(preBootFileName));
}

if (postDeployFileName != null) {
creator.setPostDeployCommands(new File(postDeployFileName));
}

if (logPropertiesFile) {
creator.setLoggingPropertiesFile(new File(userLogPropertiesFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class UberJarCreator {
private File postBootCommands;

private static final Logger LOGGER = Logger.getLogger(UberJarCreator.class.getName());
private File postDeployCommands;

UberJarCreator(String fileName) {
this(new File(fileName));
Expand Down Expand Up @@ -127,6 +128,10 @@ public void setPreBootCommands(File preBootCommands) {
public void setPostBootCommands(File postBootCommands) {
this.postBootCommands = postBootCommands;
}

public void setPostDeployCommands(File postDeployCommands) {
this.postDeployCommands = postDeployCommands;
}

public void addRuntimeJar(File jar) {
runtimeJars.add(jar);
Expand Down Expand Up @@ -197,7 +202,9 @@ public void buildUberJar() {
is = new FileInputStream(postBootCommands);
} else if (entry.toString().contains("MICRO-INF/pre-boot-commands.txt") && (preBootCommands != null)) {
is = new FileInputStream(preBootCommands);
} else if (entry.toString().contains("MICRO-INF/domain/domain.xml") && (domainXML != null)) {
} else if (entry.toString().contains("MICRO-INF/post-deploy-commands.txt") && (postDeployCommands != null)) {
is = new FileInputStream(postDeployCommands);
}else if (entry.toString().contains("MICRO-INF/domain/domain.xml") && (domainXML != null)) {
is = new FileInputStream(domainXML);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ requesttracingthresholdunit=Sets the time unit for the requestTracingThresholdVa
requesttracingthresholdvalue=Sets the threshold time before a request is traced
prebootcommandfile=Provides a file of asadmin commands to run before booting the server
postbootcommandfile=Provides a file of asadmin commands to run after booting the server
postdeploycommandfile=Provides a file of asadmin commands to run after all deployments have completed
help=Shows this message and exits
instancegroup=Sets the instance group
group=Sets the instance group
Expand Down
29 changes: 29 additions & 0 deletions appserver/extras/payara-micro/payara-micro-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,35 @@
<type>zip</type>
<optional>true</optional>
</dependency>
<!-- JMS Clilent dependencies -->
<dependency>
<groupId>org.glassfish.main.ejb</groupId>
<artifactId>ejb-full-container</artifactId>
<version>${project.version}</version>
<type>jar</type>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.main.security</groupId>
<artifactId>ejb.security</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.connectors</groupId>
<artifactId>connectors-inbound-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.jms</groupId>
<artifactId>gf-jms-injection</artifactId>
<version>${project.version}</version>
</dependency>
<!-- End of JMS Client Dependencies -->
<dependency>
<groupId>org.glassfish.main.packager</groupId>
<artifactId>glassfish-jsf</artifactId>
Expand Down
Loading