/** * Returns an array of all known runtime instances of * the given runtime type. This convenience method filters the list of known * runtime ({@link ServerCore#getRuntimes()}) for ones with a matching * runtime type ({@link IRuntime#getRuntimeType()}). The array will not * contain any working copies. * <p> * A new array is returned on each call, so clients may store or modify the result. * </p> * * @param runtimeType the runtime type * @return a possibly-empty list of runtime instances {@link IRuntime} * of the given runtime type */ public static IRuntime[] getRuntimes(IRuntimeType runtimeType) { List list = new ArrayList(); IRuntime[] runtimes = ServerCore.getRuntimes(); if (runtimes != null) { int size = runtimes.length; for (int i = 0; i < size; i++) { if (runtimes[i].getRuntimeType() != null && runtimes[i].getRuntimeType().equals(runtimeType)) list.add(runtimes[i]); } } IRuntime[] r = new IRuntime[list.size()]; list.toArray(r); return r; }
public int getServerTargetIndexFromItems(IRuntime serverTarget) { if (items != null && items.length > 0) { String serverTargetLabel = serverTarget.getName() + " (" + serverTarget.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < items.length; i++) { String label = items[i]; if (label.equals(serverTargetLabel)) { return i; } } } return -1; }
public int compare(Viewer viewer, Object e1, Object e2) { IRuntime r1 = (IRuntime) e1; IRuntime r2 = (IRuntime) e2; if (sortByName) return getComparator().compare(notNull(r1.getName()), notNull(r2.getName())); if (r1.getRuntimeType() == null) return -1; if (r2.getRuntimeType() == null) return 1; return getComparator().compare(notNull(r1.getRuntimeType().getName()), notNull(r2.getRuntimeType().getName())); }
if (sRuntime != null && sRuntime.getRuntimeType() != null && runtimeTypeId.equals(sRuntime.getRuntimeType().getId()))
public ITomcatVersionHandler getVersionHandler() { IRuntimeType type = getRuntime().getRuntimeType(); return TomcatPlugin.getTomcatVersionHandler(type.getId()); }
public void fillTree() { clean(); List list = new ArrayList(); IRuntime[] runtimes = ServerCore.getRuntimes(); if (runtimes != null) { int size = runtimes.length; for (int i = 0; i < size; i++) { IRuntimeType runtimeType = runtimes[i].getRuntimeType(); try { TreeElement ele = getOrCreate(list, runtimeType.getVendor()); ele.contents.add(runtimes[i]); elementToParentMap.put(runtimes[i], ele); } catch (Exception e) { Trace.trace(Trace.WARNING, "Error in runtime content provider", e); } } } elements = list.toArray(); } }
public static ServerTargetComboHelper getValidServerTargetComboItems(String j2eeType, String selectedVersion) { IRuntime[] validServerTargets = ServerUtil.getRuntimes(j2eeType, selectedVersion); String[] serverTargetList = null; if (validServerTargets.length>0) { int serverTargetListSize = validServerTargets.length; serverTargetList = new String[serverTargetListSize]; for (int i = 0; i < validServerTargets.length; i++) { IRuntime runtime = validServerTargets[i]; serverTargetList[i] = runtime.getName() + " (" + runtime.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } } return new ServerTargetComboHelper(Arrays.asList(validServerTargets), serverTargetList); }
if (serverTypeId.matches(serverId)) { String kieVersion = e.getAttribute("runtimeId"); String rid = server.getRuntime().getRuntimeType().getVersion();
public String getColumnText(Object element, int columnIndex) { if (element instanceof ServerTreeContentProvider.TreeElement) { if (columnIndex == 0) return ((ServerTreeContentProvider.TreeElement) element).text; return ""; } IRuntime runtime = (IRuntime) element; if (columnIndex == 0) { String text = notNull(runtime.getName()); if (decorator != null) { String dec = decorator.decorateText(text, runtime); if (dec != null) return dec; } return text; } else if (columnIndex == 1) { if (runtime.getRuntimeType() != null) return notNull(runtime.getRuntimeType().getName()); return ""; } return ""; } }
/** * @see ITableLabelProvider#getColumnImage(Object, int) */ public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) { IRuntime runtime = (IRuntime) element; IRuntimeType runtimeType = runtime.getRuntimeType(); if (runtimeType != null) { Image image = ImageResource.getImage(runtimeType.getId()); if (decorator != null) { Image dec = decorator.decorateImage(image, element); if (dec != null) return dec; } return image; } } return null; }
/** * */ protected Image getImageImpl(Object element) { IRuntime runtime = (IRuntime) element; IRuntimeType runtimeType = runtime.getRuntimeType(); if (runtimeType != null) { Image image = ImageResource.getImage(runtimeType.getId()); if (decorator != null) { Image dec = decorator.decorateImage(image, element); if (dec != null) return dec; } return image; } return null; }
/** * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime) */ public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) { IPath installPath = runtime.getLocation(); if (installPath == null) return new IClasspathEntry[0]; List list = new ArrayList(); String runtimeId = runtime.getRuntimeType().getId(); if (runtimeId.indexOf("32") > 0) { IPath path = installPath.append("lib"); addLibraryEntries(list, path.toFile(), true); } else if (runtimeId.indexOf("60") > 0) { // TODO May need some flexibility in case the installation has been configured differently // This lib "simplification" may cause issues for some. // Not known yet whether packaged Linux installs will go along. IPath path = installPath.append("lib"); addLibraryEntries(list, path.toFile(), true); } else { IPath path = installPath.append("common"); addLibraryEntries(list, path.append("lib").toFile(), true); addLibraryEntries(list, path.append("endorsed").toFile(), true); } return (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]); } }
if (sRuntime != null) IRuntimeType runtimeType = sRuntime.getRuntimeType(); if (runtimeType != null && runtimeTypeId.equals(runtimeType.getId()))
private IStatus doesProjectTargetMatchServerType(IProject p, String serverFactoryId) { if (p!=null && p.exists()) { IRuntime projectTarget = ServerSelectionUtils.getRuntimeTarget(p.getName()); if (projectTarget!=null) { String projectTargetId = projectTarget.getRuntimeType().getId(); String serverTargetId = ServerUtils.getRuntimeTargetIdFromFactoryId(serverFactoryId); if (serverTargetId!=null && serverTargetId.length()>0) { if(!projectTargetId.equals(serverTargetId)) { return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVER_TARGET_MISMATCH,new String[]{p.getName()}) ); } } } } return Status.OK_STATUS; }
protected boolean matchesRuntime(IRuntime r) { String text = r.getName(); if (wordMatches(text)) return true; if (r.getLocation() != null) { text = r.getLocation().toPortableString(); if (wordMatches(text)) return true; text = r.getLocation().toOSString(); if (wordMatches(text)) return true; } if (r.getRuntimeType() != null && matchesRuntimeType(r.getRuntimeType())) return true; return false; }
/** * @see ITableLabelProvider#getColumnText(Object, int) */ public String getColumnText(Object element, int columnIndex) { IRuntime runtime = (IRuntime) element; if (columnIndex == 0) { String text = notNull(runtime.getName()); if (decorator != null) { String dec = decorator.decorateText(text, element); if (dec != null) return dec; } return text; } else if (columnIndex == 1) { IRuntimeType runtimeType = runtime.getRuntimeType(); if (runtimeType != null) return notNull(runtimeType.getName()); return ""; } else return ""; }
/** * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer) */ public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server) { IStatus status; // If serving modules without publishing, loader jar is needed if (server.isServeModulesWithoutPublish()) { status = TomcatVersionHelper.copyLoaderJar( getRuntimeBaseDirectory(server).append("server/lib"), server.getServer().getRuntime().getRuntimeType().getId()); // If copy successful and running a separate server instance, modify catalina.properties if (status.isOK() && server.isTestEnvironment()) { status = TomcatVersionHelper.updatePropertiesToServeDirectly(baseDir, "server/lib", "server"); } } // Else ensure jar is removed else { TomcatVersionHelper.removeLoaderJar( getRuntimeBaseDirectory(server).append("server/lib"), server.getServer().getRuntime().getRuntimeType().getId()); // TODO Decide what to do with removal warning, maybe nothing status = Status.OK_STATUS; } return status; }
/** * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer) */ public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server) { IStatus status; // If serving modules without publishing, loader jar is needed // TODO Need to examine catalina.properties to ensure loader jar and catalina.properties are handled appropriately if (server.isServeModulesWithoutPublish()) { status = TomcatVersionHelper.copyLoaderJar( getRuntimeBaseDirectory(server).append("lib"), server.getServer().getRuntime().getRuntimeType().getId()); // If copy successful and running a separate server instance, modify catalina.properties if (status.isOK() && server.isTestEnvironment()) { status = TomcatVersionHelper.updatePropertiesToServeDirectly(baseDir, "lib", "common"); } } // Else ensure jar is removed else { TomcatVersionHelper.removeLoaderJar( getRuntimeBaseDirectory(server).append("lib"), server.getServer().getRuntime().getRuntimeType().getId()); // TODO Decide what to do with removal warning, maybe nothing status = Status.OK_STATUS; } return status; }
/** * @param module * @param runtime * @return */ public List getDeployModuleExtensions(IProject project, IRuntime runtime) { String typeID = ""; //$NON-NLS-1$ if (J2EEProjectUtilities.isEARProject(project)) typeID = J2EEProjectUtilities.ENTERPRISE_APPLICATION; else if (J2EEProjectUtilities.isApplicationClientProject(project)) typeID = J2EEProjectUtilities.APPLICATION_CLIENT; else if (J2EEProjectUtilities.isDynamicWebProject(project)) typeID = J2EEProjectUtilities.DYNAMIC_WEB; else if (J2EEProjectUtilities.isStaticWebProject(project)) typeID = J2EEProjectUtilities.STATIC_WEB; else if (J2EEProjectUtilities.isEJBProject(project)) typeID = J2EEProjectUtilities.EJB; else if (J2EEProjectUtilities.isJCAProject(project)) typeID = J2EEProjectUtilities.JCA; else if (J2EEProjectUtilities.isUtilityProject(project)) typeID = J2EEProjectUtilities.UTILITY; String runtimeID = runtime.getRuntimeType().getId(); return getDeployers(typeID, runtimeID); }
} else if (element instanceof IRuntime) { IRuntime runtime = (IRuntime) element; return ImageResource.getImageDescriptor(runtime.getRuntimeType().getId()); } else if (element instanceof IServerType) { IServerType serverType = (IServerType) element;