Author: adietish
Date: 2011-07-04 13:05:30 -0400 (Mon, 04 Jul 2011)
New Revision: 32571
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
Log:
[JBIDE-9125] added #checkedGetBehaviorDelegate
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2011-07-04
17:03:24 UTC (rev 32570)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2011-07-04
17:05:30 UTC (rev 32571)
@@ -27,6 +27,8 @@
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import
org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior.JBossBehaviourDelegate;
public class ServerUtil {
public static IPath getServerStateLocation(IServer server) {
@@ -45,8 +47,8 @@
}
@SuppressWarnings("unchecked")
- public static <BEHAVIOR> BEHAVIOR checkedGetServerBehavior(IServer server,
Class<BEHAVIOR> behaviorClass) throws CoreException {
- BEHAVIOR serverBehavior = (BEHAVIOR) server.loadAdapter(behaviorClass, new
NullProgressMonitor());
+ public static <ADAPTER> ADAPTER checkedGetServerAdapter(IServer server,
Class<ADAPTER> behaviorClass) throws CoreException {
+ ADAPTER serverBehavior = (ADAPTER) server.loadAdapter(behaviorClass, new
NullProgressMonitor());
if (serverBehavior == null) {
throw new CoreException(
new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
@@ -55,6 +57,16 @@
return serverBehavior;
}
+ public static JBossBehaviourDelegate checkedGetBehaviorDelegate(IServer server) throws
CoreException {
+ JBossBehaviourDelegate delegate = checkedGetServerAdapter(server,
JBossServerBehavior.class).getDelegate();
+ if (delegate == null) {
+ throw new CoreException(
+ new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.CouldNotFindServerBehavior, server.getName())));
+ }
+ return delegate;
+ }
+
@Deprecated
public static IPath makeRelative(IJBossServerRuntime rt, IPath p) {
if( rt != null && rt.getRuntime() != null )
Show replies by date