[370832] Auto publish will not triggered for structure changes
diff --git a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
index bbe43e8..e9540d9 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
+++ b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
@@ -15,6 +15,8 @@
<h3>Plugin(s) replaced:</h3>
<ul><li>org.eclipse.wst.server.core</li></ul>
<p>Bug <a href='https://bugs.eclipse.org/364482'>364482</a>. A race condition could occur in Server code</p>
+<p>Bug <a href='https://bugs.eclipse.org/370832'>370832</a>. Auto publish will not triggered for structure changes</p>
+<p>Bug <a href='https://bugs.eclipse.org/370992'>370992</a>. Extensible Server Start Jobs</p>
</body></html>
\ No newline at end of file
diff --git a/features/org.eclipse.wst.server_core.feature.patch/feature.properties b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
index c44afc3..ebad37a 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/feature.properties
+++ b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
@@ -28,6 +28,8 @@
Contains fixes described in the following bugzilla(s):\n\
\n\
Bug https://bugs.eclipse.org/364482 A race condition could occur in Server code\n\
+Bug https://bugs.eclipse.org/370832 Auto publish will not triggered for structure changes\n\
+Bug https://bugs.eclipse.org/370992 Extensible Server Start Jobs\n\
\n\
# "copyright" property - text of the "Feature Update Copyright"
copyright=\
diff --git a/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd b/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd
index 02ff65b..20cd1fc 100644
--- a/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd
+++ b/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd
@@ -165,6 +165,13 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="synchronousStart" type="boolean">
+ <annotation>
+ <documentation>
+ boolean value "true" or "false" to specify whether the server needs to be started synchronously. If "true", the server will execute publish and start jobs serially.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
index cdedc84..bfec066 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -230,6 +230,7 @@
if (getServerPublishInfo().hasStructureChanged(modules2)) {
int newState = getServerPublishState() == IServer.PUBLISH_STATE_FULL ? IServer.PUBLISH_STATE_FULL : IServer.PUBLISH_STATE_INCREMENTAL;
setServerPublishState(newState);
+ changed[0] = true;
}
if (!changed[0])
@@ -1999,7 +2000,8 @@
// make sure that the delegate is loaded and the server state is correct
loadAdapter(ServerBehaviourDelegate.class, null);
- IStatus status = publishBeforeStart(monitor,false);
+ boolean synchronous = ((ServerType)getServerType()).synchronousStart();
+ IStatus status = publishBeforeStart(monitor,synchronous);
if (status != null && status.getSeverity() == IStatus.ERROR){
if (Trace.FINEST) {
@@ -2011,6 +2013,7 @@
StartJob startJob = new StartJob(mode2);
// 287442 - only do publish after start if the server start is successful.
final IProgressMonitor monitor2 = monitor;
+ final boolean synchronous2 = synchronous;
startJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
IStatus resultStatus = event.getResult();
@@ -2020,11 +2023,19 @@
"Skipping auto publish after server start since the server start failed.");
}
} else {
- publishAfterStart(monitor2,false,null);
+ publishAfterStart(monitor2,synchronous2,null);
}
}
});
startJob.schedule();
+ try {
+ if(synchronous)
+ startJob.join();
+ } catch (InterruptedException e) {
+ if (Trace.WARNING) {
+ Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e);
+ }
+ }
}
/**
@@ -2040,7 +2051,8 @@
// make sure that the delegate is loaded and the server state is correct
loadAdapter(ServerBehaviourDelegate.class, null);
- IStatus status = publishBeforeStart(null,false);
+ boolean synchronous = ((ServerType)getServerType()).synchronousStart();
+ IStatus status = publishBeforeStart(null,synchronous);
if (status != null && status.getSeverity() == IStatus.ERROR){
if (Trace.FINEST) {
@@ -2073,6 +2085,7 @@
});
}
// 287442 - only do publish after start if the server start is successful.
+ final boolean synchronous2 = synchronous;
if (pub == StartJob.PUBLISH_AFTER) {
startJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
@@ -2086,12 +2099,21 @@
opListener.done(Status.OK_STATUS);
}
else {
- publishAfterStart(null,false,opListener);
+ publishAfterStart(null,synchronous2,opListener);
}
}
});
}
startJob.schedule();
+
+ try {
+ if(synchronous)
+ startJob.join();
+ } catch (InterruptedException e) {
+ if (Trace.WARNING) {
+ Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e);
+ }
+ }
}
public void synchronousStart(String mode2, IProgressMonitor monitor) throws CoreException {
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
index c4668fa..a72a72a 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -70,6 +70,14 @@
}
}
+ public boolean synchronousStart() {
+ try {
+ return "true".equals(element.getAttribute("synchronousStart"));
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
public String getDescription() {
try {
return element.getAttribute("description");