use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.
the class GenericServer method getServerPorts.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.server.core.model.IMonitorableServer#getServerPorts()
*/
public org.eclipse.wst.server.core.ServerPort[] getServerPorts() {
List<ServerPort> ports = new ArrayList<ServerPort>();
Iterator pIter = this.getServerDefinition().getPort().iterator();
while (pIter.hasNext()) {
Port element = (Port) pIter.next();
int port = Integer.parseInt(getServerDefinition().getResolver().resolveProperties(element.getNo()));
// $NON-NLS-1$
ports.add(new ServerPort("server", element.getName(), port, element.getProtocol()));
}
return ports.toArray(new org.eclipse.wst.server.core.ServerPort[ports.size()]);
}
use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.
the class GenericServerBehaviour method startPingThread.
/**
* Call to start Ping thread that will check for startup of the server.
*/
protected void startPingThread() {
try {
// $NON-NLS-1$
String url = "http://" + getServer().getHost();
ServerPort[] ports = getServer().getServerPorts(null);
ServerPort sp = null;
for (int i = 0; i < ports.length; i++) {
if (ports[i].getProtocol().equalsIgnoreCase("http")) {
// $NON-NLS-1$
sp = ports[i];
}
}
if (sp == null) {
// $NON-NLS-1$
Trace.trace(Trace.SEVERE, "Can't ping for server startup.");
return;
}
int port = sp.getPort();
if (port != 80)
// $NON-NLS-1$
url += ":" + port;
ping = new PingThread(getServer(), url, this);
} catch (Exception e) {
// $NON-NLS-1$
Trace.trace(Trace.SEVERE, "Can't ping for server startup.");
}
}
use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.
the class Tomcat85Configuration 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 name = "HTTP/1.1";
String protocol2 = "HTTP";
boolean advanced = true;
String[] contentTypes = null;
int port = -1;
try {
port = Integer.parseInt(connector.getPort());
} catch (Exception e) {
// ignore
}
String protocol = connector.getProtocol();
if (protocol != null && protocol.length() > 0) {
if (protocol.startsWith("HTTP")) {
name = protocol;
} else if (protocol.startsWith("AJP")) {
name = protocol;
protocol2 = "AJP";
} else {
// Get Tomcat equivalent name if protocol handler class specified
name = protocolHandlerMap.get(protocol);
if (name != null) {
// Prepare simple protocol string for ServerPort protocol
int index = name.indexOf('/');
if (index > 0)
protocol2 = name.substring(0, index);
else
protocol2 = name;
} else // Specified protocol is unknown, just use as is
{
name = protocol;
protocol2 = protocol;
}
}
}
if (protocol2.toLowerCase().equals("http"))
contentTypes = new String[] { "web", "webservices" };
String secure = connector.getSecure();
if (secure != null && secure.length() > 0) {
name = "SSL";
protocol2 = "SSL";
} else
advanced = false;
String portId;
if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
portId = Integer.toString(j);
else
portId = i + "/" + j;
ports.add(new ServerPort(portId, name, port, protocol2, contentTypes, advanced));
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error getting server ports", e);
}
return ports;
}
use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.
the class ConfigurationPortEditorSection method initialize.
/**
* Initialize the fields in this editor.
*/
protected void initialize() {
if (ports == null)
return;
ports.removeAll();
Iterator iterator = tomcatConfiguration.getServerPorts().iterator();
while (iterator.hasNext()) {
ServerPort port = (ServerPort) iterator.next();
TableItem item = new TableItem(ports, SWT.NONE);
String portStr = "-";
if (port.getPort() >= 0)
portStr = port.getPort() + "";
String[] s = new String[] { port.getName(), portStr };
item.setText(s);
item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PORT));
item.setData(port);
}
if (readOnly) {
viewer.setCellEditors(new CellEditor[] { null, null });
viewer.setCellModifier(null);
} else {
setupPortEditors();
}
}
use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.
the class ConfigurationPortEditorSection method changePortNumber.
/**
* @param id java.lang.String
* @param port int
*/
protected void changePortNumber(String id, int port) {
TableItem[] items = ports.getItems();
int size = items.length;
for (int i = 0; i < size; i++) {
ServerPort sp = (ServerPort) items[i].getData();
if (sp.getId().equals(id)) {
items[i].setData(new ServerPort(id, sp.getName(), port, sp.getProtocol()));
items[i].setText(1, port + "");
/*if (i == selection) {
selectPort();
}*/
return;
}
}
}
Aggregations