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 2008/09/24 19:44:46 UTC
svn commit: r698669 - in
/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server:
OpenEJBRuntimeClasspathProviderDelegate.java OpenEJBRuntimeDelegate.java
OpenEJBRuntimeFragment.java
Author: jgallimore
Date: Wed Sep 24 10:44:45 2008
New Revision: 698669
URL: http://svn.apache.org/viewvc?rev=698669&view=rev
Log:
OEP-20 added option to runtime to include EJB3.1 API jar
Modified:
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeClasspathProviderDelegate.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeDelegate.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeClasspathProviderDelegate.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeClasspathProviderDelegate.java?rev=698669&r1=698668&r2=698669&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeClasspathProviderDelegate.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeClasspathProviderDelegate.java Wed Sep 24 10:44:45 2008
@@ -22,26 +22,49 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
public class OpenEJBRuntimeClasspathProviderDelegate extends RuntimeClasspathProviderDelegate {
+ protected OpenEJBRuntimeDelegate getRuntimeDelegate(IRuntime runtime) {
+ IRuntimeWorkingCopy wc = runtime.createWorkingCopy();
+
+ return (OpenEJBRuntimeDelegate) wc.loadAdapter(OpenEJBRuntimeDelegate.class, new NullProgressMonitor());
+ }
+
@Override
public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) {
+ return resolveClasspathContainer(runtime);
+ }
+
+ @Override
+ public IClasspathEntry[] resolveClasspathContainer(IRuntime runtime) {
IPath installPath = runtime.getLocation();
-
+ boolean ejb31JarIncluded = getRuntimeDelegate(runtime).isEjb31JarIncluded();
if (installPath == null)
return new IClasspathEntry[0];
- List<IClasspathEntry> list = getClientJars(installPath);
+ List<IClasspathEntry> list = getClientJars(installPath, ejb31JarIncluded);
return (IClasspathEntry[])list.toArray(new IClasspathEntry[0]);
}
- private List<IClasspathEntry> getClientJars(IPath installPath) {
+ @Override
+ public IClasspathEntry[] resolveClasspathContainerImpl(IProject project, IRuntime runtime) {
+ return resolveClasspathContainer(runtime);
+ }
+
+ @Override
+ public IClasspathEntry[] resolveClasspathContainerImpl(IRuntime runtime) {
+ return resolveClasspathContainer(runtime);
+ }
+
+ private List<IClasspathEntry> getClientJars(IPath installPath, boolean includeEjb31Jar) {
File libFolder = new File(installPath.toString() + File.separator + "lib");
if (! libFolder.exists()) {
return null;
@@ -52,7 +75,8 @@
for (File file : files) {
if ((file.getName().startsWith("javaee-api") && file.getName().endsWith(".jar"))
- || (file.getName().startsWith("openejb-client") && file.getName().endsWith(".jar"))) {
+ || (file.getName().startsWith("openejb-client") && file.getName().endsWith(".jar"))
+ || (includeEjb31Jar && file.getName().startsWith("ejb31-api-experimental") && file.getName().endsWith(".jar"))) {
Path jar = new Path(file.getAbsolutePath());
classpathEntries.add(JavaCore.newLibraryEntry(jar, null, null));
}
@@ -60,5 +84,4 @@
return classpathEntries;
}
-
}
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeDelegate.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeDelegate.java?rev=698669&r1=698668&r2=698669&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeDelegate.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeDelegate.java Wed Sep 24 10:44:45 2008
@@ -27,6 +27,7 @@
import org.eclipse.wst.server.core.model.RuntimeDelegate;
public class OpenEJBRuntimeDelegate extends RuntimeDelegate implements IJavaRuntime {
+ private static final String INCLUDE_EJB31_JARS = "INCLUDE_EJB31_JARS";
private static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id"; //$NON-NLS-1$
private static final String PROP_VM_INSTALL_ID = "vm-install-id"; //$NON-NLS-1$
@@ -135,4 +136,16 @@
return getAttribute(PROP_VM_INSTALL_ID, (String)null);
}
+ public void setEjb31JarIncluded(boolean selection) {
+ setAttribute(INCLUDE_EJB31_JARS, Boolean.toString(selection));
+ }
+
+ public boolean isEjb31JarIncluded() {
+ try {
+ return Boolean.parseBoolean(getAttribute(INCLUDE_EJB31_JARS, "false"));
+ } catch (Exception e) {
+ }
+
+ return false;
+ }
}
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.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.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java?rev=698669&r1=698668&r2=698669&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.server/src/main/java/org/apache/openejb/eclipse/server/OpenEJBRuntimeFragment.java Wed Sep 24 10:44:45 2008
@@ -17,12 +17,17 @@
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;
@@ -31,6 +36,9 @@
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;
@@ -39,6 +47,7 @@
public class OpenEJBRuntimeFragment extends WizardFragment {
private IWizardHandle handle;
+ private Button includeEjb31Button;
@Override
public boolean hasComposite() {
@@ -83,8 +92,8 @@
Button browseEjbJarButton = new Button(composite, SWT.NONE);
browseEjbJarButton.setText("Browse");
- browseEjbJarButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
- public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ browseEjbJarButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(composite.getShell());
dialog.setMessage("Selection installation dir");
dialog.setFilterPath(locationText.getText());
@@ -94,6 +103,28 @@
}
});
+ Label ejb31Label = new Label(composite, SWT.NONE);
+ ejb31Label.setText("Include experimental EJB 3.1 Jars in classpath");
+
+ includeEjb31Button = new Button(composite, SWT.CHECK);
+
+ try {
+ includeEjb31Button.setSelection(getRuntimeDelegate().isEjb31JarIncluded());
+ } catch (Exception e) {
+ }
+
+ includeEjb31Button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getRuntimeDelegate().setEjb31JarIncluded(includeEjb31Button.getSelection());
+ validate();
+ }
+ });
+
+ try {
+ validate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "org.apache.openejb.help.runtime");
return composite;
}
@@ -111,6 +142,8 @@
File installationDirectory = getRuntimeDelegate().getRuntimeWorkingCopy().getLocation().toFile();
if (! installationDirectory.exists()) {
handle.setMessage("Directory does not exist", IMessageProvider.ERROR);
+ includeEjb31Button.setEnabled(false);
+ includeEjb31Button.setSelection(false);
return;
}
@@ -121,6 +154,23 @@
}
handle.setMessage("", IMessageProvider.NONE);
+ includeEjb31Button.setEnabled(installationFolderHasEjb31Jar(installationDirectory));
+ }
+
+ private boolean installationFolderHasEjb31Jar(File installationDirectory) {
+ File libDirectory = new File(installationDirectory.getAbsolutePath() + File.separator + "lib");
+ if (! libDirectory.exists()) {
+ return false;
+ }
+
+ File[] files = libDirectory.listFiles();
+ for (File file : files) {
+ if (file.getName().startsWith("ejb31-api-experimental") && file.getName().endsWith(".jar")) {
+ return true;
+ }
+ }
+
+ return false;
}
@Override
@@ -129,5 +179,31 @@
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) {
+ }
+ }
}