diff options
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen')
26 files changed, 0 insertions, 2847 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Generator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Generator.java deleted file mode 100644 index a260ac085..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Generator.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - - - -/** -* Objects of this class represent a generator. -* */ -public class Generator implements VisitorAction -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * The StringBuffer that holds the codegen - * */ - protected StringBuffer fbuffer; - - /** - * The Visitor that calls the visit method - * */ - protected Visitor fVisitor; - - /** - * Vector that holds state data for this generator - * */ - protected Vector fResidentVector; - - /* - * This int holds the current number - */ - protected int fUniqueNumber =0; - - - protected String fClientFolderPath; - - public static final String FACTORY = "Factory"; - - public static final String TAB = " "; - public static final String DOUBLE_TAB = " "; - public static final String SPACE = " "; - - /** - * Constructor. - * - */ - public Generator () - { - fbuffer = new StringBuffer(); - fResidentVector = new Vector(); - - } - - /** - * Constructor. - * @param StringBuffer Takes the buffer it will write code to - */ - public Generator (StringBuffer buffer) - { - fbuffer = buffer; - fResidentVector = new Vector(); - } - - public void initialize(String resident) - { - //nothing to be done but must be implemented - } - - public String getClientFolderPath() - { - return fClientFolderPath; - } - - public void setClientFolderPath(String fClientFolderPath_) - { - fClientFolderPath = fClientFolderPath_; - } - - protected String serviceName = ""; - protected String portName = ""; - protected String packageName = ""; - protected String proxyBaseName = ""; - - public void setInfo(String service, String port, String packageName, String proxyBase) - { - serviceName = service; - portName = port; - this.packageName = packageName; - proxyBaseName = proxyBase; - } - - private static final char[] BAD_SYMBOLS = {'-', ' '}; // symbols that can appear in the folder name but it is not allowed in a java bean name - private static final char UNDERSCORE = '_'; // replace the above ones by underscore - public String getSessionBeanId() - { - String name = getClientFolderPath(); - int index = name.lastIndexOf("/"); - index++; - String newName = name.substring(index); - for ( int i = 0; i < BAD_SYMBOLS.length; i++ ) { - newName = newName.replace ( BAD_SYMBOLS[i], UNDERSCORE ); - } - return newName+ "id"; - } - - /* - * The Number Factory is here for naming purposes. In - * this way we insure no names we create in a piece of - * code gen are the same. We keep track of the numbers - * used and we hand back the next one. Like take a number - * buddy - * @param int number we are at as the state data has to be settable - */ - public void setNumberFactory(int number) - { - fUniqueNumber = number; - } - - - /* - * This is a unique number for state purposes - * @return int - */ - public int getNumberFactory() - { - return fUniqueNumber; - } - /* - * This is a unique number for naming purposes - * @return int - */ - public int getUniqueNumber() - { - return fUniqueNumber++; - } - - - /** - * returns the current StringBuffer - * @return StringBuffer Takes the buffer it will write code too - */ - public StringBuffer getStringBuffer () - { - return fbuffer; - } - - - /** - * returns the Visitor that called this generator - * @return Visitor - */ - public Visitor getVisitor () - { - return fVisitor; - } - - - - - /** - * vector used to hold state data - * @parameter Visitor - */ - public void putResidentVector (Object object) - { - fResidentVector.addElement(object); - } - - - /** - * vector used to hold state data - * @parameter Visitor - */ - public void setResidentVector (Vector vector) - { - fResidentVector = vector; - } - - - /** - * returns the resident vector - * @return Visitor - */ - public Vector getResidentVector () - { - return fResidentVector; - } - - - /** - * This function is used to initialize any state a generator may have - * - **/ - - public void initialize() - { - //to be implemented in sublasses - } - - - /** - * sets the visitor that calls the visit - * @parameter Visitor - */ - - public void setVisitor(Visitor visitor) - { - fVisitor = visitor; - } - - - public IStatus visit (Object object) - { - //implemented by subclasses - return Status.OK_STATUS; - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/RelVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/RelVisitor.java deleted file mode 100644 index fac00ac9b..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/RelVisitor.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen; - -import java.util.Enumeration; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.ws.internal.datamodel.BasicElement; -import org.eclipse.wst.ws.internal.datamodel.Rel; - - -/** -* Objects of this class represent a visitor. -* This vistor will visit elements in a model given a -* particular rel -* */ -public class RelVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private int fElementCounter; - private int fTotalElements; - private String frelName; - - /** - * Constructor. - * - */ - - public RelVisitor (String relName) - { - frelName = relName; - } - - public int getTotalElementsToVisit() - { - return fTotalElements; - } - - public boolean isLastElement() - { - if(getTotalElementsToVisit() - presentElement() == 0) return true; - return false; - } - - public int presentElement() - { - return fElementCounter; - } - - public void initialize(VisitorAction va) - { - //implemented by subclasses - } - public IStatus run (Object sourceElement,VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - initialize(vAction); - - vAction.setVisitor(this); - Rel rel = ((BasicElement)sourceElement).getRel(frelName); - //set some state data - fTotalElements = rel.getNumberOfTargetElements(); - fElementCounter = 0; - - Enumeration e = rel.getTargetElements(); - while (e.hasMoreElements()){ - BasicElement targetElement = (BasicElement)e.nextElement(); - fElementCounter++; - initialize(vAction); - status = vAction.visit(targetElement); - } - return status; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Visitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Visitor.java deleted file mode 100644 index c68cdadb0..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/Visitor.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen; - -import org.eclipse.core.runtime.IStatus; - - -/** -* Objects of this class represent a visitor. -* */ -public interface Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public IStatus run (Object object, VisitorAction vAction); - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/VisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/VisitorAction.java deleted file mode 100644 index 9a3d6537f..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/VisitorAction.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen; - -import org.eclipse.core.runtime.IStatus; - - -/** -* Objects of this class represent a VisitorAction. -* The visitor walks the model and the VisitorAction -* does the action -* */ -public interface VisitorAction -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - public IStatus visit (Object object); - public void setVisitor(Visitor visitor); - public void initialize(String residentString); -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/AttributeVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/AttributeVisitor.java deleted file mode 100644 index a01a64112..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/AttributeVisitor.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import java.util.Vector; -import org.eclipse.jst.ws.internal.consumption.codegen.RelVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; -import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.InputFileAttributeGenerator; - - -/** -* Objects of this class represent a visitor. -* */ -public class AttributeVisitor extends RelVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private Vector fResidentVector1; - private Vector fResidentVector2; - - /** - * Constructor. - * - */ - - public AttributeVisitor () - { - super(TypeElement.REL_ATTRIBUTES); - } - - public AttributeVisitor (String rel) - { - super(rel); - } - - public void setResidentString(String resident) - { - } - - public void setResidentVector1(Vector resident) - { - fResidentVector1 = resident; - } - - public void setResidentVector2(Vector resident) - { - fResidentVector2 = resident; - } - - - public void initialize(VisitorAction vAction) - { - //hack for 197726 - - if(vAction instanceof InputFileAttributeGenerator){ - if(fResidentVector1 == null) fResidentVector1=new Vector(); - if(fResidentVector2 == null) fResidentVector2=new Vector(); - ((InputFileAttributeGenerator)vAction).setParentGetters(fResidentVector1,fResidentVector2); - } - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/FieldVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/FieldVisitor.java deleted file mode 100644 index 5a9ad690a..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/FieldVisitor.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import java.util.Vector; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; -import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.InputFileAttributeGenerator; - - -/** -* Objects of this class represent a visitor. -* */ -public class FieldVisitor extends AttributeVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private Vector fResidentVector1; - private Vector fResidentVector2; - - /** - * Constructor. - * - */ - - public FieldVisitor () - { - super(TypeElement.REL_FIELDS); - } - - public void setResidentString(String resident) - { - } - - public void setResidentVector1(Vector resident) - { - fResidentVector1 = resident; - } - - public void setResidentVector2(Vector resident) - { - fResidentVector2 = resident; - } - - - public void initialize(VisitorAction vAction) - { - //hack for 197726 - - if(vAction instanceof InputFileAttributeGenerator){ - if(fResidentVector1 == null) fResidentVector1=new Vector(); - if(fResidentVector2 == null) fResidentVector2=new Vector(); - ((InputFileAttributeGenerator)vAction).setParentGetters(fResidentVector1,fResidentVector2); - } - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/MethodVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/MethodVisitor.java deleted file mode 100644 index 34664622f..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/MethodVisitor.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import org.eclipse.jst.ws.internal.consumption.codegen.RelVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; - - -/** -* Objects of this class represent a visitor. -* */ -public class MethodVisitor extends RelVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * Constructor. - * - */ - - public MethodVisitor () - { - super(BeanElement.REL_METHODS); - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ParameterVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ParameterVisitor.java deleted file mode 100644 index 0749312d4..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ParameterVisitor.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import org.eclipse.jst.ws.internal.consumption.codegen.RelVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; - - -/** -* Objects of this class represent a visitor. -* */ -public class ParameterVisitor extends RelVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * Constructor. - * - */ - - public ParameterVisitor () - { - super(MethodElement.REL_PARAMETERS); - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ReturnParameterVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ReturnParameterVisitor.java deleted file mode 100644 index 1f6207072..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/ReturnParameterVisitor.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import org.eclipse.jst.ws.internal.consumption.codegen.RelVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; - - -/** -* Objects of this class represent a visitor. -* */ -public class ReturnParameterVisitor extends RelVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * Constructor. - * - */ - - public ReturnParameterVisitor () - { - super(MethodElement.REL_RETURN_PARAMETERS); - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/TypeVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/TypeVisitor.java deleted file mode 100644 index d254615d7..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/bean/TypeVisitor.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.bean; - -import org.eclipse.jst.ws.internal.consumption.codegen.RelVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; - - -/** -* Objects of this class represent a visitor. -* */ -public class TypeVisitor extends RelVisitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * Constructor. - * - */ - - public TypeVisitor () - { - super(TypeElement.REL_TYPE); - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsBeanVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsBeanVisitorAction.java deleted file mode 100644 index 730077693..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsBeanVisitorAction.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Vector; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofMethodVisitor; - - - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a BeanElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk the methods in the JavaClass -* */ -public class DetectNonJavaCharsBeanVisitorAction extends VisitorActionImpl -{ - private static char UNDERSCORE = '_'; - - public DetectNonJavaCharsBeanVisitorAction ( Vector messages, Vector beans) - { - super (messages, beans); - } - - /** - * The visit will create the bean - * Walk the methods - * @param JavaClass the class to be used to create the bean model - **/ - public IStatus visit (Object javaclass) - { - JavaClass javaClass = (JavaClass)javaclass; - String packageName = javaClass.getJavaPackage().getPackageName(); - String beanName = javaClass.getName(); - - if (!isBeanVisited(javaClass)) { - addVisitedBean(javaClass); - // check the bean name - checkBeanName(beanName); - checkPackageName(packageName, beanName); - DetectNonJavaCharsMethodVisitorAction methodVisitorAction = new DetectNonJavaCharsMethodVisitorAction(getMessages(), getBeansVisited()); - JavaMofMethodVisitor methodVisitor = new JavaMofMethodVisitor(); - methodVisitor.run(javaClass,methodVisitorAction); - } - - return Status.OK_STATUS; - } - - private void checkBeanName(String beanName) - { - - // check if the bean starts with a lower case - if ( Character.isLowerCase(beanName.charAt(0))) - addMessage(ConsumptionMessages.WARN_BEAN_NAME_STARTS_WITH_LOWER_CASE, new String[]{beanName}); - - - //check if the name has an underscore, then next letter should be upper case - int underScoreIndex = beanName.indexOf(UNDERSCORE); - String tempName = beanName; - while(underScoreIndex !=-1) { - tempName = tempName.substring(underScoreIndex+1); - if ( Character.isLowerCase(tempName.charAt(0))) { - addMessage(ConsumptionMessages.MSG_WARN_METHOD_NAME_INVALID, new String[] { beanName }); - break; - } - else - underScoreIndex = tempName.indexOf(UNDERSCORE); - } - } - - private void checkPackageName(String packageName, String beanName) - { - if (!packageName.equals(packageName.toLowerCase())) - addMessage(ConsumptionMessages.MSG_WARN_PACKAGE_NAME_HAS_UPPER_CASE, new String[] { packageName, beanName }); - } - } diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsMethodVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsMethodVisitorAction.java deleted file mode 100644 index 16bca06e6..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsMethodVisitorAction.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofParameterVisitor; - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a BeanElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk the methods in the JavaClass -* */ -public class DetectNonJavaCharsMethodVisitorAction extends VisitorActionImpl -{ - private static char UNDERSCORE = '_'; - private boolean serviceBean = false; - - public DetectNonJavaCharsMethodVisitorAction ( Vector messages, Vector beans) - { - super (messages, beans); - if ( beans.size() == 1) - serviceBean = true; - } - - /** - * Create a method element from the method - * @param Method the class to be used to create the method - **/ - public IStatus visit (Object imethod) - { - - Method method = (Method)imethod; - String className = method.getContainingJavaClass().getName(); - String name = method.getName(); - - if ( serviceBean && !method.isConstructor() ) - checkUpperCase(name, className); - - // for service bean or any referenced bean property accessors - if ( serviceBean || name.startsWith("get") || name.startsWith("set") || name.startsWith("is")) - { - checkUnderScore(name, className); - checkNumericDigits(name, className); - checkBooleanProperties(method, className); - - DetectNonJavaCharsParameterVisitorAction parameterVisitorAction = new DetectNonJavaCharsParameterVisitorAction(getMessages(), getBeansVisited()); - // rsk Passing in null for the environment. DetectNonJavaCharsParameterVisitorAction always returns an OK status. - JavaMofParameterVisitor parameterVisitor = new JavaMofParameterVisitor(null); - parameterVisitor.run(method, parameterVisitorAction); - } - - return Status.OK_STATUS; - } - - private void checkUpperCase(String name, String className) - { - // in a service bean check if any method starts with upper case letter - if ( Character.isUpperCase(name.charAt(0))) - addMessage(ConsumptionMessages.MSG_WARN_JAVA_METHOD_START_WITH_UPPER_CASE, new String[]{name, className}); - - } - - private void checkUnderScore(String name, String className) - { - //check if the name has an underscore, then next letter should be upper case - int underScoreIndex = name.indexOf(UNDERSCORE); - String tempName = name; - while(underScoreIndex !=-1) { - tempName = tempName.substring(underScoreIndex+1); - if ( Character.isLowerCase(tempName.charAt(0))) { - addMessage(ConsumptionMessages.MSG_WARN_METHOD_NAME_INVALID, new String[]{name, className}); - break; - } - else - underScoreIndex = tempName.indexOf(UNDERSCORE); - } - } - - private void checkNumericDigits(String name, String className) - { - //check if the name has a numeric, then next letter should be upper case - for ( int i = 0; i < name.length(); i++) - { - if ( Character.isDigit(name.charAt(i))) - { - if (Character.isLowerCase(name.charAt(i+1))) { - addMessage(ConsumptionMessages.MSG_WARN_METHOD_NAME_INVALID, new String[]{name, className}); - break; - } - } - } - } - private void checkBooleanProperties(Method method, String className) - { - if (!serviceBean && method.getName().startsWith("get") && - (method.getReturnType().getName().equals("boolean") || - method.getReturnType().getName().equals("java.lang.Boolean"))) - addMessage(ConsumptionMessages.MSG_WARN_BOOLEAN_PROPERTY_ACCESSORS, new String[]{method.getName(), className}); - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsParameterVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsParameterVisitorAction.java deleted file mode 100644 index 680c07964..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/DetectNonJavaCharsParameterVisitorAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.ArrayType; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofBeanVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; - - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a BeanElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk the methods in the JavaClass -* */ -public class DetectNonJavaCharsParameterVisitorAction extends VisitorActionImpl -{ - - public DetectNonJavaCharsParameterVisitorAction ( Vector messages, Vector beans) - { - super (messages, beans); - } - - /** - * Create a method element from the method - * @param Method the class to be used to create the method - **/ - public IStatus visit (Object ijavaParameter) - { - - JavaParameter javaParameter = (JavaParameter) ijavaParameter; - JavaClass javaClass = null; - if ( javaParameter.getJavaType() instanceof JavaClass) - { - javaClass = (JavaClass) javaParameter.getJavaType(); - if (javaClass.isArray()) - { - JavaHelpers componentType = ((ArrayType)javaClass).getComponentTypeAsHelper(); - if (componentType instanceof JavaClass) - { - javaClass = (JavaClass)componentType; - } - else - { - javaClass = null; //The array contains primitive types, there is no need for further checking. - } - } - } - if (toBeVisited(javaClass)) { - DetectNonJavaCharsBeanVisitorAction beanVisitorAction = new DetectNonJavaCharsBeanVisitorAction(getMessages(), getBeansVisited()); - JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor(); - beanVisitor.run(javaClass,beanVisitorAction); - } - - return Status.OK_STATUS; - } - - - private boolean toBeVisited (JavaClass javaClass) - { - //check for recognized types - if( javaClass == null || - javaClass.isPrimitive() || - javaClass.getJavaName().startsWith("javax") || - TypeFactory.recognizedBean(javaClass.getJavaName())) - return false; - else - return true; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofAttributeVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofAttributeVisitorAction.java deleted file mode 100644 index 1a9ac05d2..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofAttributeVisitorAction.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofTypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.AttributeElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.jst.ws.internal.consumption.sampleapp.common.SamplePropertyDescriptor; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.common.environment.ILog; -import org.eclipse.wst.common.environment.StatusException; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a AttributeElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk a complex type -* */ -public class JavaMofAttributeVisitorAction extends JavaMofBeanVisitorAction -{ - - /* - *Constructor - **/ - public JavaMofAttributeVisitorAction(Element parentElement, String project, IEnvironment env) - { - super(parentElement,project, env); - } - - public IStatus visit (Object propertyDecorator) - { - IStatus status = Status.OK_STATUS; - - //PropertyDecorator pd = (PropertyDecorator)propertyDecorator; - SamplePropertyDescriptor pd = (SamplePropertyDescriptor)propertyDecorator; - - - try{ - //if the type of this attribute is unsupported dont make an Attribute - if(!(getReturnParam() && TypeFactory.isRecognizedReturnType((JavaHelpers)pd.getPropertyType())) - && (TypeFactory.isUnSupportedType((JavaHelpers)pd.getPropertyType()))){ - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)pd.getPropertyType()).getJavaName() ); - //getStatusMonitor().reportStatus( new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - //ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)pd.getPropertyType()).getJavaName(),null)); - return status; - } - - Method setMethod = pd.getWriteMethod(); - Method getMethod = pd.getReadMethod(); - if(setMethod != null){ - if(setMethod.isStatic()){ - setMethod=null; - } - } - if(getMethod != null){ - if(getMethod.isStatic()){ - getMethod=null; - } - } - if(pd.isfStatic()){ - return status; - } - - AttributeElement attributeElement = (AttributeElement)BeanModelElementsFactory.getBeanModelElement(propertyDecorator,fParentElement); - - if(attributeElement != null){ - - //lets check and see if the getter takes input params - //if so throw an error - //now the inputs - if(getMethod != null){ - JavaParameter javaParameter[] = getMethod.listParametersWithoutReturn(); - if(javaParameter.length > 0){ - if(getReturnParam()) return status; - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_INDEXED_PROPERTIES + getMethod.getName() ); - //getStatusMonitor().reportStatus (new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - // ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_INDEXED_PROPERTIES + getMethod.getName(),null)); - return status; - } - } - if(setMethod != null) attributeElement.setSetterMethod(setMethod.getMethodElementSignature()); - if(getMethod != null) attributeElement.setGetterMethod(getMethod.getMethodElementSignature()); - - JavaMofTypeVisitorAction typeVisitorAction = new JavaMofTypeVisitorAction(attributeElement,clientProject, env_); - typeVisitorAction.setStatusMonitor(getStatusMonitor()); - typeVisitorAction.setBeansCreated(getBeansCreated()); - typeVisitorAction.setReturnParam(getReturnParam()); - JavaMofTypeVisitor typeVisitor = new JavaMofTypeVisitor(env_); - typeVisitor.setClientProject(getProject()); - status = typeVisitor.run(pd,typeVisitorAction); - - } - - return status; - }catch(Exception e) - { - env_.getLog().log(ILog.WARNING, 5054, this, "visit", e); - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_ERROR_JTS_JSP_GEN, e); - try { - env_.getStatusHandler().report(status); - } catch (StatusException e1) { - status = StatusUtils.errorStatus(ConsumptionMessages.MSG_ERROR_JTS_JSP_GEN); - } - return status; - } - //env.Log.write(this,"visit",ILog.OK,e);} - - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofBeanVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofBeanVisitorAction.java deleted file mode 100644 index 9af115278..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofBeanVisitorAction.java +++ /dev/null @@ -1,425 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.command.NullStatusMonitor; -import org.eclipse.jst.ws.internal.command.StatusMonitor; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofAttributeVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofFieldVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofMethodVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection; -import org.eclipse.wst.common.environment.Choice; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.ws.internal.datamodel.Element; -import org.eclipse.wst.ws.internal.datamodel.Model; - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a BeanElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk the methods in the JavaClass -* */ -public class JavaMofBeanVisitorAction implements VisitorAction -{ - - protected IEnvironment env_; - protected Visitor fVisitor; - - /* - * The project that defines the context - **/ - protected String clientProject; - - /* - * The Status monitor - **/ - protected StatusMonitor monitor_; - - /* - * The model that will be created - **/ - protected Model fModel; - - /* - * This is the parent element used when creating a - * new element - */ - protected Element fParentElement; - - /* - * Methods processed from proxy - */ - protected Vector fBeansCreated; - - private BooleanSelection[] fMethodsSelected; - - /* - * this boolean tells wether the bean is a return parameter or an input parameter - * usually this should be set around the parametervisitoraction, and passed on from there - */ - protected boolean fReturnParam=false; - - public JavaMofBeanVisitorAction(String clientProject,BooleanSelection[] methods, IEnvironment env) - { - this.clientProject = clientProject; - fMethodsSelected = methods; - env_ = env; - } - - - - /* - *Constructor - * @param Model model is the Model that this bean will be placed in - * @param IProject used in nature - **/ - public JavaMofBeanVisitorAction(Model model, String clientProject, IEnvironment env) - { - this.clientProject = clientProject; - fModel = model; - env_ = env; - } - - /* - *Constructor - * @param Element the parent element that this element will be added too - * @param IProject used in nature - **/ - public JavaMofBeanVisitorAction(Element parentElement, String clientProject, IEnvironment env ) - { - fParentElement = parentElement; - this.clientProject = clientProject; - env_ = env; - } - - /** - * The visit will create the bean - * Walk the methods - * @param JavaClass the class to be used to create the bean model - **/ - public IStatus visit (Object javaclass) - { - Choice OKChoice = new Choice('O', ConsumptionMessages.LABEL_OK, ConsumptionMessages.DESCRIPTION_OK); - Choice CancelChoice = new Choice('C', ConsumptionMessages.LABEL_CANCEL, ConsumptionMessages.DESCRIPTION_CANCEL); - IStatus status = Status.OK_STATUS; - JavaClass javaClass = (JavaClass)javaclass; - - - BeanElement beanElement = (BeanElement)BeanModelElementsFactory.getBeanModelElement(javaClass,fParentElement,fModel); - if(beanElement.isOwnerParameter()) { - resetBeansCreated(); - } - fModel = beanElement.getModel(); - - //this for the subsequent beans that represent types - //first do the attributes - //if we are not on the root - if (!(beanElement == fModel.getRootElement())){ - Enumeration e = getBeansCreated().elements(); - while(e.hasMoreElements()){ - String name = (String)e.nextElement(); - if(name.equals(javaClass.getName())){ - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_ERROR_JTS_CYCLIC_BEAN ); - //getStatusMonitor().reportStatus(new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - //WebServiceConsumptionPlugin.getMessage( "%MSG_ERROR_JTS_CYCLIC_BEAN" ),null)); - return status; - } - } - - JavaMofAttributeVisitorAction attributeVisitorAction = new JavaMofAttributeVisitorAction(beanElement,clientProject, env_); - //attributeVisitorAction.setStatusMonitor(getStatusMonitor()); - Vector childVector = ((Vector)getBeansCreated().clone()); - childVector.addElement(javaClass.getName()); - attributeVisitorAction.setBeansCreated(childVector); - attributeVisitorAction.setReturnParam(getReturnParam()); - JavaMofAttributeVisitor attributeVisitor = new JavaMofAttributeVisitor(); - attributeVisitor.setReturnParameter(getReturnParam()); - attributeVisitor.setProject(getProject()); - attributeVisitor.setEnvironment(env_); - status = attributeVisitor.run(javaClass,attributeVisitorAction); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus(ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - - JavaMofFieldVisitorAction fieldVisitorAction = new JavaMofFieldVisitorAction(beanElement,clientProject, env_); - //fieldVisitorAction.setStatusMonitor(getStatusMonitor()); - Vector childVector2 = ((Vector)getBeansCreated().clone()); - childVector2.addElement(javaClass.getName()); - fieldVisitorAction.setBeansCreated(childVector2); - fieldVisitorAction.setReturnParam(getReturnParam()); - JavaMofFieldVisitor fieldVisitor = new JavaMofFieldVisitor(); - fieldVisitor.setProject(getProject()); - status = fieldVisitor.run(javaClass,fieldVisitorAction); - // - severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - - } - - //this is to insure we are on the proxy - //now do the methods - if (beanElement == fModel.getRootElement()){ - //first lets make sure the proxy is in good form - //-it has a default constructor - //-it has at least one method - //otherwise return the problem in the form of a status - - if (!proxyCheck(javaClass, status)) return status; - JavaMofMethodVisitorAction methodVisitorAction = new JavaMofMethodVisitorAction(beanElement,clientProject, env_); - - //methodVisitorAction.setStatusMonitor(getStatusMonitor()); - JavaMofMethodVisitor methodVisitor = new JavaMofMethodVisitor(); - methodVisitor.setMethodSelection(fMethodsSelected); - status = methodVisitor.run(javaClass,methodVisitorAction); - - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - //This is where we check for several things: - //-if no methods were processed because of unsupported types then we send back that result - //-if there were any methods omitted we should warn them - - //first no methods - if (!methodVisitorAction.wereMethodsProcessed()){ - //this has to be done to insure the dialog is an error - status = StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_JTS_NO_PROXY_METHODS_PROCESSED ); - return status; - //getStatusMonitor().reportStatus( new Status(IStatus.ERROR,WebServiceConsumptionPlugin.ID,0, - // WebServiceConsumptionPlugin.getMessage( "%MSG_ERROR_JTS_NO_PROXY_METHODS_PROCESSED" ),null)); - } - //now methods omitted - else if(methodVisitorAction.wereMethodsOmitted()){ - //The dialog is already a warning so we just need to set the overall message - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_PROXY_METHODS_OMITTED ); - return status; - //getStatusMonitor().reportStatus( new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - // ConsumptionMessages.MSG_WARN_JTS_PROXY_METHODS_OMITTED,null)); - } - } - return status; - } - - public void initialize(String resident) - { - //nothing to be done but must be implemented - } - - - /* - * Return the model that was created - * @return Model the bean model that was created - */ - public Model getModel() - { - return fModel; - } - - /* - * The proxy check insures there is a default constructor and - * at Least one method - * @param JavaClass javaClass is used to traverse the methods on the proxy - */ - public boolean proxyCheck(JavaClass javaClass, IStatus status) - { - // first check for a method - Iterator m=javaClass.getPublicMethods().iterator(); - if (!m.hasNext()){ - status = StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_JTS_PROXY_HAS_NO_METHODS ); - //getStatusMonitor().reportStatus( new Status(IStatus.ERROR,WebServiceConsumptionPlugin.ID,0, - // ConsumptionMessages.MSG_ERROR_JTS_PROXY_HAS_NO_METHODS,null)); - return false; - } - //now check for a default constructor - while (m.hasNext()) { - Method method=(Method)m.next(); - if (javaClass.getName().equals(method.getName())){ - //now the inputs - JavaParameter javaParameter[] = method.listParametersWithoutReturn(); - if (javaParameter.length > 0){ - //then we have no default constructor - status = StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_JTS_PROXY_HAS_NO_DEFAULT ); - //getStatusMonitor().reportStatus( new Status(IStatus.ERROR,WebServiceConsumptionPlugin.ID,0, - //ConsumptionMessages.MSG_ERROR_JTS_PROXY_HAS_NO_DEFAULT,null)); - return false; - } - } - } - return true; - - } - - /** - * Sets the status monitor that this action will use to report status that occres while executing the Action. - */ - public void setStatusMonitor ( StatusMonitor monitor ) - { - monitor_ = monitor; - } - - /** - * Returns the status monitor that this task is using to report status. - */ - public StatusMonitor getStatusMonitor () - { - if (monitor_ == null) - { - monitor_ = new NullStatusMonitor(); - } - return monitor_; - } - - - /** - * check if the action has finished sucsessfully - */ - /* - public boolean isSuccessful () - { - return getStatusMonitor().canContinue(); - } - */ - public void resetBeansCreated() - { - fBeansCreated = new Vector(); - } - - public void setEnvironment(IEnvironment env) - { - env_ = env; - } - - /* - * The command that called this will get the results of the operation in the form - * of a status. - */ - public Vector getBeansCreated () - { - if(fBeansCreated == null) fBeansCreated = new Vector(); - return fBeansCreated; - } - - /* - * The command that called this will get the results of the operation in the form - * of a status. - */ - public void setBeansCreated (Vector beansCreated) - { - fBeansCreated = beansCreated; - } - - /* - * This boolean tells wether we are dealing with a return param - */ - public boolean getReturnParam () - { - return fReturnParam; - } - - /* - * This boolean tells wether we are dealing with a return param - */ - public void setReturnParam (boolean returnparam) - { - fReturnParam = returnparam; - } - - /* - * This boolean tells wether we are dealing with a return param - */ - public String getProject () - { - return clientProject; - } - - /* - * This boolean tells wether we are dealing with a return param - */ - public void setProject (String clientProject) - { - this.clientProject = clientProject; - } - - - /** - * sets the visitor that calls the visit - * @parameter Visitor - */ - - public void setVisitor(Visitor visitor) - { - fVisitor = visitor; - } - - /* - * Sets the parent element the child then knows where to - * add itself to the model - * @param Element parent element - */ - public void setParentElement(Element element) - { - fParentElement = element; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofFieldVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofFieldVisitorAction.java deleted file mode 100644 index 143774f22..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofFieldVisitorAction.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.Field; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofTypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.FieldElement; -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.IEnvironment; -import org.eclipse.wst.common.environment.ILog; -import org.eclipse.wst.common.environment.StatusException; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a AttributeElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk a complex type -* */ -public class JavaMofFieldVisitorAction extends JavaMofBeanVisitorAction -{ - - /* - *Constructor - **/ - public JavaMofFieldVisitorAction(Element parentElement, String project, IEnvironment env) - { - super(parentElement,project, env); - } - - - public IStatus visit (Object field_) - { - IStatus status = Status.OK_STATUS; - Field field = (Field)field_; - - try{ - //if the type of this attribute is unsupported dont make an Attribute - if(!(getReturnParam() && TypeFactory.isRecognizedReturnType((JavaHelpers)field.getJavaClass())) - && (TypeFactory.isUnSupportedType((JavaHelpers)field.getJavaClass()))){ - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)field.getJavaClass()).getJavaName() ); - //getStatusMonitor().reportStatus( new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - //ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)field.getJavaClass()).getJavaName(),null)); - return status; - } - - - FieldElement fieldElement = (FieldElement)BeanModelElementsFactory.getBeanModelElement(field,fParentElement); - - if(fieldElement != null){ - //lets check and see if the getter takes input params - //if so throw an error - //now the inputs - - JavaMofTypeVisitorAction typeVisitorAction = new JavaMofTypeVisitorAction(fieldElement,clientProject, env_); - typeVisitorAction.setStatusMonitor(getStatusMonitor()); - typeVisitorAction.setBeansCreated(getBeansCreated()); - typeVisitorAction.setReturnParam(getReturnParam()); - JavaMofTypeVisitor typeVisitor = new JavaMofTypeVisitor(env_); - typeVisitor.setClientProject(getProject()); - status = typeVisitor.run(field,typeVisitorAction); - - } - return status; - - }catch(Exception e) - { - env_.getLog().log(ILog.WARNING, 5055, this, "visit", e); - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_ERROR_JTS_JSP_GEN, e); - try { - env_.getStatusHandler().report(status); - } - catch (StatusException e1) - { - status = StatusUtils.errorStatus(ConsumptionMessages.MSG_ERROR_JTS_JSP_GEN, e1 ); - } - return status; - } - - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofMethodVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofMethodVisitorAction.java deleted file mode 100644 index abe72790a..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofMethodVisitorAction.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Iterator; -import java.util.Vector; - -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.JavaParameter; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofParameterVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; -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.IEnvironment; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a BeanElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk the methods in the JavaClass -* */ -public class JavaMofMethodVisitorAction extends JavaMofBeanVisitorAction -{ - - public String fUnsupportedParameterName; - - /* - * Methods omitted from the proxy - */ - protected Vector fMethodsOmitted; - - /* - * Methods processed from proxy - */ - protected Vector fMethodsProcessed; - - - /* - *Constructor - **/ - public JavaMofMethodVisitorAction(Element parentElement,String project, IEnvironment env) - { - super(parentElement,project, env); - fMethodsOmitted = new Vector(); - fMethodsProcessed = new Vector(); - - } - - /** - * Create a method element from the method - * @param Method the class to be used to create the method - **/ - public IStatus visit (Object imethod) - { - IStatus status = Status.OK_STATUS; - Method method = (Method)imethod; - - if (methodCheck(method)){ - //this is to check immediate input and return parameters - //if there is an unsupported type in these we can react immediately - //we add it to the omitted methods an go to the next one - if(!parameterCheck(method)){ - status = StatusUtils.warningStatus(ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_PARAMETERS_ARRAYS + fUnsupportedParameterName ); - //getStatusMonitor().reportStatus (new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - // ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_PARAMETERS_ARRAYS + fUnsupportedParameterName,null)); - fMethodsOmitted.addElement(method.getMethodElementSignature()); - return status; - } - if(!nullConstructor(method)){ - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_PARAMETERS_INPUTS + fUnsupportedParameterName ); - //getStatusMonitor().reportStatus (new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - // ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_PARAMETERS_INPUTS + fUnsupportedParameterName,null)); - fMethodsOmitted.addElement(method.getMethodElementSignature()); - return status; - - } - - //carry on all parameters supported - MethodElement methodElement = (MethodElement)BeanModelElementsFactory.getBeanModelElement(method,fParentElement); - JavaMofParameterVisitorAction parameterVisitorAction = new JavaMofParameterVisitorAction(methodElement,clientProject,env_); - parameterVisitorAction.setStatusMonitor(getStatusMonitor()); - JavaMofParameterVisitor parameterVisitor = new JavaMofParameterVisitor(env_); - status = parameterVisitor.run(method,parameterVisitorAction); - //something may have gone wrong with an internal type - if (status.getSeverity()!=Status.OK){ - //This method has to be omitted - fMethodsOmitted.addElement(method.getMethodElementSignature()); - methodElement.setMethodOmmission(true); - } - else { - fMethodsProcessed.addElement(method.getMethodElementSignature()); - } - } - - return status; - } - - /* - * Tells wether any methods were processed - * @return boolean true if any methods were processed - */ - public boolean wereMethodsProcessed() - { - if(fMethodsProcessed.isEmpty()) return false; - return true; - } - - /* - * Tells wether there were methods omitted because of unsupported types - * @return boolean true if methods were omitted - */ - public boolean wereMethodsOmitted() - { - if(fMethodsOmitted.isEmpty()) return false; - return true; - } - - /** - * There may be methods that we dont support - * and dont want in the model - * @param boolean true if all parameters are fine - **/ - public boolean methodCheck(Method method) - { - boolean ok = true; - // if we have a constructor we return false - if (method.isConstructor()) return false; - - - return ok; - } - - /** - * There may be parameters of this method that have types - * not yet supported return false if we find any - * @param boolean true if all parameters are fine - **/ - public boolean parameterCheck(Method method) - { - - boolean ok = true; - - //now the inputs - JavaParameter javaParameter[] = method.listParametersWithoutReturn(); - for (int i = 0;i<javaParameter.length;i++) { - JavaParameter param=javaParameter[i]; - JavaHelpers javaHelper1 = param.getJavaType(); - if(TypeFactory.isUnSupportedType(javaHelper1)) { - fUnsupportedParameterName = param.getName(); - return false; - } - } - return ok; - } - - - /** - * There may be parameters of this method that have types - * not yet supported return false if we find any - * @param boolean true if all parameters are fine - **/ - public boolean nullConstructor(Method method) - { - - boolean ok = true; - //now the inputs - JavaParameter javaParameter[] = method.listParametersWithoutReturn(); - for (int i = 0;i<javaParameter.length;i++) { - JavaParameter param=javaParameter[i]; - JavaHelpers javaHelper1 = param.getJavaType(); - if(javaHelper1 instanceof JavaClass){ - JavaClass javaClass = (JavaClass)javaHelper1; - if(TypeFactory.recognizedBean(javaClass.getJavaName()))return true; - Iterator m=javaClass.getMethods().iterator(); - while (m.hasNext()) { - Method method2=(Method)m.next(); - if (javaClass.getName().equals(method2.getName())){ - //now the inputs - JavaParameter javaParam[] = method2.listParametersWithoutReturn(); - if (javaParam.length > 0){ - //then we have no default constructor - fUnsupportedParameterName = param.getName(); - ok = false; - } - else return true; - } - } - } - } - return ok; - } - - - - - - - - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofParameterVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofParameterVisitorAction.java deleted file mode 100644 index 2a1fb4547..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofParameterVisitorAction.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofTypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanModelElementsFactory; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.ParameterElement; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.environment.Choice; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.ws.internal.datamodel.Element; - - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a parameterElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk to its type -* */ -public class JavaMofParameterVisitorAction extends JavaMofBeanVisitorAction -{ - - - /* - *Constructor - **/ - public JavaMofParameterVisitorAction(Element parentElement,String project, IEnvironment env) - { - super(parentElement,project, env); - } - - /** - * Create a parameter element from the method - * @param JavaParameter the mof element to be used to create the Parameter - **/ - public IStatus visit (Object ijavaParameter) - { - IStatus status = Status.OK_STATUS; - Choice OKChoice = new Choice('O',ConsumptionMessages.LABEL_OK, ConsumptionMessages.DESCRIPTION_OK); - Choice CancelChoice = new Choice('C', ConsumptionMessages.LABEL_CANCEL, ConsumptionMessages.DESCRIPTION_CANCEL); - - ParameterElement parameterElement = (ParameterElement)BeanModelElementsFactory.getBeanModelElement(ijavaParameter,fParentElement); - JavaMofTypeVisitorAction typeVisitorAction = new JavaMofTypeVisitorAction(parameterElement,clientProject, env_); - //typeVisitorAction.setStatusMonitor(getStatusMonitor()); - typeVisitorAction.setReturnParam(parameterElement.isReturn()); - JavaMofTypeVisitor typeVisitor = new JavaMofTypeVisitor(env_); - typeVisitor.setClientProject(getProject()); - status = typeVisitor.run(ijavaParameter,typeVisitorAction); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - return status; - } -} 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 deleted file mode 100644 index 88aa4591b..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/JavaMofTypeVisitorAction.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -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.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.TypeFactory; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.environment.Choice; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.ws.internal.datamodel.Element; - - - - -/** -* Objects of this class represent a JavaMofBeanVisitorAction. -* This VisitorAction will create a TypeElement using the -* JavaClass and the BeanModelElementsFactory -* It will also automatically walk a complex type -* */ -public class JavaMofTypeVisitorAction extends JavaMofBeanVisitorAction -{ - - /* - *Constructor - **/ - public JavaMofTypeVisitorAction(Element parentElement,String project, IEnvironment env) - { - super(parentElement,project, env); - } - - /** - * Create a type element from the JavaHelper - * @param JavaHelper the mof element to be used to create the Type - **/ - public IStatus visit (Object typeNavigator) - { - IStatus status = Status.OK_STATUS; - Choice OKChoice = new Choice('O', ConsumptionMessages.LABEL_OK, ConsumptionMessages.DESCRIPTION_OK); - Choice CancelChoice = new Choice('C', ConsumptionMessages.LABEL_CANCEL, ConsumptionMessages.DESCRIPTION_CANCEL); - - //if bean - JavaClass javaClass = null; - if(typeNavigator instanceof JavaClass){ - javaClass = (JavaClass)typeNavigator; - } - - - /* If we are dealing with a return parameter then we need to treat this differently then if it is an input - * parameter. - * We need to first see if it is a special case for return types if not we treat it the same as everything - * else. - */ - if(getReturnParam() && TypeFactory.isRecognizedReturnType((JavaHelpers)typeNavigator)) - { - BeanModelElementsFactory.getBeanModelElement(typeNavigator,fParentElement); - } - else{ - if(TypeFactory.isUnSupportedType((JavaHelpers)typeNavigator)){ - status = StatusUtils.warningStatus( ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)typeNavigator).getJavaName() ); - //getStatusMonitor().reportStatus( new Status(IStatus.WARNING,WebServiceConsumptionPlugin.ID,0, - //ConsumptionMessages.MSG_WARN_JTS_UNSUPPORTED_TYPE + ((JavaHelpers)typeNavigator).getJavaName(),null)); - return status; - } - - //if javaclass is null then we have a simple type - if((javaClass == null) || TypeFactory.recognizedBean(javaClass.getJavaName())) - { - BeanModelElementsFactory.getBeanModelElement(typeNavigator,fParentElement); - } - else{ - JavaMofBeanVisitorAction beanVisitorAction = new JavaMofBeanVisitorAction(fParentElement,clientProject, env_); - beanVisitorAction.setStatusMonitor(getStatusMonitor()); - beanVisitorAction.setBeansCreated(getBeansCreated()); - beanVisitorAction.setReturnParam(getReturnParam()); - JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor(); - status = beanVisitor.run(javaClass,beanVisitorAction); - } - } - - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - return status; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/VisitorActionImpl.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/VisitorActionImpl.java deleted file mode 100644 index 35833fbd4..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitoractions/VisitorActionImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitoractions; - -import java.util.Vector; - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.osgi.util.NLS; - - - - - -/** -* Objects of this class represent a VisitorAction. -* It will automatically walk the methods in the JavaClass -* */ -public abstract class VisitorActionImpl implements VisitorAction -{ - - private Vector beansVisited = null; - private Vector messages = null; - - public VisitorActionImpl( Vector messages, Vector beansVisited) - { - this.messages = messages; - this.beansVisited = beansVisited; - } - - public void initialize(String resident) - { - //nothing to be done but must be implemented - } - - /** - * Returns the vector of all messages found - */ - public Vector getMessages () - { - if (messages == null) - messages = new Vector(); - return messages; - } - - public Vector getBeansVisited() - { - if ( beansVisited == null) - beansVisited = new Vector(); - return beansVisited; - } - - public void addVisitedBean( JavaClass bean) - { - if ( beansVisited == null) - beansVisited = new Vector(); - beansVisited.add(bean); - } - - public boolean isBeanVisited (JavaClass bean) - { - return (beansVisited != null && beansVisited.contains(bean)); - } - - /** - * sets the visitor that calls the visit - * @parameter Visitor - */ - - public void setVisitor(Visitor visitor) - { - } - - protected void addMessage ( String key ) - { - getMessages().add(key); - } - - protected void addMessage ( String key, Object[] args ) - { - getMessages().add(NLS.bind(key,args)); - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofAttributeVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofAttributeVisitor.java deleted file mode 100644 index 6d2d6a044..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofAttributeVisitor.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.Field; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.command.common.JavaMofReflectionCommand; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.jst.ws.internal.consumption.sampleapp.common.SamplePropertyDescriptor; -import org.eclipse.wst.common.environment.IEnvironment; - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofAttributeVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private String clientProject; - private boolean returnParameter; - private IEnvironment env; - - - public void setEnvironment(IEnvironment env) - { - this.env = env; - } - - /* - * Use this to reflect - */ - public void setProject(String clientProject) - { - this.clientProject = clientProject; - } - - /* - * Use this to reflect - */ - public String getProject() - { - return clientProject; - } - - public void setReturnParameter(boolean returnParameter) - { - this.returnParameter = returnParameter; - } - - - /* - * Get the attribute belonging to this complex type - * @param JavaParameter javaParameter that owns the type - * @param VisitorAction Action to be performed on each method - **/ - public IStatus run ( Object javaclass, VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - JavaClass javaClass = (JavaClass)javaclass; - - Hashtable spdMap = new Hashtable(); - for (Iterator m=javaClass.getPublicMethods().iterator(); m.hasNext(); ) { - Method method=(Method)m.next(); - if (((method.getMethodElementSignature().startsWith("get") - || method.getMethodElementSignature().startsWith("is")) - && method.listParametersWithoutReturn().length == 0 ) - || (method.getMethodElementSignature().startsWith("set") - && method.listParametersWithoutReturn().length > 0)) { - int sub = 3; - if(method.getMethodElementSignature().startsWith("is")) - sub = 2; - String propertyName = method.getMethodElementSignature().substring(sub); - String lower = propertyName.substring(0,1).toLowerCase(); - String remainder = propertyName.substring(1); - propertyName = lower + remainder; - int index = propertyName.lastIndexOf("("); - String temp = propertyName; - propertyName = temp.substring(0,index); - - //find the propertydescriptor - SamplePropertyDescriptor spd = (SamplePropertyDescriptor)spdMap.get(propertyName); - if(spd == null){ - spd = new SamplePropertyDescriptor(propertyName); - spdMap.put(propertyName,spd); - } - if(method.getMethodElementSignature().startsWith("set")) - spd.setWriteMethod(method); - else - spd.setReadMethod(method); - - Field field = javaClass.getFieldNamed(propertyName); - JavaHelpers propertyType = null; - if(field != null){ - propertyType = (JavaHelpers)field.getEType(); - spd.setfStatic(field.isStatic()); - } - else{ - if(method.getMethodElementSignature().startsWith("get") || method.getMethodElementSignature().startsWith("is")) - propertyType = method.getReturnType(); - else{ - JavaParameter params[] = method.listParametersWithoutReturn(); - propertyType = params[0].getJavaType(); - } - } - - spd.setPropertyType(propertyType); - - } - } - Enumeration spdEnum = spdMap.elements(); - while(spdEnum.hasMoreElements()){ - SamplePropertyDescriptor spd = (SamplePropertyDescriptor)spdEnum.nextElement(); - if(spdCheck(spd)) - status = vAction.visit(spd); - } - - return status; - - } - - private boolean spdCheck(SamplePropertyDescriptor spd) - { - //check for indexed properties - Method writeMethod = spd.getWriteMethod(); - if(writeMethod != null) - if(writeMethod.listParametersWithoutReturn().length > 1) return false; - - if(spd.getPropertyType() == null) return false; - if(spd.getPropertyType().isPrimitive()) return true; - if(returnParameter && TypeFactory.isRecognizedReturnType(spd.getPropertyType())) return true; - if(!returnParameter && TypeFactory.isUnSupportedType(spd.getPropertyType())) return true; - if(!checkPolarity(spd)) return false; - - // so its a bean make sure it has a default constructor - JavaMofReflectionCommand javaMofRef = new JavaMofReflectionCommand(); - javaMofRef.setClientProject(getProject()); - javaMofRef.setProxyBean(((JavaHelpers)spd.getPropertyType()).getQualifiedName()); - javaMofRef.setEnvironment( env ); - javaMofRef.execute(null, null); - if(javaMofRef.getJavaClass() instanceof JavaClass){ - if(TypeFactory.recognizedBean(javaMofRef.getJavaClass().getJavaName())) return true; - return defaultCheck((JavaClass)javaMofRef.getJavaClass()); - - } - return true; - - } - - private boolean checkPolarity(SamplePropertyDescriptor spd){ - - Method readMethod = spd.getReadMethod(); - Method writeMethod = spd.getWriteMethod(); - if((readMethod == null && writeMethod != null) || (readMethod != null && writeMethod == null)) - return true; - if(readMethod == null && writeMethod == null) - return false; - - JavaParameter javaParameter[] = writeMethod.listParametersWithoutReturn(); - for(int i = 0;i< javaParameter.length;i++){ - JavaParameter jp = javaParameter[i]; - jp.getJavaType().getJavaName(); - readMethod.getReturnType().getJavaName(); - if(jp.getJavaType().getJavaName().equals(readMethod.getReturnType().getJavaName())) - return true; - } - return false; - } - - private boolean defaultCheck(JavaClass javaClass){ - - Iterator m=javaClass.getMethods().iterator(); - //now check for a default constructor - boolean defaultConst = true; - while (m.hasNext()) { - Method method=(Method)m.next(); - if (javaClass.getName().equals(method.getName())){ - //now the inputs - JavaParameter javaParameter[] = method.listParametersWithoutReturn(); - if (javaParameter.length > 0){ - //then we have no default constructor - defaultConst = false; - } - else if(javaParameter.length == 0){ - if (method.getJavaVisibility().getValue() == 0) - return true; - } - } - } - - return defaultConst; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofBeanVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofBeanVisitor.java deleted file mode 100644 index 2b571f830..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofBeanVisitor.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; - - - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofBeanVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /* - *Constructor - **/ - public JavaMofBeanVisitor() - { - } - - public IStatus run ( Object javaClass, VisitorAction vAction) - { - return vAction.visit((JavaClass)javaClass); - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofFieldVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofFieldVisitor.java deleted file mode 100644 index f693dfab0..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofFieldVisitor.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import java.util.Iterator; -import java.util.ListIterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jem.java.Field; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jem.java.JavaVisibilityKind; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.command.common.JavaMofReflectionCommand; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofFieldVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private String clientProject; - - /* - * Constructor - **/ - public JavaMofFieldVisitor() - { - } - - /* - * Use this to reflect - */ - public void setProject(String clientProject) - { - this.clientProject = clientProject; - } - - /* - * Use this to reflect - */ - public String getProject() - { - return clientProject; - } - - /* - * Get the attribute belonging to this complex type - * @param JavaParameter javaParameter that owns the type - * @param VisitorAction Action to be performed on each method - **/ - public IStatus run ( Object javaclass, VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - JavaClass javaClass = (JavaClass)javaclass; - - boolean holderClass = false; - EList implemented = javaClass.getImplementsInterfaces(); - for (int i = 0; i < implemented.size(); i++) { - JavaClass anInterface = (JavaClass) implemented.get(i); - if (anInterface.getQualifiedName().equals("javax.xml.rpc.holders.Holder")) - holderClass = true; - } - - //beaninfo code - if(holderClass){ - EList e = javaClass.getFields(); - ListIterator list = e.listIterator(); - while(list.hasNext()){ - Field field = (Field)list.next(); - if(field.getJavaVisibility().getValue() == JavaVisibilityKind.PUBLIC && !field.isFinal() && !field.isStatic()){ - if(fieldCheck(field)) - status = vAction.visit(field); - } - } - } - - return status; - } - private boolean fieldCheck(Field field) - { - // so its a bean make sure it has a default constructor - JavaMofReflectionCommand javaMofRef = new JavaMofReflectionCommand(); - javaMofRef.setProxyBean(((JavaHelpers)field.getEType()).getQualifiedName()); - javaMofRef.setClientProject(getProject()); - javaMofRef.execute(null, null); - if(javaMofRef.getJavaClass() instanceof JavaClass){ - if(TypeFactory.recognizedBean(javaMofRef.getJavaClass().getJavaName())) return true; - return defaultCheck((JavaClass)javaMofRef.getJavaClass()); - } - return true; - } - - private boolean defaultCheck(JavaClass javaClass){ - - Iterator m=javaClass.getMethods().iterator(); - //now check for a default constructor - boolean defaultConst = true; - while (m.hasNext()) { - Method method=(Method)m.next(); - if (javaClass.getName().equals(method.getName())){ - //now the inputs - JavaParameter javaParameter[] = method.listParametersWithoutReturn(); - if (javaParameter.length > 0){ - //then we have no default constructor - defaultConst = false; - } - else if(javaParameter.length == 0){ - if (method.getJavaVisibility().getValue() == 0) - return true; - else if(method.getJavaVisibility().getValue() == 1) - defaultConst = false; - } - } - } - - return defaultConst; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofMethodVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofMethodVisitor.java deleted file mode 100644 index 3e37c717a..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofMethodVisitor.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import java.util.Iterator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection; - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofMethodVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - public String SET_ENDPOINT = "setEndPoint"; - public String GET_ENDPOINT = "getEndPoint"; - private BooleanSelection[] fMethodsSelected; - - - /* - * Constructor - **/ - public JavaMofMethodVisitor() - { - } - - public String UNDER_SCORE = "_"; - - /* - * Run through all the methods in this bean - * @param JavaClass javaclass that holds the methods - * @param VisitorAction Action to be performed on each method - **/ - public IStatus run ( Object javaclass, VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - JavaClass javaClass = (JavaClass)javaclass; - for (Iterator m=javaClass.getPublicMethods().iterator(); m.hasNext(); ) { - Method method=(Method)m.next(); - if(fMethodsSelected != null) { - boolean methodSelected = false; - for(int i =0;i < fMethodsSelected.length;i++){ - if(fMethodsSelected[i] == null) continue; - if ( fMethodsSelected[i].getValue().equals(method.getMethodElementSignature())) - methodSelected = (boolean) fMethodsSelected[i].isSelected(); - } - - method.getName(); - - if(methodSelected) - status = vAction.visit(method); - - } - else { - status = vAction.visit(method); - } - - } - return status; - } - - public void setMethodSelection(BooleanSelection[] methodSelected) - { - fMethodsSelected = methodSelected; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofParameterVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofParameterVisitor.java deleted file mode 100644 index f297c3d7f..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofParameterVisitor.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jem.java.Method; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.environment.Choice; -import org.eclipse.wst.common.environment.IEnvironment; - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofParameterVisitor implements Visitor -{ - private IEnvironment env_; - - /* - * Constructor - **/ - public JavaMofParameterVisitor(IEnvironment env) - { - env_ = env; - } - - /* - * Run through all the parameters in this method - * @param JavaClass javaclass that holds the parameters - * @param VisitorAction Action to be performed on each method - **/ - public IStatus run ( Object imethod, VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - Choice OKChoice = new Choice('O', ConsumptionMessages.LABEL_OK, ConsumptionMessages.DESCRIPTION_OK); - Choice CancelChoice = new Choice('C', ConsumptionMessages.LABEL_CANCEL, ConsumptionMessages.DESCRIPTION_CANCEL); - Method method = (Method)imethod; - - JavaHelpers javaReturnParameter = method.getReturnType(); - //pgm This visitor used to take a JavaParameter type and now it is being called - // with a JavaHelpers type. Gil, please ensure that this is Ok. - status = vAction.visit(javaReturnParameter); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - - //now the inputs - List parameters = method.getParameters(); - - for (int index = 0; index < parameters.size(); index++) - { - JavaParameter param=(JavaParameter)parameters.get(index); - status = vAction.visit(param); - // - severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env_.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - } - - return status; - - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofTypeVisitor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofTypeVisitor.java deleted file mode 100644 index db1f25571..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/codegen/javamofvisitors/JavaMofTypeVisitor.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ws.internal.consumption.codegen.javamofvisitors; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.Field; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaParameter; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.command.common.JavaMofReflectionCommand; -import org.eclipse.jst.ws.internal.consumption.sampleapp.common.SamplePropertyDescriptor; -import org.eclipse.wst.common.environment.IEnvironment; - - - -/** -* Objects of this class represent a visitor. -* */ -public class JavaMofTypeVisitor implements Visitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - private IEnvironment env_; - - private String clientProject; - - /* - * Constructor - **/ - public JavaMofTypeVisitor(IEnvironment env) - { - env_ = env; - } - - /* - * Use this to reflect - */ - public void setClientProject(String clientProject) - { - this.clientProject = clientProject; - } - - /* - * Use this to reflect - */ - public String getClientProject() - { - return clientProject; - } - - /* - * Get the type belonging to the parameter - * @param JavaParameter javaParameter that owns the type - * @param VisitorAction Action to be performed on each method - **/ - public IStatus run ( Object typeNavigator, VisitorAction vAction) - { - IStatus status = Status.OK_STATUS; - if (typeNavigator instanceof JavaParameter){ - - JavaParameter javaParameter = (JavaParameter)typeNavigator; - JavaHelpers javaHelpers = javaParameter.getJavaType(); - status = vAction.visit(javaHelpers); - } - else if (typeNavigator instanceof JavaHelpers){ - status = vAction.visit(typeNavigator); - } - else if (typeNavigator instanceof SamplePropertyDescriptor){ - SamplePropertyDescriptor pd = (SamplePropertyDescriptor)typeNavigator; - JavaMofReflectionCommand javaMofRef = new JavaMofReflectionCommand(); - javaMofRef.setClientProject(clientProject); - javaMofRef.setProxyBean(((JavaHelpers)pd.getPropertyType()).getQualifiedName()); - javaMofRef.setEnvironment( env_ ); - status = javaMofRef.execute( null, null ); - if (status.getSeverity()==Status.ERROR) - return status; - - status = vAction.visit(javaMofRef.getJavaClass()); - } - else if (typeNavigator instanceof Field){ - Field field = (Field)typeNavigator; - JavaMofReflectionCommand javaMofRef = new JavaMofReflectionCommand(); - javaMofRef.setClientProject(clientProject); - javaMofRef.setProxyBean(((JavaHelpers)field.getEType()).getQualifiedName()); - javaMofRef.setEnvironment( env_ ); - - status = javaMofRef.execute( null, null ); - if (status.getSeverity()==Status.ERROR) - return status; - - status = vAction.visit(javaMofRef.getJavaClass()); - } - - return status; - } - - - -} - |