org.eclipse.wst.server.core.ServerCore Java Examples
The following examples show how to use
org.eclipse.wst.server.core.ServerCore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebContainerUtils.java From developer-studio with Apache License 2.0 | 6 votes |
public static String getDeployedWSDLURL(IProject serverProject, String ServerFactoryId, String ServerInstanceId, String serviceName){ // Note that ServerCore.findServer() might return null if the server cannot be found and // ServerUtils.getEncodedWebComponentURL() can handle null server properly (by using ServerFactoryId) String deployedWSDLURLpath = null; IServer server = null; if (ServerInstanceId != null) { server = ServerCore.findServer(ServerInstanceId); } deployedWSDLURLpath = ServerUtils.getEncodedWebComponentURL(serverProject, ServerFactoryId, server); if (deployedWSDLURLpath == null) { deployedWSDLURLpath = Constants.LOCAL_SERVER_PORT; } String[] deployedWSDLURLParts = {Constants.SERVICES,serviceName}; return FileUtils.addNodesToURL(deployedWSDLURLpath, deployedWSDLURLParts)+"?wsdl"; }
Example #2
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void updateRuntimeLocationIfNeeded() { for (final IRuntime runtime : ServerCore.getRuntimes()) { if (runtime instanceof org.eclipse.wst.server.core.internal.Runtime && runtime.getLocation() != null && !runtime.getLocation().toFile().getAbsolutePath().equals(tomcatInstanceLocation)) { final IRuntimeWorkingCopy copy = runtime.createWorkingCopy(); final String oldLocation = copy.getLocation().toFile() .getAbsolutePath(); copy.setLocation(Path.fromOSString(tomcatInstanceLocation)); final File serverXmlFile = new File(tomcatInstanceLocation, "conf" + File.separatorChar + "server.xml"); try { com.google.common.io.Files.write( com.google.common.io.Files.toString(serverXmlFile, UTF8_CHARSET).replace(oldLocation, tomcatInstanceLocation), serverXmlFile, UTF8_CHARSET); } catch (final IOException e1) { BonitaStudioLog.error(e1, EnginePlugin.PLUGIN_ID); } try { copy.save(true, Repository.NULL_PROGRESS_MONITOR); } catch (final CoreException e) { BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID); } } } }
Example #3
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IServer createServer(final IProgressMonitor monitor, final IProject confProject, final IRuntime runtime) throws CoreException { final IServerType sType = ServerCore.findServerType(TOMCAT_SERVER_TYPE); final IFile file = confProject.getFile("bonitaTomcatServerSerialization"); final IFolder configurationFolder = confProject .getFolder("tomcat_conf"); final File sourceFolder = new File(tomcatInstanceLocation, "conf"); PlatformUtil.copyResource(configurationFolder.getLocation().toFile(), sourceFolder, Repository.NULL_PROGRESS_MONITOR); configurationFolder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR); final IServer server = configureServer(runtime, sType, file, configurationFolder, monitor); portConfigurator = newPortConfigurator(server); portConfigurator.configureServerPort(Repository.NULL_PROGRESS_MONITOR); return server; }
Example #4
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IServer configureServer(final IRuntime runtime, final IServerType sType, final IFile file, final IFolder configurationFolder, final IProgressMonitor monitor) throws CoreException { final IServer server = ServerCore.findServer(BONITA_TOMCAT_SERVER_ID); IServerWorkingCopy serverWC = null; if (server != null) { serverWC = server.createWorkingCopy(); } if (serverWC == null) { serverWC = sType.createServer(BONITA_TOMCAT_SERVER_ID, file, runtime, monitor); } serverWC.setServerConfiguration(configurationFolder); serverWC.setAttribute(ITomcatServer.PROPERTY_INSTANCE_DIR, tomcatInstanceLocation); serverWC.setAttribute(ITomcatServer.PROPERTY_DEPLOY_DIR, tomcatInstanceLocation + File.separatorChar + "webapps"); serverWC.setAttribute(START_TIMEOUT, 300); return serverWC.save(true, monitor); }
Example #5
Source File: AppEngineStandardFacet.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
public static org.eclipse.wst.server.core.IRuntime createAppEngineServerRuntime( IProgressMonitor monitor) throws CoreException { IRuntimeType appEngineRuntimeType = ServerCore.findRuntimeType(AppEngineStandardFacet.DEFAULT_RUNTIME_ID); if (appEngineRuntimeType == null) { logger.warning("RuntimeTypes: " + Joiner.on(",").join(ServerCore.getRuntimeTypes())); throw new NullPointerException( "Could not find " + AppEngineStandardFacet.DEFAULT_RUNTIME_NAME + " runtime type"); } IRuntimeWorkingCopy appEngineRuntimeWorkingCopy = appEngineRuntimeType.createRuntime(null /* id */, monitor); return appEngineRuntimeWorkingCopy.save(true, monitor); }
Example #6
Source File: AppEngineStandardFacet.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static org.eclipse.wst.server.core.IRuntime[] getAppEngineRuntimes() { org.eclipse.wst.server.core.IRuntime[] allRuntimes = ServerCore.getRuntimes(); List<org.eclipse.wst.server.core.IRuntime> appEngineRuntimes = new ArrayList<>(); for (int i = 0; i < allRuntimes.length; i++) { if (isAppEngineStandardRuntime(allRuntimes[i])) { appEngineRuntimes.add(allRuntimes[i]); } } org.eclipse.wst.server.core.IRuntime[] appEngineRuntimesArray = new org.eclipse.wst.server.core.IRuntime[appEngineRuntimes.size()]; return appEngineRuntimes.toArray(appEngineRuntimesArray); }
Example #7
Source File: LocalAppEngineServerDelegateTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private LocalAppEngineServerDelegate getDelegateWithServer() throws CoreException { IServerWorkingCopy serverWorkingCopy = ServerCore.findServerType("com.google.cloud.tools.eclipse.appengine.standard.server") .createServer("testServer", null, null); IRuntimeWorkingCopy runtimeWorkingCopy = ServerCore.findRuntimeType("com.google.cloud.tools.eclipse.appengine.standard.runtime") .createRuntime("testRuntime", null); IRuntime runtime = runtimeWorkingCopy.save(true, null); serverWorkingCopy.setRuntime(runtime); IServer original = serverWorkingCopy.save(true, null); return LocalAppEngineServerDelegate.getAppEngineServer(original); }
Example #8
Source File: LocalAppEnginePublishOperationTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Verify that multi-web-module works. */ @Test public void testPublishingSubmodules() throws CoreException { IServerType serverType = ServerCore.findServerType("com.google.cloud.tools.eclipse.appengine.standard.server"); IServerWorkingCopy serverWorkingCopy = serverType.createServer(getClass().getName(), null, null); serverWorkingCopy.modifyModules(new IModule[] {serverModule}, null, null); server = serverWorkingCopy.saveAll(true, null); assertTrue(server.canPublish().isOK()); assertTrue("publish failed", server.publish(IServer.PUBLISH_CLEAN, null).isOK()); LocalAppEngineServerBehaviour serverBehaviour = server.getAdapter(LocalAppEngineServerBehaviour.class); assertNotNull(serverBehaviour); // now verify the result IPath deployDirectory = serverBehaviour.getModuleDeployDirectory(serverModule); File publishedModule = deployDirectory.toFile(); assertTrue(publishedModule.isDirectory()); File webInf = new File(publishedModule, "WEB-INF"); assertTrue(webInf.isDirectory()); assertTrue(new File(webInf, "appengine-web.xml").isFile()); assertTrue(new File(webInf, "web.xml").isFile()); assertTrue(new File(webInf, "classes/sox/server/GreetingServiceImpl.class").isFile()); assertTrue(new File(webInf, "lib/servlet-2.5.jar").isFile()); assertTrue(new File(webInf, "lib/sox-shared.jar").isFile()); }
Example #9
Source File: ServerTracker.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected void after() { ServerCore.removeServerLifecycleListener(lifecycleListener); for (IServer server : servers) { try { server.delete(); } catch (CoreException ex) { /* ignore */ } } }
Example #10
Source File: RegisterAppEngineStandardRuntimeStartup.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override public void startup() { IRuntime runtime = ServerCore.findRuntime(RUNTIME_ID); if (runtime != null) { return; } try { AppEngineStandardFacet.createAppEngineServerRuntime(new NullProgressMonitor()); } catch (CoreException ex) { logger.log(Level.SEVERE, "Unable to create default runtime instance", ex); } }
Example #11
Source File: LaunchHelper.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Look for servers that may match. * * @param modules the web modules to search for * @param exact if true, look for exact module match * @return an existing server */ @VisibleForTesting Collection<IServer> findExistingServers(IModule[] modules, boolean exact, SubMonitor progress) { if (modules.length == 1) { IServer defaultServer = ServerCore.getDefaultServer(modules[0]); if (defaultServer != null && defaultServer.getServerType() != null && LocalAppEngineServerDelegate.SERVER_TYPE_ID .equals(defaultServer.getServerType().getId())) { return Collections.singletonList(defaultServer); } } Set<IModule> myModules = ImmutableSet.copyOf(modules); List<IServer> matches = new ArrayList<>(); // Look for servers that contain these modules // Could prioritize servers that have *exactly* these modules, // or that have the smallest overlap for (IServer server : ServerCore.getServers()) { // obsolete or unavailable server definitions have serverType == null if (server.getServerType() == null || !LocalAppEngineServerDelegate.SERVER_TYPE_ID.equals(server.getServerType().getId())) { continue; } Set<IModule> serverModules = ImmutableSet.copyOf(server.getModules()); SetView<IModule> overlap = Sets.intersection(myModules, serverModules); if (overlap.size() == myModules.size() && (!exact || overlap.size() == serverModules.size())) { matches.add(server); } } return matches; }
Example #12
Source File: LaunchHelper.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private IServer createServer(IModule[] modules, SubMonitor progress) throws CoreException { IServerType serverType = ServerCore.findServerType(LocalAppEngineServerDelegate.SERVER_TYPE_ID); IServerWorkingCopy serverWorkingCopy = serverType.createServer(null, null, progress.newChild(4)); serverWorkingCopy.modifyModules(modules, null, progress.newChild(4)); return serverWorkingCopy.save(false, progress.newChild(2)); }
Example #13
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IRuntime createServerRuntime(final IRuntimeType type, final IProgressMonitor monitor) throws CoreException { IRuntime runtime = ServerCore.findRuntime(BONITA_TOMCAT_RUNTIME_ID); if (runtime == null) { runtime = type.createRuntime(BONITA_TOMCAT_RUNTIME_ID, monitor); } final IRuntimeWorkingCopy tomcatRuntimeWC = runtime.createWorkingCopy(); tomcatRuntimeWC.setLocation(Path.fromOSString(tomcatInstanceLocation)); final IStatus status = tomcatRuntimeWC.validate(null); if (!status.isOK()) { throw new RuntimeException("Failed to create a tomcat server : " + status.getMessage()); } return tomcatRuntimeWC.save(true, monitor); }
Example #14
Source File: ServerTracker.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
@Override protected void before() { ServerCore.addServerLifecycleListener(lifecycleListener); }
Example #15
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
@Override public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 50); if (!super.finalLaunchCheck(configuration, mode, progress.newChild(10))) { return false; } IStatus status = validateCloudSdk(progress.newChild(20)); if (!status.isOK()) { // Throwing a CoreException will result in the ILaunch hanging around in // an invalid state StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG); return false; } // If we're auto-publishing before launch, check if there may be stale // resources not yet published. See // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1832 if (ServerCore.isAutoPublishing() && ResourcesPlugin.getWorkspace().isAutoBuilding()) { // Must wait for any current autobuild to complete so resource changes are triggered // and WTP will kick off ResourceChangeJobs. Note that there may be builds // pending that are unrelated to our resource changes, so simply checking // <code>JobManager.find(FAMILY_AUTO_BUILD).length > 0</code> produces too many // false positives. try { Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, progress.newChild(20)); } catch (InterruptedException ex) { /* ignore */ } IServer server = ServerUtil.getServer(configuration); if (server.shouldPublish() || hasPendingChangesToPublish()) { IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus); if (prompter != null) { Object continueLaunch = prompter .handleStatus(StaleResourcesStatusHandler.CONTINUE_LAUNCH_REQUEST, configuration); if (!(Boolean) continueLaunch) { // cancel the launch so Server.StartJob won't raise an error dialog, since the // server won't have been started monitor.setCanceled(true); return false; } } } } return true; }
Example #16
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public synchronized void startServer(Repository repository, IProgressMonitor monitor) { if (!serverIsStarted()) { BonitaHomeUtil.configureBonitaClient(); copyTomcatBundleInWorkspace(monitor); monitor.subTask(Messages.startingWebServer); if (BonitaStudioLog.isLoggable(IStatus.OK)) { BonitaStudioLog.debug("Starting tomcat...", EnginePlugin.PLUGIN_ID); } WatchdogManager.getInstance().startWatchdog(); updateRuntimeLocationIfNeeded(); final IRuntimeType type = ServerCore.findRuntimeType(TOMCAT_RUNTIME_TYPE); try { final IProject confProject = createServerConfigurationProject(Repository.NULL_PROGRESS_MONITOR); final IRuntime runtime = createServerRuntime(type, Repository.NULL_PROGRESS_MONITOR); tomcat = createServer(monitor, confProject, runtime); UIDesignerServerManager uidManager = UIDesignerServerManager.getInstance(); if (uidManager.getPortalPort() != portConfigurator.getHttpPort()) { uidManager.setPortalPort(portConfigurator.getHttpPort()); uidManager.stop(); uidManager.start(repository, monitor); } createLaunchConfiguration(tomcat, Repository.NULL_PROGRESS_MONITOR); confProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, Repository.NULL_PROGRESS_MONITOR); startResult = null; tomcat.start(ILaunchManager.RUN_MODE, result -> startResult = result); waitServerRunning(); } catch (final CoreException e) { if (tomcat != null) { try { tomcat.delete(); tomcat = null; } catch (CoreException e1) { BonitaStudioLog.error(e1); } } handleCoreExceptionWhileStartingTomcat(e); } } }