net.anotheria.portalkit.services.profileservice.ProfileServiceFactory Maven / Gradle / Ivy
package net.anotheria.portalkit.services.profileservice;
import net.anotheria.anoprise.metafactory.AbstractParameterizedServiceFactory;
import java.io.Serializable;
/**
* @author asamoilich.
*/
public class ProfileServiceFactory extends AbstractParameterizedServiceFactory> {
/**
* Parameter name for entity class.
* Required.
*/
public static final String PARAMETER_ENTITY_CLASS = "entityClass";
/**
* Parameter name for {@link ProfileServiceConfig} configuration name.
* Not required. If null
default configuration name will be used.
*/
public static final String PARAMETER_CONFIGURATION = "conf";
/**
* Parameter name for ConfigureMe {@link org.configureme.Environment} configuration.
* Not required. If null
current system environment will be used.
*/
public static final String PARAMETER_ENVIRONMENT = "env";
@Override
public ProfileService create() {
Serializable rawEntityClass = getParameterValue(PARAMETER_ENTITY_CLASS);
if (rawEntityClass == null || !(rawEntityClass instanceof Class))
throw new RuntimeException("Wrong entity class[" + rawEntityClass + "] configuration.");
@SuppressWarnings("unchecked")
Class entityClass = (Class) rawEntityClass;
String conf = getParameterValueAsString(PARAMETER_CONFIGURATION);
String env = getParameterValueAsString(PARAMETER_ENVIRONMENT);
return new ProfileServiceImpl(entityClass, conf, env);
}
}