当前位置: 首页>>代码示例>>Java>>正文


Java ServerUtil类代码示例

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


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


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