container/services/src/main/java/org/mobicents/slee/container/deployment/ConcreteSbbGenerator.java
protected void createCMPAccessors(Collection<CMPFieldDescriptor> cmps)
			throws DeploymentException {

		for (CMPFieldDescriptor cmp : cmps) {
			String fieldName = cmp.getCmpFieldName();
			// Set the first char of the accessor to UpperCase to follow the
			// javabean requirements
			fieldName = fieldName.substring(0, 1).toUpperCase()
					+ fieldName.substring(1);

			String getterMethodName = "get" + fieldName;
			CtMethod getterMethod = (CtMethod) abstractMethods
					.get(getterMethodName);
			if (getterMethod == null) {
				getterMethod = (CtMethod) this.superClassesAbstractMethods
				.get(getterMethodName);
			}
			if (getterMethod == null) {
				throw new SLEEException("can't find abstract method "
						+ getterMethodName);
			}

			// generate the acessor method name sufix from type
			String getterHandlerMethodName = "getCMPFieldOfType";
			boolean getterHandlerMethodNeedResultCast = false;
			String setterHandlerMethodName = "setCMPFieldOfType";
			try {
				CtClass ctClassCmpType = getterMethod.getReturnType();
				if (ctClassCmpType.isPrimitive()) {
					// boolean, byte, char, short, int, long, float, double
					String ctClassCmpTypeName = ctClassCmpType.getName();
					if (ctClassCmpTypeName.equals(boolean.class.getName())) {
						getterHandlerMethodName += "Boolean";	
					}
					else if (ctClassCmpTypeName.equals(byte.class.getName())) {
						getterHandlerMethodName += "Byte";	
					}
					else if (ctClassCmpTypeName.equals(char.class.getName())) {
						getterHandlerMethodName += "Char";
					}
					else if (ctClassCmpTypeName.equals(short.class.getName())) {
						getterHandlerMethodName += "Short";
					}
					else if (ctClassCmpTypeName.equals(int.class.getName())) {
						getterHandlerMethodName += "Integer";
					}
					else if (ctClassCmpTypeName.equals(long.class.getName())) {
						getterHandlerMethodName += "Long";
					}
					else if (ctClassCmpTypeName.equals(float.class.getName())) {
						getterHandlerMethodName += "Float";
					}
					else if (ctClassCmpTypeName.equals(double.class.getName())) {
						getterHandlerMethodName += "Double";
					}
					else {
						throw new SLEEException("unexpected primitive type "
								+ ctClassCmpTypeName);
					}				
					getterHandlerMethodNeedResultCast = true;
					setterHandlerMethodName += "PrimitiveOrUnknown";
				}
				else {
					// aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown, array, enum, annotation
					if (!ctClassCmpType.isArray() && !ctClassCmpType.isEnum() && !ctClassCmpType.isAnnotation()) {
						// aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown
						Class<?> classCmpType = Thread.currentThread().getContextClassLoader().loadClass(ctClassCmpType.getName());
						if (javax.slee.ActivityContextInterface.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "ActivityContextInterface";
							setterHandlerMethodName += "ActivityContextInterface";
						}
						else if (EventContext.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "EventContext";
							setterHandlerMethodName += "EventContext";
						}
						else if (ProfileLocalObject.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "ProfileLocalObject";
							setterHandlerMethodName += "ProfileLocalObject";
						}
						else if (SbbLocalObject.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "SbbLocalObject";
							setterHandlerMethodName += "SbbLocalObject";
						}
						else {
							// Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown
							if (this.initializeReferenceDataTypesWithNull) {
								getterHandlerMethodName += "Unknown";
								getterHandlerMethodNeedResultCast = true;
							} else { // initialized with 0
								String ctClassCmpTypeName = ctClassCmpType.getName();
								if (ctClassCmpTypeName.equals(Boolean.class.getName())) {
									getterHandlerMethodName += "Boolean";
								} else if (ctClassCmpTypeName.equals(Byte.class.getName())) {
									getterHandlerMethodName += "Byte";
								} else if (ctClassCmpTypeName.equals(Character.class.getName())) {
									getterHandlerMethodName += "Char";
								} else if (ctClassCmpTypeName.equals(Short.class.getName())) {
									getterHandlerMethodName += "Short";
								} else if (ctClassCmpTypeName.equals(Integer.class.getName())) {
									getterHandlerMethodName += "Integer";
								} else if (ctClassCmpTypeName.equals(Long.class.getName())) {
									getterHandlerMethodName += "Long";
								} else if (ctClassCmpTypeName.equals(Float.class.getName())) {
									getterHandlerMethodName += "Float";
								} else if (ctClassCmpTypeName.equals(Double.class.getName())) {
									getterHandlerMethodName += "Double";
								} else {
									getterHandlerMethodName += "Unknown";
									getterHandlerMethodNeedResultCast = true;
								}
							}
							setterHandlerMethodName += "PrimitiveOrUnknown";
						}
					}
					else {
						// array, enum, annotation == same as unknown
						getterHandlerMethodName += "Unknown";
						getterHandlerMethodNeedResultCast = true;
						setterHandlerMethodName += "PrimitiveOrUnknown";
					}								
				}
			} catch (Exception cce) {
				throw new SLEEException("Cannot determine the cmp type for cmp field named "+fieldName, cce);
			}
			
			try {
				// copy method from abstract to concrete class
				CtMethod concreteGetterMethod = CtNewMethod.copy(getterMethod,
						sbbConcreteClass, null);
				// create the method body

				// FIXED: NPE when accessing not initialized CMP
				// see https://github.com/RestComm/jain-slee/issues/87
				String concreteGetterMethodBody = "{ "
						+ "if (sbbEntity == null) "
						+ "    throw new TransactionRequiredLocalException(\"Cannot get CMP field. SBB entity is null\");"
						+ "return " + ( getterHandlerMethodNeedResultCast ? "($r)" : "") + SbbAbstractMethodHandler.class.getName() + "." + getterHandlerMethodName+ "(sbbEntity,\"" + cmp.getCmpFieldName() + "\");"
						+ " }";
				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method " + getterMethodName
							+ " , body = " + concreteGetterMethodBody);
				}
				concreteGetterMethod.setBody(concreteGetterMethodBody);
				sbbConcreteClass.addMethod(concreteGetterMethod);
			} catch (Exception cce) {
				throw new SLEEException("Cannot compile method "
						+ getterMethod.getName(), cce);
			}

			String setterMethodName = "set" + fieldName;
			CtMethod setterMethod = (CtMethod) abstractMethods
					.get(setterMethodName);
			if (setterMethod == null) {
				setterMethod = (CtMethod) this.superClassesAbstractMethods
						.get(setterMethodName);
			}
			if (setterMethod == null) {
				throw new SLEEException("can't find abstract method "
						+ setterMethodName);
			}

			try {
				// copy method from abstract to concrete class
				CtMethod concreteSetterMethod = CtNewMethod.copy(setterMethod,
						sbbConcreteClass, null);
				// create the method body

				// FIXED: NPE when accessing not initialized CMP
				// see https://github.com/RestComm/jain-slee/issues/87
				String concreteSetterMethodBody = "{ "
						+ "if (sbbEntity == null) "
						+ "    throw new TransactionRequiredLocalException(\"Cannot set CMP field. SBB entity is null\");"
						+ SbbAbstractMethodHandler.class.getName()
						+ "."+setterHandlerMethodName+"(sbbEntity,\"" + cmp.getCmpFieldName()
						+ "\",$1); }";
				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method " + setterMethodName
							+ " , body = " + concreteSetterMethodBody);
				}
				concreteSetterMethod.setBody(concreteSetterMethodBody);
				sbbConcreteClass.addMethod(concreteSetterMethod);
			} catch (CannotCompileException cce) {
				throw new SLEEException("Cannot compile method "
						+ getterMethod.getName(), cce);
			}
		}

	}
protected void createCMPAccessors(Collection<CMPFieldDescriptor> cmps)
			throws DeploymentException {

		for (CMPFieldDescriptor cmp : cmps) {
			String fieldName = cmp.getCmpFieldName();
			// Set the first char of the accessor to UpperCase to follow the
			// javabean requirements
			fieldName = fieldName.substring(0, 1).toUpperCase()
					+ fieldName.substring(1);

			String getterMethodName = "get" + fieldName;
			CtMethod getterMethod = (CtMethod) abstractMethods
					.get(getterMethodName);
			if (getterMethod == null) {
				getterMethod = (CtMethod) this.superClassesAbstractMethods
				.get(getterMethodName);
			}
			if (getterMethod == null) {
				throw new SLEEException("can't find abstract method "
						+ getterMethodName);
			}

			// generate the acessor method name sufix from type
			String getterHandlerMethodName = "getCMPFieldOfType";
			boolean getterHandlerMethodNeedResultCast = false;
			String setterHandlerMethodName = "setCMPFieldOfType";
			try {
				CtClass ctClassCmpType = getterMethod.getReturnType();
				if (ctClassCmpType.isPrimitive()) {
					// boolean, byte, char, short, int, long, float, double
					String ctClassCmpTypeName = ctClassCmpType.getName();
					if (ctClassCmpTypeName.equals(boolean.class.getName())) {
						getterHandlerMethodName += "Boolean";	
					}
					else if (ctClassCmpTypeName.equals(byte.class.getName())) {
						getterHandlerMethodName += "Byte";	
					}
					else if (ctClassCmpTypeName.equals(char.class.getName())) {
						getterHandlerMethodName += "Char";
					}
					else if (ctClassCmpTypeName.equals(short.class.getName())) {
						getterHandlerMethodName += "Short";
					}
					else if (ctClassCmpTypeName.equals(int.class.getName())) {
						getterHandlerMethodName += "Integer";
					}
					else if (ctClassCmpTypeName.equals(long.class.getName())) {
						getterHandlerMethodName += "Long";
					}
					else if (ctClassCmpTypeName.equals(float.class.getName())) {
						getterHandlerMethodName += "Float";
					}
					else if (ctClassCmpTypeName.equals(double.class.getName())) {
						getterHandlerMethodName += "Double";
					}
					else {
						throw new SLEEException("unexpected primitive type "
								+ ctClassCmpTypeName);
					}				
					getterHandlerMethodNeedResultCast = true;
					setterHandlerMethodName += "PrimitiveOrUnknown";
				}
				else {
					// aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown, array, enum, annotation
					if (!ctClassCmpType.isArray() && !ctClassCmpType.isEnum() && !ctClassCmpType.isAnnotation()) {
						// aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown
						Class<?> classCmpType = Thread.currentThread().getContextClassLoader().loadClass(ctClassCmpType.getName());
						if (javax.slee.ActivityContextInterface.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "ActivityContextInterface";
							setterHandlerMethodName += "ActivityContextInterface";
						}
						else if (EventContext.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "EventContext";
							setterHandlerMethodName += "EventContext";
						}
						else if (ProfileLocalObject.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "ProfileLocalObject";
							setterHandlerMethodName += "ProfileLocalObject";
						}
						else if (SbbLocalObject.class.isAssignableFrom(classCmpType)) {
							getterHandlerMethodName += "SbbLocalObject";
							setterHandlerMethodName += "SbbLocalObject";
						}
						else {
							// Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown
							if (this.initializeReferenceDataTypesWithNull) {
								getterHandlerMethodName += "Unknown";
								getterHandlerMethodNeedResultCast = true;
							} else { // initialized with 0
								String ctClassCmpTypeName = ctClassCmpType.getName();
								if (ctClassCmpTypeName.equals(Boolean.class.getName())) {
									getterHandlerMethodName += "Boolean";
								} else if (ctClassCmpTypeName.equals(Byte.class.getName())) {
									getterHandlerMethodName += "Byte";
								} else if (ctClassCmpTypeName.equals(Character.class.getName())) {
									getterHandlerMethodName += "Char";
								} else if (ctClassCmpTypeName.equals(Short.class.getName())) {
									getterHandlerMethodName += "Short";
								} else if (ctClassCmpTypeName.equals(Integer.class.getName())) {
									getterHandlerMethodName += "Integer";
								} else if (ctClassCmpTypeName.equals(Long.class.getName())) {
									getterHandlerMethodName += "Long";
								} else if (ctClassCmpTypeName.equals(Float.class.getName())) {
									getterHandlerMethodName += "Float";
								} else if (ctClassCmpTypeName.equals(Double.class.getName())) {
									getterHandlerMethodName += "Double";
								} else {
									getterHandlerMethodName += "Unknown";
									getterHandlerMethodNeedResultCast = true;
								}
							}
							setterHandlerMethodName += "PrimitiveOrUnknown";
						}
					}
					else {
						// array, enum, annotation == same as unknown
						getterHandlerMethodName += "Unknown";
						getterHandlerMethodNeedResultCast = true;
						setterHandlerMethodName += "PrimitiveOrUnknown";
					}								
				}
			} catch (Exception cce) {
				throw new SLEEException("Cannot determine the cmp type for cmp field named "+fieldName, cce);
			}
			
			try {
				// copy method from abstract to concrete class
				CtMethod concreteGetterMethod = CtNewMethod.copy(getterMethod,
						sbbConcreteClass, null);
				// create the method body

				// FIXED: NPE when accessing not initialized CMP
				// see https://github.com/RestComm/jain-slee/issues/87
				String concreteGetterMethodBody = "{ "
						+ "if (sbbEntity == null) "
						+ "    throw new TransactionRequiredLocalException(\"Cannot get CMP field. SBB entity is null\");"
						+ "return " + ( getterHandlerMethodNeedResultCast ? "($r)" : "") + SbbAbstractMethodHandler.class.getName() + "." + getterHandlerMethodName+ "(sbbEntity,\"" + cmp.getCmpFieldName() + "\");"
						+ " }";
				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method " + getterMethodName
							+ " , body = " + concreteGetterMethodBody);
				}
				concreteGetterMethod.setBody(concreteGetterMethodBody);
				sbbConcreteClass.addMethod(concreteGetterMethod);
			} catch (Exception cce) {
				throw new SLEEException("Cannot compile method "
						+ getterMethod.getName(), cce);
			}

			String setterMethodName = "set" + fieldName;
			CtMethod setterMethod = (CtMethod) abstractMethods
					.get(setterMethodName);
			if (setterMethod == null) {
				setterMethod = (CtMethod) this.superClassesAbstractMethods
						.get(setterMethodName);
			}
			if (setterMethod == null) {
				throw new SLEEException("can't find abstract method "
						+ setterMethodName);
			}

			try {
				// copy method from abstract to concrete class
				CtMethod concreteSetterMethod = CtNewMethod.copy(setterMethod,
						sbbConcreteClass, null);
				// create the method body

				// FIXED: NPE when accessing not initialized CMP
				// see https://github.com/RestComm/jain-slee/issues/87
				String concreteSetterMethodBody = "{ "
						+ "if (sbbEntity == null) "
						+ "    throw new TransactionRequiredLocalException(\"Cannot set CMP field. SBB entity is null\");"
						+ SbbAbstractMethodHandler.class.getName()
						+ "."+setterHandlerMethodName+"(sbbEntity,\"" + cmp.getCmpFieldName()
						+ "\",$1); }";
				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method " + setterMethodName
							+ " , body = " + concreteSetterMethodBody);
				}
				concreteSetterMethod.setBody(concreteSetterMethodBody);
				sbbConcreteClass.addMethod(concreteSetterMethod);
			} catch (CannotCompileException cce) {
				throw new SLEEException("Cannot compile method "
						+ getterMethod.getName(), cce);
			}
		}

	}
Create the cmp field setters and getters

@param cmps
the description of the cmp fields
@throws DeploymentException