port of server tools rework for temp m3 stream for web services
diff --git a/plugins/org.eclipse.jst.j2ee.web/plugin.xml b/plugins/org.eclipse.jst.j2ee.web/plugin.xml index 21ebc80..982e146 100644 --- a/plugins/org.eclipse.jst.j2ee.web/plugin.xml +++ b/plugins/org.eclipse.jst.j2ee.web/plugin.xml
@@ -14,6 +14,7 @@ </runtime> <requires> <import plugin="org.eclipse.jst.j2ee"/> + <import plugin="org.eclipse.core.runtime"/> <import plugin="org.eclipse.wst.server.core"/> <import plugin="org.eclipse.jst.server.core"/> <import plugin="org.eclipse.wst.common.frameworks"/> @@ -35,6 +36,7 @@ <import plugin="org.eclipse.jface"/> <import plugin="org.eclipse.jst.common.annotations.controller"/> <import plugin="org.eclipse.jst.common.frameworks"/> + <import plugin="org.eclipse.debug.ui"/> </requires> <!--============================--> @@ -167,34 +169,114 @@ <!-- Extension point: org.eclipse.etools.server.core.moduleObjectAdapters --> <!-- Purpose: Define adapters for EJB and Web resources --> <!-- ==================================================================== --> - <extension - point="org.eclipse.wst.server.core.moduleArtifactAdapters"> - <moduleArtifactAdapter + <extension + point="org.eclipse.wst.server.ui.moduleArtifactAdapters"> + <!-- <moduleArtifactAdapter class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableObjectAdapter" objectClass="org.eclipse.jst.j2ee.internal.webapplication.WebApp" id="org.eclipse.jst.web.server.webresource"> - </moduleArtifactAdapter> + </moduleArtifactAdapter> --> + <moduleArtifactAdapter + id="org.eclipse.jst.web.server.webresource"> + <enablement> + <with variable="selection"> + <adapt type="org.eclipse.jst.j2ee.webapplication.WebApp"/> + </with> + </enablement> + </moduleArtifactAdapter> + + + <!-- <moduleArtifactAdapter objectClass="org.eclipse.jst.j2ee.internal.webapplication.Servlet" class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableObjectAdapter" id="org.eclipse.jst.web.server.webresource2"> - </moduleArtifactAdapter> + </moduleArtifactAdapter>--> + + <moduleArtifactAdapter + id="org.eclipse.jst.web.server.webresource2"> + <enablement> + <with variable="selection"> + <adapt type="org.eclipse.jst.server.j2ee.Servlet"/> + </with> + </enablement> + </moduleArtifactAdapter> + + <!-- </moduleArtifactAdapter> <moduleArtifactAdapter objectClass="org.eclipse.core.resources.IProject" class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableObjectAdapter" id="org.eclipse.jst.web.server.webresource3"> - </moduleArtifactAdapter> - <moduleArtifactAdapter + </moduleArtifactAdapter>--> + + <moduleArtifactAdapter + id="org.eclipse.jst.web.server.webresource3"> + <enablement> + <with variable="selection"> + <adapt type="org.eclipse.core.resources.IProject"/> + </with> + </enablement> + </moduleArtifactAdapter> + <!-- <moduleArtifactAdapter objectClass="org.eclipse.core.resources.IFile" class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableObjectAdapter" id="corg.eclipse.jst.web.server.webresource4"> - </moduleArtifactAdapter> - <moduleArtifactAdapter + </moduleArtifactAdapter>--> + <moduleArtifactAdapter + id="org.eclipse.jst.web.server.webresource4"> + <enablement> + <with variable="selection"> + <adapt type="org.eclipse.core.resources.IFile"/> + </with> + </enablement> + </moduleArtifactAdapter> + + <!-- <moduleArtifactAdapter objectClass="org.eclipse.jdt.core.ICompilationUnit" class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableObjectAdapter" id="org.eclipse.jst.web.server.webresource5"> - </moduleArtifactAdapter> + </moduleArtifactAdapter>--> + + <moduleArtifactAdapter + id="org.eclipse.jst.web.server.webresource5"> + <enablement> + <with variable="selection"> + <adapt type="org.eclipse.jdt.core.ICompilationUnit"/> + </with> + </enablement> + </moduleArtifactAdapter> </extension> + + <extension point="org.eclipse.core.runtime.adapters"> + <factory + class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactAdapterFactory" + adaptableType="org.eclipse.core.resources.IProject"> + <adapter type="org.eclipse.wst.server.core.IModuleArtifact"/> + </factory> + <factory + class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactAdapterFactory" + adaptableType="org.eclipse.jdt.core.ICompilationUnit"> + <adapter type="org.eclipse.wst.server.core.IModuleArtifact"/> + </factory> + <factory + class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactAdapterFactory" + adaptableType="org.eclipse.core.resources.IFile"> + <adapter type="org.eclipse.wst.server.core.IModuleArtifact"/> + </factory> + <factory + class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactAdapterFactory" + adaptableType="org.eclipse.jst.j2ee.internal.webapplication.Servlet"> + <adapter type="org.eclipse.wst.server.core.IModuleArtifact"/> + <adapter type= "org.eclipse.debug.ui.actions.ILaunchable"/> + </factory> + <factory + class="org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactAdapterFactory" + adaptableType="org.eclipse.jst.j2ee.webapplication.WebApp"> + <adapter type="org.eclipse.wst.server.core.IModuleArtifact"/> + <adapter type= "org.eclipse.debug.ui.actions.ILaunchable"/> + </factory> + </extension> + <!-- =============================================================== --> <!-- Extension point: com.ibm.etools.server.core.moduleFactories --> <!-- Purpose: Define the default module project factory --> @@ -261,4 +343,240 @@ </extension> <!-- icon="icons/full/obj16/webapp_deploy.gif" --> + + +<!-- =========================================================== --> +<!-- Web Tag set definitions for XDoclet --> +<!-- =========================================================== --> + + <extension + id="WebTagSets" + point="org.eclipse.jst.common.annotations.controller.AnnotationTagSet"> + <AnnotationTagSet + name="web"> + </AnnotationTagSet> + </extension> + + <extension + id="WebAnnotationInfo" + point="org.eclipse.jst.common.annotations.controller.AnnotationTagInfo"> + <AnnotationTagInfo + tagSet="web" + tagName="filter" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + name="description"> + </attrib> + <attrib + name="display-name"> + </attrib> + <attrib + name="small-icon"> + </attrib> + <attrib + name="large-icon"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="filter-init-param" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + name="value"> + </attrib> + <attrib + name="description"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="filter-mapping" + scope="type"> + <attrib + name="url-pattern"> + </attrib> + <attrib + name="servlet-name"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="servlet" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + name="display-name"> + </attrib> + <attrib + name="icon"> + </attrib> + <attrib + name="description"> + </attrib> + <attrib + name="load-on-startup"> + </attrib> + <attrib + name="run-as"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="servlet-init-param" + multiplicity="*" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + name="value"> + </attrib> + <attrib + name="description"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="servlet-mapping" + multiplicity="*" + scope="type"> + <attrib + use="required" + name="url-pattern"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="listener" + scope="type"> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="security-role-ref" + scope="type"> + <attrib + use="required" + name="role-name"> + </attrib> + <attrib + use="required" + name="role-link"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="resource-env-ref" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + use="required" + name="type"> + </attrib> + <attrib + name="description"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="resource-ref" + scope="type"> + <attrib + use="required" + name="name"> + </attrib> + <attrib + use="required" + name="type"> + </attrib> + <attrib + use="required" + name="auth"> + </attrib> + <attrib + name="description"> + </attrib> + <attrib + name="scope"> + </attrib> + <attrib + name="jndi-name"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="security-role" + scope="type"> + <attrib + use="required" + name="role-name"> + </attrib> + <attrib + name="description"> + </attrib> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="env-entry" + scope="type"> + <attrib name="name" use="required"> + </attrib> + <attrib name="description"/> + <attrib name="type" type="enum"> + <enumValues value="java.lang.Boolean"/> + <enumValues value="java.lang.Byte"/> + <enumValues value="java.lang.Character"/> + <enumValues value="java.lang.String"/> + <enumValues value="java.lang.Short"/> + <enumValues value="java.lang.Integer"/> + <enumValues value="java.lang.Long"/> + <enumValues value="java.lang.Float"/> + <enumValues value="java.lang.Double"/> + </attrib> + <attrib name="value"/> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="ejb-ref" + scope="type"> + <attrib name="name" use="required"/> + <attrib name="type" type="enum" use="required"> + <enumValues value="Entity"/> + <enumValues value="Session"/> + </attrib> + <attrib name="home" use="required"/> + <attrib name="remote" use="required"/> + <attrib name="link"/> + <attrib name="description"/> + </AnnotationTagInfo> + <AnnotationTagInfo + tagSet="web" + tagName="ejb-local-ref" + scope="type"> + <attrib name="name" use="required"/> + <attrib name="type" type="enum" use="required"> + <enumValues value="Entity"/> + <enumValues value="Session"/> + </attrib> + <attrib name="home" use="required"/> + <attrib name="local" use="required"/> + <attrib name="link"/> + <attrib name="description"/> + </AnnotationTagInfo> + </extension> + </plugin>
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/J2EEWebDeployable.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/J2EEWebDeployable.java index f4249aa..7cf00a1 100644 --- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/J2EEWebDeployable.java +++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/J2EEWebDeployable.java
@@ -11,16 +11,12 @@ package org.eclipse.jst.j2ee.internal.web.deployables; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jst.j2ee.internal.deployables.J2EEDeployable; import org.eclipse.jst.j2ee.internal.deployables.LooseArchiveDeployable; import org.eclipse.jst.j2ee.internal.deployables.LooseArchiveDeployableFactory; @@ -30,11 +26,8 @@ import org.eclipse.jst.server.j2ee.ILooseArchive; import org.eclipse.jst.server.j2ee.ILooseArchiveSupport; import org.eclipse.jst.server.j2ee.IWebModule; -import org.eclipse.wst.server.core.internal.ModuleFactory; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.ServerCore; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleFactoryDelegate; +import org.eclipse.wst.server.core.IModuleType; import org.eclipse.wst.web.internal.operation.IBaseWebNature; import org.eclipse.wst.web.internal.operation.ILibModule; @@ -48,6 +41,7 @@ protected ILooseArchive[] archives; protected Map uris = new HashMap(); + /** * @param aNature @@ -59,7 +53,7 @@ } public String getId() { - return getFactoryId() +":"+ getProject().getName(); + return getProject().getName(); } public String getContextRoot() { @@ -348,41 +342,7 @@ return children; } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getModuleType() - */ - public IModuleType getModuleType() { - return new IModuleType(){ - - public String getId() { - return "j2ee.web"; - } - - public String getName() { - // TODO Auto-generated method stub - return getModuleTypeName(); - } - - public String getVersion() { - // TODO Auto-generated method stub - return getModuleTypeVersion(); - }}; - // TODO Auto-generated method stub - // return this; - } - + public String getModuleTypeName(){ return getName(); } @@ -391,24 +351,5 @@ return getVersion(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getChildModules(org.eclipse.core.runtime.IProgressMonitor) - */ - public IModule[] getChildModules(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (getModule() == null) - initialize(this); - return this; - } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableFactory.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableFactory.java index b532f42..7b8f017 100644 --- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableFactory.java +++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableFactory.java
@@ -8,23 +8,20 @@ **************************************************************************************************/ package org.eclipse.jst.j2ee.internal.web.deployables; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFactory; import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import sun.security.action.GetPropertyAction; +import com.ibm.wtp.common.logger.proxy.Logger; public class WebDeployableFactory extends J2EEDeployableFactory { private static final String ID = "com.ibm.wtp.web.server"; //$NON-NLS-1$ + + protected static final IPath[] PATHS = new IPath[] { new Path(".j2ee") //$NON-NLS-1$ }; @@ -50,10 +47,23 @@ * @see org.eclise.wtp.j2ee.servers.J2EEDeployableFactory#createDeployable(org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature) */ public IModule createModule(J2EENature nature) { - IModule deployable = (IModule) nature.getModule(); - if (deployable == null) - deployable = new J2EEWebDeployable(nature, ID); - return deployable; + if (nature == null) + return null; + J2EEWebDeployable moduleDelegate = null; + IModule module = nature.getModule(); + if (module == null) { + try { + moduleDelegate = new J2EEWebDeployable(nature, ID); + module = createModule(moduleDelegate.getId(), moduleDelegate.getName(), moduleDelegate.getType(), moduleDelegate.getVersion(), moduleDelegate.getProject()); + nature.setModule(module); + moduleDelegate.initialize(module); + } catch (Exception e) { + Logger.getLogger().write(e); + } finally { + moduleDelegates.add(moduleDelegate); + } + } + return module; } /* @@ -63,46 +73,7 @@ return PATHS; } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ - public ModuleDelegate getModuleDelegate(IModule module) { - // TODO Auto-generated method stub - return null; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - if (projects == null) - cacheModules(); - int i = 0; - Iterator modules = projects.values().iterator(); - IModule[] modulesArray = new IModule[projects.values().size()]; - while (modules.hasNext()) { - IModule element = (IModule) modules.next(); - modulesArray[i++]= element; - - } - // TODO Auto-generated method stub - return modulesArray; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate#handleProjectChange(org.eclipse.core.resources.IProject, - * org.eclipse.core.resources.IResourceDelta) - */ - protected void handleProjectChange(IProject project, IResourceDelta delta) { - // TODO Auto-generated method stub - if (projects == null) - cacheModules(); - super.handleProjectChange(project, delta); - } + } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableObjectAdapter.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableObjectAdapter.java deleted file mode 100644 index 0ba1cbd..0000000 --- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/deployables/WebDeployableObjectAdapter.java +++ /dev/null
@@ -1,364 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.web.deployables; - -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants; -import org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURL; -import org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURLExtensionReader; -import org.eclipse.jst.j2ee.internal.web.operations.J2EEWebNatureRuntime; -import org.eclipse.jst.j2ee.internal.web.operations.J2EEWebNatureRuntimeUtilities; -import org.eclipse.jst.j2ee.internal.web.operations.WebEditModel; -import org.eclipse.jst.j2ee.webapplication.JSPType; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.ServletMapping; -import org.eclipse.jst.j2ee.webapplication.ServletType; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebType; -import org.eclipse.jst.server.j2ee.WebResource; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; -import org.eclipse.wst.web.internal.operation.IBaseWebNature; - -import com.ibm.wtp.emf.workbench.ProjectUtilities; - -/** - * @version 1.0 - * @author - */ -public class WebDeployableObjectAdapter extends ModuleArtifactAdapterDelegate { - private final static String[] extensionsToExclude = new String[]{"sql", "xmi"}; //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Constructor for WebDeployableObjectAdapter. - */ - public WebDeployableObjectAdapter() { - super(); - } - - /* - * @see IDeployableObjectAdapterDelegate#getDeployableObject(Object) - */ - public IModuleArtifact getModuleObject(Object obj) { - IResource resource = null; - if (obj instanceof IResource) - resource = (IResource) obj; - else if (obj instanceof IAdaptable) - resource = (IResource) ((IAdaptable) obj).getAdapter(IResource.class); - else if (obj instanceof EObject) { - resource = ProjectUtilities.getProject((EObject) obj); - - /* - * ccc - this code is a pseudo-rehash of the code below. The difference is that we have - * a Servlet, instead of an IResource that might be a Servlet - */ - if (obj instanceof Servlet) { - String mapping = null; - java.util.List mappings = ((Servlet) obj).getMappings(); - IBaseWebNature webNature = J2EEWebNatureRuntimeUtilities.getRuntime(resource.getProject()); - - if (mappings != null && !mappings.isEmpty()) { - ServletMapping map = (ServletMapping) mappings.get(0); - mapping = map.getUrlPattern(); - } - if (mapping != null) { - return new WebResource(getModule(webNature), new Path(mapping)); - } - WebType webType = ((Servlet) obj).getWebType(); - if (webType.isJspType()) { - resource = ((IProject) resource).getFile(webNature.getModuleServerRootName() + "/" + ((JSPType) webType).getJspFile()); //$NON-NLS-1$ - } else if (webType.isServletType()) { - return new WebResource(getModule(webNature), new Path("servlet/" + ((ServletType) webType).getClassName())); //$NON-NLS-1$ - } - } - } - if (resource == null) - return null; - - // find deployable - IBaseWebNature webNature = J2EEWebNatureRuntimeUtilities.getRuntime(resource.getProject()); - if (webNature == null) - return null; - - if (resource instanceof IProject) - return new WebResource(getModule(webNature), new Path("")); //$NON-NLS-1$ - - String className = getServletClassName(resource); - if (className != null) { - String mapping = getServletMapping(resource.getProject(), true, className); - if (mapping != null) { - return new WebResource(getModule(webNature), new Path(mapping)); - } - // if there is no servlet mapping, provide direct access to the servlet - // through the fully qualified class name - return new WebResource(getModule(webNature), new Path("servlet/" + className)); //$NON-NLS-1$ - - } - - // determine path - IPath rootPath = webNature.getRootPublishableFolder().getProjectRelativePath(); - IPath resourcePath = resource.getProjectRelativePath(); - - // Check to make sure the resource is under the webApplication directory - if (resourcePath.matchingFirstSegments(rootPath) != rootPath.segmentCount()) - return null; - - // Do not allow resource under the web-inf directory - resourcePath = resourcePath.removeFirstSegments(rootPath.segmentCount()); - if (resourcePath.segmentCount() > 1 && resourcePath.segment(0).equals(IWebNatureConstants.INFO_DIRECTORY)) - return null; - - if (shouldExclude(resource)) - return null; - - //Extension read to get the correct URL for Java Server Faces file if - //the jsp is of type jsfaces. - FileURL jspURL = FileURLExtensionReader.getInstance().getFilesURL(); - if (jspURL != null) { - IPath correctJSPPath = jspURL.getFileURL(resource, resourcePath); - if (correctJSPPath != null && correctJSPPath.toString().length() > 0) - return new WebResource(getModule(webNature), correctJSPPath); - } - // return Web resource type - return new WebResource(getModule(webNature), resourcePath); - } - - /** - * Method shouldExclude. - * - * @param resource - * @return boolean - */ - private boolean shouldExclude(IResource resource) { - String fileExt = resource.getFileExtension(); - - // Exclude files of certain extensions - for (int i = 0; i < extensionsToExclude.length; i++) { - String extension = extensionsToExclude[i]; - if (extension.equalsIgnoreCase(fileExt)) - return true; - } - return false; - } - - protected IModule getModule(IBaseWebNature nature) { - IModule deployable = nature.getModule(); - if (deployable != null) - return deployable; - - IProject project = nature.getProject(); - Iterator iterator = Arrays.asList(ServerUtil.getModules("j2ee.web")).iterator(); //$NON-NLS-1$ - while (iterator.hasNext()) { - deployable = (IModule) iterator.next(); - if (deployable instanceof IModule) { - if (((IModule) deployable).getProject().equals(project)) - return deployable; - } - } - return null; - } - - /** - * If this resource is a servlet, return the class name. If not, return null. - * - * @param resource - * @return java.lang.String - */ - public static String getServletClassName(IResource resource) { - if (resource == null) - return null; - - try { - IProject project = resource.getProject(); - IPath path = resource.getFullPath(); - if (!project.hasNature(JavaCore.NATURE_ID) || path == null) - return null; - - IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID); - if (!javaProject.isOpen()) - javaProject.open(new NullProgressMonitor()); - - // output location may not be on classpath - IPath outputPath = javaProject.getOutputLocation(); - if (outputPath != null && "class".equals(path.getFileExtension()) && outputPath.isPrefixOf(path)) { //$NON-NLS-1$ - int count = outputPath.segmentCount(); - path = path.removeFirstSegments(count); - } - - // remove initial part of classpath - IClasspathEntry[] classPathEntry = javaProject.getResolvedClasspath(true); - if (classPathEntry != null) { - int size = classPathEntry.length; - for (int i = 0; i < size; i++) { - IPath classPath = classPathEntry[i].getPath(); - if (classPath.isPrefixOf(path)) { - int count = classPath.segmentCount(); - path = path.removeFirstSegments(count); - i += size; - } - } - } - - // get java element - IJavaElement javaElement = javaProject.findElement(path); - - IType[] types = getTypes(javaElement); - if (types != null) { - int size2 = types.length; - for (int i = 0; i < size2; i++) { - if (isServlet(types[i])) - return types[i].getFullyQualifiedName(); - } - } - return null; - } catch (Exception e) { - return null; - } - } - - /** - * Returns the types contained within this java element. - * - * @param element - * com.ibm.jdt.core.api.IJavaElement - * @return com.ibm.jdt.core.api.IType[] - */ - private static IType[] getTypes(IJavaElement element) { - try { - if (element.getElementType() != IJavaElement.COMPILATION_UNIT) - return null; - - return ((ICompilationUnit) element).getAllTypes(); - } catch (Exception e) { - return null; - } - } - - /** - * Returns true if this java type derives from javax.servlet.GenericServlet - * - * @param type - * com.ibm.jdt.core.api.IType - * @return boolean - */ - private static boolean isServlet(IType type) { - try { - ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null); - IType[] superClasses = hierarchy.getAllSuperclasses(type); - - int size = superClasses.length; - for (int i = 0; i < size; i++) { - if ("javax.servlet.GenericServlet".equals(superClasses[i].getFullyQualifiedName())) //$NON-NLS-1$ - return true; - } - return false; - } catch (Exception e) { - return false; - } - } - - /** - * Return the mapping of a servlet or JSP file, or null if none was available. - * - * @param project - * org.eclipse.core.resources.IProject - * @param isServlet - * boolean - * @param typeName - * java.lang.String - * @return java.lang.String - */ - public static String getServletMapping(IProject project, boolean isServlet, String typeName) { - if (typeName == null || typeName.equals("")) //$NON-NLS-1$ - return null; - - J2EEWebNatureRuntime webNature = null; - WebEditModel model = null; - Object key = new Object(); - - try { - webNature = J2EEWebNatureRuntimeUtilities.getJ2EERuntime(project); - if (webNature == null) - return null; - - model = webNature.getWebAppEditModelForRead(key); - if (model == null) - return null; - WebApp webApp = model.getWebApp(); - if (webApp == null) - return null; - - // find servlet - Iterator iterator = webApp.getServlets().iterator(); - while (iterator.hasNext()) { - Servlet servlet = (Servlet) iterator.next(); - boolean valid = false; - - WebType webType = servlet.getWebType(); - if (webType.isServletType() && isServlet) { - ServletType type = (ServletType) webType; - if (typeName.equals(type.getClassName())) - valid = true; - } else if (webType.isJspType() && !isServlet) { - JSPType type = (JSPType) webType; - if (typeName.equals(type.getJspFile())) - valid = true; - } - - if (valid) { - java.util.List mappings = servlet.getMappings(); - if (mappings != null && !mappings.isEmpty()) { - ServletMapping map = (ServletMapping) mappings.get(0); - return map.getUrlPattern(); - } - } - } - - return null; - } catch (Exception e) { - return null; - } finally { - try { - if (model != null) - model.releaseAccess(key); - } catch (Exception ex) { - } - } - } - - public static String getJSPSpecificationVersion(IBaseWebNature baseWebNature) { - - if (baseWebNature.isJ2EE()) { - return ((J2EEWebNatureRuntime) baseWebNature).isJSP1_2() ? "1.2" : "1.1"; //$NON-NLS-1$ //$NON-NLS-2$ - } - return "1.2"; //$NON-NLS-1$ - - } - -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java index 4e57c9a..b17899d 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java
@@ -15,16 +15,16 @@ import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.jst.server.j2ee.IApplicationClientModule; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -public class ApplicationClientDeployable extends J2EEDeployable implements IApplicationClientModule {/* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ -public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; -} +public class ApplicationClientDeployable extends J2EEDeployable implements IApplicationClientModule {/* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) + */ + public IStatus validate(IProgressMonitor monitor) { + // TODO Auto-generated method stub + return null; + } /** * Constructor for ApplicationClientDeployable. @@ -56,25 +56,5 @@ public String getVersion() { return getNature().getJ2EEVersionText(); } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#getChildModules(org.eclipse.core.runtime.IProgressMonitor) - */ - public IModule[] getChildModules(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#getModuleType() - */ - public IModuleType getModuleType() { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } + } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java index 2bb9369..08240ca 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java
@@ -10,14 +10,11 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.deployables; - -import org.eclipse.core.resources.IProject; import org.eclipse.jst.j2ee.applicationclient.creation.IApplicationClientNatureConstants; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModule; +import com.ibm.wtp.common.logger.proxy.Logger; /** * @version 1.0 @@ -50,23 +47,25 @@ /* * @see J2EEDeployableFactory#createDeployable(J2EENature) */ + public IModule createModule(J2EENature nature) { - return new ApplicationClientDeployable(nature, ID); + if (nature == null) + return null; + ApplicationClientDeployable moduleDelegate = null; + IModule module = nature.getModule(); + if (module == null) { + try { + moduleDelegate = new ApplicationClientDeployable(nature, ID); + module = createModule(moduleDelegate.getId(), moduleDelegate.getName(), moduleDelegate.getType(), moduleDelegate.getVersion(), moduleDelegate.getProject()); + nature.setModule(module); + moduleDelegate.initialize(module); + } catch (Exception e) { + Logger.getLogger().write(e); + } finally { + moduleDelegates.add(moduleDelegate); + } + } + return module; } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ - public ModuleDelegate getModuleDelegate(IModule module) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - // TODO Auto-generated method stub - return null; - } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java index 4ca9bbf..48a340c 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java
@@ -30,409 +30,396 @@ import org.eclipse.jst.server.j2ee.ILooseArchive; import org.eclipse.jst.server.j2ee.ILooseArchiveSupport; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; +import org.eclipse.wst.server.core.model.ModuleDelegate; import org.eclipse.wst.server.core.model.ModuleFactoryDelegate; -; + public class EnterpriseApplicationDeployable extends J2EEDeployable implements IEnterpriseApplication, ILooseArchiveSupport { - // cached children - protected IJ2EEModule[] containedModules; + // cached children + protected IJ2EEModule[] containedModules; - protected ILooseArchive[] containedArchives; + protected ILooseArchive[] containedArchives; - // cached URIs - deployable to String - protected Map containedModuleURIs = new HashMap(4); + // cached URIs - deployable to String + protected Map containedModuleURIs = new HashMap(4); - protected Map containedArchiveURIs = new HashMap(4); + protected Map containedArchiveURIs = new HashMap(4); - /** - * Constructor for EnterpriseApplicationDeployable. - * - * @param aNature - * @param aFactoryId - */ - public EnterpriseApplicationDeployable(J2EENature aNature, String aFactoryId) { - super(aNature, aFactoryId); + /** + * Constructor for EnterpriseApplicationDeployable. + * + * @param aNature + * @param aFactoryId + */ + public EnterpriseApplicationDeployable(J2EENature aNature, String aFactoryId) { + super(aNature, aFactoryId); - update(); - } + update(); + } - /** - * @see IEnterpriseApplication#containsLooseModules() - */ - public boolean containsLooseModules() { - return true; - } + /** + * @see IEnterpriseApplication#containsLooseModules() + */ + public boolean containsLooseModules() { + return true; + } - /** - * @see IEnterpriseApplication#containsLooseArchives() - */ - public boolean containsLooseArchives() { - return true; - } + /** + * @see IEnterpriseApplication#containsLooseArchives() + */ + public boolean containsLooseArchives() { + return true; + } - /* - * @see IEnterpriseApplication#getModules() - */ - public IJ2EEModule[] getModules() { - return containedModules; - } + /* + * @see IEnterpriseApplication#getModules() + */ + public IJ2EEModule[] getModules() { + return containedModules; + } - /* - * @see IEnterpriseApplication#getVendorSupport() - */ - public String[] getVendorSupport() { - return null; - } + /* + * @see IEnterpriseApplication#getVendorSupport() + */ + public String[] getVendorSupport() { + return null; + } - protected EARNatureRuntime getEARNature() { - return (EARNatureRuntime) getNature(); - } + protected EARNatureRuntime getEARNature() { + return (EARNatureRuntime) getNature(); + } - protected static IModule getModule(J2EENature nature) { - IModule dep = nature.getModule(); - if (dep == null) { - ModuleFactoryDelegate fac = getModuleFactory(nature); - if (fac != null) { - if (fac instanceof J2EEDeployableFactory) { - dep = ((J2EEDeployableFactory) fac).getModuleProject(nature.getProject()); - } - } - } - return dep; - } + protected static IModule getModule(J2EENature nature) { + IModule dep = nature.getModule(); + if (dep == null) { + ModuleFactoryDelegate fac = getModuleFactory(nature); + if (fac != null) { + if (fac instanceof J2EEDeployableFactory) { + dep = ((J2EEDeployableFactory) fac).getModuleProject(nature.getProject()); + } + } + } + return dep; + } - protected static ModuleFactoryDelegate getModuleFactory(J2EENature nature) { - /* - * Iterator factories = ServerCore.getModuleFactories().iterator(); - * while (factories.hasNext()) { ModuleFactory deployableFactory = - * (ModuleFactory) factories.next(); if - * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { - * ModuleFactoryDelegate deployableFactoryDelegate = - * deployableFactory.getDelegate(); if (deployableFactoryDelegate - * instanceof J2EEDeployableFactory) { J2EEDeployableFactory fac = - * (J2EEDeployableFactory) deployableFactory.getDelegate(); if - * (fac.getNatureID().equals(nature.getNatureID())) { return fac; } } } } - */ - return null; - } + protected static ModuleFactoryDelegate getModuleFactory(J2EENature nature) { + /* + * Iterator factories = ServerCore.getModuleFactories().iterator(); while + * (factories.hasNext()) { ModuleFactory deployableFactory = (ModuleFactory) + * factories.next(); if + * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { + * ModuleFactoryDelegate deployableFactoryDelegate = deployableFactory.getDelegate(); if + * (deployableFactoryDelegate instanceof J2EEDeployableFactory) { J2EEDeployableFactory fac = + * (J2EEDeployableFactory) deployableFactory.getDelegate(); if + * (fac.getNatureID().equals(nature.getNatureID())) { return fac; } } } } + */ + return null; + } - protected static LooseArchiveDeployableFactory getLooseArchiveDeployableFactory() { - /* - * Iterator factories = ServerCore.getModuleFactories().iterator(); - * while (factories.hasNext()) { ModuleFactory deployableFactory = - * (ModuleFactory) factories.next(); if - * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { - * ModuleFactoryDelegate deployableFactoryDelegate = - * deployableFactory.getDelegate(); if (deployableFactoryDelegate - * instanceof LooseArchiveDeployableFactory) return - * (LooseArchiveDeployableFactory) deployableFactoryDelegate; } } - */ - return null; - } + protected static LooseArchiveDeployableFactory getLooseArchiveDeployableFactory() { + /* + * Iterator factories = ServerCore.getModuleFactories().iterator(); while + * (factories.hasNext()) { ModuleFactory deployableFactory = (ModuleFactory) + * factories.next(); if + * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { + * ModuleFactoryDelegate deployableFactoryDelegate = deployableFactory.getDelegate(); if + * (deployableFactoryDelegate instanceof LooseArchiveDeployableFactory) return + * (LooseArchiveDeployableFactory) deployableFactoryDelegate; } } + */ + return null; + } - /* - * @see IEnterpriseApplication#getURI(IJ2EEModule) - */ - public String getURI(IJ2EEModule module) { - try { - return (String) containedModuleURIs.get(module); - } catch (Exception e) { - } - return null; - } + /* + * @see IEnterpriseApplication#getURI(IJ2EEModule) + */ + public String getURI(IJ2EEModule module) { + try { + return (String) containedModuleURIs.get(module); + } catch (Exception e) { + } + return null; + } - public String getURI(ILooseArchive archive) { - try { - return (String) containedArchiveURIs.get(archive); - } catch (Exception e) { - } - return null; - } + public String getURI(ILooseArchive archive) { + try { + return (String) containedArchiveURIs.get(archive); + } catch (Exception e) { + } + return null; + } - public ILooseArchive[] getLooseArchives() { - return containedArchives; - } + public ILooseArchive[] getLooseArchives() { + return containedArchives; + } - protected ILooseArchive getArchiveDeployable(IProject aProject, LooseArchiveDeployableFactory fact) { - return (ILooseArchive) fact.getModuleProject(aProject); - } + protected ILooseArchive getArchiveDeployable(IProject aProject, LooseArchiveDeployableFactory fact) { + try { + return (ILooseArchive) fact.getModuleProject(aProject); + } catch (RuntimeException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } - protected void update() { - IJ2EEModule[] oldModules = containedModules; - containedModules = getContainedModules(); - ILooseArchive[] oldArchives = containedArchives; - containedArchives = getContainedArchives(); + protected void update() { + IJ2EEModule[] oldModules = containedModules; + containedModules = getContainedModules(); + ILooseArchive[] oldArchives = containedArchives; + containedArchives = getContainedArchives(); - // get add events - List add = new ArrayList(2); - addAddedObjects(add, oldModules, containedModules); - addAddedObjects(add, oldArchives, containedArchives); + // get add events + List add = new ArrayList(2); + addAddedObjects(add, oldModules, containedModules); + addAddedObjects(add, oldArchives, containedArchives); - // get remove events - List remove = new ArrayList(2); - addRemovedObjects(remove, oldModules, containedModules); - addRemovedObjects(remove, oldArchives, containedArchives); + // get remove events + List remove = new ArrayList(2); + addRemovedObjects(remove, oldModules, containedModules); + addRemovedObjects(remove, oldArchives, containedArchives); - // fire change events - int size = containedModules.length; - List change = new ArrayList(size); - for (int i = 0; i < size; i++) { - String newURI = getContainedURI(containedModules[i]); - String oldURI = getURI(containedModules[i]); + // fire change events + int size = containedModules.length; + List change = new ArrayList(size); + for (int i = 0; i < size; i++) { + String newURI = getContainedURI(containedModules[i]); + String oldURI = getURI(containedModules[i]); - if (oldURI != null && !oldURI.equals(newURI)) { - change.add(containedModules[i]); - } - containedModuleURIs.put(containedModules[i], newURI); - } + if (oldURI != null && !oldURI.equals(newURI)) { + change.add(containedModules[i]); + } + containedModuleURIs.put(containedModules[i], newURI); + } - size = containedArchives.length; - for (int i = 0; i < size; i++) { - String newURI = getContainedURI(containedArchives[i]); - String oldURI = getURI(containedArchives[i]); + size = containedArchives.length; + for (int i = 0; i < size; i++) { + String newURI = getContainedURI(containedArchives[i]); + String oldURI = getURI(containedArchives[i]); - if (oldURI != null && !oldURI.equals(newURI)) { - change.add(containedArchives[i]); - } - containedArchiveURIs.put(containedArchives[i], newURI); - } + if (oldURI != null && !oldURI.equals(newURI)) { + change.add(containedArchives[i]); + } + containedArchiveURIs.put(containedArchives[i], newURI); + } - if (!add.isEmpty() || !remove.isEmpty() || !change.isEmpty()) { - IModule[] added = new IModule[add.size()]; - add.toArray(added); - IModule[] changed = new IModule[change.size()]; - change.toArray(changed); - IModule[] removed = new IModule[remove.size()]; - remove.toArray(removed); - fireModuleChangeEvent(true, added, changed, removed); - } - } + if (!add.isEmpty() || !remove.isEmpty() || !change.isEmpty()) { + IModule[] added = new IModule[add.size()]; + getModulesFromDelegates(add).toArray(added); + IModule[] changed = new IModule[change.size()]; + getModulesFromDelegates(change).toArray(changed); + IModule[] removed = new IModule[remove.size()]; + getModulesFromDelegates(remove).toArray(removed); + fireModuleChangeEvent(true, added, changed, removed); + } + } - /** - * Return the objects that have been added between array a and array b. - * Assumes that there are no null objects in the array. - */ - protected static void addAddedObjects(List list, Object[] a, Object[] b) { - if (b == null) - return; - else if (a == null) { - int size = b.length; - for (int i = 0; i < size; i++) - list.add(b[i]); - return; - } - int size = b.length; - for (int i = 0; i < size; i++) { - Object obj = b[i]; - boolean found = false; - if (a != null) { - int size2 = a.length; - for (int j = 0; !found && j < size2; j++) { - if (obj.equals(a[j])) - found = true; - } - } - if (!found) - list.add(obj); - } - } + protected List getModulesFromDelegates(List delegates) { + List result = new ArrayList(); + for (int i = 0; i < delegates.size(); i++) { + Object delegate = delegates.get(i); + if (delegate != null && delegate instanceof J2EEDeployable) + result.add(((J2EEDeployable) delegate).getModule()); + } + return result; + } - /** - * Return the objects that have been removed between array a and array b. - * Assumes that there are no null objects in the array. - */ - protected static void addRemovedObjects(List list, Object[] a, Object[] b) { - if (a == null) - return; - else if (b == null) { - int size = a.length; - for (int i = 0; i < size; i++) - list.add(a[i]); - return; - } - int size = a.length; - for (int i = 0; i < size; i++) { - Object obj = a[i]; - boolean found = false; - if (b != null) { - int size2 = b.length; - for (int j = 0; !found && j < size2; j++) { - if (obj.equals(b[j])) - found = true; - } - } - if (!found) - list.add(obj); - } - } + /** + * Return the objects that have been added between array a and array b. Assumes that there are + * no null objects in the array. + */ + protected static void addAddedObjects(List list, Object[] a, Object[] b) { + if (b == null) + return; + else if (a == null) { + int size = b.length; + for (int i = 0; i < size; i++) + list.add(b[i]); + return; + } + int size = b.length; + for (int i = 0; i < size; i++) { + Object obj = b[i]; + boolean found = false; + if (a != null) { + int size2 = a.length; + for (int j = 0; !found && j < size2; j++) { + if (obj.equals(a[j])) + found = true; + } + } + if (!found) + list.add(obj); + } + } - /** - * - */ - protected IJ2EEModule[] getContainedModules() { - Collection projects = getEARNature().getModuleProjects().values(); - List mods = new ArrayList(projects.size()); - Iterator it = projects.iterator(); - J2EENature nat = null; - while (it.hasNext()) { - nat = (J2EENature) it.next(); - if (nat != null) { - Object module = getModule(nat); - if (module != null) - mods.add(module); - } - } - IJ2EEModule[] result = new IJ2EEModule[mods.size()]; - mods.toArray(result); - return result; - } + /** + * Return the objects that have been removed between array a and array b. Assumes that there are + * no null objects in the array. + */ + protected static void addRemovedObjects(List list, Object[] a, Object[] b) { + if (a == null) + return; + else if (b == null) { + int size = a.length; + for (int i = 0; i < size; i++) + list.add(a[i]); + return; + } + int size = a.length; + for (int i = 0; i < size; i++) { + Object obj = a[i]; + boolean found = false; + if (b != null) { + int size2 = b.length; + for (int j = 0; !found && j < size2; j++) { + if (obj.equals(b[j])) + found = true; + } + } + if (!found) + list.add(obj); + } + } - /** - * - */ - protected ILooseArchive[] getContainedArchives() { - EAREditModel editModel = getEARNature().getEarEditModelForRead(this); - try { - List maps = editModel.getUtilityJARMappings(); - if (maps == null) - return new ILooseArchive[0]; + /** + * + */ + protected IJ2EEModule[] getContainedModules() { + Collection projects = getEARNature().getModuleProjects().values(); + List mods = new ArrayList(projects.size()); + Iterator it = projects.iterator(); + J2EENature nat = null; + while (it.hasNext()) { + nat = (J2EENature) it.next(); + if (nat != null) { + Object module = getModule(nat); + if (module != null && module instanceof IModule) { + Object moduleDelegate = ((IModule) module).getAdapter(ModuleDelegate.class); + if (moduleDelegate != null) + mods.add(moduleDelegate); + } + } + } + IJ2EEModule[] result = new IJ2EEModule[mods.size()]; + mods.toArray(result); + return result; + } - LooseArchiveDeployableFactory fact = getLooseArchiveDeployableFactory(); - List arcs = new ArrayList(maps.size()); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - IProject proj = null; - if (map.getProjectName() != null) - proj = J2EEPlugin.getWorkspace().getRoot().getProject(map.getProjectName()); - if (proj != null && proj.exists()) { - ILooseArchive archive = getArchiveDeployable(proj, fact); - if (archive != null) - arcs.add(archive); - } - } - ILooseArchive[] result = new ILooseArchive[arcs.size()]; - arcs.toArray(result); - return result; - } finally { - if (editModel != null) - editModel.releaseAccess(this); - } - } + /** + * + */ + protected ILooseArchive[] getContainedArchives() { + EAREditModel editModel = getEARNature().getEarEditModelForRead(this); + try { + List maps = editModel.getUtilityJARMappings(); + if (maps == null) + return new ILooseArchive[0]; - /* - * @see IEnterpriseApplication#getURI(IJ2EEModule) - */ - protected String getContainedURI(ILooseArchive deployable) { - if (deployable instanceof LooseArchiveDeployable) { - LooseArchiveDeployable archive = (LooseArchiveDeployable) deployable; - EAREditModel editModel = getEARNature().getEarEditModelForRead(this); - try { - UtilityJARMapping map = editModel.getUtilityJARMapping(archive.getProject()); - if (map != null) - return map.getUri(); - return null; - } finally { - editModel.releaseAccess(this); - } - } + LooseArchiveDeployableFactory fact = getLooseArchiveDeployableFactory(); + List arcs = new ArrayList(maps.size()); + for (int i = 0; i < maps.size(); i++) { + UtilityJARMapping map = (UtilityJARMapping) maps.get(i); + IProject proj = null; + if (map.getProjectName() != null) + proj = J2EEPlugin.getWorkspace().getRoot().getProject(map.getProjectName()); + if (proj != null && proj.exists()) { + ILooseArchive archive = getArchiveDeployable(proj, fact); + if (archive != null) + arcs.add(archive); + } + } + ILooseArchive[] result = new ILooseArchive[arcs.size()]; + arcs.toArray(result); + return result; + } finally { + if (editModel != null) + editModel.releaseAccess(this); + } + } - return null; - } + /* + * @see IEnterpriseApplication#getURI(IJ2EEModule) + */ + protected String getContainedURI(ILooseArchive deployable) { + if (deployable instanceof LooseArchiveDeployable) { + LooseArchiveDeployable archive = (LooseArchiveDeployable) deployable; + EAREditModel editModel = getEARNature().getEarEditModelForRead(this); + try { + UtilityJARMapping map = editModel.getUtilityJARMapping(archive.getProject()); + if (map != null) + return map.getUri(); + return null; + } finally { + editModel.releaseAccess(this); + } + } - protected String getContainedURI(IJ2EEModule deployable) { - if (deployable instanceof J2EEDeployable) { - IProject aProject = ((IModule) deployable).getProject(); - if (aProject != null) { - Module m = getEARNature().getModule(aProject); - if (m != null) - return m.getUri(); - } - } - return null; - } + return null; + } - public String getType() { - return "j2ee.ear"; //$NON-NLS-1$ - } + protected String getContainedURI(IJ2EEModule deployable) { + if (deployable instanceof J2EEDeployable) { + IProject aProject = ((J2EEDeployable) deployable).getProject(); + if (aProject != null) { + Module m = getEARNature().getModule(aProject); + if (m != null) + return m.getUri(); + } + } + return null; + } - public String getVersion() { - return getNature().getJ2EEVersionText(); - } + public String getType() { + return "j2ee.ear"; //$NON-NLS-1$ + } - /* - * (non-Javadoc) - * - * @see org.eclipse.server.j2ee.IEnterpriseApplication#getLocation() - */ - public IPath getLocation() { - if (getProject() != null && getProject().isAccessible()) - return getProject().getLocation(); - return null; - } + public String getVersion() { + return getNature().getJ2EEVersionText(); + } - /** - * Returns the child modules of this module. - * - * @return org.eclipse.wst.server.core.model.IModule[] - */ - public IModule[] getChildModules() { - List list = new ArrayList(); + /* + * (non-Javadoc) + * + * @see org.eclipse.server.j2ee.IEnterpriseApplication#getLocation() + */ + public IPath getLocation() { + if (getProject() != null && getProject().isAccessible()) + return getProject().getLocation(); + return null; + } - if (containedModules != null) { - int size = containedModules.length; - for (int i = 0; i < size; i++) - list.add(containedModules[i]); - } - if (containedArchives != null) { - int size = containedArchives.length; - for (int i = 0; i < size; i++) - list.add(containedArchives[i]); - } + /** + * Returns the child modules of this module. + * + * @return org.eclipse.wst.server.core.model.IModule[] + */ + public IModule[] getChildModules() { + List list = new ArrayList(); - IModule[] children = new IModule[list.size()]; - list.toArray(children); - return children; - } + if (containedModules != null) { + int size = containedModules.length; + for (int i = 0; i < size; i++) + list.add(containedModules[i]); + } + if (containedArchives != null) { + int size = containedArchives.length; + for (int i = 0; i < size; i++) + list.add(containedArchives[i]); + } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } + IModule[] children = new IModule[list.size()]; + list.toArray(children); + return children; + } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getModuleType() - */ - public IModuleType getModuleType() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getChildModules(org.eclipse.core.runtime.IProgressMonitor) - */ - public IModule[] getChildModules(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) + */ + public IStatus validate(IProgressMonitor monitor) { + // TODO Auto-generated method stub + return null; + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java index 6805b36..68b5bce 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java
@@ -10,20 +10,27 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.deployables; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.util.ProjectModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; + +import com.ibm.wtp.common.logger.proxy.Logger; /** * @version 1.0 * @author */ -public class EnterpriseApplicationDeployableFactory extends J2EEDeployableFactory { +public class EnterpriseApplicationDeployableFactory extends J2EEDeployableFactory {/* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() + */ + public IModule[] getModules() { + return null; + } + protected static final String ID = "com.ibm.wtp.server.j2ee.application"; //$NON-NLS-1$ protected static final IPath[] PATHS = new IPath[]{new Path("META-INF/application.xml"), //$NON-NLS-1$ @@ -51,11 +58,25 @@ return IEARNatureConstants.NATURE_ID; } - /* - * @see J2EEDeployableFactory#createDeployable(J2EENature) - */ + public IModule createModule(J2EENature nature) { - return new EnterpriseApplicationDeployable(nature, ID); + if (nature == null) + return null; + EnterpriseApplicationDeployable moduleDelegate = null; + IModule module = nature.getModule(); + if (module == null) { + try { + moduleDelegate = new EnterpriseApplicationDeployable(nature, ID); + module = createModule(moduleDelegate.getId(), moduleDelegate.getName(), moduleDelegate.getType(), moduleDelegate.getVersion(), moduleDelegate.getProject()); + nature.setModule(module); + moduleDelegate.initialize(module); + } catch (Exception e) { + Logger.getLogger().write(e); + } finally { + moduleDelegates.add(moduleDelegate); + } + } + return module; } /* @@ -65,27 +86,6 @@ return PATHS; } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate#createModule(org.eclipse.core.resources.IProject) - */ - protected IModule createModule(IProject project) { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ - public ModuleDelegate getModuleDelegate(IModule module) { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - // TODO Auto-generated method stub - return null; - } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableObjectAdapter.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableObjectAdapter.java index b6e2a0b..d6d43ee 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableObjectAdapter.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableObjectAdapter.java
@@ -17,17 +17,15 @@ import org.eclipse.jst.j2ee.application.Application; import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IModuleArtifactAdapter; import org.eclipse.wst.server.core.IModule; - +import org.eclipse.wst.server.core.IModuleArtifact; import com.ibm.wtp.emf.workbench.ProjectUtilities; /** * Creates the Object adapter for ear projects. */ -public class EnterpriseApplicationDeployableObjectAdapter implements IModuleArtifactAdapter { +public class EnterpriseApplicationDeployableObjectAdapter { /** * Constructor for EnterpriseApplicationDeployableObjectAdapter.
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java index 1355e1b..494d896 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java
@@ -10,19 +10,19 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.deployables; - import org.eclipse.core.runtime.IPath; import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.jst.server.j2ee.IJ2EEModule; -import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IModuleType; import org.eclipse.wst.server.core.util.ProjectModule; /** * J2EE deployable superclass. */ -public abstract class J2EEDeployable extends ProjectModule implements IJ2EEModule, IModule { +public abstract class J2EEDeployable extends ProjectModule implements IJ2EEModule { private String factoryId; + private J2EENature nature; /** @@ -73,7 +73,7 @@ */ protected void setNature(J2EENature nature) { this.nature = nature; - nature.setModule(this); + nature.setModule(getModule()); } /** @@ -84,11 +84,40 @@ return nature != null && ((J2EEModuleNature) nature).isBinaryProject(); return false; } - - public Object getAdapter(Class adapter) { - if (getModule() == null) - initialize(this); - return this; - } - + + public String getModuleTypeName() { + return getName(); + } + + public String getModuleTypeVersion() { + return getVersion(); + } + + public String getVersion() { + return "1.2"; //$NON-NLS-1$ + }; + + public String getType() { + return "j2ee.ear"; //$NON-NLS-1$ + } + + public IModuleType getModuleType() { + return new IModuleType() { + + public String getId() { + return getType(); + } + + public String getName() { + return getModuleTypeName(); + } + + public String getVersion() { + return getModuleTypeVersion(); + } + }; + + } + + } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java index 0de392c..5531569 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java
@@ -10,12 +10,14 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.deployables; +import java.util.ArrayList; +import java.util.Iterator; + import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.jst.j2ee.internal.project.J2EENature; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModule; import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate; /** @@ -23,6 +25,8 @@ */ public abstract class J2EEDeployableFactory extends ProjectModuleFactoryDelegate { + protected ArrayList moduleDelegates = new ArrayList(); + public J2EEDeployableFactory() { super(); } @@ -73,16 +77,37 @@ * @return com.ibm.etools.server.core.model.IProjectModule */ public abstract IModule createModule(J2EENature nature); - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate#handleProjectChange(org.eclipse.core.resources.IProject, org.eclipse.core.resources.IResourceDelta) - */ - protected void handleProjectChange(IProject project, IResourceDelta delta) { - if (projects == null) - cacheModules(); - super.handleProjectChange(project, delta); - } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ + + + protected void handleProjectChange(IProject project, IResourceDelta delta) { + if (projects == null) + cacheModules(); + super.handleProjectChange(project, delta); + } + + public ModuleDelegate getModuleDelegate(IModule module) { + for (Iterator iter = moduleDelegates.iterator(); iter.hasNext();) { + ModuleDelegate element = (ModuleDelegate) iter.next(); + if (module == element.getModule()) + return element; + } + return null; + } + + public IModule[] getModules() { + if (projects == null) + cacheModules(); + int i = 0; + Iterator modules = projects.values().iterator(); + IModule[] modulesArray = new IModule[projects.values().size()]; + while (modules.hasNext()) { + IModule element = (IModule) modules.next(); + modulesArray[i++] = element; + + } + // TODO Auto-generated method stub + return modulesArray; + } + } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/plugin.xml b/plugins/org.eclipse.jst.j2ee/plugin.xml index 2d9ef3f..1aeb074 100644 --- a/plugins/org.eclipse.jst.j2ee/plugin.xml +++ b/plugins/org.eclipse.jst.j2ee/plugin.xml
@@ -53,7 +53,7 @@ <!--============================--> <!-- Codegen Contributions --> <!--============================--> - <extension-point id="basecodegenextensionpoint" name="Base Code Generation Extension Point"/> + <!-- This extension-point sends notification to all extensions when J2EEModules are imported. Each extension can specify a set of different module types to listen for or listen to them all. The default is to receive notification for all module types. Notification is sent @@ -76,7 +76,7 @@ </extension> --> <extension-point id="J2EEModulePostImport" name="J2EEModulePostImport" schema="schema/J2EEModulePostImport.exsd"/> - <extension-point id="GeneratorDictionaryExtension" name="GeneratorDictionaryExtension" schema="schema/GeneratorDictionaryExtension.exsd"/> + <extension-point id="EARModuleExtension" name="EARModuleExtension" schema="schema/EARModuleExtension.exsd"/> <extension-point id="DeployerExtension" name="J2EE Deployer Extension" schema="schema/DeployerExtension.exsd"/> <extension-point id="resourceEnvRefType" name="Resource Environment Reference Type" schema="schema/resourceEnvRefType.exsd"/> @@ -465,7 +465,7 @@ <!-- Extension point: com.ibm.etools.server.core.deployableObjectAdapters --> <!-- ==================================================================== --> - <extension + <!-- <extension point="org.eclipse.wst.server.core.moduleArtifactAdapters"> <moduleArtifactAdapter objectClass="org.eclipse.jst.j2ee.application.Application" @@ -482,7 +482,7 @@ class="org.eclipse.jst.j2ee.internal.deployables.EnterpriseApplicationDeployableObjectAdapter" id="com.ibm.wtp.server.j2ee.ear3"> </moduleArtifactAdapter> - </extension> + </extension> --> <!-- =============================================================== --> <!-- Purpose: Define the default deployable project factory --> <!-- Extension point: com.ibm.etools.server.core.deployableFactories -->