From 7c4903adaab747c86ba447a99cfc641216ec1d47 Mon Sep 17 00:00:00 2001 From: Rena Tsantouli Date: Tue, 19 Apr 2011 09:12:45 +0000 Subject: [PATCH] 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 --- .../framework/core/util/ServiceUtils.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/org/gcube/application/framework/core/util/ServiceUtils.java diff --git a/src/org/gcube/application/framework/core/util/ServiceUtils.java b/src/org/gcube/application/framework/core/util/ServiceUtils.java new file mode 100644 index 0000000..200832c --- /dev/null +++ b/src/org/gcube/application/framework/core/util/ServiceUtils.java @@ -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; + } + +}