public static synchronized List<String> getServerInstanceIds(FileObject suiteDir) { if (suiteDir == null) { return null; } Path suitePath = Paths.get(suiteDir.getPath()); Deployment d = Deployment.getDefault(); if (d == null || d.getServerInstanceIDs() == null) { return null; } List<String> result = new ArrayList<>(); for (String uri : d.getServerInstanceIDs()) { InstanceProperties ip = InstanceProperties.getInstanceProperties(uri); String foundSuiteLocation = SuiteUtil.getSuiteProjectLocation(ip); if (foundSuiteLocation == null || !new File(foundSuiteLocation).exists()) { // May be not a native plugin server continue; } Project foundSuite = BaseUtil.getOwnerProject(FileUtil.toFileObject(new File(foundSuiteLocation))); if (foundSuite == null) { continue; } Path p = Paths.get(foundSuiteLocation); if (suitePath.equals(p)) { result.add(uri); } } return result; }
private JaxWsPoliciesSupport findPolicySupport(String serverInstanceId) { try { J2eePlatform j2eePlatform = Deployment.getDefault().getServerInstance(serverInstanceId).getJ2eePlatform(); return JaxWsPoliciesSupport.getInstance(j2eePlatform); } catch (InstanceRemovedException e) { Logger.getLogger(PolicyManager.class.getName()).log(Level.INFO, null, e); } return null; }
/** * Unique instance identifier used to differentiate different Tomcat instances in a human-readable * form, unlike InstanceProperties.URL_ATTR. */ private String getInstanceID() { String name = ip.getProperty(PROP_INSTANCE_ID); if (name != null) { return name; } // generate unique tomcat instance identifier (e.g. tomcat55, tomcat55_1, ... // for Tomcat 5.5.x and tomcat50, tomcat50_1... for Tomcat 5.0.x) String prefix; String serverID; switch (tm.getTomcatVersion()) { case TOMCAT_70: prefix = "tomcat70"; // NIO18N serverID = TomcatFactory.SERVER_ID_70; break; case TOMCAT_60: prefix = "tomcat60"; // NIO18N serverID = TomcatFactory.SERVER_ID_60; break; case TOMCAT_55: prefix = "tomcat55"; // NIO18N serverID = TomcatFactory.SERVER_ID_55; break; case TOMCAT_50: default: prefix = "tomcat50"; // NIO18N serverID = TomcatFactory.SERVER_ID_50; } String[] instanceURLs = Deployment.getDefault().getInstancesOfServer(serverID); for (int i = 0; name == null; i++) { if (i == 0) { name = prefix; } else { name = prefix + "_" + i; // NOI18N } for (String url : instanceURLs) { if (!tm.getUri().equals(url)) { InstanceProperties ip = InstanceProperties.getInstanceProperties(url); if (ip != null) { String anotherName = ip.getProperty(PROP_INSTANCE_ID); if (name.equals(anotherName)) { name = null; break; } } } } } ip.setProperty(PROP_INSTANCE_ID, name); return name; }
private void init() { J2eeModuleProvider moduleProvider = project.getLookup().lookup(J2eeModuleProvider.class); if (moduleProvider != null) { String id = moduleProvider.getServerInstanceID(); support = findPolicySupport(id); if (support != null && !hasServicePolicies(wsdl, Collections.singletonList(support.getLookup(wsdl)))) { support = null; } } else { String[] serverInstanceIds = Deployment.getDefault().getServerInstanceIDs(); Collection<JaxWsPoliciesSupport> supports = new ArrayList<JaxWsPoliciesSupport>(serverInstanceIds.length); List<Lookup> supportsLookup = new ArrayList<Lookup>(serverInstanceIds.length); for (String id : serverInstanceIds) { JaxWsPoliciesSupport foundSupport = findPolicySupport(id); if (foundSupport != null) { supports.add(foundSupport); supportsLookup.add(foundSupport.getLookup(wsdl)); } } if (supports.isEmpty()) { return; } if (hasServicePolicies(wsdl, supportsLookup)) { int i = 0; for (JaxWsPoliciesSupport sup : supports) { if (sup.supports(wsdl, supportsLookup.get(i))) { support = sup; return; } i++; } } } }