private static File getSeamRoot(RuntimeDefinition runtimeDefinition) { String type = runtimeDefinition.getType(); if (SEAM.equals(type)) { return runtimeDefinition.getLocation(); } return null; }
@Override public String getVersion(RuntimeDefinition runtimeDefinition) { if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) { return null; } return getVersion(runtimeDefinition.getLocation().getAbsolutePath(), DEFAULT_CONFIGURATION); }
@Override public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) { Map<String, SeamRuntime> map = new HashMap<String, SeamRuntime>(); for (RuntimeDefinition runtimeDefinition : runtimeDefinitions) { if (runtimeDefinition.isEnabled()) { String type = runtimeDefinition.getType(); if (SEAM.equals(type)) { addSeam(map, runtimeDefinition, runtimeDefinition.getLocation()); } } initializeRuntimes(runtimeDefinition.getIncludedRuntimeDefinitions()); } SeamRuntimeManager.getInstance().save(); }
@Override public boolean exists(RuntimeDefinition runtimeDefinition) { if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) { return false; } return esbExists(runtimeDefinition); }
@Override public void computeIncludedRuntimeDefinition(RuntimeDefinition runtimeDefinition) { runtimeDefinition.getIncludedRuntimeDefinitions().clear(); List<RuntimeDefinition> runtimeDefinitions = runtimeDefinition.getIncludedRuntimeDefinitions(); final File location = getLocation(runtimeDefinition); File[] directories = runtimeDefinition .getLocation() .listFiles( new FileFilter() { public boolean accept(File file) { if (!file.isDirectory() || file.equals(location)) { return false; } return true; } }); List<RuntimeDefinition> definitions = new ArrayList<RuntimeDefinition>(); JBossRuntimeLocator locator = new JBossRuntimeLocator(); Set<IRuntimeDetector> seamDetectors = new HashSet<IRuntimeDetector>(); Set<IRuntimeDetector> runtimeDetectors = RuntimeCoreActivator.getDefault().getRuntimeDetectors(); for (IRuntimeDetector runtimeDetector : runtimeDetectors) { if (runtimeDetector instanceof RuntimeDetector) { IRuntimeDetectorDelegate delegate = ((RuntimeDetector) runtimeDetector).getDelegate(); if (delegate instanceof SeamHandler) { seamDetectors.add(runtimeDetector); break; } } } for (File directory : directories) { locator.searchDirectory(directory, definitions, 1, seamDetectors, new NullProgressMonitor()); for (RuntimeDefinition definition : definitions) { definition.setParent(runtimeDefinition); } } for (RuntimeDefinition definition : definitions) { if (!runtimeDefinitions.contains(definition)) { runtimeDefinitions.add(definition); } } }
private static void addSeam( Map<String, SeamRuntime> map, RuntimeDefinition runtimeDefinition, File seamFile) { if (seamFile.exists() && seamFile.canRead() && seamFile.isDirectory()) { SeamVersion seamVersion = getSeamVersion(seamFile.getAbsolutePath()); if (seamVersion != null) { String name = "Seam " + runtimeDefinition.getName() + " " + seamVersion; // $NON-NLS-1$ //$NON-NLS-2$ List<String> names = SeamRuntimeManager.getInstance().getAllRuntimeNames(); if (names != null && names.size() > 0) { int i = 2; String baseName = "Seam " + runtimeDefinition.getName(); // $NON-NLS-1$ while (names.contains(name)) { name = baseName + " (" + i++ + ") " + seamVersion; // $NON-NLS-1$ //$NON-NLS-2$ } } addSeam(map, seamFile.getAbsolutePath(), seamVersion, name); } } }
/** * @param serverDefinition * @return */ private static boolean esbExists(RuntimeDefinition runtimeDefinition) { JBossESBRuntime[] runtimes = JBossRuntimeManager.getInstance().getRuntimes(); for (JBossESBRuntime runtime : runtimes) { String location = runtime.getHomeDir(); if (location != null && location.equals(runtimeDefinition.getLocation().getAbsolutePath())) { return true; } } return false; }
@Override public boolean exists(RuntimeDefinition runtimeDefinition) { if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) { return false; } File seamRoot = getSeamRoot(runtimeDefinition); if (seamRoot == null || !seamRoot.isDirectory()) { return false; } String path = seamRoot.getAbsolutePath(); return seamExists(path); }
@Override public void computeIncludedRuntimeDefinition(RuntimeDefinition runtimeDefinition) { File esbRoot = null; if (JBossServerType.SOAP.getId().equals(runtimeDefinition.getType())) { esbRoot = runtimeDefinition.getLocation(); } if (JBossServerType.SOAP_STD.getId().equals(runtimeDefinition.getType())) { esbRoot = new File(runtimeDefinition.getLocation(), JBOSS_ESB_FOLDER); } RuntimeDefinition child = createRuntimeDefinition(esbRoot, runtimeDefinition.getName(), new NullProgressMonitor()); if (child != null) { child.setParent(runtimeDefinition); runtimeDefinition.getIncludedRuntimeDefinitions().add(child); } }
public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) { for (RuntimeDefinition runtimeDefinition : runtimeDefinitions) { String type = runtimeDefinition.getType(); if (runtimeDefinition.isEnabled() && !esbExists(runtimeDefinition)) { if (ESB.equals(type)) { JBossESBRuntime runtime = new JBossESBRuntime(); if (!runtimeDefinition.getName().startsWith(ESB_PREFIX)) runtime.setName(ESB_PREFIX + runtimeDefinition.getName()); runtime.setHomeDir(runtimeDefinition.getLocation().getAbsolutePath()); runtime.setConfiguration(DEFAULT_CONFIGURATION); runtime.setVersion(runtimeDefinition.getVersion()); JBossRuntimeManager.getInstance().addRuntime(runtime); } } initializeRuntimes(runtimeDefinition.getIncludedRuntimeDefinitions()); } }
private static File getLocation(RuntimeDefinition runtimeDefinitions) { String type = runtimeDefinitions.getType(); String version = runtimeDefinitions.getVersion(); if ("EAP".equals(type) && version != null && version.startsWith("6")) { // $NON-NLS-1$ //$NON-NLS-2$ return runtimeDefinitions.getLocation(); } if ("SOA_P".equals(type) || "EAP".equals(type) || "EPP".equals(type)) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return new File(runtimeDefinitions.getLocation(), "jboss-as"); // $NON-NLS-1$ } if ("SOA_P_STD".equals(type)) { // $NON-NLS-1$ return new File(runtimeDefinitions.getLocation(), "jboss-esb"); // $NON-NLS-1$ } if ("EWP".equals(type)) { // $NON-NLS-1$ return new File(runtimeDefinitions.getLocation(), "jboss-as-web"); // $NON-NLS-1$ } if ("AS".equals(type) || "EAP_STD".equals(type)) { // $NON-NLS-1$//$NON-NLS-2$ return runtimeDefinitions.getLocation(); } return null; }
@Override public String getVersion(RuntimeDefinition runtimeDefinition) { return runtimeDefinition.getVersion(); }