[180952][181065] Mutiple bugs committed.
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofTypeVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofTypeVisitorAction.java
index 88aa459..ff98fbe 100644
--- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofTypeVisitorAction.java
+++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofTypeVisitorAction.java
@@ -1,23 +1,32 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitoractions;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jem.java.JavaHelpers;
+import org.eclipse.jem.java.JavaVisibilityKind;
+import org.eclipse.jem.java.Method;
import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages;
import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofBeanVisitor;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory;
+import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory;
import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
import org.eclipse.wst.common.environment.Choice;
@@ -83,6 +92,13 @@
{
BeanModelElementsFactory.getBeanModelElement(typeNavigator,fParentElement);
}
+ else if (javaClass != null && !getReturnParam() &&
+ // the following cases cannot be instantiated for input
+ (javaClass.isInterface() || javaClass.isAbstract() || !hasDefaultConstructor(javaClass))) {
+
+ Element element = BeanModelElementsFactory.getBeanModelElement(typeNavigator,fParentElement);
+ element.setPropertyAsObject(TypeElement.NON_INSTANTIABLE, Boolean.TRUE);
+ }
else{
JavaMofBeanVisitorAction beanVisitorAction = new JavaMofBeanVisitorAction(fParentElement,clientProject, env_);
beanVisitorAction.setStatusMonitor(getStatusMonitor());
@@ -111,4 +127,30 @@
//
return status;
}
+
+ /**
+ * Determine if the given javaClass has a default constructor.
+ * @param javaClass The java class
+ * @return true if javaClass has a default constructor, false otherwise
+ */
+ private boolean hasDefaultConstructor(JavaClass javaClass) {
+
+ List methods = javaClass.getMethods();
+ Iterator iter = methods.iterator();
+
+ boolean foundConstructor = false;
+
+ while (iter.hasNext()) {
+ Method method = (Method) iter.next();
+
+ if (method.getName().equals(javaClass.getName())) {
+ if (method.listParametersWithoutReturn().length == 0)
+ return method.getJavaVisibility().getValue() == JavaVisibilityKind.PUBLIC;
+ foundConstructor = true;
+ }
+ }
+
+ // if no constructor is found at this point, a default one is implicitly provided
+ return !foundConstructor;
+ }
}
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/datamodel/beanmodel/TypeElement.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/datamodel/beanmodel/TypeElement.java
index f1592f6..af80d7f 100644
--- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/datamodel/beanmodel/TypeElement.java
+++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/datamodel/beanmodel/TypeElement.java
@@ -1,12 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel;
@@ -24,7 +27,7 @@
// Copyright
public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
+ public static final String NON_INSTANTIABLE = "nonInstantiable";
public static int BEAN = 0;
public static int SIMPLE = 1;
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java
index af2d94e..b03521e 100644
--- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java
+++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java
@@ -10,6 +10,7 @@
* yyyymmdd bug Email and other contact information
* -------- -------- -----------------------------------------------------------
* 20060612 145433 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen;
@@ -162,6 +163,9 @@
{
TypeElement element = (TypeElement)object;
+ if (Boolean.TRUE.equals(element.getPropertyAsObject(TypeElement.NON_INSTANTIABLE)))
+ return Status.OK_STATUS;
+
if (element instanceof SimpleElement) fIsSimple = true;
else fIsSimple = false;
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java
index f78cd59..dea6887 100644
--- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java
+++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java
@@ -1,12 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen;
@@ -69,34 +72,40 @@
String typeName = typeElement.getName();
fTypeIdName = idName(typeName);
- AttributeVisitor attributeVisitor = new AttributeVisitor();
- ResultFileAttributeGenerator resultFileAttributeGenerator = new ResultFileAttributeGenerator(fbuffer);
- resultFileAttributeGenerator.setNumberFactory(getNumberFactory());
- attributeVisitor.run(typeElement,resultFileAttributeGenerator);
- setNumberFactory(resultFileAttributeGenerator.getNumberFactory());
- fbuffer = resultFileAttributeGenerator.getStringBuffer();
-
- FieldVisitor fieldVisitor = new FieldVisitor();
- ResultFileAttributeGenerator resultFileAttributeGenerator2 = new ResultFileAttributeGenerator(fbuffer);
- resultFileAttributeGenerator2.setNumberFactory(getNumberFactory());
- fieldVisitor.run(typeElement,resultFileAttributeGenerator2);
- setNumberFactory(resultFileAttributeGenerator2.getNumberFactory());
- fbuffer = resultFileAttributeGenerator2.getStringBuffer();
+ if (!Boolean.TRUE.equals(typeElement.getPropertyAsObject(TypeElement.NON_INSTANTIABLE))) {
+
+ AttributeVisitor attributeVisitor = new AttributeVisitor();
+ ResultFileAttributeGenerator resultFileAttributeGenerator = new ResultFileAttributeGenerator(fbuffer);
+ resultFileAttributeGenerator.setNumberFactory(getNumberFactory());
+ attributeVisitor.run(typeElement,resultFileAttributeGenerator);
+ setNumberFactory(resultFileAttributeGenerator.getNumberFactory());
+ fbuffer = resultFileAttributeGenerator.getStringBuffer();
+
+ FieldVisitor fieldVisitor = new FieldVisitor();
+ ResultFileAttributeGenerator resultFileAttributeGenerator2 = new ResultFileAttributeGenerator(fbuffer);
+ resultFileAttributeGenerator2.setNumberFactory(getNumberFactory());
+ fieldVisitor.run(typeElement,resultFileAttributeGenerator2);
+ setNumberFactory(resultFileAttributeGenerator2.getNumberFactory());
+ fbuffer = resultFileAttributeGenerator2.getStringBuffer();
- fbuffer.append(Generator.DOUBLE_TAB + "%>" + StringUtils.NEWLINE);
- fbuffer.append(Generator.DOUBLE_TAB + "<jsp:useBean id=\"" + fTypeIdName + "\" scope=\"session\" class=\"" + typeName + "\" />" + StringUtils.NEWLINE);
- fbuffer.append(Generator.DOUBLE_TAB + "<%" + StringUtils.NEWLINE);
-
- Enumeration e = resultFileAttributeGenerator.getResidentVector().elements();
- while(e.hasMoreElements()){
- fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e.nextElement() + StringUtils.NEWLINE);
- }
-
- Enumeration e2 = resultFileAttributeGenerator2.getResidentVector().elements();
- while(e2.hasMoreElements()){
- fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e2.nextElement() + StringUtils.NEWLINE);
- }
+ fbuffer.append(Generator.DOUBLE_TAB + "%>" + StringUtils.NEWLINE);
+ fbuffer.append(Generator.DOUBLE_TAB + "<jsp:useBean id=\"" + fTypeIdName + "\" scope=\"session\" class=\"" + typeName + "\" />" + StringUtils.NEWLINE);
+ fbuffer.append(Generator.DOUBLE_TAB + "<%" + StringUtils.NEWLINE);
+
+ Enumeration e = resultFileAttributeGenerator.getResidentVector().elements();
+ while(e.hasMoreElements()){
+ fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e.nextElement() + StringUtils.NEWLINE);
+ }
+
+ Enumeration e2 = resultFileAttributeGenerator2.getResidentVector().elements();
+ while(e2.hasMoreElements()){
+ fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e2.nextElement() + StringUtils.NEWLINE);
+ }
+ }
+ else
+ fbuffer.append(Generator.DOUBLE_TAB + typeName + " " + fTypeIdName + " = null;"+ StringUtils.NEWLINE);
+
putResidentVector(fTypeIdName);
//end of changes
diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java
index 939623b..7f4d6a0 100644
--- a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java
+++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java
@@ -1,12 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2002, 2004 IBM Corporation and others.
+ * Copyright (c) 2002, 2007 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
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070404 181065 makandre@ca.ibm.com - Andrew Mak, WSE does not handle types referenced across inline schemas
*******************************************************************************/
package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment;
@@ -29,7 +32,7 @@
XSDElementDeclaration element = (XSDElementDeclaration)config.getXSDComponent();
if (element != null) {
XSDElementDeclaration resolvedElement = resolveXSDElementDeclaration(element);
- XSDTypeDefinition typeDef = getXSDTypeDefinition(resolvedElement);
+ XSDTypeDefinition typeDef = resolveXSDTypeDefinition(getXSDTypeDefinition(resolvedElement));
if (typeDef != null) {
int minOccurs = FragmentConstants.DEFAULT_MIN_OCCURS;
int maxOccurs = FragmentConstants.DEFAULT_MAX_OCCURS;
@@ -76,6 +79,17 @@
else
return element;
}
+
+ private XSDTypeDefinition resolveXSDTypeDefinition(XSDTypeDefinition typeDef) {
+
+ if (!isComponentResolvable(typeDef)) {
+ XSDComponent resolvedComponent = getWSDLPartsToXSDTypeMapper().resolveXSDNamedComponent(typeDef);
+ if (resolvedComponent instanceof XSDTypeDefinition)
+ return (XSDTypeDefinition) resolvedComponent;
+ }
+
+ return typeDef;
+ }
private XSDTypeDefinition getXSDTypeDefinition(XSDElementDeclaration element) {
// port to org.eclipse.xsd