added the retrieval of eprs from IS for a specified service - to be removed later

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@37740 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Rena Tsantouli 2011-04-19 09:12:45 +00:00
parent 6bc34aa6de
commit 7c4903adaa
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package org.gcube.application.framework.core.util;
import java.util.Random;
import org.apache.axis.message.addressing.EndpointReference;
import org.gcube.application.framework.core.cache.RIsManager;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.informationsystem.cache.SrvType;
public class ServiceUtils {
/**
*
* @param srvClass The service class
* @param srvName The service name
* @param srvType The service type (SIMPLE, FACTORY or STATEFULL)
* @param session
* @return the epr Address
*/
public static String getEprAddressOfService(String srvClass, String srvName, String srvType, ASLSession session) {
EndpointReference[] eprs;
try {
eprs = RIsManager.getInstance().getISCache(
session.getScope()).getEPRsFor(srvClass, srvName,
srvType);
Random rand = new Random();
int random = rand.nextInt(eprs.length);
return eprs[random].getAddress().toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}