• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ServerUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.wst.server.core.ServerUtil的典型用法代码示例。如果您正苦于以下问题:Java ServerUtil类的具体用法?Java ServerUtil怎么用?Java ServerUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerUtil类属于org.eclipse.wst.server.core包,在下文中一共展示了ServerUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@Before
public void setUp() throws IOException, CoreException {
  projects = ProjectUtils.importProjects(getClass(),
      "projects/test-submodules.zip", true /* checkBuildErrors */, null);
  assertEquals(2, projects.size());
  assertTrue("sox-server".equals(projects.get(0).getName())
      || "sox-server".equals(projects.get(1).getName()));
  assertTrue("sox-shared".equals(projects.get(1).getName())
      || "sox-shared".equals(projects.get(0).getName()));
  serverProject = projects.get("sox-server".equals(projects.get(0).getName()) ? 0 : 1);
  assertNotNull("sox-server", serverProject);
  sharedProject = projects.get("sox-shared".equals(projects.get(0).getName()) ? 0 : 1);
  assertNotNull("sox-shared", sharedProject);

  // To diagnose https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1798.
  logModules(serverProject);
  logModules(sharedProject);

  serverModule = ServerUtil.getModule(serverProject);
  assertNotNull(serverModule);
  sharedModule = ServerUtil.getModule(sharedProject);
  assertNotNull(sharedModule);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:24,代码来源:LocalAppEnginePublishOperationTest.java


示例2: checkConflictingLaunches

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@VisibleForTesting
void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode,
    DefaultRunConfiguration runConfig, ILaunch[] launches) throws CoreException {

  for (ILaunch launch : launches) {
    if (launch.isTerminated()
        || launch.getLaunchConfiguration() == null
        || launch.getLaunchConfiguration().getType() != launchConfigType) {
      continue;
    }
    IServer otherServer = ServerUtil.getServer(launch.getLaunchConfiguration());
    DefaultRunConfiguration otherRunConfig =
        generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode);
    IStatus conflicts = checkConflicts(runConfig, otherRunConfig,
        new MultiStatus(Activator.PLUGIN_ID, 0,
            Messages.getString("conflicts.with.running.server", otherServer.getName()), //$NON-NLS-1$
            null));
    if (!conflicts.isOK()) {
      throw new CoreException(StatusUtil.filter(conflicts));
    }
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:23,代码来源:LocalAppEngineServerLaunchConfigurationDelegate.java


示例3: asModule

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
private IModule asModule(Object object) throws CoreException {
  IModule module = AdapterUtil.adapt(object, IModule.class);
  if (module != null) {
    return module;
  }
  IProject project = toProject(object);
  if (project != null) {
    module = ServerUtil.getModule(project);
    if (module != null) {
      return module;
    }
  }
  logger.warning("Unable to map to a module: " + object);
  throw new CoreException(
      StatusUtil.error(this, Messages.getString("CANNOT_DETERMINE_EXECUTION_CONTEXT"))); //$NON-NLS-1$
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:17,代码来源:LaunchHelper.java


示例4: getModuleArtifact

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
public IModuleArtifact getModuleArtifact(Object obj) {
	IProject project = (IProject) ((IAdaptable) obj).getAdapter(IProject.class);

	if (!StandAloneModuleFactory.canHandle(project)) {
		return null;
	}
	// Bypass WTP to load registered module factories as to possibly avoid
	// invoking the module factory on other components that support Java
	// type modules. See org.eclipse.wst.server.core.ServerUtil on how
	// to get modules through the WTP framework.

	IModule[] modules = ServerUtil.getModules(project);
	if (modules == null || modules.length == 0) {
		return null;
	}
	return new WebResource(modules[0], Path.EMPTY);
}
 
开发者ID:eclipse,项目名称:cft,代码行数:18,代码来源:StandaloneArtifactAdapter.java


示例5: testCreateWarFile

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
public void testCreateWarFile() throws Exception {
	harness.createProject("appclient-module");
	project = harness.createProject("dynamic-webapp-with-appclient-module");
	harness.addModule(project);

	IModule[] modules = ServerUtil.getModules(project);
	File file = CloudUtil.createWarFile(modules, (Server) server, new NullProgressMonitor());

	List<String> files = new ArrayList<String>();
	ZipFile zipFile = new ZipFile(file);
	Enumeration<? extends ZipEntry> en = zipFile.entries();
	while (en.hasMoreElements()) {
		ZipEntry entry = en.nextElement();
		files.add(entry.getName());
	}
	// the directory entry is not always present, remove to avoid test
	// failure
	files.remove("WEB-INF/lib/");
	Collections.sort(files);
	List<String> expected = Arrays.asList("META-INF/", "META-INF/MANIFEST.MF", "WEB-INF/", "WEB-INF/classes/",
			"WEB-INF/classes/TestServlet.class", "WEB-INF/lib/appclient-module.jar", "WEB-INF/web.xml",
			"index.html");
	assertEquals(expected, files);
}
 
开发者ID:eclipse,项目名称:cft,代码行数:25,代码来源:CloudUtilTest.java


示例6: run

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@Override
public void run(IProgressMonitor monitor) throws CoreException {
	IServer server = cloudServer.getServer();

	IServerWorkingCopy wc = server.createWorkingCopy();

	ModuleCache moduleCache = CloudFoundryPlugin.getModuleCache();
	ServerData data = moduleCache.getData(cloudServer.getServerOriginal());
	data.tagForReplace(appModule);

	ServerUtil.modifyModules(wc, new IModule[0], new IModule[] { appModule.getLocalModule() }, monitor);
	wc.save(true, monitor);

	CloudFoundryApplicationModule updatedModule = cloudServer
			.getExistingCloudModule(appModule.getDeployedApplicationName());

	if (updatedModule != null) {
		// Do a complete update of the module with Cloud information since
		// the link/unlink project may re-create
		// the module
		cloudServer.getBehaviour().operations().updateModule(updatedModule.getLocalModule()).run(monitor);
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:24,代码来源:UnmapProjectOperation.java


示例7: doMap

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
protected void doMap(IProject project, IProgressMonitor monitor) throws CoreException {
	IServer server = cloudServer.getServer();

	IServerWorkingCopy wc = server.createWorkingCopy();

	final IModule[] modules = ServerUtil.getModules(project);

	if (modules == null || modules.length == 0) {
		throw CloudErrorUtil
				.toCoreException("Unable to create module for " + project.getName() + ". Failed to map to " + appModule.getDeployedApplicationName()); //$NON-NLS-1$ //$NON-NLS-2$
	}

	if (ServerUtil.containsModule(server, modules[0], monitor)) {
		throw CloudErrorUtil
				.toCoreException("Unable to create module for " + project.getName() + ". Module already exists. Failed to map to " + appModule.getDeployedApplicationName()); //$NON-NLS-1$ //$NON-NLS-2$
	}

	IModule[] add = new IModule[] { modules[0] };

	ServerUtil.modifyModules(wc, add, new IModule[] { appModule.getLocalModule() }, monitor);
	wc.save(true, monitor);

}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:24,代码来源:MapToProjectOperation.java


示例8: canAddWebModule

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
protected boolean canAddWebModule()
{
    IModule[] modules = ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes());
    if (modules != null)
    {
        int size = modules.length;
        for (int i = 0; i < size; i++)
        {
            IWebModule webModule = (IWebModule)modules[i].loadAdapter(IWebModule.class,null);
            if (webModule != null)
            {
                IStatus status = server.canModifyModules(new IModule[]
                { modules[i] },null,null);
                if (status != null && status.isOK())
                    return true;
            }
        }
    }
    return false;
}
 
开发者ID:bengalaviz,项目名称:JettyWTPPlugin,代码行数:21,代码来源:ConfigurationWebModuleEditorPart.java


示例9: loadKarafPlatform

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@Override
protected void loadKarafPlatform(final ILaunchConfigurationWorkingCopy configuration) {
    try {
        server = ServerUtil.getServer(configuration);

        if (server == null) {
            return;
        }

        this.karafPlatform = KarafPlatformModelRegistry.findPlatformModel(server.getRuntime().getLocation());

        this.startupSection = (StartupSection) this.karafPlatform.getAdapter(StartupSection.class);
        this.startupSection.load();
    } catch (final CoreException e) {
    }
}
 
开发者ID:apache,项目名称:karaf-eik,代码行数:17,代码来源:KarafServerLaunchConfigurationInitializer.java


示例10: createRuntime

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
private static IRuntime createRuntime(String runtimeName, String location,
		IProgressMonitor progressMonitor) throws CoreException {
	IRuntimeWorkingCopy runtime = null;
	String type = null;
	String version = null;
	String runtimeId = null;
	org.eclipse.core.runtime.IPath jbossAsLocationPath = new Path(location);
	IRuntimeType runtimeTypes[] = ServerUtil.getRuntimeTypes(type, version,
			"org.eclipse.jst.server.tomcat.runtime.60");
	if (runtimeTypes.length > 0) {
		runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
		runtime.setLocation(jbossAsLocationPath);
		if (runtimeName != null)
			runtime.setName(runtimeName);
		IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
		((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID",
				defaultVM.getId());
		((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID",
				defaultVM.getVMInstallType().getId());
		return runtime.save(false, progressMonitor);
	} else {
		return runtime;
	}
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:25,代码来源:TomcatStartup.java


示例11: sendQuitRequest

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
private void sendQuitRequest() throws CoreException {
  final IServer server = ServerUtil.getServer(getLaunch().getLaunchConfiguration());
  if (server == null) {
    return;
  }
  server.stop(true);
  try {
    // the stop command is async, let's give it some time to execute
    Thread.sleep(2000L);
  } catch (InterruptedException e) {
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:13,代码来源:DevAppServerRuntimeProcess.java


示例12: getLaunch

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
  IServer server = ServerUtil.getServer(configuration);
  DefaultRunConfiguration runConfig = generateServerRunConfiguration(configuration, server, mode);
  ILaunch[] launches = getLaunchManager().getLaunches();
  checkConflictingLaunches(configuration.getType(), mode, runConfig, launches);
  return super.getLaunch(configuration, mode);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:9,代码来源:LocalAppEngineServerLaunchConfigurationDelegate.java


示例13: finalLaunchCheck

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode,
    IProgressMonitor monitor) throws CoreException {
  SubMonitor progress = SubMonitor.convert(monitor, 40);
  if (!super.finalLaunchCheck(configuration, mode, progress.newChild(20))) {
    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;
      }
    }
  }
  return true;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:41,代码来源:LocalAppEngineServerLaunchConfigurationDelegate.java


示例14: hasPendingChangesToPublish

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
/**
 * Check if there are pending changes to be published: this is a nasty condition that can occur if
 * the user saves changes as part of launching the server.
 */
private boolean hasPendingChangesToPublish() {
  Job[] serverJobs = Job.getJobManager().find(ServerUtil.SERVER_JOB_FAMILY);
  Job currentJob = Job.getJobManager().currentJob();
  for (Job job : serverJobs) {
    // Launching from Server#start() means this will be running within a
    // Server.StartJob. All other jobs should be ResourceChangeJob or
    // PublishJob, both of which indicate unpublished changes.
    if (job != currentJob) {
      return true;
    }
  }
  return false;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:18,代码来源:LocalAppEngineServerLaunchConfigurationDelegate.java


示例15: getReferencedProjects

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
private static IProject[] getReferencedProjects(ILaunchConfiguration configuration)
    throws CoreException {
  IServer thisServer = ServerUtil.getServer(configuration);
  IModule[] modules = ModuleUtils.getAllModules(thisServer);
  Set<IProject> projects = new HashSet<>();
  for (IModule module : modules) {
    IProject project = module.getProject();
    if (project != null) {
      projects.add(project);
    }
  }
  return projects.toArray(new IProject[projects.size()]);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:14,代码来源:LocalAppEngineServerLaunchConfigurationDelegate.java


示例16: addModule

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
public void addModule(IProject project) throws CoreException {
	Assert.isNotNull(server, "Invoke createServer() first");

	IModule[] modules = ServerUtil.getModules(project);
	IServerWorkingCopy wc = server.createWorkingCopy();
	wc.modifyModules(modules, new IModule[0], null);
	wc.save(true, null);
}
 
开发者ID:eclipse,项目名称:cft,代码行数:9,代码来源:CloudFoundryTestFixture.java


示例17: doMap

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
protected void doMap(IProject project, IProgressMonitor monitor) throws CoreException {
	IServer server = cloudServer.getServer();

	IServerWorkingCopy wc = server.createWorkingCopy();

	final IModule[] modules = ServerUtil.getModules(project);

	if (modules == null || modules.length == 0) {
		throw CloudErrorUtil
				.toCoreException("Unable to create module for " + project.getName() + ". Failed to link the project with " + appModule.getDeployedApplicationName()); //$NON-NLS-1$ //$NON-NLS-2$
	}

	if (ServerUtil.containsModule(server, modules[0], monitor)) {
		throw CloudErrorUtil
				.toCoreException("Unable to create module for " + project.getName() + ". Module already exists. Failed to link the project with " + appModule.getDeployedApplicationName()); //$NON-NLS-1$ //$NON-NLS-2$
	}

	IModule[] add = new IModule[] { modules[0] };

	ServerUtil.modifyModules(wc, add, new IModule[] { appModule.getLocalModule() }, monitor);
	wc.save(true, monitor);

	CloudFoundryServerBehaviour behaviour = cloudServer.getBehaviour();
	if (behaviour != null) {
		behaviour.cleanModuleStates(add, monitor);
	}

	CloudFoundryApplicationModule updatedModule = cloudServer.getExistingCloudModule(appModule
			.getDeployedApplicationName());

	if (updatedModule != null) {
		// Do a complete update of the module with Cloud information since
		// the link/unlink project may re-create
		// the module
		cloudServer.getBehaviour().operations().updateModule(updatedModule.getLocalModule()).run(monitor);
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:38,代码来源:MapToProjectOperation.java


示例18: launch

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
/**
 * Programmatic launch. Generally done by the WST framework (e.g. when a
 * user double clicks on the server instance in the Server's view or selects
 * "Connect"). This is generally used only for unit test cases.
 * @param project
 * @param monitor
 * @return
 * @throws CoreException
 */
public IServer launch(IProject project, IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask("Launching " + project.getName(), IProgressMonitor.UNKNOWN); //$NON-NLS-1$

		IServer server = createServer(new SubProgressMonitor(monitor, 1), NEVER_OVERWRITE);

		IServerWorkingCopy wc = server.createWorkingCopy();
		IModule[] modules = ServerUtil.getModules(project);
		if (modules == null || modules.length == 0) {
			throw new CoreException(
					CloudFoundryPlugin.getErrorStatus("Sample project does not contain web modules: " + project)); //$NON-NLS-1$
		}

		if (!Arrays.asList(wc.getModules()).contains(modules[0])) {
			wc.modifyModules(modules, new IModule[0], monitor);
			server = wc.save(true, monitor);
		}
		server.publish(IServer.PUBLISH_INCREMENTAL, monitor);

		restartServer(server, monitor);

		return server;
	}
	finally {
		monitor.done();
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:37,代码来源:ServerHandler.java


示例19: launch

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
/**
 * Programmatic launch. Generally done by the WST framework (e.g. when a
 * user double clicks on the server instance in the Server's view or selects
 * "Connect"). This is generally used only for unit test cases.
 * @param project
 * @param monitor
 * @return
 * @throws CoreException
 */
public IServer launch(IProject project, IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask("Launching " + project.getName(), IProgressMonitor.UNKNOWN); //$NON-NLS-1$

		IServer server = createServer(new SubProgressMonitor(monitor, 1), NEVER_OVERWRITE);

		IServerWorkingCopy wc = server.createWorkingCopy();
		IModule[] modules = ServerUtil.getModules(project);
		if (modules == null || modules.length == 0) {
			throw new CoreException(
					DockerFoundryPlugin.getErrorStatus("Sample project does not contain web modules: " + project)); //$NON-NLS-1$
		}

		if (!Arrays.asList(wc.getModules()).contains(modules[0])) {
			wc.modifyModules(modules, new IModule[0], monitor);
			server = wc.save(true, monitor);
		}
		server.publish(IServer.PUBLISH_INCREMENTAL, monitor);

		restartServer(server, monitor);

		return server;
	}
	finally {
		monitor.done();
	}
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:37,代码来源:ServerHandler.java


示例20: getServerFromLaunchConfig

import org.eclipse.wst.server.core.ServerUtil; //导入依赖的package包/类
private IServer getServerFromLaunchConfig(ILaunch launch) {
  ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
  if (launchConfig == null) {
    return null;
  }

  IServer server = null;
  try {
    server = ServerUtil.getServer(launchConfig);
  } catch (CoreException e) {
    logError("getServerFromLaunchConfig: Getting the WTP server error.", e);
    return null;
  }
  return server;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:16,代码来源:GwtWtpPlugin.java



注:本文中的org.eclipse.wst.server.core.ServerUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CamelExchangeException类代码示例发布时间:2022-05-22
下一篇:
Java FloatCoder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap