blob: 61b5e42b15f692cf4d437fa65137a4445d41e285 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2003, 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.j2ee.internal.jca.operations;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jem.util.logger.proxy.Logger;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationOperation;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.J2EEVersionUtil;
import org.eclipse.jst.j2ee.jca.modulecore.util.ConnectorArtifactEdit;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationDataModel;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.componentcore.resources.ComponentHandle;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
//TODO delete
/**
* @deprecated
*
*/
public class ConnectorComponentCreationOperation extends J2EEComponentCreationOperation {
public ConnectorComponentCreationOperation(ConnectorComponentCreationDataModel dataModel) {
super(dataModel);
}
/* (non-Javadoc)
* @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#createAndLinkJ2EEComponents()
*/
protected void createAndLinkJ2EEComponents() throws CoreException {
IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName());
component.create(0, null);
//create and link connectorModule Source Folder
IVirtualFolder connectorModuleFolder = component.getFolder(new Path("/")); //$NON-NLS-1$
connectorModuleFolder.createLink(new Path("/" + getModuleName() + "/connectorModule"), 0, null); //$NON-NLS-1$ //$NON-NLS-2$
//create and link META-INF folder
IVirtualFolder metaInfFolder = connectorModuleFolder.getFolder(J2EEConstants.META_INF);
metaInfFolder.create(IResource.FORCE, null);
}
protected void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
ConnectorArtifactEdit artifactEdit = null;
try {
ComponentHandle handle = ComponentHandle.create(getProject(),operationDataModel.getStringProperty(ComponentCreationDataModel.COMPONENT_DEPLOY_NAME));
artifactEdit = ConnectorArtifactEdit.getConnectorArtifactEditForWrite(handle);
Integer version = (Integer)operationDataModel.getProperty(ComponentCreationDataModel.COMPONENT_VERSION);
artifactEdit.createModelRoot(version.intValue());
artifactEdit.save(monitor);
} catch (Exception e) {
Logger.getLogger().logError(e);
} finally {
if (artifactEdit != null)
artifactEdit.dispose();
}
}
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
super.execute(IModuleConstants.JST_CONNECTOR_MODULE, monitor);
}
/* (non-Javadoc)
* @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#getVersion()
*/
protected String getVersion() {
int version = operationDataModel.getIntProperty(ComponentCreationDataModel.COMPONENT_VERSION);
return J2EEVersionUtil.getJCATextVersion(version);
}
}