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


Java ServerUtil.getModules方法代码示例

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


在下文中一共展示了ServerUtil.getModules方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: maybePublishModulesToWarDirectory

import org.eclipse.wst.server.core.ServerUtil; //导入方法依赖的package包/类
/**
 * Publish any {@link IModule}s that the project has if it is not using a managed war directory and it is running a
 * server.
 */
public static void maybePublishModulesToWarDirectory(ILaunchConfiguration configuration, IProgressMonitor monitor,
    IJavaProject javaProject, boolean forceFullPublish) throws CoreException {

  if (javaProject == null) {
    // No Java Project
    return;
  }

  IProject project = javaProject.getProject();

  List<String> args = LaunchConfigurationProcessorUtilities.parseProgramArgs(configuration);
  if (WebAppUtilities.hasManagedWarOut(project) || NoServerArgumentProcessor.hasNoServerArg(args)) {
    // Project has a managed war directory or it is running in noserver
    // mode
    return;
  }

  WarParser parser = WarArgumentProcessor.WarParser.parse(args, javaProject);
  if (parser.resolvedUnverifiedWarDir == null) {
    // Invalid war directory
    return;
  }

  IModule[] modules = ServerUtil.getModules(project);
  if (modules.length > 0) {
    Path unmanagedWarPath = new Path(parser.resolvedUnverifiedWarDir);
    WtpPublisher.publishModulesToWarDirectory(project, modules, unmanagedWarPath, forceFullPublish, monitor);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:34,代码来源:WebAppLaunchDelegate.java

示例10: flattenResources

import org.eclipse.wst.server.core.ServerUtil; //导入方法依赖的package包/类
private static IModuleResource[] flattenResources(IProject project, IPath safeWorkDirectory,
    IProgressMonitor monitor) throws CoreException {
  List<IModuleResource> resources = new ArrayList<>();

  IModule[] modules = ServerUtil.getModules(project);
  for (IModule module : modules) {
    ModuleDelegate delegate = (ModuleDelegate) module.loadAdapter(ModuleDelegate.class, monitor);
    if (delegate == null) {
      continue;
    }

    // module references can either be as members or child modules (http://eclip.se/467759)
    Collections.addAll(resources, delegate.members());

    // now handle web fragment child modules, if they exist
    for (IModule child : delegate.getChildModules()) {
      ModuleDelegate childDelegate = (ModuleDelegate)
          child.loadAdapter(ModuleDelegate.class, monitor);
      IJ2EEModule j2eeModule = (IJ2EEModule) child.loadAdapter(IJ2EEModule.class, monitor);
      IUtilityModule utilityModule =
          (IUtilityModule) child.loadAdapter(IUtilityModule.class, monitor);
      if (childDelegate == null || (j2eeModule == null && utilityModule == null)) {
        logger.log(Level.WARNING, "child modules other than J2EE module or utility module are "
            + "not supported: module=" + child + ", moduleType=" + child.getModuleType());
        continue;
      }

      // destination (relative to root), e.g., "WEB-INF/lib/spring-web-4.3.6.RELEASE.jar"
      IPath destination = new Path(delegate.getPath(child));
      String zipName = destination.lastSegment();  // to be created
      IPath zipParent = destination.removeLastSegments(1);

      boolean alreadyZip = j2eeModule != null && j2eeModule.isBinary()
          || utilityModule != null && utilityModule.isBinary();
      if (alreadyZip) {
        // per "isBinary()" Javadoc, "members()" should have a single resource.
        IModuleResource zipResource = childDelegate.members()[0];

        File javaIoFile = zipResource.getAdapter(File.class);
        IFile iFile = zipResource.getAdapter(IFile.class);

        if (javaIoFile != null) {
          resources.add(new ModuleFile(javaIoFile, zipName, zipParent));
        } else if (iFile != null) {
          resources.add(new ModuleFile(iFile, zipName, zipParent));
        }
      } else {
        IPath tempZip = safeWorkDirectory.append(zipName);
        PublishUtil.publishZip(childDelegate.members(), tempZip, monitor);
        resources.add(new ModuleFile(tempZip.toFile(), destination.lastSegment(), zipParent));
      }
    }
  }
  return resources.toArray(new IModuleResource[0]);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:56,代码来源:WarPublisher.java


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