public static void serverAdded(IServer server) { ICarbonOperationManager serverOperationManager = getServerOperationManager(server); if (serverOperationManager != null) { getServers().add(server); isServerAdded = true; IServerManager wsasServerManager = ServerController.getInstance().getServerManager(); HashMap<String, Object> operationParameters = new HashMap<String, Object>(); operationParameters.put( ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_GET_SERVER_PORTS); Object r; CarbonServerInformation serverInformation = new CarbonServerInformation(); serverInformation.setServerId(server.getId()); ServerPort[] wsasPorts = new ServerPort[] {}; try { r = wsasServerManager.executeOperationOnServer(server, operationParameters); if (r instanceof ServerPort[]) wsasPorts = (ServerPort[]) r; CarbonServerUtils.setServicePath(server); } catch (NoSuchCarbonOperationDefinedException e) { // ports cannot be retrieved } catch (Exception e) { log.error(e); } serverInformation.setServerPorts(wsasPorts); // The localrepo path is for now is the bin distribution path. this // needs to be fixed in order to be set inside the workspace path // String workspaceRootPath = // ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); // String serverPath=FileUtils.addNodesToPath(workspaceRootPath, new // String[]{".metadata",".carbon",server.getId()}); IPath serverHome = getServerHome(server); if (serverHome != null) { String serverPath = serverHome.toOSString(); (new File(serverPath)).mkdirs(); serverInformation.setServerLocalWorkspacePath(serverPath); } getAppServerInformation().put(server, serverInformation); try { initializeServerConfigurations(server); } catch (Exception e) { log.error(e); } } }
public static URL getServerURL(IServer server) throws Exception { if (server != null) { IServerManager esbServerManager = ServerController.getInstance().getServerManager(); HashMap<String, Object> operationParameters = new HashMap<String, Object>(); operationParameters.put( ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_SERVER_URL); Object serverURL = esbServerManager.executeOperationOnServer(server, operationParameters); if (serverURL instanceof URL) { String serverId = server.getServerType().getId(); URL urlWithContextRoot = (URL) serverURL; if (!CARBON_SERVER_TYPE_REMOTE.equals(serverId)) { urlWithContextRoot = new URL(urlWithContextRoot, CarbonServerUtils.getWebContextRoot(server)); } return urlWithContextRoot; } } return null; }