Skip to content

Commit 0e44b22

Browse files
committed
Removed default registristation of generic exception types
1 parent 1ab196d commit 0e44b22

File tree

11 files changed

+3
-94
lines changed

11 files changed

+3
-94
lines changed

com.btc.serviceidl.tests/src/com/btc/serviceidl/tests/generator/cpp/CppGeneratorTest.xtend

-8
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ class CppGeneratorTest extends AbstractGeneratorTest
7676
#include "modules/Infrastructure/ServiceHost/Demo/API/ServiceAPI/include/IKeyValueStore.h"
7777
7878
#include "modules/Commons/include/BeginCabInclude.h" // CAB -->
79-
#include "Commons/Core/include/InvalidArgumentException.h"
8079
#include "Commons/Core/include/String.h"
81-
#include "Commons/Core/include/UnsupportedOperationException.h"
8280
#include "Commons/CoreExtras/include/UUID.h"
8381
#include "ServiceComm/API/include/IServiceFaultHandler.h"
8482
#include "ServiceComm/Base/include/DefaultServiceFaultHandler.h"
@@ -103,12 +101,6 @@ class CppGeneratorTest extends AbstractGeneratorTest
103101
104102
void RegisterKeyValueStoreServiceFaults(BTC::ServiceComm::API::IServiceFaultHandlerManager& serviceFaultHandlerManager)
105103
{
106-
107-
// most commonly used exception types
108-
BTC::ServiceComm::Base::RegisterServiceFault<BTC::Commons::Core::InvalidArgumentException>(
109-
serviceFaultHandlerManager, BTC::Commons::Core::String("BTC.Commons.Core.InvalidArgumentException"));
110-
BTC::ServiceComm::Base::RegisterServiceFault<BTC::Commons::Core::UnsupportedOperationException>(
111-
serviceFaultHandlerManager, BTC::Commons::Core::String("BTC.Commons.Core.UnsupportedOperationException"));
112104
}
113105
}}}}}}}
114106
''')

com.btc.serviceidl.tests/src/com/btc/serviceidl/tests/generator/java/JavaGeneratorTest.xtend

-6
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ public class TypesCodec {
316316
import com.btc.cab.servicecomm.api.IServiceFaultHandler;
317317
import com.btc.cab.servicecomm.faulthandling.DefaultServiceFaultHandler;
318318
import com.btc.cab.servicecomm.faulthandling.ErrorMessage;
319-
import java.lang.IllegalArgumentException;
320-
import java.lang.UnsupportedOperationException;
321319
import java.lang.reflect.Constructor;
322320
import java.util.Optional;
323321
import org.apache.commons.collections4.BidiMap;
@@ -330,10 +328,6 @@ public class TypesCodec {
330328

331329
static
332330
{
333-
334-
// most commonly used exception types
335-
errorMap.put("BTC.Commons.Core.InvalidArgumentException", IllegalArgumentException.class);
336-
errorMap.put("BTC.Commons.Core.UnsupportedOperationException", UnsupportedOperationException.class);
337331
}
338332

339333
public static final IServiceFaultHandler createServiceFaultHandler()

com.btc.serviceidl/src/com/btc/serviceidl/generator/cpp/CodecGenerator.xtend

-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ class CodecGenerator extends BasicCppGenerator
6868
«val exceptionName = exception.getCommonExceptionName(qualifiedNameProvider)»
6969
faultHandlers["«exceptionName»"] = [](«cabString» const& msg) { return «cabCreateUnique»<«exceptionType»>(msg); };
7070
«ENDFOR»
71-
72-
// most commonly used exception types
73-
«val defaultExceptions = typeResolver.defaultExceptionRegistration»
74-
«FOR exception : defaultExceptions.keySet.sort»
75-
faultHandlers["«exception»"] = [](«cabString» const& msg) { return «cabCreateUnique»<«defaultExceptions.get(exception)»>(msg); };
76-
«ENDFOR»
7771
});
7872
}
7973

com.btc.serviceidl/src/com/btc/serviceidl/generator/cpp/ServiceAPIGenerator.xtend

-7
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ class ServiceAPIGenerator extends BasicCppGenerator {
231231
«registerServiceFault»<«resolveExcName»>(
232232
serviceFaultHandlerManager, «cabString»("«exception.getCommonExceptionName(qualifiedNameProvider)»"));
233233
«ENDFOR»
234-
235-
// most commonly used exception types
236-
«val defaultExceptions = typeResolver.defaultExceptionRegistration»
237-
«FOR exception : defaultExceptions.keySet.sort»
238-
«registerServiceFault»<«defaultExceptions.get(exception)»>(
239-
serviceFaultHandlerManager, «cabString»("«exception»"));
240-
«ENDFOR»
241234
}
242235
'''
243236
}

com.btc.serviceidl/src/com/btc/serviceidl/generator/cpp/TypeResolverExtensions.xtend

-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package com.btc.serviceidl.generator.cpp
22

33
import com.btc.serviceidl.generator.common.GuidMapper
44
import com.btc.serviceidl.idl.StructDeclaration
5-
import com.btc.serviceidl.util.Constants
6-
import java.util.Map
75

86
class TypeResolverExtensions {
97
static def String makeEventGUIDImplementations(extension TypeResolver typeResolver,
@@ -27,14 +25,4 @@ class TypeResolverExtensions {
2725
'''
2826
}
2927

30-
static def Map<String, String> getDefaultExceptionRegistration(extension TypeResolver typeResolver)
31-
{
32-
// TODO these must not be registered, the default must be empty
33-
#{
34-
Constants.INVALID_ARGUMENT_EXCEPTION_FAULT_HANDLER -> resolveSymbol("BTC::Commons::Core::InvalidArgumentException")
35-
,Constants.UNSUPPORTED_OPERATION_EXCEPTION_FAULT_HANDLER -> resolveSymbol("BTC::Commons::Core::UnsupportedOperationException")
36-
}
37-
}
38-
39-
4028
}

com.btc.serviceidl/src/com/btc/serviceidl/generator/dotnet/ServiceFaultHandlingGenerator.xtend

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class ServiceFaultHandlingGenerator extends GeneratorBase
3939
4040
static «className»()
4141
{
42-
// most commonly used exception types
43-
errorMap["«Constants.INVALID_ARGUMENT_EXCEPTION_FAULT_HANDLER»"] = typeof(«resolve("System.ArgumentException").fullyQualifiedName»);
44-
errorMap["«Constants.UNSUPPORTED_OPERATION_EXCEPTION_FAULT_HANDLER»"] = typeof(«resolve("System.NotSupportedException").fullyQualifiedName»);
45-
4642
«FOR e : raisedExceptions.sortBy[name] SEPARATOR System.lineSeparator»
4743
errorMap["«e.getCommonExceptionName(qualifiedNameProvider)»"] = typeof(«resolve(e)»);
4844
«ENDFOR»

com.btc.serviceidl/src/com/btc/serviceidl/generator/dotnet/TypeResolver.xtend

+2-16
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ class TypeResolver
5252

5353
def ResolvedName resolve(String name)
5454
{
55-
val effectiveName = resolveException(name) ?: name
56-
val fullyQualifiedName = QualifiedName.create(
57-
effectiveName.split(Pattern.quote(Constants.SEPARATOR_PACKAGE)))
55+
val effectiveName = name
56+
val fullyQualifiedName = QualifiedName.create(effectiveName.split(Pattern.quote(Constants.SEPARATOR_PACKAGE)))
5857
val namespace = fullyQualifiedName.skipLast(1).toString
5958

6059
if (namespace.startsWith("System"))
@@ -148,19 +147,6 @@ class TypeResolver
148147
return new ResolvedName(result, TransformType.PACKAGE, FULLY_QUALIFIED)
149148
}
150149

151-
private static def String resolveException(String name)
152-
{
153-
// temporarily some special handling for exceptions, because not all
154-
// C++ CAB exceptions are supported by the .NET CAB
155-
switch (name)
156-
{
157-
case "BTC.Commons.Core.InvalidArgumentException":
158-
return "System.ArgumentException"
159-
default:
160-
return null
161-
}
162-
}
163-
164150
private def boolean isSameProject(QualifiedName referencedPackage)
165151
{
166152
GeneratorUtil.getTransformedModuleName(parameterBundle, ArtifactNature.DOTNET, TransformType.PACKAGE) ==

com.btc.serviceidl/src/com/btc/serviceidl/generator/java/BasicJavaSourceGenerator.xtend

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class BasicJavaSourceGenerator
5454

5555
def dispatch String toText(ExceptionDeclaration element)
5656
{
57-
typeResolver.resolveException(qualifiedNameProvider.getFullyQualifiedName(element).toString) ?:
58-
'''«typeResolver.resolve(element)»'''
57+
'''«typeResolver.resolve(element)»'''
5958
}
6059

6160
def dispatch String toText(SequenceDeclaration item)

com.btc.serviceidl/src/com/btc/serviceidl/generator/java/ServiceFaultHandlerFactoryGenerator.xtend

-6
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class ServiceFaultHandlerFactoryGenerator
4747

4848
// TODO except for the static initializer, this can be extracted into a reusable class, which can be provided
4949
// from com.btc.cab.servicecomm
50-
// TODO InvalidArgumentException and UnsupportedOperationException should not be added to the error map, only
51-
// service-specific subtypes
5250
'''
5351
public class «className»
5452
{
@@ -61,10 +59,6 @@ class ServiceFaultHandlerFactoryGenerator
6159
«FOR exception : exceptions.sortBy[name]»
6260
errorMap.put("«Util.getCommonExceptionName(exception, basicJavaSourceGenerator.qualifiedNameProvider)»", «getClassOrObject(typeResolver.resolve(exception))»);
6361
«ENDFOR»
64-
65-
// most commonly used exception types
66-
errorMap.put("«Constants.INVALID_ARGUMENT_EXCEPTION_FAULT_HANDLER»", «getClassOrObject(typeResolver.resolve("java.lang.IllegalArgumentException"))»);
67-
errorMap.put("«Constants.UNSUPPORTED_OPERATION_EXCEPTION_FAULT_HANDLER»", «getClassOrObject(typeResolver.resolve("java.lang.UnsupportedOperationException"))»);
6862
}
6963
7064
public static final «typeResolver.resolve(JavaClassNames.SERVICE_FAULT_HANDLER)» createServiceFaultHandler()

com.btc.serviceidl/src/com/btc/serviceidl/generator/java/TypeResolver.xtend

-22
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ class TypeResolver
105105
{
106106
var name = qualifiedNameProvider.getFullyQualifiedName(element)
107107

108-
// try to resolve CAB-related pseudo-exceptions
109-
if (element.isException)
110-
{
111-
val exceptionName = resolveException(name.toString)
112-
if (exceptionName !== null)
113-
return new ResolvedName(exceptionName, TransformType.PACKAGE, fullyQualified)
114-
}
115-
116108
if (name === null)
117109
{
118110
if (element instanceof AbstractType)
@@ -157,20 +149,6 @@ class TypeResolver
157149
return new ResolvedName(fullyQualifiedName, TransformType.PACKAGE, fullyQualified)
158150
}
159151

160-
def String resolveException(String name)
161-
{
162-
// temporarily some special handling for exceptions, because not all
163-
// C++ CAB exceptions are supported by the Java CAB
164-
switch (name)
165-
{
166-
case "BTC.Commons.Core.InvalidArgumentException":
167-
// TODO shouldn't this use resolve("java.util.IllegalArgumentException")?
168-
"IllegalArgumentException"
169-
default:
170-
null
171-
}
172-
}
173-
174152
private static def String getObservableName(EventDeclaration event)
175153
{
176154
if (event.name === null)

com.btc.serviceidl/src/com/btc/serviceidl/util/Constants.java

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ public interface Constants {
5555
public static final String FILE_NAME_ODB_COMMON = "common";
5656
public static final String FILE_NAME_ODB_TRAITS = "traits";
5757

58-
// GUID for default exception registration thrown by not implemented methods
59-
public static final String UNSUPPORTED_OPERATION_EXCEPTION_FAULT_HANDLER = "BTC.Commons.Core.UnsupportedOperationException";
60-
61-
public static final String INVALID_ARGUMENT_EXCEPTION_FAULT_HANDLER = "BTC.Commons.Core.InvalidArgumentException";
62-
6358
public static final int DEFAULT_PORT = 5555;
6459

6560
public static final String AUTO_GENERATED_METHOD_STUB_MESSAGE = "Auto-generated method stub is not implemented!";

0 commit comments

Comments
 (0)