use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector in project webtools.servertools by eclipse.
the class Tomcat40Configuration method getServerPorts.
/**
* Returns a list of ServerPorts that this configuration uses.
*
* @return java.util.List
*/
public List getServerPorts() {
List<ServerPort> ports = new ArrayList<ServerPort>();
// first add server port
try {
int port = Integer.parseInt(server.getPort());
ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
} catch (Exception e) {
// ignore
}
// add connectors
try {
String instanceServiceName = serverInstance.getService().getName();
int size = server.getServiceCount();
for (int i = 0; i < size; i++) {
Service service = server.getService(i);
int size2 = service.getConnectorCount();
for (int j = 0; j < size2; j++) {
Connector connector = service.getConnector(j);
String className = connector.getClassName();
String name = Messages.portUnknown;
String protocol = "TCPIP";
boolean advanced = true;
String[] contentTypes = null;
int port = -1;
try {
port = Integer.parseInt(connector.getPort());
} catch (Exception e) {
// ignore
}
if (HTTP_CONNECTOR.equals(className)) {
name = "HTTP Connector";
protocol = "HTTP";
contentTypes = new String[] { "web", "webservices" };
// check for SSL connector
try {
Element element = connector.getSubElement("Factory");
if (SSL_SOCKET_FACTORY.equals(element.getAttribute("className"))) {
name = "SSL Connector";
protocol = "SSL";
}
} catch (Exception e) {
// ignore
}
if ("HTTP".equals(protocol))
advanced = false;
} else if (AJP_CONNECTOR.equals(className))
name = "AJP Connector";
else if (WARP_CONNECTOR.equals(className))
name = "Warp Connector";
String portId;
if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
portId = Integer.toString(j);
else
portId = i + "/" + j;
if (className != null && className.length() > 0)
ports.add(new ServerPort(portId, name, port, protocol, contentTypes, advanced));
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error getting server ports", e);
}
return ports;
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector in project webtools.servertools by eclipse.
the class Tomcat41Configuration method modifyServerPort.
/**
* Modify the port with the given id.
*
* @param id java.lang.String
* @param port int
*/
public void modifyServerPort(String id, int port) {
try {
if ("server".equals(id)) {
server.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
return;
}
int i = id.indexOf("/");
// If a connector in the instance Service
if (i < 0) {
int connNum = Integer.parseInt(id);
Connector connector = serverInstance.getConnector(connNum);
if (connector != null) {
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} else // Else a connector in another Service
{
int servNum = Integer.parseInt(id.substring(0, i));
int connNum = Integer.parseInt(id.substring(i + 1));
Service service = server.getService(servNum);
Connector connector = service.getConnector(connNum);
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
}
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector in project webtools.servertools by eclipse.
the class XmlTestCase method testDefaultServerXml50.
/**
* Test reading of the default server.xml provided by the
* current Tomcat 5.0 release (28).
*/
public void testDefaultServerXml50() {
Server server = getXml40Server("default.serverxml.50");
assertNotNull(server);
// Check contents of XML
String port = server.getPort();
assertEquals("8005", port);
assertEquals(server.getListenerCount(), 2);
Listener listener = server.getListener(0);
assertNotNull(listener);
assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
listener = server.getListener(1);
assertNotNull(listener);
assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
assertEquals(1, server.getServiceCount());
Service service = server.getService(0);
assertNotNull(service);
assertEquals("Catalina", service.getName());
assertEquals(2, service.getConnectorCount());
Connector connector = service.getConnector(0);
assertNotNull(connector);
assertEquals("8080", connector.getPort());
assertNull(connector.getProtocol());
connector = service.getConnector(1);
assertNotNull(connector);
assertEquals("8009", connector.getPort());
assertEquals("AJP/1.3", connector.getProtocol());
Engine engine = service.getEngine();
assertNotNull(engine);
assertEquals("Catalina", engine.getName());
assertEquals("localhost", engine.getDefaultHost());
assertEquals(engine.getHostCount(), 1);
Host host = engine.getHost(0);
assertNotNull(host);
assertEquals("localhost", host.getName());
assertEquals("webapps", host.getAppBase());
assertEquals("true", host.getAttributeValue("unpackWARs"));
assertEquals("true", host.getAttributeValue("autoDeploy"));
assertEquals(0, host.getContextCount());
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector in project webtools.servertools by eclipse.
the class XmlTestCase method testDefaultServerXml55.
/**
* Test reading of the default server.xml provided by the
* current Tomcat 5.5 release (20).
*/
public void testDefaultServerXml55() {
Server server = getXml40Server("default.serverxml.55");
assertNotNull(server);
// Check contents of XML
String port = server.getPort();
assertEquals("8005", port);
assertEquals(server.getListenerCount(), 4);
Listener listener = server.getListener(0);
assertNotNull(listener);
assertEquals("org.apache.catalina.core.AprLifecycleListener", listener.getClassName());
listener = server.getListener(1);
assertNotNull(listener);
assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
listener = server.getListener(2);
assertNotNull(listener);
assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
listener = server.getListener(3);
assertNotNull(listener);
assertEquals("org.apache.catalina.storeconfig.StoreConfigLifecycleListener", listener.getClassName());
assertEquals(server.getServiceCount(), 1);
Service service = server.getService(0);
assertNotNull(service);
assertEquals("Catalina", service.getName());
assertEquals(2, service.getConnectorCount());
Connector connector = service.getConnector(0);
assertNotNull(connector);
assertEquals("8080", connector.getPort());
assertNull(connector.getProtocol());
connector = service.getConnector(1);
assertNotNull(connector);
assertEquals("8009", connector.getPort());
assertEquals("AJP/1.3", connector.getProtocol());
Engine engine = service.getEngine();
assertNotNull(engine);
assertEquals("Catalina", engine.getName());
assertEquals("localhost", engine.getDefaultHost());
assertEquals(1, engine.getHostCount());
Host host = engine.getHost(0);
assertNotNull(host);
assertEquals("localhost", host.getName());
assertEquals("webapps", host.getAppBase());
assertEquals("true", host.getAttributeValue("unpackWARs"));
assertEquals("true", host.getAttributeValue("autoDeploy"));
assertEquals(0, host.getContextCount());
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector in project webtools.servertools by eclipse.
the class XmlTestCase method testServerInstance32.
/**
* Test behavior of ServerInstance with Tomcat 3.2 default server.xml.
*/
public void testServerInstance32() {
org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server server = getXml32Server("default.serverxml.32");
assertNotNull(server);
org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance si = new org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance(server);
assertNotNull(si.getContextManager());
org.eclipse.jst.server.tomcat.core.internal.xml.server32.Connector[] connectors = si.getConnectors();
assertNotNull(connectors);
assertEquals(2, connectors.length);
Parameter parameter = connectors[0].getParameter(0);
assertEquals("handler", parameter.getName());
assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
parameter = connectors[0].getParameter(1);
assertEquals("port", parameter.getName());
assertEquals("8080", parameter.getValue());
parameter = connectors[1].getParameter(0);
assertEquals("handler", parameter.getName());
assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
parameter = connectors[1].getParameter(1);
assertEquals("port", parameter.getName());
assertEquals("8007", parameter.getValue());
parameter = si.getConnector(0).getParameter(0);
assertEquals("handler", parameter.getName());
assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
parameter = si.getConnector(0).getParameter(1);
assertEquals("port", parameter.getName());
assertEquals("8080", parameter.getValue());
parameter = si.getConnector(1).getParameter(0);
assertEquals("handler", parameter.getName());
assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
parameter = si.getConnector(1).getParameter(1);
assertEquals("port", parameter.getName());
assertEquals("8007", parameter.getValue());
org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context[] contexts = si.getContexts();
assertNotNull(contexts);
assertEquals(2, contexts.length);
assertEquals("/examples", contexts[0].getPath());
assertEquals("/admin", contexts[1].getPath());
assertEquals("/examples", si.getContext(0).getPath());
assertEquals("/admin", si.getContext(1).getPath());
assertEquals("/examples", si.getContext("examples").getPath());
assertEquals("/admin", si.getContext("/admin").getPath());
org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context context = si.createContext(2);
context.setPath("/WebApp1");
contexts = si.getContexts();
assertNotNull(contexts);
assertEquals(3, contexts.length);
assertEquals("/examples", contexts[0].getPath());
assertEquals("/admin", contexts[1].getPath());
assertEquals("/WebApp1", contexts[2].getPath());
assertEquals(new Path("/Base/work/localhost_8080%2Fexamples"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("examples")));
assertEquals(new Path("/Base/work/localhost_8080%2Fadmin"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("admin")));
assertEquals(new Path("/Base/work/localhost_8080%2FWebApp1"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("WebApp1")));
assertTrue(si.removeContext(2));
contexts = si.getContexts();
assertNotNull(contexts);
assertEquals(2, contexts.length);
assertEquals("/examples", contexts[0].getPath());
assertEquals("/admin", contexts[1].getPath());
context = si.createContext(2);
context.setPath("");
context = si.getContext("");
assertNotNull(context);
assertEquals("", context.getPath());
assertEquals(new Path("/Base/work/localhost_8080"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("")));
assertEquals(si.getServerWorkDirectory(new Path("/Base")), new Path("/Base/work"));
}
Aggregations