aslcore/src/org/gcube/application/framework/core/util/ServiceUtils.java

40 lines
1.0 KiB
Java

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;
}
}