/** * Returns a server, from the cache if possible and otherwise by creating * * @param type the server type * @param isLocalhost true if the server is local * @param monitor a progress monitor * @return a server working copy * @throws CoreException if anything goes wrong */ public IServerWorkingCopy getServer(IServerType type, boolean isLocalhost, IProgressMonitor monitor) throws CoreException { IServerWorkingCopy server = getCachedServer(type, isLocalhost); if (server != null) return server; server = type.createServer(null, null, (IRuntime)null, monitor); cache.put(getKey(type, isLocalhost), server); return server; }
public void runtimeFound(IRuntimeWorkingCopy runtime) { String runtimeTypeId = runtime.getRuntimeType().getId(); String serverTypeId = runtimeTypeId.substring(0, runtimeTypeId.length() - 8); IServerType serverType = ServerCore.findServerType(serverTypeId); try { IServerWorkingCopy server = serverType.createServer(serverTypeId, null, runtime, monitor); listener.serverFound(server); } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not create Tomcat server", e); } } };
/** * Get a server of the given type. */ protected IServerWorkingCopy getServer() { if (serverType == null || runtime == null || !serverType.hasRuntime()) return null; IServerWorkingCopy server = (IServerWorkingCopy) serverCache.get(runtime); if (server != null) return server; try { server = serverType.createServer(null, null, runtime, null); if (server != null) { server.setHost("localhost"); ServerUtil.setServerDefaultName(server); serverCache.put(runtime, server); return server; } } catch (CoreException ce) { Trace.trace(Trace.SEVERE, "Error creating server", ce); } return null; }