Search in sources :

Example 6 with ServerPort

use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.

the class ConfigurationPortEditorSection method setupPortEditors.

protected void setupPortEditors() {
    viewer.setCellEditors(new CellEditor[] { null, new TextCellEditor(ports) });
    ICellModifier cellModifier = new ICellModifier() {

        public Object getValue(Object element, String property) {
            ServerPort sp = (ServerPort) element;
            if (sp.getPort() < 0)
                return "-";
            return sp.getPort() + "";
        }

        public boolean canModify(Object element, String property) {
            if ("port".equals(property))
                return true;
            return false;
        }

        public void modify(Object element, String property, Object value) {
            try {
                Item item = (Item) element;
                ServerPort sp = (ServerPort) item.getData();
                int port = Integer.parseInt((String) value);
                execute(new ModifyPortCommand(tomcatConfiguration, sp.getId(), port));
            } catch (Exception ex) {
            // ignore
            }
        }
    };
    viewer.setCellModifier(cellModifier);
    // preselect second column (Windows-only)
    String os = System.getProperty("os.name");
    if (os != null && os.toLowerCase().indexOf("win") >= 0) {
        ports.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                try {
                    int n = ports.getSelectionIndex();
                    viewer.editElement(ports.getItem(n).getData(), 1);
                } catch (Exception e) {
                // ignore
                }
            }
        });
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Item(org.eclipse.swt.widgets.Item) ServerPort(org.eclipse.wst.server.core.ServerPort)

Example 7 with ServerPort

use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.

the class ModifyPortCommand method execute.

/**
 * Execute the command.
 */
public void execute() {
    // find old port number
    Iterator iterator = configuration.getServerPorts().iterator();
    while (iterator.hasNext()) {
        ServerPort temp = (ServerPort) iterator.next();
        if (id.equals(temp.getId()))
            oldPort = temp.getPort();
    }
    // make the change
    configuration.modifyServerPort(id, port);
}
Also used : Iterator(java.util.Iterator) ServerPort(org.eclipse.wst.server.core.ServerPort)

Example 8 with ServerPort

use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.

the class Tomcat50Configuration 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;
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) ArrayList(java.util.ArrayList) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) ServerPort(org.eclipse.wst.server.core.ServerPort) CoreException(org.eclipse.core.runtime.CoreException)

Example 9 with ServerPort

use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.

the class Tomcat55Configuration 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;
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) ArrayList(java.util.ArrayList) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) ServerPort(org.eclipse.wst.server.core.ServerPort) CoreException(org.eclipse.core.runtime.CoreException)

Example 10 with ServerPort

use of org.eclipse.wst.server.core.ServerPort in project webtools.servertools by eclipse.

the class Tomcat60Configuration 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;
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) ArrayList(java.util.ArrayList) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) ServerPort(org.eclipse.wst.server.core.ServerPort) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ServerPort (org.eclipse.wst.server.core.ServerPort)26 CoreException (org.eclipse.core.runtime.CoreException)14 ArrayList (java.util.ArrayList)10 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)9 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)9 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 Iterator (java.util.Iterator)3 TableItem (org.eclipse.swt.widgets.TableItem)3 IOException (java.io.IOException)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 IModule (org.eclipse.wst.server.core.IModule)2 IStaticWeb (org.eclipse.wst.server.core.util.IStaticWeb)2 Element (org.w3c.dom.Element)2 List (java.util.List)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 Port (org.eclipse.jst.server.generic.servertype.definition.Port)1 IMemento (org.eclipse.jst.server.preview.adapter.internal.IMemento)1 XMLMemento (org.eclipse.jst.server.preview.adapter.internal.XMLMemento)1 ITomcatConfigurationWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy)1