Author: rob.stryker(a)jboss.com
Date: 2012-05-03 07:59:59 -0400 (Thu, 03 May 2012)
New Revision: 40749
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/AS7DeploymentScannerUtility.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7DeploymentScannerAdditions.java
Log:
JBIDE-9239 - current scanners loaded from server instead
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/AS7DeploymentScannerUtility.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/AS7DeploymentScannerUtility.java 2012-05-03
11:37:11 UTC (rev 40748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/AS7DeploymentScannerUtility.java 2012-05-03
11:59:59 UTC (rev 40749)
@@ -23,6 +23,7 @@
import org.jboss.ide.eclipse.as.management.core.JBoss7ManagerUtil;
public class AS7DeploymentScannerUtility {
+ public static final String SCANNER_PREFIX = "JBossToolsScanner";
//$NON-NLS-1$
public IStatus addDeploymentScanner(final IServer server, String scannerName, final
String folder) {
ModelNode op = new ModelNode();
@@ -89,6 +90,35 @@
return retval;
}
+
+ public HashMap<String, String> getDeploymentScannersFromServer(final IServer
server, boolean all) {
+ ModelNode op = new ModelNode();
+ op.get("operation").set("read-resource"); //$NON-NLS-1$
//$NON-NLS-2$
+ ModelNode addr = op.get("address"); //$NON-NLS-1$
+ addr.add("subsystem", "deployment-scanner");
//$NON-NLS-1$//$NON-NLS-2$
+ addr.add("scanner", "*"); //$NON-NLS-1$ //$NON-NLS-2$
+ final String request = op.toJSONString(true);
+ ModelNode response = null;
+ try {
+ response = executeWithResult(server, request);
+ } catch(Exception e) {
+ return new HashMap<String, String>();
+ }
+
+ HashMap<String, String> retval=new HashMap<String, String>();
+ List<ModelNode> list = response.asList();
+ for( int i = 0; i <list.size(); i++ ) {
+ ModelNode address = list.get(i).get("address"); //$NON-NLS-1$
+ String scannerName = address.asList().get(1).get("scanner").asString();
//$NON-NLS-1$
+ if( all || scannerName.startsWith(SCANNER_PREFIX)) {
+ ModelNode arr = list.get(i).get("result"); //$NON-NLS-1$
+ String loc = arr.get("path").toString(); //$NON-NLS-1$
+ retval.put(scannerName, loc);
+ }
+ }
+ return retval;
+ }
+
protected IStatus execute(final IServer server, final String request) {
try {
ModelNode node = executeWithResult(server, request);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7DeploymentScannerAdditions.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7DeploymentScannerAdditions.java 2012-05-03
11:37:11 UTC (rev 40748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7DeploymentScannerAdditions.java 2012-05-03
11:59:59 UTC (rev 40749)
@@ -10,21 +10,15 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.v7;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.Properties;
+import java.util.Map;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerEvent;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Trace;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
@@ -61,21 +55,10 @@
added.addAll(Arrays.asList(folders));
ArrayList<String> removed = new ArrayList<String>(); // list of the scanner
names
- IPath p =
JBossServerCorePlugin.getServerStateLocation(server).append(SCANNER_PROP_FILE);
- Properties props = new Properties();
- if( p.toFile().exists()) {
- try {
- props.load(new FileInputStream(p.toFile()));
- } catch( IOException ioe) {
- // shouldnt happen. Log this
- Status failStat = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Unable to read deployment scanner property file " +
p.toFile().getAbsolutePath(), ioe); //$NON-NLS-1$
- JBossServerCorePlugin.log(failStat);
- }
- }
+ Map<String, String> props = loadScannersFromServer(server);
// Properties file of format like: JBossToolsScanner4=/some/folder
- Iterator<Object> lastStartup = props.keySet().iterator();
+ Iterator<String> lastStartup = props.keySet().iterator();
String k = null;
String v = null;
while(lastStartup.hasNext()) {
@@ -118,26 +101,19 @@
Trace.trace(Trace.STRING_FINER, "Added Deployment Scanner:
success="+s.isOK() + ", " + scannerName + ":" +
props.get(newScannerName)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- // Write the file out
- if( added.size() != 0 || removed.size() != 0 ) {
- try {
- props.store(new FileOutputStream(p.toFile()), "Deployment scanners for the
application server"); //$NON-NLS-1$
- } catch( IOException ioe) {
- Status failStat = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Unable to save deployment scanner property file " +
p.toFile().getAbsolutePath(), ioe); //$NON-NLS-1$
- JBossServerCorePlugin.log(failStat);
- }
- }
Trace.trace(Trace.STRING_FINER, "Finished Adding AS7 Deployment Scanners");
//$NON-NLS-1$
}
- private static final String SCANNER_PREFIX = "JBossToolsScanner";
//$NON-NLS-1$
- protected String findNextScannerName(Properties props) {
+ protected Map<String, String> loadScannersFromServer(IServer server) {
+ return new AS7DeploymentScannerUtility().getDeploymentScannersFromServer(server,
false);
+ }
+
+ protected String findNextScannerName(Map<String,String> props) {
int i = 1;
- while( props.get(SCANNER_PREFIX + i) != null ) {
+ while( props.get(AS7DeploymentScannerUtility.SCANNER_PREFIX + i) != null ) {
i++;
}
- return SCANNER_PREFIX + i;
+ return AS7DeploymentScannerUtility.SCANNER_PREFIX + i;
}
public void serverChanged(ServerEvent event) {
Show replies by date