[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped ...
Robert Stryker
rawblem at gmail.com
Fri Dec 22 18:24:42 EST 2006
User: rawb
Date: 06/12/22 18:24:42
Added: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped
DeployableServerRuntime.java DeployableServer.java
DeployableLaunchConfiguration.java
DeployableServerBehavior.java
Log:
New PackageTypes for marshall.
Added deploy-only server (cannot start or stop)
Other associated changes.
Revision Changes Path
1.1 date: 2006/12/22 23:24:42; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerRuntime.java
Index: DeployableServerRuntime.java
===================================================================
package org.jboss.ide.eclipse.as.core.server.stripped;
import org.eclipse.wst.server.core.model.RuntimeDelegate;
public class DeployableServerRuntime extends RuntimeDelegate {
public DeployableServerRuntime() {
// TODO Auto-generated constructor stub
}
}
1.1 date: 2006/12/22 23:24:42; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServer.java
Index: DeployableServer.java
===================================================================
package org.jboss.ide.eclipse.as.core.server.stripped;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.model.ServerDelegate;
import org.jboss.ide.eclipse.as.core.server.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
public class DeployableServer extends ServerDelegate implements IDeployableServer {
public static final String DEPLOY_DIRECTORY = "org.jboss.ide.eclipse.as.core.server.stripped.deploy_directory";
public DeployableServer() {
// TODO Auto-generated constructor stub
}
public IStatus canModifyModules(IModule[] add, IModule[] remove) {
// TODO Auto-generated method stub
return null;
}
public IModule[] getChildModules(IModule[] module) {
// TODO Auto-generated method stub
return null;
}
public IModule[] getRootModules(IModule module) throws CoreException {
// TODO Auto-generated method stub
return null;
}
public void modifyModules(IModule[] add, IModule[] remove,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer#getDeployDirectory()
*/
public String getDeployDirectory() {
return getAttribute(DEPLOY_DIRECTORY, "");
}
public ServerAttributeHelper getAttributeHelper() {
IServerWorkingCopy copy = getServerWorkingCopy();
if( copy == null ) {
copy = getServer().createWorkingCopy();
}
return new ServerAttributeHelper(getServer(), copy);
}
}
1.1 date: 2006/12/22 23:24:42; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java
Index: DeployableLaunchConfiguration.java
===================================================================
package org.jboss.ide.eclipse.as.core.server.stripped;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.core.server.JBossServerBehavior;
public class DeployableLaunchConfiguration implements
ILaunchConfigurationDelegate {
public static final String ACTION_KEY = "org.jboss.ide.eclipse.as.core.server.stripped.DeployableLaunchConfiguration.Action";
public static final String START = "_START_";
public static final String STOP = "_STOP_";
public static DeployableServerBehavior getServerBehavior(ILaunchConfiguration configuration) throws CoreException {
IServer server = ServerUtil.getServer(configuration);
DeployableServerBehavior jbossServerBehavior = (DeployableServerBehavior) server.getAdapter(DeployableServerBehavior.class);
return jbossServerBehavior;
}
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
String action = configuration.getAttribute(ACTION_KEY, START);
DeployableServerBehavior behavior = getServerBehavior(configuration);
if( START.equals(action)) behavior.setServerStarted();
if( STOP.equals(action)) behavior.setServerStopped();
}
}
1.1 date: 2006/12/22 23:24:42; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerBehavior.java
Index: DeployableServerBehavior.java
===================================================================
package org.jboss.ide.eclipse.as.core.server.stripped;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.Module;
import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.JBossServerCore;
import org.jboss.ide.eclipse.as.core.module.PathModuleFactory;
import org.jboss.ide.eclipse.as.core.publishers.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.publishers.JstPackagesPublisher;
import org.jboss.ide.eclipse.as.core.publishers.NullPublisher;
import org.jboss.ide.eclipse.as.core.publishers.PackagesPublisher;
import org.jboss.ide.eclipse.as.core.publishers.PathPublisher;
import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
import org.jboss.ide.eclipse.packages.core.model.PackagesCore;
public class DeployableServerBehavior extends ServerBehaviourDelegate {
public DeployableServerBehavior() {
}
public void stop(boolean force) {
setServerStopped(); // simple enough
}
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
workingCopy.setAttribute(DeployableLaunchConfiguration.ACTION_KEY, DeployableLaunchConfiguration.START);
}
// By default, goes to check if the members are all the same or any changes
public IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module) {
return ((Server)getServer()).getPublishedResourceDelta(module);
}
protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor) throws CoreException {
// kind = [incremental, full, auto, clean] = [1,2,3,4]
// delta = [no_change, added, changed, removed] = [0,1,2,3]
System.out.print("publishing module: ");
switch( kind ) {
case IServer.PUBLISH_INCREMENTAL: System.out.print("incremental, "); break;
case IServer.PUBLISH_FULL: System.out.print("full, "); break;
case IServer.PUBLISH_AUTO: System.out.print("auto, "); break;
case IServer.PUBLISH_CLEAN: System.out.print("clean, "); break;
}
switch( deltaKind ) {
case ServerBehaviourDelegate.NO_CHANGE: System.out.print("no change"); break;
case ServerBehaviourDelegate.ADDED: System.out.print("added"); break;
case ServerBehaviourDelegate.CHANGED: System.out.print("changed"); break;
case ServerBehaviourDelegate.REMOVED: System.out.print("removed"); break;
}
System.out.println("");
if( module.length == 0 ) return;
IJBossServerPublisher publisher;
int modulePublishState = getServer().getModulePublishState(module) + 0;
/**
* If our modules are already packaged as ejb jars, wars, aop files,
* then go ahead and publish
*/
if( arePathModules(module)) {
publisher = new PathPublisher(JBossServerCore.getDeployableServer(getServer()), this);
} else if( hasPackagingConfiguration(module) ) {
publisher = new PackagesPublisher(JBossServerCore.getDeployableServer(getServer()));
} else if( areJstModules(module)){
publisher = new JstPackagesPublisher(JBossServerCore.getDeployableServer(getServer()));
} else {
publisher = new NullPublisher();
}
publisher.publishModule(kind, deltaKind, modulePublishState, module, monitor);
setModulePublishState(module, publisher.getPublishState());
}
// Is it just a file being deployed?
// .xml, or .jar specifically
public boolean arePathModules(IModule[] module) {
if( module.length == 1 && module[0] instanceof Module ) {
ModuleFactoryDelegate delegate =
((Module)module[0]).getModuleFactory().getDelegate(new NullProgressMonitor());
if( delegate instanceof PathModuleFactory ) return true;
}
return false;
}
/* Temporary and will need to be fixed */
protected boolean areJstModules(IModule[] module) {
String type;
for( int i = 0; i < module.length; i++ ) {
type = module[i].getModuleType().getId();
if( type.equals("jst.ejb") || type.equals("jst.client")
|| type.equals("jst.web") || type.equals("jst.ear"))
continue;
return false;
}
return true;
}
/* Temporary and will need to be fixed */
protected boolean hasPackagingConfiguration(IModule[] module) {
try {
String projectName = module[0].getName();
IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
return PackagesCore.getProjectPackages(proj, new NullProgressMonitor()).length == 0 ? false : true;
} catch( Exception e ) {}
return false;
}
/*
* Change the state of the server
*/
public void setServerStarted() {
setServerState(IServer.STATE_STARTED);
}
public void setServerStarting() {
setServerState(IServer.STATE_STARTING);
}
public void setServerStopped() {
setServerState(IServer.STATE_STOPPED);
}
public void setServerStopping() {
setServerState(IServer.STATE_STOPPING);
}
}
More information about the jboss-cvs-commits
mailing list