📄 javageneratorfactory.java
字号:
if (unusedPortTypes.contains(ptEntry)) { unusedPortTypes.remove(ptEntry); } } else { bEntry.setIsReferenced(false); // If a binding is not of type TYPE_SOAP, then mark its portType as // unused ONLY if it hasn't already been marked as used. if (!usedPortTypes.contains(ptEntry)) { unusedPortTypes.add(ptEntry); } } } } } // Go through all the portTypes that are marked as unused and set their isReferenced flags // to false. for (int i = 0; i < unusedPortTypes.size(); ++i) { PortTypeEntry ptEntry = (PortTypeEntry) unusedPortTypes.get(i); ptEntry.setIsReferenced(false); } } // ignoreNonSOAPBindings /** * Method constructSignatures * * @param symbolTable */ protected void constructSignatures(SymbolTable symbolTable) { Iterator it = symbolTable.getHashMap().values().iterator(); while (it.hasNext()) { Vector v = (Vector) it.next(); for (int i = 0; i < v.size(); ++i) { SymTabEntry entry = (SymTabEntry) v.elementAt(i); if (entry instanceof BindingEntry) { BindingEntry bEntry = (BindingEntry) entry; Binding binding = bEntry.getBinding(); PortType portType = binding.getPortType(); Iterator operations = portType.getOperations().iterator(); while (operations.hasNext()) { Operation operation = (Operation) operations.next(); String wsdlOpName = operation.getName(); OperationType type = operation.getStyle(); String javaOpName = getOperationJavaNameHook(bEntry, wsdlOpName); // for derived class if (javaOpName == null) { javaOpName = operation.getName(); } Parameters parameters = bEntry.getParameters(operation); if (OperationType.SOLICIT_RESPONSE.equals(type)) { parameters.signature = " // " + Messages.getMessage("invalidSolResp00", javaOpName); System.err.println( Messages.getMessage("invalidSolResp00", javaOpName)); } else if (OperationType.NOTIFICATION.equals(type)) { parameters.signature = " // " + Messages.getMessage("invalidNotif00", javaOpName); System.err.println( Messages.getMessage("invalidNotif00", javaOpName)); } else { // ONE_WAY or REQUEST_RESPONSE if (parameters != null) { String returnType = getReturnTypeJavaNameHook(bEntry, wsdlOpName); if (returnType != null) { if (parameters.returnParam != null) { // 'void' return type??? parameters.returnParam.getType().setName(returnType); } } for (int j = 0; j < parameters.list.size(); ++j) { Parameter p = (Parameter) parameters.list.get(j); String paramType = getParameterTypeJavaNameHook(bEntry, wsdlOpName, j); if (paramType != null) { p.getType().setName(paramType); } } parameters.signature = constructSignature(parameters, javaOpName); } } } } } } } // constructSignatures protected String getOperationJavaNameHook(BindingEntry bEntry, String wsdlOpName) { return null; } protected String getReturnTypeJavaNameHook(BindingEntry bEntry, String wsdlOpName) { return null; } protected String getParameterTypeJavaNameHook(BindingEntry bEntry, String wsdlOpName, int pos) { return null; } /** * Construct the signature, which is used by both the interface and the stub. * * @param parms * @param opName * @return */ private String constructSignature(Parameters parms, String opName) { String name = Utils.xmlNameToJava(opName); String ret = "void"; if ((parms != null) && (parms.returnParam != null)) { ret = Utils.getParameterTypeName(parms.returnParam); } String signature = " public " + ret + " " + name + "("; boolean needComma = false; for (int i = 0; (parms != null) && (i < parms.list.size()); ++i) { Parameter p = (Parameter) parms.list.get(i); if (needComma) { signature = signature + ", "; } else { needComma = true; } String javifiedName = Utils.xmlNameToJava(p.getName()); if (p.getMode() == Parameter.IN) { signature += Utils.getParameterTypeName(p) + " " + javifiedName; } else { signature += Utils.holder(p, emitter) + " " + javifiedName; } } signature = signature + ") throws java.rmi.RemoteException"; if ((parms != null) && (parms.faults != null)) { // Collect the list of faults into a single string, separated by commas. Iterator i = parms.faults.values().iterator(); while (i.hasNext()) { Fault fault = (Fault) i.next(); String exceptionName = Utils.getFullExceptionName(fault.getMessage(), symbolTable); if (exceptionName != null) { signature = signature + ", " + exceptionName; } } } return signature; } // constructSignature /** * Find all inout/out parameters and add a flag to the Type of that parameter saying a holder * is needed. * * @param symbolTable */ protected void determineIfHoldersNeeded(SymbolTable symbolTable) { Iterator it = symbolTable.getHashMap().values().iterator(); while (it.hasNext()) { Vector v = (Vector) it.next(); for (int i = 0; i < v.size(); ++i) { if (v.get(i) instanceof BindingEntry) { // If entry is a BindingEntry, look at all the Parameters // in its portType BindingEntry bEntry = (BindingEntry) v.get(i); // PortTypeEntry ptEntry = // symbolTable.getPortTypeEntry(bEntry.getBinding().getPortType().getQName()); Iterator operations = bEntry.getParameters().values().iterator(); while (operations.hasNext()) { Parameters parms = (Parameters) operations.next(); for (int j = 0; j < parms.list.size(); ++j) { Parameter p = (Parameter) parms.list.get(j); // If the given parameter is an inout or out parameter, then // set a HOLDER_IS_NEEDED flag using the dynamicVar design. if (p.getMode() != Parameter.IN) { TypeEntry typeEntry = p.getType(); typeEntry.setDynamicVar( JavaTypeWriter.HOLDER_IS_NEEDED, Boolean.TRUE); // If this is a complex then set the HOLDER_IS_NEEDED // for the reftype too. if (!typeEntry.isSimpleType() && (typeEntry.getRefType() != null)) { typeEntry.getRefType().setDynamicVar( JavaTypeWriter.HOLDER_IS_NEEDED, Boolean.TRUE); } // If the type is a DefinedElement, need to // set HOLDER_IS_NEEDED on the anonymous type. QName anonQName = SchemaUtils.getElementAnonQName( p.getType().getNode()); if (anonQName != null) { TypeEntry anonType = symbolTable.getType(anonQName); if (anonType != null) { anonType.setDynamicVar( JavaTypeWriter.HOLDER_IS_NEEDED, Boolean.TRUE); } } } } } } } } } // determineIfHoldersNeeded /** * Get TypeMapping to use for translating * QNames to java base types */ BaseTypeMapping btm = null; /** * Method setBaseTypeMapping * * @param btm */ public void setBaseTypeMapping(BaseTypeMapping btm) { this.btm = btm; } /** * Method getBaseTypeMapping * * @return */ public BaseTypeMapping getBaseTypeMapping() { if (btm == null) { btm = new BaseTypeMapping() { public String getBaseName(QName qNameIn) { javax.xml.namespace.QName qName = new javax.xml.namespace.QName(qNameIn.getNamespaceURI(), qNameIn.getLocalPart()); Class cls = emitter.getDefaultTypeMapping().getClassForQName(qName); if (cls == null) { return null; } else { return JavaUtils.getTextClassName(cls.getName()); } } }; } return btm; } /** * Determines whether the QName supplied should be generated by comparing * the namespace for the QName against the included and excluded names. <p/> <ul> <li>if both the includes and excludes are both empty, the element is generated</li> <li>if the namespace is in the includes, the element is generated</li> <li>if the namespace is not in the excludes and the includes are empty, the element will be generated. <li>if the namespace is only in the excludes, the element is not generated</li> <li>if the namespace is not in the includes and the includes are not empty, the element is not generated</li> @param qName @return */ protected boolean include(QName qName) { String namespace = (qName != null && qName.getNamespaceURI() != null) ? qName.getNamespaceURI() : ""; boolean doInclude = false; NamespaceSelector selector = new NamespaceSelector(namespace); if (qName == null || emitter == null || emitter.getNamespaceIncludes().contains(selector) || (emitter.getNamespaceIncludes().size() == 0 && !emitter.getNamespaceExcludes().contains(selector))) { doInclude = true; } else { log_.info( "excluding code generation for non-included QName:" + qName); } return doInclude; }} // class JavaGeneratorFactory
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -