|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2009 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 19-24
Link Here
|
| 19 |
import org.eclipse.core.resources.IFile; |
19 |
import org.eclipse.core.resources.IFile; |
| 20 |
import org.eclipse.core.resources.IFolder; |
20 |
import org.eclipse.core.resources.IFolder; |
| 21 |
import org.eclipse.core.resources.IProject; |
21 |
import org.eclipse.core.resources.IProject; |
|
|
22 |
import org.eclipse.core.resources.IResource; |
| 22 |
import org.eclipse.core.resources.IWorkspace; |
23 |
import org.eclipse.core.resources.IWorkspace; |
| 23 |
import org.eclipse.core.resources.ResourcesPlugin; |
24 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 24 |
import org.eclipse.core.runtime.CoreException; |
25 |
import org.eclipse.core.runtime.CoreException; |
|
Lines 39-48
Link Here
|
| 39 |
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; |
40 |
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; |
| 40 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; |
41 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; |
| 41 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; |
42 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; |
|
|
43 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; |
| 42 |
import org.eclipse.jst.j2ee.jca.Connector; |
44 |
import org.eclipse.jst.j2ee.jca.Connector; |
| 43 |
import org.eclipse.jst.j2ee.jca.modulecore.util.ConnectorArtifactEdit; |
45 |
import org.eclipse.jst.j2ee.jca.modulecore.util.ConnectorArtifactEdit; |
|
|
46 |
import org.eclipse.jst.j2ee.model.IModelProvider; |
| 47 |
import org.eclipse.jst.j2ee.model.ModelProviderManager; |
| 48 |
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; |
| 49 |
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties; |
| 44 |
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; |
50 |
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; |
| 45 |
import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDelegate; |
51 |
import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDelegate; |
|
|
52 |
import org.eclipse.jst.javaee.core.DisplayName; |
| 53 |
import org.eclipse.jst.javaee.core.JavaeeFactory; |
| 46 |
import org.eclipse.wst.common.componentcore.ComponentCore; |
54 |
import org.eclipse.wst.common.componentcore.ComponentCore; |
| 47 |
import org.eclipse.wst.common.componentcore.datamodel.FacetDataModelProvider; |
55 |
import org.eclipse.wst.common.componentcore.datamodel.FacetDataModelProvider; |
| 48 |
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; |
56 |
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; |
|
Lines 95-101
Link Here
|
| 95 |
IPath configFolderpath = pjpath.append(configFolderName); |
103 |
IPath configFolderpath = pjpath.append(configFolderName); |
| 96 |
sourceFolder = ws.getRoot().getFolder(configFolderpath); |
104 |
sourceFolder = ws.getRoot().getFolder(configFolderpath); |
| 97 |
|
105 |
|
| 98 |
if (!sourceFolder.getFile(J2EEConstants.RAR_DD_URI).exists()) { |
106 |
if( fv == IJ2EEFacetConstants.JCA_16) |
|
|
107 |
{ |
| 108 |
if(model.getBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD)){ |
| 109 |
// Create the deployment descriptor (ra.xml) if one doesn't exist |
| 110 |
IFile rarFile = sourceFolder.getFile(new Path(J2EEConstants.RAR_DD_URI)); |
| 111 |
if (!rarFile.exists()) { |
| 112 |
try { |
| 113 |
if(!rarFile.getParent().exists() |
| 114 |
&& (rarFile.getParent().getType() == IResource.FOLDER)){ |
| 115 |
((IFolder)rarFile.getParent()).create(true, true, monitor); |
| 116 |
} |
| 117 |
InputStream in = getClass().getResourceAsStream(CONNECTOR_XML_TEMPLATE_16); |
| 118 |
rarFile.create(in, true, monitor); |
| 119 |
populateDefaultContent(project, fv); |
| 120 |
} catch (CoreException e) { |
| 121 |
J2EEPlugin.logError(e); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
else if (!sourceFolder.getFile(J2EEConstants.RAR_DD_URI).exists()) { |
| 99 |
String ver = model.getStringProperty(IFacetDataModelProperties.FACET_VERSION_STR); |
127 |
String ver = model.getStringProperty(IFacetDataModelProperties.FACET_VERSION_STR); |
| 100 |
int nVer = J2EEVersionUtil.convertVersionStringToInt(ver); |
128 |
int nVer = J2EEVersionUtil.convertVersionStringToInt(ver); |
| 101 |
|
129 |
|
|
Lines 109-117
Link Here
|
| 109 |
else if (nVer == J2EEVersionConstants.JCA_1_5_ID) { |
137 |
else if (nVer == J2EEVersionConstants.JCA_1_5_ID) { |
| 110 |
template = CONNECTOR_XML_TEMPLATE_15; |
138 |
template = CONNECTOR_XML_TEMPLATE_15; |
| 111 |
} |
139 |
} |
| 112 |
else { |
140 |
// JCA 1.6 handled separately |
| 113 |
template = CONNECTOR_XML_TEMPLATE_16; |
141 |
// else { |
| 114 |
} |
142 |
// template = CONNECTOR_XML_TEMPLATE_16; |
|
|
143 |
// } |
| 115 |
|
144 |
|
| 116 |
InputStream in = getClass().getResourceAsStream(template); |
145 |
InputStream in = getClass().getResourceAsStream(template); |
| 117 |
if (in != null) { |
146 |
if (in != null) { |
|
Lines 203-206
Link Here
|
| 203 |
|
232 |
|
| 204 |
} |
233 |
} |
| 205 |
|
234 |
|
|
|
235 |
private void populateDefaultContent(final IProject project, |
| 236 |
final IProjectFacetVersion fv) { |
| 237 |
final IModelProvider provider = ModelProviderManager.getModelProvider(project, fv); |
| 238 |
Runnable runnable = new Runnable(){ |
| 239 |
|
| 240 |
public void run() { |
| 241 |
Connector connector = (Connector) provider.getModelObject(); |
| 242 |
|
| 243 |
// Add the display-name tag |
| 244 |
DisplayName displayName = JavaeeFactory.eINSTANCE.createDisplayName(); |
| 245 |
displayName.setValue(project.getName()); |
| 246 |
connector.getDisplayNames().add(displayName); |
| 247 |
} |
| 248 |
}; |
| 249 |
provider.modify(runnable, null); |
| 250 |
} |
| 206 |
} |
251 |
} |