Author: rob.stryker(a)jboss.com
Date: 2012-02-16 05:55:51 -0500 (Thu, 16 Feb 2012)
New Revision: 38810
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PortalUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLaunchAdapter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/LocalJBossStartLaunchConfigurator.java
Log:
JBIDE-10680 - patch for gatein to start properly
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLaunchAdapter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLaunchAdapter.java 2012-02-16
10:08:00 UTC (rev 38809)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLaunchAdapter.java 2012-02-16
10:55:51 UTC (rev 38810)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,19 +10,16 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jst.server.core.EJBBean;
import org.eclipse.jst.server.core.JndiLaunchable;
import org.eclipse.jst.server.core.JndiObject;
@@ -40,6 +37,7 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.PortalUtil;
/**
*
@@ -48,24 +46,10 @@
*/
public class JBossLaunchAdapter extends LaunchableAdapterDelegate {
- private static final String SIMPLE_PORTAL_PATH = "simple-portal";
//$NON-NLS-1$
- private static final String JBOSS_PORTLET = "jboss.portlet"; //$NON-NLS-1$
- private static final String PORTAL_PATH = "portal"; //$NON-NLS-1$
-
private static final String JAVA_NAMING_PROVIDER_URL_PROPKEY =
IJBossRuntimeConstants.NAMING_FACTORY_PROVIDER_URL;
private static final String JAVA_NAMING_FACTORY_INITIAL_PROPKEY =
IJBossRuntimeConstants.NAMING_FACTORY_KEY;
+ private static final String JBOSS_PORTLET = "jboss.portlet"; //$NON-NLS-1$
- private static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR =
"deploy/jboss-portal.sar"; //$NON-NLS-1$
-
- private static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_HA_SAR =
"deploy/jboss-portal-ha.sar"; //$NON-NLS-1$
-
- private static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL =
"deploy/simple-portal"; //$NON-NLS-1$
-
- private static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL_SAR =
"deploy/simple-portal.sar"; //$NON-NLS-1$
-
- private static final String SERVER_DEFAULT_DEPLOY_GATEIN =
"deploy/gatein.ear"; //$NON-NLS-1$
-
-
public JBossLaunchAdapter() {
}
@@ -153,68 +137,35 @@
}
private URL getPortletURL(IModuleArtifact moduleObject, ServerDelegate delegate, IServer
server) {
+ // null checks all over the place
+ IRuntime runtime = server.getRuntime();
IModule module = moduleObject.getModule();
- if (module != null && server != null) {
- IProject project = module.getProject();
- if (project != null) {
- try {
- if (FacetedProjectFramework.hasProjectFacet(project, JBOSS_PORTLET)) {
- IRuntime runtime = server.getRuntime();
- if (runtime == null || runtime.getLocation() == null) {
- return null;
- }
- IJBossServerRuntime jbossRuntime =
(IJBossServerRuntime)runtime.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
- if (jbossRuntime != null) {
- String urlString = "http://" + server.getHost(); //$NON-NLS-1$
- if (delegate instanceof JBossServer) {
- JBossServer jBossServer = (JBossServer) delegate;
- urlString = urlString + ":" + jBossServer.getJBossWebPort() +
"/"; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- return null;
- }
- URL url = new URL(urlString);
- IPath jbossLocation = runtime.getLocation();
- IPath configPath =
jbossLocation.append(IJBossRuntimeResourceConstants.SERVER).append(jbossRuntime.getJBossConfiguration());
- File configFile = configPath.toFile();
- // JBoss Portal server
- if (exists(configFile, SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR)) {
- return new URL(url,PORTAL_PATH);
- }
- // JBoss Portal clustering server
- if (exists(configFile,
- SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_HA_SAR)) {
- return new URL(url,PORTAL_PATH);
- }
- // JBoss portletcontainer
- if (exists(configFile,SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL) ||
- exists(configFile,SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL_SAR)) {
- return new URL(url,SIMPLE_PORTAL_PATH);
- }
- // GateIn Portal Server
- if (exists(configFile, SERVER_DEFAULT_DEPLOY_GATEIN)) {
- return new URL(url,PORTAL_PATH);
- }
- }
- }
- } catch (MalformedURLException e) {
- // ignore
- } catch (CoreException e) {
- // ignore
+ if (runtime == null || runtime.getLocation() == null ||
+ module == null || server == null || module.getProject() == null)
+ return null;
+
+ IJBossServerRuntime jbossRuntime =
(IJBossServerRuntime)runtime.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ if( jbossRuntime== null || !(delegate instanceof JBossServer))
+ return null;
+
+ try {
+ if (FacetedProjectFramework.hasProjectFacet(module.getProject(), JBOSS_PORTLET)) {
+ // We are a portal project. Is the runtime also a portal runtime?
+ String suffix = PortalUtil.getPortalSuffix(jbossRuntime);
+ if( suffix != null ) {
+ String urlString = "http://" + server.getHost(); //$NON-NLS-1$
+ urlString = urlString + ":" + ((JBossServer)delegate).getJBossWebPort() +
"/"; //$NON-NLS-1$ //$NON-NLS-2$
+ URL url = new URL(urlString);
+ return new URL(url, suffix);
}
}
+ } catch (MalformedURLException e) {
+ } catch (CoreException e) {
}
+ // No launchable found
return null;
}
- private static boolean exists(final File location,String portalDir) {
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- portalDir = portalDir.replace("/", "\\"); //$NON-NLS-1$
//$NON-NLS-2$
- }
- File file = new File(location,portalDir);
- return file.exists();
- }
-
-
public static class JBTCustomHttpLaunchable {
private IURLProvider2 urlProvider;
private IModuleArtifact artifact;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/LocalJBossStartLaunchConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/LocalJBossStartLaunchConfigurator.java 2012-02-16
10:08:00 UTC (rev 38809)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/LocalJBossStartLaunchConfigurator.java 2012-02-16
10:55:51 UTC (rev 38810)
@@ -30,6 +30,7 @@
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.PortalUtil;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class LocalJBossStartLaunchConfigurator extends AbstractStartLaunchConfigurator {
@@ -118,9 +119,20 @@
@Override
protected String getDefaultProgramArguments(JBossServer server, IJBossServerRuntime
runtime) {
- return runtime.getDefaultRunArgs() +
- IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
- IJBossRuntimeConstants.SPACE + server.getServer().getHost();
+ StringBuffer sb = new StringBuffer();
+ sb.append(runtime.getDefaultRunArgs());
+ sb.append(IJBossRuntimeConstants.SPACE);
+ sb.append(IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT);
+ sb.append(IJBossRuntimeConstants.SPACE);
+ sb.append(server.getServer().getHost());
+
+ // Gate-in
+ if( PortalUtil.getServerPortalType(runtime) == PortalUtil.TYPE_GATE_IN) {
+ sb.append(IJBossRuntimeConstants.SPACE);
+ sb.append("-Dexo.conf.dir.name=gatein"); //$NON-NLS-1$
+ }
+
+ return sb.toString();
}
@Override
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PortalUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PortalUtil.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PortalUtil.java 2012-02-16
10:55:51 UTC (rev 38810)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.util;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+
+
+public class PortalUtil {
+ public static int TYPE_PORTAL_UNKNOWN = 0;
+ public static int TYPE_PORTAL = 1;
+ public static int TYPE_PORTAL_CLUSTER = 2;
+ public static int TYPE_PORTLET_CONTAINER = 3;
+ public static int TYPE_GATE_IN = 4;
+
+ private static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR =
"deploy/jboss-portal.sar"; //$NON-NLS-1$
+ private static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_HA_SAR =
"deploy/jboss-portal-ha.sar"; //$NON-NLS-1$
+ private static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL =
"deploy/simple-portal"; //$NON-NLS-1$
+ private static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL_SAR =
"deploy/simple-portal.sar"; //$NON-NLS-1$
+ private static final String SERVER_DEFAULT_DEPLOY_GATEIN =
"deploy/gatein.ear"; //$NON-NLS-1$
+
+ private static final String SIMPLE_PORTAL_PATH = "simple-portal";
//$NON-NLS-1$
+ private static final String PORTAL_PATH = "portal"; //$NON-NLS-1$
+
+ public static int getServerPortalType(IServer server) {
+ IRuntime rt = server.getRuntime();
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ return getServerPortalType(jbsrt);
+ }
+
+ public static int getServerPortalType(IJBossServerRuntime runtime) {
+ IPath configPath = runtime.getConfigurationFullPath();
+ File configFile = configPath.toFile();
+
+ // JBoss Portal server
+ if (exists(configFile, SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR)) {
+ return TYPE_PORTAL_UNKNOWN;
+ }
+ // JBoss Portal clustering server
+ if (exists(configFile, SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_HA_SAR)) {
+ return TYPE_PORTAL_CLUSTER;
+ }
+ // JBoss portletcontainer
+ if (exists(configFile,SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL) ||
+ exists(configFile,SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL_SAR)) {
+ return TYPE_PORTLET_CONTAINER;
+ }
+ // GateIn Portal Server
+ if (exists(configFile, SERVER_DEFAULT_DEPLOY_GATEIN)) {
+ return TYPE_GATE_IN;
+ }
+ return TYPE_PORTAL_UNKNOWN;
+ }
+
+ public static String getPortalSuffix(IJBossServerRuntime runtime) {
+ int type = getServerPortalType(runtime);
+ if( type != TYPE_PORTAL_UNKNOWN) {
+ if( type == TYPE_PORTLET_CONTAINER)
+ return SIMPLE_PORTAL_PATH;
+ return PORTAL_PATH;
+ }
+ return null;
+ }
+
+ private static boolean exists(final File location,String portalDir) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ portalDir = portalDir.replace("/", "\\"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ File file = new File(location,portalDir);
+ return file.exists();
+ }
+
+}