@SuppressWarnings("rawtypes")
	private BeanDefinition createProxyBeanDefinition(String serviceName,
			Class serviceInterface, Exposer exposer) {

		// HTTP http://host:port/contextPath/serviceName
		String httpServiceUrl = new StringBuilder(HTTP_PROTOCOL)
				.append(getHost()).append(":").append(getHttpPort())
				.append(getHttpContextPath()).append("/").append(serviceName)
				.toString();

		// RMI rmi://host:port//serviceName
		String rmiServiceUrl = new StringBuilder(RMI_PROTOCOL)
				.append(getHost()).append(":").append(getRmiPort()).append("/")
				.append(serviceName).toString();

		BeanDefinitionBuilder beanDefinitionBuilder = null;

		UsernamePasswordCredentials credentials = null;
		if (!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password))
			credentials = new UsernamePasswordCredentials(userName, password);

		if (Exposer.BURLAP == exposer) {
			LOGGER.debug("Creating BURLAP service definition");
			beanDefinitionBuilder = BeanDefinitionBuilder
					.genericBeanDefinition(BurlapProxyFactoryBean.class)
					.addPropertyValue("serviceInterface", serviceInterface)
					.addPropertyValue("serviceUrl", httpServiceUrl);
			if (null != credentials) {
				beanDefinitionBuilder.addPropertyValue("username",
						credentials.getUserName()).addPropertyValue("password",
						credentials.getPassword());
			}
		} else if (Exposer.HESSIAN == exposer) {
			LOGGER.debug("Creating HESSIAN service definition");
			beanDefinitionBuilder = BeanDefinitionBuilder
					.genericBeanDefinition(HessianProxyFactoryBean.class)
					.addPropertyValue("serviceInterface", serviceInterface)
					.addPropertyValue("serviceUrl", httpServiceUrl);
			if (null != credentials) {
				beanDefinitionBuilder.addPropertyValue("username",
						credentials.getUserName()).addPropertyValue("password",
						credentials.getPassword());
			}
		} else if (Exposer.HTTP == exposer) {
			LOGGER.debug("Creating HTTP service definition");
			beanDefinitionBuilder = BeanDefinitionBuilder
					.genericBeanDefinition(HttpInvokerProxyFactoryBean.class)
					.addPropertyValue("serviceInterface", serviceInterface)
					.addPropertyValue("serviceUrl", httpServiceUrl);
			if (null != credentials) {
				SimpleHttpState httpState = new SimpleHttpState();
				httpState.setCredentials(credentials);
				HttpClient httpClient = new HttpClient();
				httpClient.setState(httpState);
				beanDefinitionBuilder.addPropertyValue(
						"httpInvokerRequestExecutor",
						new CommonsHttpInvokerRequestExecutor(httpClient));
			}
		} else if (Exposer.RMI == exposer) {
			LOGGER.debug("Creating RMI service definition");
			beanDefinitionBuilder = BeanDefinitionBuilder
					.genericBeanDefinition(RmiProxyFactoryBean.class)
					.addPropertyValue("serviceInterface", serviceInterface)
					.addPropertyValue("serviceUrl", rmiServiceUrl);
		}

		return beanDefinitionBuilder.getBeanDefinition();
	}