container/profiles/src/main/java/org/mobicents/slee/container/deployment/profile/ConcreteProfileMBeanGenerator.java
public void generateProfileMBeanInterface() throws Exception {
		
		if (SleeProfileClassCodeGenerator.checkCombination(component) == -1) {
			throw new DeploymentException("Profile Specification doesn't match any combination " + "from the JSLEE spec 1.0 section 10.5.2");
		}
		
		String profileMBeanConcreteInterfaceName = cmpProfileInterfaceName + "MBean";
		
		profileMBeanConcreteInterface = pool.makeInterface(profileMBeanConcreteInterfaceName);

		try {
			cmpProfileInterface = pool.get(cmpProfileInterfaceName);
			profileManagementInterface = profileManagementInterfaceName != null ? pool.get(profileManagementInterfaceName) : null;
		}
		catch (NotFoundException nfe) {
			throw new DeploymentException("Failed to locate CMP/Management Interface for " + component, nfe);
		}
		
		// set interface
		try {
			profileMBeanConcreteInterface.addInterface(pool.get(AbstractProfileMBean.class.getName()));
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(),e);
		}
		
		// gather exceptions that the mbean methods may throw
		CtClass[] managementMethodExceptions = new CtClass[3];
		try {
			managementMethodExceptions[0] = pool.get(ManagementException.class.getName());
			managementMethodExceptions[1] = pool.get(InvalidStateException.class.getName());
			managementMethodExceptions[2] = pool.get(ProfileImplementationException.class.getName());
		}
		catch (NotFoundException e) {
			throw new SLEEException(e.getMessage(),e);
		}
		CtClass[] cmpGetAcessorMethodExceptions = new CtClass[] {managementMethodExceptions[0]};
		CtClass[] cmpSetAcessorMethodExceptions = new CtClass[] {managementMethodExceptions[0],managementMethodExceptions[1]};
		
		// gather all Object class methods, we don't want those in the mbean
		Set<CtMethod> objectMethods = new HashSet<CtMethod>();
		try {
			CtClass objectClass = pool.get(Object.class.getName());
			for (CtMethod ctMethod : objectClass.getMethods()) {
				objectMethods.add(ctMethod);
			}
		}
		catch (NotFoundException e) {
			throw new SLEEException(e.getMessage(),e);
		}
		
		// gather methods to copy
		Set<CtMethod> cmpAcessorMethods = new HashSet<CtMethod>();
		Set<CtMethod> managementMethods = new HashSet<CtMethod>();
		if (profileManagementInterface != null) {
			// If the Profile Specification defines a Profile Management Interface, the profileMBean interface has the same methods
			// 1. gather all methods from management interface
			for (CtMethod ctMethod : profileManagementInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					managementMethods.add(ctMethod);
				}
			}
			// 2. gather all methods present also in cmp interface, removing those from the ones gather from management interface
			for (CtMethod ctMethod : cmpProfileInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					if (managementMethods.remove(ctMethod)) {
						cmpAcessorMethods.add(ctMethod);					
					}
				}
			}
		}
		else {
			for (CtMethod ctMethod : cmpProfileInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					cmpAcessorMethods.add(ctMethod);									
				}
			}
		}
		
		// copy cmp acessor & mngt methods
		for (CtMethod ctMethod : cmpAcessorMethods) {
			// copy method
			CtMethod methodCopy = new CtMethod(ctMethod, profileMBeanConcreteInterface, null);
			// set exceptions
			CtClass[] exceptions = null;
			if(ctMethod.getName().startsWith("set")) {
				exceptions = cmpSetAcessorMethodExceptions;							
			}
			else if(ctMethod.getName().startsWith("get")) {
				exceptions = cmpGetAcessorMethodExceptions;
			}
			else {
				throw new DeploymentException("unexpected method in profile cmp interface "+ctMethod);
			}
			methodCopy.setExceptionTypes(exceptions);
			// add to class
			profileMBeanConcreteInterface.addMethod(methodCopy);
			// store in set to be used in mbean impl
			mBeanCmpAcessorMethods.add(methodCopy);
		}
		for (CtMethod ctMethod : managementMethods) {
			// copy method
			CtMethod methodCopy = new CtMethod(ctMethod, profileMBeanConcreteInterface, null);
			// set exceptions
			methodCopy.setExceptionTypes(managementMethodExceptions);
			// add to class
			profileMBeanConcreteInterface.addMethod(methodCopy);
			// store in set to be used in mbean impl
			mBeanManagementMethods.add(methodCopy);

		}
		
		// write class file
		try {
			profileMBeanConcreteInterface.writeFile(this.component.getDeploymentDir().getAbsolutePath());
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(), e);
		}
		finally {
			profileMBeanConcreteInterface.defrost();	
		}
		
		// and load it to the component
		try {
			this.component.setProfileMBeanConcreteInterfaceClass(Thread.currentThread().getContextClassLoader().loadClass(profileMBeanConcreteInterfaceName));
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(), e);
		}	
	}
public void generateProfileMBeanInterface() throws Exception {
		
		if (SleeProfileClassCodeGenerator.checkCombination(component) == -1) {
			throw new DeploymentException("Profile Specification doesn't match any combination " + "from the JSLEE spec 1.0 section 10.5.2");
		}
		
		String profileMBeanConcreteInterfaceName = cmpProfileInterfaceName + "MBean";
		
		profileMBeanConcreteInterface = pool.makeInterface(profileMBeanConcreteInterfaceName);

		try {
			cmpProfileInterface = pool.get(cmpProfileInterfaceName);
			profileManagementInterface = profileManagementInterfaceName != null ? pool.get(profileManagementInterfaceName) : null;
		}
		catch (NotFoundException nfe) {
			throw new DeploymentException("Failed to locate CMP/Management Interface for " + component, nfe);
		}
		
		// set interface
		try {
			profileMBeanConcreteInterface.addInterface(pool.get(AbstractProfileMBean.class.getName()));
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(),e);
		}
		
		// gather exceptions that the mbean methods may throw
		CtClass[] managementMethodExceptions = new CtClass[3];
		try {
			managementMethodExceptions[0] = pool.get(ManagementException.class.getName());
			managementMethodExceptions[1] = pool.get(InvalidStateException.class.getName());
			managementMethodExceptions[2] = pool.get(ProfileImplementationException.class.getName());
		}
		catch (NotFoundException e) {
			throw new SLEEException(e.getMessage(),e);
		}
		CtClass[] cmpGetAcessorMethodExceptions = new CtClass[] {managementMethodExceptions[0]};
		CtClass[] cmpSetAcessorMethodExceptions = new CtClass[] {managementMethodExceptions[0],managementMethodExceptions[1]};
		
		// gather all Object class methods, we don't want those in the mbean
		Set<CtMethod> objectMethods = new HashSet<CtMethod>();
		try {
			CtClass objectClass = pool.get(Object.class.getName());
			for (CtMethod ctMethod : objectClass.getMethods()) {
				objectMethods.add(ctMethod);
			}
		}
		catch (NotFoundException e) {
			throw new SLEEException(e.getMessage(),e);
		}
		
		// gather methods to copy
		Set<CtMethod> cmpAcessorMethods = new HashSet<CtMethod>();
		Set<CtMethod> managementMethods = new HashSet<CtMethod>();
		if (profileManagementInterface != null) {
			// If the Profile Specification defines a Profile Management Interface, the profileMBean interface has the same methods
			// 1. gather all methods from management interface
			for (CtMethod ctMethod : profileManagementInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					managementMethods.add(ctMethod);
				}
			}
			// 2. gather all methods present also in cmp interface, removing those from the ones gather from management interface
			for (CtMethod ctMethod : cmpProfileInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					if (managementMethods.remove(ctMethod)) {
						cmpAcessorMethods.add(ctMethod);					
					}
				}
			}
		}
		else {
			for (CtMethod ctMethod : cmpProfileInterface.getMethods()) {
				if (!objectMethods.contains(ctMethod)) {
					cmpAcessorMethods.add(ctMethod);									
				}
			}
		}
		
		// copy cmp acessor & mngt methods
		for (CtMethod ctMethod : cmpAcessorMethods) {
			// copy method
			CtMethod methodCopy = new CtMethod(ctMethod, profileMBeanConcreteInterface, null);
			// set exceptions
			CtClass[] exceptions = null;
			if(ctMethod.getName().startsWith("set")) {
				exceptions = cmpSetAcessorMethodExceptions;							
			}
			else if(ctMethod.getName().startsWith("get")) {
				exceptions = cmpGetAcessorMethodExceptions;
			}
			else {
				throw new DeploymentException("unexpected method in profile cmp interface "+ctMethod);
			}
			methodCopy.setExceptionTypes(exceptions);
			// add to class
			profileMBeanConcreteInterface.addMethod(methodCopy);
			// store in set to be used in mbean impl
			mBeanCmpAcessorMethods.add(methodCopy);
		}
		for (CtMethod ctMethod : managementMethods) {
			// copy method
			CtMethod methodCopy = new CtMethod(ctMethod, profileMBeanConcreteInterface, null);
			// set exceptions
			methodCopy.setExceptionTypes(managementMethodExceptions);
			// add to class
			profileMBeanConcreteInterface.addMethod(methodCopy);
			// store in set to be used in mbean impl
			mBeanManagementMethods.add(methodCopy);

		}
		
		// write class file
		try {
			profileMBeanConcreteInterface.writeFile(this.component.getDeploymentDir().getAbsolutePath());
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(), e);
		}
		finally {
			profileMBeanConcreteInterface.defrost();	
		}
		
		// and load it to the component
		try {
			this.component.setProfileMBeanConcreteInterfaceClass(Thread.currentThread().getContextClassLoader().loadClass(profileMBeanConcreteInterfaceName));
		}
		catch (Throwable e) {
			throw new SLEEException(e.getMessage(), e);
		}	
	}
Generates the Profile MBean interface

@return the interface generated