You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2009/03/15 20:56:29 UTC

svn commit: r754734 [2/2] - in /openejb/trunk/sandbox/openejb-eclipse-plugin: assembly/ assembly/src/main/assembly/ features/org.apache.openejb.feature.server/ features/org.apache.openejb.feature/ plugins/ plugins/echo.stateless.bean/ plugins/echo.stat...

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java Sun Mar 15 19:56:27 2009
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.eclipse.server;
+
+import java.io.File;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class OpenEJBRuntimeFragment extends WizardFragment {
+
+	private IWizardHandle handle;
+
+	@Override
+	public boolean hasComposite() {
+		return true;
+	}
+
+	@Override
+	public Composite createComposite(Composite parent, IWizardHandle handle) {
+		this.handle = handle;
+		handle.setTitle(Messages.getString("org.apache.openejb.eclipse.server.runtimeTitle"));
+		handle.setDescription(Messages.getString("org.apache.openejb.eclipse.server.runtimeDescription"));
+		handle.setImageDescriptor(Activator.getDefault().getImageDescriptor("RUNTIME"));
+		final Composite composite = new Composite(parent, SWT.NULL);
+		GridLayout gridLayout = new GridLayout(3, false);
+		composite.setLayout(gridLayout);
+		
+		GridData gridData = new GridData();
+		gridData.minimumWidth = 200;
+		gridData.minimumHeight = 200;
+		
+		Label locationLabel = new Label(composite, SWT.NONE);
+		locationLabel.setText(Messages.getString("org.apache.openejb.eclipse.server.openejbhomelabel"));
+		
+		final Text locationText = new Text(composite, SWT.BORDER);
+		GridData textData = new GridData();
+		textData.widthHint = 200;
+		locationText.setLayoutData(textData);
+		
+		try {
+			String location = getRuntimeDelegate().getRuntimeWorkingCopy().getLocation().toString();
+			locationText.setText(location);
+		} catch (Exception e) {
+		}
+		
+		locationText.addModifyListener(new org.eclipse.swt.events.ModifyListener() {
+			public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
+				getRuntimeDelegate().getRuntimeWorkingCopy().setLocation(new Path(locationText.getText()));
+				validate();
+			}
+		});
+		
+		Button browseEjbJarButton = new Button(composite, SWT.NONE);
+		browseEjbJarButton.setText("Browse");
+		
+		browseEjbJarButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				DirectoryDialog dialog = new DirectoryDialog(composite.getShell());
+                dialog.setMessage("Selection installation dir");
+                dialog.setFilterPath(locationText.getText());
+                String selectedDirectory = dialog.open();
+                if (selectedDirectory != null)
+                    locationText.setText(selectedDirectory);
+			}
+		});
+
+		try {
+			validate();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "org.apache.openejb.help.runtime");
+		return composite;
+	}
+
+	protected OpenEJBRuntimeDelegate getRuntimeDelegate() {
+		IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+		if (wc == null) {
+			return null;
+		}
+		
+		return (OpenEJBRuntimeDelegate) wc.loadAdapter(OpenEJBRuntimeDelegate.class, new NullProgressMonitor());
+	}
+	
+	private void validate() {
+		File installationDirectory = getRuntimeDelegate().getRuntimeWorkingCopy().getLocation().toFile();
+		if (! installationDirectory.exists()) {
+			handle.setMessage("Directory does not exist", IMessageProvider.ERROR);
+			return;
+		}
+		
+		IStatus status = getRuntimeDelegate().getRuntimeWorkingCopy().validate(new NullProgressMonitor());
+		if (status.getSeverity() != IStatus.OK) {
+			handle.setMessage(status.getMessage(), IMessageProvider.ERROR);
+			return;
+		}
+		
+		handle.setMessage("", IMessageProvider.NONE);
+	}
+
+	@Override
+	public boolean isComplete() {
+		IRuntimeWorkingCopy wc = getRuntimeDelegate().getRuntimeWorkingCopy();
+        IStatus status = wc.validate(null);
+        return status == null || status.getSeverity() != IStatus.ERROR;
+	}
+
+	@Override
+	public void performFinish(IProgressMonitor monitor) throws CoreException {
+		super.performFinish(monitor);
+		refreshProjectsUsingThisRuntime();
+	}
+
+	private void refreshProjectsUsingThisRuntime() {
+		try {
+			Set<IFacetedProject> facetedProjects = ProjectFacetsManager.getFacetedProjects();
+			IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+			
+			for (IFacetedProject facetedProject : facetedProjects) {
+				Set<IRuntime> targetedRuntimes = facetedProject.getTargetedRuntimes();
+				
+				for (IRuntime runtime : targetedRuntimes) {
+					if (runtime.getName().equals(wc.getName())) {
+						facetedProject.removeTargetedRuntime(runtime, new NullProgressMonitor());
+						facetedProject.addTargetedRuntime(runtime, new NullProgressMonitor());
+						
+						break;
+					}
+				}
+			}
+		} catch (CoreException e) {
+		}
+	}
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServer.java?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServer.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServer.java Sun Mar 15 19:56:27 2009
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.eclipse.server;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.server.core.FacetUtil;
+import org.eclipse.jst.server.core.IEnterpriseApplication;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+
+public class OpenEJBServer extends ServerDelegate {
+
+	@Override
+	public IStatus canModifyModules(IModule[] add, IModule[] remove) {
+		if (add != null) {
+			for (int i = 0; i < add.length; i++) {
+				if (!isSupportedModule(add[i])) {
+					return new Status(IStatus.ERROR, "org.eclipse.jst.generic.openejb", "Module not compatible", null);
+				}
+				if (add[i].getProject() != null) {
+					IStatus status = FacetUtil.verifyFacets(add[i].getProject(), getServer());
+					if (status != null && !status.isOK())
+						return status;
+				}
+			}
+		}
+		return Status.OK_STATUS;
+	}
+
+	private boolean isSupportedModule(IModule module) {
+		return (module.getModuleType() != null 
+				&& ("jst.ejb".equals(module.getModuleType().getId())
+						|| "jst.ear".equals(module.getModuleType().getId())));
+	
+	}
+
+	@Override
+	public IModule[] getChildModules(IModule[] module) {
+		return new IModule[0];
+	}
+
+	@Override
+	public IModule[] getRootModules(IModule module) throws CoreException {
+		if (!isSupportedModule(module))
+			return null;
+		IStatus status = canModifyModules(new IModule[] { module }, null);
+		if (status != null && !status.isOK())
+			throw new CoreException(status);
+
+		IModule[] parents = doGetParentModules(module);
+		if (parents.length > 0)
+			return parents;
+		return new IModule[] { module };
+	}
+
+	@SuppressWarnings("unchecked")
+	public IModule[] doGetParentModules(IModule module) {
+		IModule[] ears = ServerUtil.getModules("jst.ear"); //$NON-NLS-1$
+		ArrayList list = new ArrayList();
+		for (int i = 0; i < ears.length; i++) {
+			IEnterpriseApplication ear = (IEnterpriseApplication) ears[i].loadAdapter(IEnterpriseApplication.class, null);
+			IModule[] childs = ear.getModules();
+			for (int j = 0; j < childs.length; j++) {
+				if (childs[j].equals(module))
+					list.add(ears[i]);
+			}
+		}
+		return (IModule[]) list.toArray(new IModule[list.size()]);
+	}
+
+	@Override
+	public void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException {
+	}
+
+	public void setEJBPort(String port) {
+		setAttribute("org.apache.openejb.eclipse.server.ejbport", port);
+	}
+	
+	public String getEJBPort() {
+		return getAttribute("org.apache.openejb.eclipse.server.ejbport", "4201");
+	}
+
+	public void setHTTPEJBPort(String port) {
+		setAttribute("org.apache.openejb.eclipse.server.httpejbport", port);
+	}
+	
+	public String getHTTPEJBPort() {
+		return getAttribute("org.apache.openejb.eclipse.server.httpejbport", "4204");
+	}
+
+	public void setHSQLPort(String port) {
+		setAttribute("org.apache.openejb.eclipse.server.hsqlport", port);
+	}
+	
+	public String getHSQLPort() {
+		return getAttribute("org.apache.openejb.eclipse.server.hsqlport", "9001");
+	}
+
+	public void setTelnetPort(String port) {
+		setAttribute("org.apache.openejb.eclipse.server.telnetport", port);
+	}
+	
+	public String getTelnetPort() {
+		return getAttribute("org.apache.openejb.eclipse.server.telnetport", "4202");
+	}
+
+	public void setAdminPort(String port) {
+		setAttribute("org.apache.openejb.eclipse.server.adminport", port);
+	}
+	
+	public String getAdminPort() {
+		return getAttribute("org.apache.openejb.eclipse.server.adminport", "4200");
+	}
+
+	public void setConfigFile(String configFile) {
+		setAttribute("org.apache.openejb.eclipse.server.configfile", configFile);
+	}
+	
+	public String getConfigFile() {
+		return getAttribute("org.apache.openejb.eclipse.server.configfile", "");
+	}
+
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerBehaviour.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerBehaviour.java?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerBehaviour.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerBehaviour.java Sun Mar 15 19:56:27 2009
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.eclipse.server;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jst.j2ee.application.internal.operations.EARComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.ejb.datamodel.properties.IEJBComponentExportDataModelProperties;
+import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBComponentExportDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+
+public class OpenEJBServerBehaviour extends ServerBehaviourDelegate {
+
+	@SuppressWarnings("serial")
+	public class ServerStoppedException extends Exception {
+	}
+
+	private class ServerMonitor extends Thread {
+
+		private static final int ONE_SECOND = 1000;
+		private boolean running = false;
+		private int adminPort = getAdminPort();
+
+		@Override
+		public void run() {
+			while (true) {
+				try {
+					Thread.sleep(ONE_SECOND);
+				} catch (Exception e) {
+				}
+
+				try {
+					check();
+				} catch (ServerStoppedException e) {
+					// break out the loop and stop monitoring
+					// a restart will start a new monitor
+					break;
+				}
+			}
+		}
+
+		private void check() throws ServerStoppedException {
+			// connect to admin interface
+			try {
+				Socket socket = new Socket("localhost", adminPort);
+				socket.close();
+				
+				// update the server status if this is first time we've connected
+				if (! running) {
+					running = true;
+					setState(IServer.STATE_STARTED);
+					
+					// republish everything
+					doFullPublish();
+				}
+			} catch (IOException e) {
+				if (running) {
+					// looks like server has started successfully, but has died
+					setServerState(IServer.STATE_STOPPED);
+					running = false;
+					cleanup();
+					throw new ServerStoppedException();
+				}
+				// server might not be started yet
+			}
+			// if success, server is running
+		}
+		
+		public void terminate() {
+			this.interrupt();
+		}
+
+		public ServerMonitor() {
+			super();
+		}
+	}
+	
+	private ServerMonitor monitor;
+	private Map<IModule, String> publishedModules = new HashMap<IModule, String>();
+
+	private int getAdminPort() {
+		try {
+			OpenEJBServer openEJBServer = (OpenEJBServer) (getServer().getAdapter(OpenEJBServer.class));
+			return Integer.parseInt(openEJBServer.getAdminPort());
+		} catch (NumberFormatException e) {
+			return 4200;
+		}
+	}
+
+	private int getEJBDPort() {
+		try {
+			OpenEJBServer openEJBServer = (OpenEJBServer) (getServer().getAdapter(OpenEJBServer.class));
+			return Integer.parseInt(openEJBServer.getEJBPort());
+		} catch (NumberFormatException e) {
+			return 4201;
+		}
+	}
+	
+	@Override
+	public void stop(boolean force) {
+		stopServer();
+	}
+	
+	/*
+	 * @see org.apache.openejb.server.admin.AdminDaemon.service(Socket socket)
+	 */
+	private void stopServer() {
+		// connect to admin interface, and send 'Q' to stop the server
+		try {
+			Socket socket = new Socket("localhost", getAdminPort());
+			socket.getOutputStream().write('Q');
+			socket.close();
+			
+			setState(IServer.STATE_STOPPING);
+		} catch (IOException e) {
+			// we're really stuck
+		}
+	}
+
+
+	@Override
+	public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
+		workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.apache.openejb.cli.Bootstrap");
+
+		OpenEJBRuntimeDelegate runtime = getRuntimeDelegate();
+		OpenEJBServer openejbServer = (OpenEJBServer) (getServer().getAdapter(OpenEJBServer.class));
+		
+		IVMInstall vmInstall = runtime.getVMInstall();
+		if (vmInstall != null)
+			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+
+		String args = " start";
+		if (openejbServer.getConfigFile() != null && openejbServer.getConfigFile().length() > 0) {
+			args += " --conf=\"" + openejbServer.getConfigFile() + "\"";
+		}
+		workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
+		workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dejbd.port=" + openejbServer.getEJBPort() + 
+				" -Dhttpejbd.port=" + openejbServer.getHTTPEJBPort() +
+				" -Dhsql.port=" + openejbServer.getHSQLPort() + 
+				" -Dtelnet.port=" + openejbServer.getTelnetPort() + 
+				" -Dadmin.port=" + openejbServer.getAdminPort() + 
+				" -Dopenejb.home=\"" +  getServer().getRuntime().getLocation().toString() + 
+				"\" -javaagent:\"" + runtime.getJavaAgent() + "\"");
+		
+		List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
+		IPath serverJar = new Path(runtime.getCore());
+		cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(serverJar));
+		
+		List<String> classPath = new ArrayList<String>();
+		for (IRuntimeClasspathEntry entry : cp) {
+			classPath.add(entry.getMemento());
+		}
+		
+		workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classPath);
+		workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+	}
+
+	private OpenEJBRuntimeDelegate getRuntimeDelegate() {
+		OpenEJBRuntimeDelegate rd = (OpenEJBRuntimeDelegate) getServer().getRuntime().getAdapter(OpenEJBRuntimeDelegate.class);
+		if (rd == null)
+			rd = (OpenEJBRuntimeDelegate) getServer().getRuntime().loadAdapter(OpenEJBRuntimeDelegate.class, new NullProgressMonitor());
+		return rd;
+	}
+
+	public void setState(int state) {
+		setServerState(state);
+	}
+	
+	public void start(ILaunch launch) {
+		monitor = new ServerMonitor();
+		monitor.start();
+	}
+
+	private void doFullPublish() {
+		Iterator<IModule> iterator = publishedModules.keySet().iterator();
+		while (iterator.hasNext()) {
+			IModule module = (IModule) iterator.next();
+			doPublish(module, ADDED);
+		}
+		
+		if (IServer.STATE_STARTED == getServer().getServerState()) {
+			setServerPublishState(IServer.PUBLISH_STATE_NONE);
+		}
+	}
+	
+	private void cleanup() {
+		Iterator<IModule> iterator = publishedModules.keySet().iterator();
+		while (iterator.hasNext()) {
+			IModule module = (IModule) iterator.next();
+			String publishedFile = publishedModules.get(module);
+			if (publishedFile != null) {
+				new File(publishedFile).delete();
+			}
+		}
+		
+		publishedModules.clear();
+		setServerPublishState(IServer.PUBLISH_STATE_FULL);
+	}
+	
+	private void doPublish(IModule module, int kind) {
+		ServerDeployer serverDeployer = new ServerDeployer(getRuntimeDelegate().getRuntime().getLocation().toFile().getAbsolutePath(), getEJBDPort());
+		
+		// if module already published, try an undeploy first, and cleanup temp file
+		String jarFile = publishedModules.get(module);
+		if (jarFile != null) {
+			serverDeployer.undeploy(jarFile);
+			new File(jarFile).delete();
+			publishedModules.remove(module);
+		}
+		
+		if (kind == REMOVED) {
+			return;
+		}
+		
+		// now do the export
+		String newJarFile = exportModule(module);
+		
+		// publish the new export
+		if (newJarFile != null) {
+			String path = serverDeployer.deploy(newJarFile);
+			publishedModules.put(module, path);
+//			setModulePublishState(new IModule[] { module }, IServer.PUBLISH_STATE_NONE);
+		}
+	}
+	
+	@Override
+	protected IStatus publishModule(int kind, IModule[] modules, int deltaKind, IProgressMonitor monitor) {
+		if (IServer.STATE_STARTED != getServer().getServerState()) {
+			for (IModule module : modules) {
+				if (deltaKind == REMOVED) {
+					String jarFile = publishedModules.get(module);
+					if (jarFile != null) {
+						new File(jarFile).delete();
+					}
+					
+					publishedModules.remove(module);
+				} else {
+					publishedModules.put(module, null);
+				}
+			}
+		} else {
+			for (IModule module : modules) {
+				doPublish(module, deltaKind);
+			}
+		}
+		
+		return super.publishModule(kind, modules, deltaKind, monitor);
+	}
+
+	protected String exportModule(IModule module) {
+		IDataModel model;
+		File tempJarFile;
+		
+		try {
+			if ("jst.ear".equals(module.getModuleType().getId())) {
+				model = DataModelFactory.createDataModel(new EARComponentExportDataModelProvider());
+				tempJarFile = File.createTempFile("oejb", ".ear");
+			} else {
+				model = DataModelFactory.createDataModel(new EJBComponentExportDataModelProvider());
+				tempJarFile = File.createTempFile("oejb", ".jar");
+			}
+
+			model.setProperty(IEJBComponentExportDataModelProperties.PROJECT_NAME, module.getProject().getName());
+			model.setProperty(IEJBComponentExportDataModelProperties.ARCHIVE_DESTINATION, tempJarFile.getAbsolutePath());
+			model.getDefaultOperation().execute(null, null);
+
+			return tempJarFile.getAbsolutePath();
+		} catch (Exception e) {
+			return null;
+		}
+	}
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerFragment.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerFragment.java?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerFragment.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBServerFragment.java Sun Mar 15 19:56:27 2009
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.eclipse.server;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class OpenEJBServerFragment extends WizardFragment implements ModifyListener {
+
+	private IWizardHandle handle;
+	private Label portLabel;
+	private Text portText;
+	private Label httpEjbPortLabel;
+	private Text httpEjbPort;
+	private Label hsqlPortLabel;
+	private Text hsqlPort;
+	private Label telnetPortLabel;
+	private Text telnetPort;
+	private Label adminPortLabel;
+	private Text adminPort;
+	private Label configFileLabel;
+	private Text configFile;
+	private Button configFileBrowseButton;
+	
+	@Override
+	public Composite createComposite(Composite parent, IWizardHandle handle) {
+		OpenEJBServer server = getServer();
+		
+		this.handle = handle;
+		handle.setTitle("OpenEJB Server");
+		handle.setImageDescriptor(Activator.getDefault().getImageDescriptor("RUNTIME"));
+		final Composite serverComposite = new Composite(parent, SWT.NULL);
+		
+		portLabel = new Label(serverComposite, SWT.NONE);
+		portLabel.setText(Messages.getString("org.apache.openejb.eclipse.server.ejbPort"));
+		portText = new Text(serverComposite, SWT.BORDER);
+		portText.addModifyListener(this);
+		Label filler5 = new Label(serverComposite, SWT.NONE);
+		httpEjbPortLabel = new Label(serverComposite, SWT.NONE);
+		httpEjbPortLabel.setText("HTTP EJB Port");
+		httpEjbPort = new Text(serverComposite, SWT.BORDER);
+		httpEjbPort.addModifyListener(this);
+		Label filler4 = new Label(serverComposite, SWT.NONE);
+		hsqlPortLabel = new Label(serverComposite, SWT.NONE);
+		hsqlPortLabel.setText("HSQL Port");
+		hsqlPort = new Text(serverComposite, SWT.BORDER);
+		hsqlPort.addModifyListener(this);
+		Label filler3 = new Label(serverComposite, SWT.NONE);
+		telnetPortLabel = new Label(serverComposite, SWT.NONE);
+		telnetPortLabel.setText("Telnet Port");
+		telnetPort = new Text(serverComposite, SWT.BORDER);
+		telnetPort.addModifyListener(this);
+		Label filler2 = new Label(serverComposite, SWT.NONE);
+		adminPortLabel = new Label(serverComposite, SWT.NONE);
+		adminPortLabel.setText("Admin Port");
+		adminPort = new Text(serverComposite, SWT.BORDER);
+		adminPort.addModifyListener(this);
+		Label filler1 = new Label(serverComposite, SWT.NONE);
+		configFileLabel = new Label(serverComposite, SWT.NONE);
+		configFileLabel.setText("Configuration file");
+		configFile = new Text(serverComposite, SWT.BORDER);
+		configFile.addModifyListener(this);
+		configFileBrowseButton = new Button(serverComposite, SWT.NONE);
+		configFileBrowseButton.setText("...");
+		configFileBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				FileDialog dialog = new FileDialog(serverComposite.getShell());
+                dialog.setFilterExtensions(new String[] {"*.xml", "*.*"});
+                dialog.setFilterNames(new String[] {"XML files", "All files"});
+                dialog.setText("Selection openejb.xml configuration file");
+                String selectedFile = dialog.open();
+                if (selectedFile != null)
+                    configFile.setText(selectedFile);
+			}
+			
+		});
+		GridLayout gridLayout = new GridLayout();
+		gridLayout.numColumns = 3;
+		serverComposite.setLayout(gridLayout);
+
+		String ejbPortNum = "4201";
+		String httpEjbPortNum = "4204";
+		String hsqlPortNum = "9001";
+		String telnetPortNum = "4202";
+		String adminPortNum = "4200";
+		String alternateConfigFile = "";
+		
+		try {
+			ejbPortNum = server.getEJBPort();
+			httpEjbPortNum = server.getHTTPEJBPort();
+			hsqlPortNum = server.getHSQLPort();
+			telnetPortNum = server.getTelnetPort();
+			adminPortNum = server.getAdminPort();
+			alternateConfigFile = server.getConfigFile();
+		} catch (Exception e) {
+		}
+			
+		portText.setText(ejbPortNum);
+		httpEjbPort.setText(httpEjbPortNum);		
+		hsqlPort.setText(hsqlPortNum);
+		telnetPort.setText(telnetPortNum);
+		adminPort.setText(adminPortNum);
+		configFile.setText(alternateConfigFile);
+		
+		validate();
+		
+		return serverComposite;
+	}
+
+	@Override
+	public boolean hasComposite() {
+		return true;
+	}
+
+	@Override
+	public void performFinish(IProgressMonitor monitor) throws CoreException {
+		super.performFinish(monitor);
+	}
+
+	private OpenEJBServer getServer() {
+		IServerWorkingCopy wc = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
+		if (wc == null) {
+		}
+		
+		OpenEJBServer server = (OpenEJBServer) wc.loadAdapter(OpenEJBServer.class, new NullProgressMonitor());
+		return server;
+	}
+
+	private void validate() {
+		if (configFile.getText() != null && configFile.getText().length() > 0) {
+			File config = new File(configFile.getText());
+			if (! config.exists()) {
+				handle.setMessage("Directory does not exist", IMessageProvider.ERROR);
+				return;
+			}
+		}
+		
+		String ejbdPortNum = portText.getText();
+		if (! checkPort(ejbdPortNum)) {
+			handle.setMessage("Invalid EJBD port", IMessageProvider.ERROR);
+			return;
+		}
+			
+
+		String httpEjbdPortNum = httpEjbPort.getText();
+		if (! checkPort(httpEjbdPortNum)) {
+			handle.setMessage("Invalid HTTP EJB port", IMessageProvider.ERROR);
+			return;
+		}
+
+		String hsqlPortNum = hsqlPort.getText();
+		if (! checkPort(hsqlPortNum)) {
+			handle.setMessage("Invalid HSQL port", IMessageProvider.ERROR);
+			return;
+		}
+
+		String telnetPortNum = telnetPort.getText();
+		if (! checkPort(telnetPortNum)) {
+			handle.setMessage("Invalid Telnet port", IMessageProvider.ERROR);
+			return;
+		}
+
+		String adminPortNum = adminPort.getText();
+		if (! checkPort(adminPortNum)) {
+			handle.setMessage("Invalid Admin port", IMessageProvider.ERROR);
+			return;
+		}
+		
+		Set<String> ports = new HashSet<String>();
+		ports.add(ejbdPortNum);
+		ports.add(httpEjbdPortNum);
+		ports.add(hsqlPortNum);
+		ports.add(telnetPortNum);
+		ports.add(adminPortNum);
+		
+		if (ports.size() != 5) {
+			handle.setMessage("Ports must be unique", IMessageProvider.ERROR);
+			return;
+		}
+
+		OpenEJBServer server = getServer();
+		server.setEJBPort(portText.getText());
+		server.setHTTPEJBPort(httpEjbPort.getText());
+		server.setHSQLPort(hsqlPort.getText());
+		server.setTelnetPort(telnetPort.getText());
+		server.setAdminPort(adminPort.getText());
+		server.setConfigFile(configFile.getText());
+
+		handle.setMessage("", IMessageProvider.NONE);
+	}
+
+	private boolean checkPort(String portNum) {
+		try {
+			int port = Integer.parseInt(portNum);
+			return (port > 0 && port < 65535);
+		} catch (NumberFormatException e) {
+			return false;
+		}
+	}
+
+	public void modifyText(ModifyEvent e) {
+		validate();
+	}
+
+	@Override
+	public boolean isComplete() {
+		return IMessageProvider.NONE == handle.getMessageType();
+	}
+	
+	
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/ServerDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/ServerDeployer.java?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/ServerDeployer.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/java/org/apache/openejb/eclipse/server/ServerDeployer.java Sun Mar 15 19:56:27 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.eclipse.server;
+
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+
+
+public class ServerDeployer {
+	private String openejbDir;
+	private final int ejbdPort;
+	
+	public ServerDeployer(String openejbDir, int ejbdPort) {
+		super();
+		this.openejbDir = openejbDir;
+		this.ejbdPort = ejbdPort;
+	}
+
+	public String deploy(String filename) {
+		Object obj = callDeployerBusinessRemote("deploy", filename);
+		if (obj == null) {
+			return null;
+		}
+		
+		try {
+			return (String) obj.getClass().getDeclaredField("jarPath").get(obj);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	private Object callDeployerBusinessRemote(String methodName, String filename) {
+		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Properties properties =	 new Properties();
+			properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.RemoteInitialContextFactory");
+			properties.put(Context.PROVIDER_URL, "ejbd://localhost:" + ejbdPort);
+			
+			URL[] urls = getUrls(openejbDir);
+			URLClassLoader cl = new URLClassLoader(urls, classLoader);
+			Thread.currentThread().setContextClassLoader(cl);
+			
+			InitialContext context = new InitialContext(properties);
+			Object ref = context.lookup("openejb/DeployerBusinessRemote");
+			
+			Method method = ref.getClass().getMethod(methodName, String.class);
+			return method.invoke(ref, filename);
+		} catch (Exception e) {
+			return null;
+		} finally {
+			Thread.currentThread().setContextClassLoader(classLoader);
+		}
+	}
+
+	public boolean undeploy(String filename) {
+		return callDeployerBusinessRemote("undeploy", filename) != null;
+	}
+
+	private URL[] getUrls(String directory) {
+		List<URL> urlList = new ArrayList<URL>();
+		File openEjbDir = new File(directory + File.separator + "lib");
+		File[] files = openEjbDir.listFiles();
+		
+		for (File file : files) {
+			if (file.getName().endsWith(".jar")) {
+				try {
+					urlList.add(file.getAbsoluteFile().toURL());
+				} catch (MalformedURLException e) {
+				}
+			}
+		}
+
+		return urlList.toArray(new URL[urlList.size()]);
+	}
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages.properties?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages.properties (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages.properties Sun Mar 15 19:56:27 2009
@@ -0,0 +1,24 @@
+#######################################################################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# $Rev: 577442 $ $Date: 2007-09-19 21:43:00 +0100 (Wed, 19 Sep 2007) $
+#
+#######################################################################
+org.apache.openejb.eclipse.server.runtimeTitle=OpenEJB Runtime
+org.apache.openejb.eclipse.server.runtimeDescription=Set configuration options for the OpenEJB runtime
+org.apache.openejb.eclipse.server.openejbhomelabel=OpenEJB home directory
+org.apache.openejb.eclipse.server.ejbPort=EJB Port

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages_de.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages_de.properties?rev=754734&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages_de.properties (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/messages_de.properties Sun Mar 15 19:56:27 2009
@@ -0,0 +1,24 @@
+#######################################################################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# $Rev: 577442 $ $Date: 2007-09-19 21:43:00 +0100 (Wed, 19 Sep 2007) $
+#
+#######################################################################
+org.apache.openejb.eclipse.server.runtimeTitle=OpenEJB Runtime
+org.apache.openejb.eclipse.server.runtimeDescription=Set configuration options for the OpenEJB runtime
+org.apache.openejb.eclipse.server.openejbhomelabel=OpenEJB home directory
+org.apache.openejb.eclipse.server.ejbPort=EJB Port

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/runtime.gif
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/runtime.gif?rev=754734&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.wtp.server/src/main/resources/org/apache/openejb/eclipse/server/runtime.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml?rev=754734&r1=754733&r2=754734&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml Sun Mar 15 19:56:27 2009
@@ -148,12 +148,11 @@
 		<module>org.apache.openejb.helper.annotation</module>
 		<module>org.apache.openejb.builder</module>
 		<module>org.apache.openejb.helper.annotation.test</module>
-		<module>org.apache.openejb.server</module>
 		<module>org.apache.openejb.help</module>
 		<module>org.apache.openejb.help.nl1</module>
 		<module>org.apache.openejb.help.nl2</module>
 		<module>org.apache.openejb.help.nl2a</module>
 		<module>org.apache.openejb.help.nlBidi</module>
-		<module>openejb.server</module>
+		<module>org.apache.openejb.wtp.server</module>
 	</modules>
 </project>