Collection<ServiceConfig> services = new ArrayList<ServiceConfig>();
// Set the service type (one service config instance created per service type)
//
if ( pws.getTypes() == null || pws.getTypes().length < 1 ) {
throw new PlatformPluginRegistrationException( Messages.getInstance().getErrorString(
"PluginManager.ERROR_0023_SERVICE_TYPE_UNSPECIFIED", pws.getId() ) ); //$NON-NLS-1$
}
for ( String type : pws.getTypes() ) {
ServiceConfig ws = new ServiceConfig();
ws.setServiceType( type );
ws.setTitle( pws.getTitle() );
ws.setDescription( pws.getDescription() );
String serviceClassName =
( StringUtils.isEmpty( pws.getServiceClass() ) ) ? pws.getServiceBeanId() : pws.getServiceClass();
String serviceId;
if ( !StringUtils.isEmpty( pws.getId() ) ) {
serviceId = pws.getId();
} else {
serviceId = serviceClassName;
if ( serviceClassName.indexOf( '.' ) > 0 ) {
serviceId = serviceClassName.substring( serviceClassName.lastIndexOf( '.' ) + 1 );
}
}
ws.setId( serviceId );
// Register the service class
//
final String serviceClassKey =
ws.getServiceType() + "-" + ws.getId() + "/" + serviceClassName; //$NON-NLS-1$ //$NON-NLS-2$
assertUnique( plugin.getId(), serviceClassKey );
// defining plugin beans the old way through the plugin provider ifc supports only prototype scope
BeanDefinition beanDef =
BeanDefinitionBuilder.rootBeanDefinition( serviceClassName ).setScope( BeanDefinition.SCOPE_PROTOTYPE )
.getBeanDefinition();
beanFactoryMap.get( plugin.getId() ).registerBeanDefinition( serviceClassKey, beanDef );
if ( !this.isBeanRegistered( serviceClassKey ) ) {
throw new PlatformPluginRegistrationException( Messages.getInstance().getErrorString(
"PluginManager.ERROR_0020_NO_SERVICE_CLASS_REGISTERED", serviceClassKey ) ); //$NON-NLS-1$
}
// Load/set the service class and supporting types
//
try {
ws.setServiceClass( loadClass( serviceClassKey ) );
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
if ( pws.getExtraClasses() != null ) {
for ( String extraClass : pws.getExtraClasses() ) {
classes.add( loadClass( extraClass ) );
}
}
ws.setExtraClasses( classes );
} catch ( PluginBeanException e ) {
throw new PlatformPluginRegistrationException( Messages.getInstance().getErrorString(
"PluginManager.ERROR_0021_SERVICE_CLASS_LOAD_FAILED", serviceClassKey ), e ); //$NON-NLS-1$
}
services.add( ws );
}