Fixing WebServer integration after created server
The web page was not loading
This commit is contained in:
parent
bebd8093c0
commit
2a6422bc6f
|
@ -42,6 +42,8 @@ public abstract class Configurable
|
|||
|
||||
private String brokerInstance;
|
||||
|
||||
private String brokerHome;
|
||||
|
||||
private FileConfiguration fileConfiguration;
|
||||
|
||||
protected String getBrokerInstance()
|
||||
|
@ -61,6 +63,23 @@ public abstract class Configurable
|
|||
return brokerInstance;
|
||||
}
|
||||
|
||||
protected String getBrokerHome()
|
||||
{
|
||||
if (brokerHome == null)
|
||||
{
|
||||
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
|
||||
the ARTEMIS_HOME variable will include back slashes (An invalid file URI character path separator). For this
|
||||
reason we overwrite the ARTEMIS_HOME variable with backslashes replaced with forward slashes. */
|
||||
brokerHome = System.getProperty("artemis.home");
|
||||
if (brokerHome != null)
|
||||
{
|
||||
brokerHome = brokerHome.replace("\\", "/");
|
||||
System.setProperty("artemis.home", brokerHome);
|
||||
}
|
||||
}
|
||||
return brokerHome;
|
||||
}
|
||||
|
||||
|
||||
protected FileConfiguration getFileConfiguration() throws Exception
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Run extends Configurable implements Action
|
|||
{
|
||||
Class clazz = this.getClass().getClassLoader().loadClass(componentDTO.componentClassName);
|
||||
ExternalComponent component = (ExternalComponent)clazz.newInstance();
|
||||
component.configure(componentDTO, getBrokerInstance());
|
||||
component.configure(componentDTO, getBrokerInstance(), getBrokerHome());
|
||||
component.start();
|
||||
components.add(component);
|
||||
}
|
||||
|
|
|
@ -21,5 +21,5 @@ import org.apache.activemq.artemis.dto.ComponentDTO;
|
|||
|
||||
public interface ExternalComponent extends ActiveMQComponent
|
||||
{
|
||||
void configure(ComponentDTO config, String activemqHome) throws Exception;
|
||||
void configure(ComponentDTO config, String artemisInstance, String artemisHome) throws Exception;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.component;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.activemq.artemis.components.ExternalComponent;
|
||||
import org.apache.activemq.artemis.dto.AppDTO;
|
||||
import org.apache.activemq.artemis.dto.ComponentDTO;
|
||||
|
@ -28,8 +30,6 @@ import org.eclipse.jetty.server.handler.ResourceHandler;
|
|||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class WebServerComponent implements ExternalComponent
|
||||
{
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class WebServerComponent implements ExternalComponent
|
|||
private WebServerDTO webServerConfig;
|
||||
|
||||
@Override
|
||||
public void configure(ComponentDTO config, String activemqHome) throws Exception
|
||||
public void configure(ComponentDTO config, String artemisInstance, String artemisHome) throws Exception
|
||||
{
|
||||
webServerConfig = (WebServerDTO)config;
|
||||
String path = webServerConfig.path.startsWith("/") ? webServerConfig.path : "/" + webServerConfig.path;
|
||||
|
@ -56,17 +56,17 @@ public class WebServerComponent implements ExternalComponent
|
|||
{
|
||||
for (AppDTO app : webServerConfig.apps)
|
||||
{
|
||||
deployWar(app.url, app.war, activemqHome, path);
|
||||
deployWar(app.url, app.war, artemisHome, path);
|
||||
}
|
||||
}
|
||||
|
||||
WebAppContext handler = new WebAppContext();
|
||||
handler.setContextPath("/");
|
||||
handler.setResourceBase(activemqHome + path);
|
||||
handler.setResourceBase(artemisHome + path);
|
||||
handler.setLogUrlOnStart(true);
|
||||
|
||||
ResourceHandler resourceHandler = new ResourceHandler();
|
||||
resourceHandler.setResourceBase(activemqHome + path);
|
||||
resourceHandler.setResourceBase(artemisHome + path);
|
||||
resourceHandler.setDirectoriesListed(true);
|
||||
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
|
||||
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -39,11 +44,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WebServerComponentTest extends Assert
|
||||
{
|
||||
static final String URL = System.getProperty("url", "http://localhost:8161/WebServerComponentTest.txt");
|
||||
|
@ -64,7 +64,7 @@ public class WebServerComponentTest extends Assert
|
|||
webServerDTO.bind = "http://localhost:8161";
|
||||
webServerDTO.path = "webapps";
|
||||
WebServerComponent webServerComponent = new WebServerComponent();
|
||||
webServerComponent.configure(webServerDTO, "./src/test/resources/");
|
||||
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
|
||||
webServerComponent.start();
|
||||
// Make the connection attempt.
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
|
Loading…
Reference in New Issue