package eu.dnetlib.enabling.tools.registration; import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.PENDING; import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.REGISTERED; /** * This service registration manager implementation performs automatic service profile validation. *
* This is useful during automated testing. You can use it simply by overriding the default class in the service * registration manager bean template: *
* ** <template:instance name="serviceRegistrationManager" * t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl" * t:name="myServiceRegistrationManager" t:service="myService" t:endpoint="myServiceEndpoint" * t:jobScheduler="jobScheduler"/> ** *
* If your service needs to receive blackboard messages, the notification can be automatically subscribed to your * service profile simply by using a different service registrator component (blackboardServiceRegistrator): *
* ** <template:instance name="serviceRegistrationManager" * t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl" * t:name="myServiceRegistrationManager" t:service="myService" t:endpoint="myServiceEndpoint" * t:jobScheduler="jobScheduler" t:serviceRegistrator="blackboardServiceRegistrator"/> ** *
* This option is very useful for example to the MDStoreService or the IndexService. *
* * @author marko * */ public class ValidatingServiceRegistrationManagerImpl extends ServiceRegistrationManagerImpl { /** * {@inheritDoc} * * @see eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl#tick() */ @Override public void tick() { synchronized (getRegistrator()) { if (getState() == PENDING) { if(getProfileId() == null) { throw new IllegalStateException("State is PENDING but profile id isn't initialized"); } final String newId = getRegistrator().validateProfile(getProfileId(), getEndpoint()); setProfileId(newId); setState(REGISTERED); return; } } super.tick(); } }