You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2011/01/24 06:29:04 UTC
svn commit: r1062651 - in /cxf/trunk/tools/corba/src:
main/java/org/apache/cxf/tools/corba/idlpreprocessor/
main/java/org/apache/cxf/tools/corba/processors/idl/
test/java/org/apache/cxf/tools/corba/processors/ test/resources/idl/
test/resources/idlprep...
Author: ffang
Date: Mon Jan 24 05:29:04 2011
New Revision: 1062651
URL: http://svn.apache.org/viewvc?rev=1062651&view=rev
Log:
[CXF-3264]idl2wsdl tool should be able to honor #pragma directive
Added:
cxf/trunk/tools/corba/src/test/resources/idl/PragmaPrefix.idl
cxf/trunk/tools/corba/src/test/resources/idl/expected_PragmaPrefix.wsdl
Modified:
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReader.java
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
cxf/trunk/tools/corba/src/test/resources/idlpreprocessor/C.idl
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReader.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReader.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReader.java Mon Jan 24 05:29:04 2011
@@ -79,6 +79,8 @@ public final class IdlPreprocessorReader
private final StringBuilder buf = new StringBuilder();
private int readPos;
+
+ private String pragmaPrefix;
/**
* Creates a new IncludeReader.
@@ -184,6 +186,8 @@ public final class IdlPreprocessorReader
handleElse(lineNo, ise);
} else if (line.startsWith("#define")) {
handleDefine(line);
+ } else if (line.startsWith("#pragma")) {
+ handlePragma(line);
} else {
throw new PreprocessingException("unknown preprocessor instruction", ise.getURL(), lineNo);
}
@@ -272,6 +276,18 @@ public final class IdlPreprocessorReader
buf.append(LF);
}
+ private void handlePragma(String line) {
+ String symbol = line.substring(line.indexOf("prefix") + "prefix".length()).trim();
+ if (symbol.startsWith("\"")) {
+ symbol = symbol.substring(1);
+ }
+ if (symbol.endsWith("\"")) {
+ symbol = symbol.substring(0, symbol.length() - 1);
+ }
+ setPragmaPrefix(symbol);
+ buf.append(LF);
+ }
+
private void handleIfndef(String line) {
String symbol = line.substring("#ifndef".length()).trim();
boolean isDefined = defineState.isDefined(symbol);
@@ -358,4 +374,12 @@ public final class IdlPreprocessorReader
buf.append("# ").append(lineNumber).append(' ').append(location).append(' ').append(flag).append(LF);
}
+ public void setPragmaPrefix(String pragmaPrefix) {
+ this.pragmaPrefix = pragmaPrefix;
+ }
+
+ public String getPragmaPrefix() {
+ return pragmaPrefix;
+ }
+
}
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java Mon Jan 24 05:29:04 2011
@@ -38,8 +38,10 @@ public class IDLProcessor implements Pro
protected ProcessorEnvironment env;
+ protected IdlPreprocessorReader preprocessor;
+
private IDLParser parser;
-
+
public void setEnvironment(ProcessorEnvironment penv) {
env = penv;
}
@@ -54,7 +56,7 @@ public class IDLProcessor implements Pro
URL orig = file.toURI().toURL();
DefaultIncludeResolver includeResolver = getDefaultIncludeResolver(file.getParentFile());
DefineState defineState = new DefineState(new HashMap<String, String>());
- IdlPreprocessorReader preprocessor = new IdlPreprocessorReader(orig,
+ preprocessor = new IdlPreprocessorReader(orig,
location,
includeResolver,
defineState);
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java Mon Jan 24 05:29:04 2011
@@ -160,7 +160,8 @@ public class IDLToWSDLProcessor extends
outputDir = ".";
try {
- WSDLASTVisitor visitor = new WSDLASTVisitor(tns, schemans, corbatypemaptns);
+ WSDLASTVisitor visitor = new WSDLASTVisitor(tns, schemans, corbatypemaptns,
+ preprocessor.getPragmaPrefix());
visitor.getManager().setIgnoreImports(ignoreImports);
if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
outputDir = (String) env.get(ToolConstants.CFG_OUTPUTDIR);
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java Mon Jan 24 05:29:04 2011
@@ -247,7 +247,11 @@ public class PortTypeVisitor extends Vis
try {
BindingType bindingType = (BindingType)
extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
+ String pragmaPrefix = (this.getWsdlVisitor().getPragmaPrefix() != null
+ && this.getWsdlVisitor().getPragmaPrefix().length() > 0)
+ ? this.getWsdlVisitor().getPragmaPrefix() + "/" : "";
bindingType.setRepositoryID(CorbaConstants.REPO_STRING
+ + pragmaPrefix
+ scopedPortTypeName.replace('.', '/')
+ CorbaConstants.IDL_VERSION);
binding.addExtensibilityElement(bindingType);
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java Mon Jan 24 05:29:04 2011
@@ -74,8 +74,9 @@ public final class WSDLASTVisitor implem
private ModuleToNSMapper moduleToNSMapper;
private WSDLSchemaManager manager;
private Map<Scope, List<Scope>> inheritScopeMap;
+ private String pragmaPrefix;
- public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns)
+ public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns, String pragmaPrefix)
throws WSDLException, JAXBException {
manager = new WSDLSchemaManager();
@@ -104,8 +105,14 @@ public final class WSDLASTVisitor implem
setBoundedStringOverride(false);
moduleToNSMapper = new ModuleToNSMapper();
+ this.setPragmaPrefix(pragmaPrefix);
}
+ public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns)
+ throws WSDLException, JAXBException {
+ this(tns, schemans, corbatypemaptns, null);
+ }
+
public void visit(AST node) {
// <specification> ::= <definition>+
@@ -455,4 +462,12 @@ public final class WSDLASTVisitor implem
moduleToNSMapper.setExcludedModuleMap(modules);
}
+ public void setPragmaPrefix(String pragmaPrefix) {
+ this.pragmaPrefix = pragmaPrefix;
+ }
+
+ public String getPragmaPrefix() {
+ return pragmaPrefix;
+ }
+
}
Modified: cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java (original)
+++ cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java Mon Jan 24 05:29:04 2011
@@ -303,6 +303,12 @@ public class IDLToWSDLGenerationTest ext
// This tests for recursive unions
testWSDLGeneration("/idl/RecursiveUnion.idl", "/idl/expected_RecursiveUnion.wsdl");
}
+
+ @Test
+ public void testPragmaPrefix() throws Exception {
+ // This tests for how pragma prefix directive affect the corba binding repositoryID
+ testWSDLGeneration("/idl/PragmaPrefix.idl", "/idl/expected_PragmaPrefix.wsdl");
+ }
public void testLogicalPhysicalSchemaGeneration(String idlFilename,
String logicalName,
Added: cxf/trunk/tools/corba/src/test/resources/idl/PragmaPrefix.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/PragmaPrefix.idl?rev=1062651&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/PragmaPrefix.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/PragmaPrefix.idl Mon Jan 24 05:29:04 2011
@@ -0,0 +1,21 @@
+#ifndef TEST2_IDL
+#define TEST2_IDL
+
+#pragma prefix "org.apache.cxf"
+
+module Test2 {
+
+
+ //const char MYCHAR = '\0';
+ //const char CLEARED = '\1';
+ const char TRANSIENT = '\2';
+#if 0
+ const char NEW = '\65';
+#endif
+
+ interface ForTesting {
+
+ void greetMe(in string who);
+ };
+};
+#endif
Added: cxf/trunk/tools/corba/src/test/resources/idl/expected_PragmaPrefix.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/expected_PragmaPrefix.wsdl?rev=1062651&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/expected_PragmaPrefix.wsdl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/expected_PragmaPrefix.wsdl Mon Jan 24 05:29:04 2011
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://cxf.apache.org/bindings/corba/idl/PragmaPrefix" xmlns:corba="http://cxf.apache.org/bindings/corba" xmlns:tns="http://cxf.apache.org/bindings/corba/idl/PragmaPrefix" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <corba:typeMapping targetNamespace="http://cxf.apache.org/bindings/corba/idl/PragmaPrefix/typemap">
+ <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" value="\2" idltype="corba:char" name="Test2.TRANSIENT" type="xs:byte"/>
+ </corba:typeMapping>
+ <wsdl:types>
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://cxf.apache.org/bindings/corba/idl/PragmaPrefix" xmlns="http://cxf.apache.org/bindings/corba/idl/PragmaPrefix" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="greetMe">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="who" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="greetMeResponse">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part name="outparameter" element="tns:greetMeResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="greetMe">
+ <wsdl:part name="inparameter" element="tns:greetMe">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test2.ForTesting">
+ <wsdl:operation name="greetMe">
+ <wsdl:input name="greetMeRequest" message="tns:greetMe">
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse" message="tns:greetMeResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Test2.ForTestingCORBABinding" type="tns:Test2.ForTesting">
+ <corba:binding repositoryID="IDL:org.apache.cxf/Test2/ForTesting:1.0"/>
+ <wsdl:operation name="greetMe">
+ <corba:operation name="greetMe">
+ <corba:param mode="in" name="who" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="greetMeRequest">
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test2.ForTestingCORBAService">
+ <wsdl:port name="Test2.ForTestingCORBAPort" binding="tns:Test2.ForTestingCORBABinding">
+ <corba:address location="IOR:"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Modified: cxf/trunk/tools/corba/src/test/resources/idlpreprocessor/C.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idlpreprocessor/C.idl?rev=1062651&r1=1062650&r2=1062651&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idlpreprocessor/C.idl (original)
+++ cxf/trunk/tools/corba/src/test/resources/idlpreprocessor/C.idl Mon Jan 24 05:29:04 2011
@@ -5,7 +5,7 @@
#else
#define _c
#endif
-
+#pragma prefix "org.apache.cxf"
module c
{
interface C {