Author: dgolovin
Date: 2007-09-27 02:42:38 -0400 (Thu, 27 Sep 2007)
New Revision: 3847
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/DataSourceXmlDeployer.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-846
now in WAR configuration src/action source folder has different output to WEB-INF/dev as
http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/gettingstarted.html... says:
# the hot-deployable components will not be visible to any classes deployed outside of
WEB-INF/dev
# Seam debug mode must be enabled
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/DataSourceXmlDeployer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/DataSourceXmlDeployer.java 2007-09-27
05:40:14 UTC (rev 3846)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/DataSourceXmlDeployer.java 2007-09-27
06:42:38 UTC (rev 3847)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.internal.core.project.facet;
import org.eclipse.core.resources.IContainer;
@@ -34,69 +34,85 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
/**
+ * This class is provided to deploy data source descriptor to JBoss AS for Seam
+ * Web Project in WAR deployment configuration.
+ *
* @author eskimo
- *
+ *
*/
public class DataSourceXmlDeployer extends Job {
IProject project = null;
+
public DataSourceXmlDeployer(IProject project) {
super("Deploying datasource to server");
this.project = project;
}
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IFacetedProject facetedProject;
- try {
- facetedProject = ProjectFacetsManager.create(project);
- } catch (CoreException e) {
- return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID, "No server selected
to deploy datasource to");
- }
- org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime =
facetedProject.getPrimaryRuntime();
- IServer s = null;
- IServer[] servers = ServerCore.getServers();
- for (IServer server : servers) {
- String primaryName = primaryRuntime.getName();
- IRuntime runtime = server.getRuntime();
- if(runtime!=null) {
- String serverName = runtime.getName();
- if(primaryName.equals(serverName)) {
- s = server;
- }
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ IFacetedProject facetedProject;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID,
+ "No server selected to deploy datasource to");
+ }
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime =
facetedProject
+ .getPrimaryRuntime();
+ IServer s = null;
+ IServer[] servers = ServerCore.getServers();
+ for (IServer server : servers) {
+ String primaryName = primaryRuntime.getName();
+ IRuntime runtime = server.getRuntime();
+ if (runtime != null) {
+ String serverName = runtime.getName();
+ if (primaryName.equals(serverName)) {
+ s = server;
}
}
+ }
- if(s==null) {
- return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID, "No server selected
to deploy datasource to");
- }
-
- // convert it to a DeployableServer instance
- DeployableServerBehavior deployer = (DeployableServerBehavior)
s.loadAdapter(DeployableServerBehavior.class, null);
+ if (s == null) {
+ return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID,
+ "No server selected to deploy datasource to");
+ }
- // if its not null, the adaptation worked.
- if( deployer == null ) {
- return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID, "Server did
not support deploy of datasource.");
- }
+ // convert it to a DeployableServer instance
+ DeployableServerBehavior deployer = (DeployableServerBehavior) s
+ .loadAdapter(DeployableServerBehavior.class, null);
- IVirtualComponent com = ComponentCore.createComponent(project);
- final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(new
Path("/WEB-INF/classes"));
- IContainer underlyingFolder = srcRootFolder.getUnderlyingFolder();
-
- IPath projectPath = new Path("/"+underlyingFolder.getProject().getName());
- IPath projectRelativePath = underlyingFolder.getProjectRelativePath();
-
- IPath append =
projectPath.append(projectRelativePath).append(project.getName()+"-ds.xml");
-
- if(SingleDeployableFactory.makeDeployable(append)) {
-
- IModule module = SingleDeployableFactory.findModule(append);
-
- // custom API to deploy / publish only one module.
- IStatus t = deployer.publishOneModule(IServer.PUBLISH_FULL, new IModule[] { module},
ServerBehaviourDelegate.ADDED, monitor);
- SingleDeployableFactory.unmakeDeployable(append);
- return t;
- } else {
- return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID, "Could not deploy
datasource " + append);
- }
+ // if its not null, the adaptation worked.
+ if (deployer == null) {
+ return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID,
+ "Server did not support deploy of datasource.");
}
+
+ IVirtualComponent com = ComponentCore.createComponent(project);
+ final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(
+ new Path("/WEB-INF/classes"));
+ IContainer underlyingFolder = srcRootFolder.getUnderlyingFolder();
+
+ IPath projectPath = new Path("/"
+ + underlyingFolder.getProject().getName());
+ IPath projectRelativePath = new Path("src/model");
+
+ IPath append = projectPath.append(projectRelativePath).append(
+ project.getName() + "-ds.xml");
+
+ if (SingleDeployableFactory.makeDeployable(append)) {
+
+ IModule module = SingleDeployableFactory.findModule(append);
+
+ // custom API to deploy / publish only one module.
+ IStatus t = deployer.publishOneModule(IServer.PUBLISH_FULL,
+ new IModule[] { module }, ServerBehaviourDelegate.ADDED,
+ monitor);
+ SingleDeployableFactory.unmakeDeployable(append);
+ return t;
+ } else {
+ return new Status(Status.WARNING, SeamCorePlugin.PLUGIN_ID,
+ "Could not deploy datasource " + append);
+ }
+ }
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-27
05:40:14 UTC (rev 3846)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-27
06:42:38 UTC (rev 3847)
@@ -320,13 +320,13 @@
IContainer source = srcRootFolder.getUnderlyingFolder();
srcRootFolder.delete(IVirtualFolder.FORCE, monitor);
- WtpUtils.createSourceFolder(project, new
Path(source.getFullPath().lastSegment()+"/action"),new
Path(source.getFullPath().lastSegment()));
- WtpUtils.createSourceFolder(project, new
Path(source.getFullPath().lastSegment()+"/model"),new
Path(source.getFullPath().lastSegment()));
+ WtpUtils.createSourceFolder(project, new
Path(source.getFullPath().lastSegment()+"/action"),new
Path(source.getFullPath().lastSegment()), new Path("WebContent/WEB-INF/dev"));
+ WtpUtils.createSourceFolder(project, new
Path(source.getFullPath().lastSegment()+"/model"),new
Path(source.getFullPath().lastSegment()), null);
// Copy sources to src
AntCopyUtils.copyFileToFile(
- new File(seamGenHomeFolder,"src/modelAuthenticator.java"),
+ new File(seamGenHomeFolder,"src/Authenticator.java"),
new
File(project.getLocation().toFile(),source.getFullPath().lastSegment()+"/model/"
+
model.getProperty(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString().replace('.',
'/')+"/"+"Authenticator.java"),
new FilterSetCollection(filtersFilterSet), true);
@@ -357,6 +357,7 @@
WtpUtils.setClasspathEntryAsExported(project, new
Path("org.eclipse.jst.j2ee.internal.web.container"), monitor);
Job create = new DataSourceXmlDeployer(project);
+ create.setUser(true);
create.setRule(ResourcesPlugin.getWorkspace().getRoot());
create.schedule();
@@ -671,8 +672,7 @@
componentsProps.createNewFile();
components.store(new FileOutputStream(componentsProps), "");
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ SeamCorePlugin.getPluginLog().logError(e);
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java 2007-09-27
05:40:14 UTC (rev 3846)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java 2007-09-27
06:42:38 UTC (rev 3847)
@@ -129,7 +129,7 @@
return "";
}
- public static IResource createSourceFolder (IProject project, IPath path, IPath exclude)
{
+ public static IResource createSourceFolder (IProject project, IPath path, IPath exclude,
Path outputFolder) {
IJavaProject javaProject;
IClasspathEntry[] javaProjectEntries;
IPath outputLocation;
@@ -172,13 +172,15 @@
}
newEntries.add(curr);
}
+ if(outputFolder!=null) {
+ CoreUtility.createDerivedFolder(project.getFolder(outputFolder), true, true, new
NullProgressMonitor());
+ }
+ IClasspathEntry newEntry= JavaCore.newSourceEntry(newSourceFolderPath,new Path[]{},new
Path[]{},outputFolder!=null?project.getFullPath().append(outputFolder):null);
- IClasspathEntry newEntry= JavaCore.newSourceEntry(newSourceFolderPath);
if (projectEntryIndex != -1) {
newEntries.set(projectEntryIndex, newEntry);
} else {
- IClasspathEntry entry= JavaCore.newSourceEntry(newSourceFolderPath);
- insertClasspathEntry(entry, newEntries);
+ insertClasspathEntry(newEntry, newEntries);
}
IClasspathEntry[] newClasspathEntries= (IClasspathEntry[]) newEntries.toArray(new
IClasspathEntry[newEntries.size()]);
@@ -203,7 +205,6 @@
}
javaProject.setRawClasspath(newClasspathEntries, newOutputLocation, new
NullProgressMonitor());
-
return newSourceFolder;
} catch (CoreException e) {
SeamCorePlugin.getPluginLog().logError(e);