You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2012/11/26 20:16:36 UTC
svn commit: r1413788 [1/3] - in /airavata/trunk/modules:
airavata-client/src/main/java/org/apache/airavata/client/
gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/
gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/ re...
Author: chathuri
Date: Mon Nov 26 19:16:30 2012
New Revision: 1413788
URL: http://svn.apache.org/viewvc?rev=1413788&view=rev
Log:
updating service methods to have a pool of airavataRegistry2 objects from the context
Added:
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/utils/RegIdentifier.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/utils/RegPoolUtils.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryInstancesPool.java
Removed:
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java
Modified:
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/RestServicesConstants.java
airavata/trunk/modules/rest/service/pom.xml
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ExperimentRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProjectRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProvenanceRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/PublishWorkflowRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/UserWorkflowRegistryResource.java
airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java
airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java
airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java Mon Nov 26 19:16:30 2012
@@ -51,7 +51,6 @@ public class AiravataAPIFactory {
AiravataClient apiObj = new AiravataClient();
apiObj.setCurrentUser(alternateUsername);
apiObj.setCallBack(callback);
- apiObj.setPassword(callback.getPassword(username));
apiObj.setRegitryURI(registryURL);
apiObj.setGateway(gateway);
return apiObj;
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java Mon Nov 26 19:16:30 2012
@@ -113,7 +113,6 @@ public class AiravataClient implements A
private static String workflow = "";
private static WorkflowContextHeaderBuilder builder;
private String currentUser;
- private String password;
private URI regitryURI;
private PasswordCallback callBack;
@@ -988,16 +987,16 @@ public class AiravataClient implements A
}
}
- public void setPassword(String password) {
- this.password = password;
- }
-
public void setRegitryURI(URI regitryURI) {
this.regitryURI = regitryURI;
}
public String getPassword() {
- return password;
+ if(getCallBack() != null){
+ return getCallBack().getPassword(getCurrentUser());
+ }
+ return null;
+
}
public URI getRegitryURI() {
Modified: airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java (original)
+++ airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java Mon Nov 26 19:16:30 2012
@@ -75,7 +75,7 @@ public class GFacService implements Serv
public static final String GFAC_CONFIGURATION = "gfacConfiguration";
public static final String GATEWAY_ID = "gateway.id";
public static final String REGISTRY_PASSWORD = "registry.password";
- public static final String REGISTRY_URL = "registry.jdbc.url";
+// public static final String REGISTRY_URL = "registry.jdbc.url";
/*
* Heart beat thread
@@ -135,8 +135,8 @@ public class GFacService implements Serv
} catch (IOException e) {
e.printStackTrace();
}
- URI baseUri = new URI(properties.getProperty(REGISTRY_URL));
- airavataAPI = AiravataAPIFactory.getAPI(baseUri, username, password);
+ String gatewayName = properties.getProperty(GATEWAY_ID);
+ airavataAPI = AiravataAPIFactory.getAPI(gatewayName, username);
context.setProperty(GFAC_URL, ServiceUtils.generateServiceURLFromConfigurationContext(context,SERVICE_NAME));
GFacConfiguration gfacConfig = new GFacConfiguration(properties.getProperty(MYPROXY_SERVER),properties.getProperty(MYPROXY_USER),
properties.getProperty(MYPROXY_PASS),Integer.parseInt(properties.getProperty(MYPROXY_LIFE)),airavataAPI,properties.getProperty(TRUSTED_CERT_LOCATION));
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java Mon Nov 26 19:16:30 2012
@@ -108,6 +108,7 @@ public class PropertiesBasedServiceImpl
public static final String REGISTRY_PASSWORD = "registry.password";
public static final String REGISTRY_USER = "registry.user";
public static final String REGISTRY_URL = "registry.jdbc.url";
+ public static final String GATEWAY_ID = "gateway.id";
private Scheduler scheduler;
private PreExecuteChain[] preChain;
@@ -248,7 +249,8 @@ public class PropertiesBasedServiceImpl
baseUri = new URI(loadFromProperty(REGISTRY_URL, true));
String regUser = loadFromProperty(REGISTRY_USER, true);
String regUserPW = loadFromProperty(REGISTRY_PASSWORD, true);
- airavataAPI = AiravataAPIFactory.getAPI(baseUri, regUser, regUserPW);
+ String gateway = loadFromProperty(GATEWAY_ID, true);
+ airavataAPI = AiravataAPIFactory.getAPI(gateway, regUser);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (RepositoryException e) {
Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java (original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java Mon Nov 26 19:16:30 2012
@@ -39,6 +39,8 @@ public class JPAResourceAccessor {
}
public GatewayResource getGateway(){
+ gatewayResource = new GatewayResource();
+ gatewayResource.setGatewayName(this.registry.getGateway().getGatewayName());
return gatewayResource;
}
@@ -47,6 +49,7 @@ public class JPAResourceAccessor {
}
public WorkerResource getWorker(){
+ workerResource = new WorkerResource(registry.getUser().getUserName(), getGateway());
return workerResource;
}
}
Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java (original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java Mon Nov 26 19:16:30 2012
@@ -26,7 +26,7 @@ import org.apache.airavata.rest.client.*
public class Test {
public static void main(String[] args) {
-// configurationResourceClientTest();
+ configurationResourceClientTest();
// hostDescriptorClientTest();
// serviceDescriptorClientTest();
// appDescriptorClientTest();
@@ -34,17 +34,18 @@ public class Test {
// experimentRegistryClient();
// userWFClientTest();
// publishWFClientTest();
- provenanceClientTest();
+// provenanceClientTest();
}
public static void configurationResourceClientTest(){
//configuration resource test
-// ConfigurationResourceClient configurationResourceClient = new ConfigurationResourceClient();
+ ConfigurationResourceClient configurationResourceClient = new ConfigurationResourceClient("admin", new PasswordCallbackImpl("admin", "admin"));
-// System.out.println("###############getConfiguration###############");
-// Object configuration = configurationResourceClient.getConfiguration("interpreter.url");
-// System.out.println(configuration.toString());
+
+ System.out.println("###############getConfiguration###############");
+ Object configuration = configurationResourceClient.getConfiguration("key3");
+ System.out.println(configuration.toString());
//
// System.out.println("###############getConfigurationList###############");
// configurationResourceClient.addWFInterpreterURI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor2");
Added: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java?rev=1413788&view=auto
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java (added)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java Mon Nov 26 19:16:30 2012
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.rest.client;
+
+import org.apache.airavata.registry.api.PasswordCallback;
+
+public class PasswordCallbackImpl implements PasswordCallback {
+
+ private String username;
+ private String password;
+
+ public PasswordCallbackImpl(String password, String username) {
+ this.password = password;
+ this.username = username;
+ }
+
+ @Override
+ public String getPassword(String username) {
+ return password;
+ }
+}
Modified: airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/RestServicesConstants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/RestServicesConstants.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/RestServicesConstants.java (original)
+++ airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/RestServicesConstants.java Mon Nov 26 19:16:30 2012
@@ -30,6 +30,8 @@ public class RestServicesConstants {
public static final String REGISTRY_USERNAME = "registry.user";
public static final String REGISTRY_USER = "airavata.user";
public static final String AIRAVATA_REGISTRY = "airavataRegistry";
+ public static final String AIRAVATA_REGISTRY_POOL = "airavataRegistryPool";
+
/**
* A method to use by clients in the case of Basic Access authentication.
Modified: airavata/trunk/modules/rest/service/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/service/pom.xml?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/service/pom.xml (original)
+++ airavata/trunk/modules/rest/service/pom.xml Mon Nov 26 19:16:30 2012
@@ -117,11 +117,11 @@
<version>1.3.168</version>
<scope>test</scope>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
- </dependency-->
+ </dependency>
<!-- Airavata -->
<dependency>
Modified: airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java (original)
+++ airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java Mon Nov 26 19:16:30 2012
@@ -26,7 +26,7 @@ import org.apache.airavata.registry.api.
import org.apache.airavata.registry.api.AiravataUser;
import org.apache.airavata.registry.api.Gateway;
import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.mappings.utils.RestServicesConstants;
+import org.apache.airavata.services.registry.rest.utils.RegPoolUtils;
import javax.servlet.ServletContext;
import javax.ws.rs.*;
@@ -36,19 +36,17 @@ import javax.ws.rs.core.Response;
@Path(ResourcePathConstants.BasicRegistryConstants.REGISTRY_API_BASICREGISTRY)
public class BasicRegistryResouce {
- protected static AiravataRegistry2 airavataRegistry;
-
@Context
ServletContext context;
@GET
@Path(ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response getGateway (){
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ public Response getGateway() {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Gateway gateway = airavataRegistry.getGateway();
- if (gateway != null){
+ if (gateway != null) {
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity(gateway);
return builder.build();
@@ -61,17 +59,21 @@ public class BasicRegistryResouce {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
@GET
@Path(ResourcePathConstants.BasicRegistryConstants.GET_USER)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response getAiravataUser (){
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ public Response getAiravataUser() {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
AiravataUser airavataUser = airavataRegistry.getAiravataUser();
- if (airavataUser != null){
+ if (airavataUser != null) {
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity(airavataUser);
return builder.build();
@@ -84,6 +86,10 @@ public class BasicRegistryResouce {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
@@ -91,8 +97,8 @@ public class BasicRegistryResouce {
@Path(ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY)
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces(MediaType.TEXT_PLAIN)
- public Response setGateway (Gateway gateway){
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ public Response setGateway(Gateway gateway) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.setGateway(gateway);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -102,6 +108,10 @@ public class BasicRegistryResouce {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
@@ -109,8 +119,8 @@ public class BasicRegistryResouce {
@Path(ResourcePathConstants.BasicRegistryConstants.SET_USER)
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces(MediaType.TEXT_PLAIN)
- public Response setAiravataUser (AiravataUser user){
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ public Response setAiravataUser(AiravataUser user) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.setAiravataUser(user);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -120,17 +130,21 @@ public class BasicRegistryResouce {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
@GET
@Path(ResourcePathConstants.BasicRegistryConstants.VERSION)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response getVersion (){
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ public Response getVersion() {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Version version = airavataRegistry.getVersion();
- if (version != null){
+ if (version != null) {
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity(version);
return builder.build();
@@ -143,6 +157,10 @@ public class BasicRegistryResouce {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
}
Modified: airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java (original)
+++ airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java Mon Nov 26 19:16:30 2012
@@ -21,11 +21,13 @@
package org.apache.airavata.services.registry.rest.resources;
+
import org.apache.airavata.registry.api.AiravataRegistry2;
import org.apache.airavata.rest.mappings.resourcemappings.ConfigurationList;
import org.apache.airavata.rest.mappings.resourcemappings.URLList;
import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
import org.apache.airavata.rest.mappings.utils.RestServicesConstants;
+import org.apache.airavata.services.registry.rest.utils.RegPoolUtils;
import javax.servlet.ServletContext;
import javax.ws.rs.*;
@@ -44,17 +46,20 @@ import java.util.List;
*/
@Path(ResourcePathConstants.ConfigResourcePathConstants.CONFIGURATION_REGISTRY_RESOURCE)
public class ConfigurationRegistryResource {
- private AiravataRegistry2 airavataRegistry;
@Context
ServletContext context;
+ public ConfigurationRegistryResource() {
+ }
+
/**
* ---------------------------------Configuration Registry----------------------------------*
*/
/**
* This method will return the configuration value corrosponding to given config key
+ *
* @param key configuration key
* @return HTTP Response
*/
@@ -62,7 +67,7 @@ public class ConfigurationRegistryResour
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response getConfiguration(@QueryParam("key") String key) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Object configuration = airavataRegistry.getConfiguration(key);
if (configuration != null) {
@@ -78,12 +83,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will return configuration list for given configuration key
+ *
* @param key configuration key
* @return HTTP response
*/
@@ -91,8 +101,9 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION_LIST)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getConfigurationList(@QueryParam("key") String key) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+
List<Object> configurationList = airavataRegistry.getConfigurationList(key);
ConfigurationList list = new ConfigurationList();
Object[] configValList = new Object[configurationList.size()];
@@ -113,15 +124,19 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
-
/**
* This method will add a configuration with given config key, config value and expiration date
- * @param key configuration key
+ *
+ * @param key configuration key
* @param value configuration value
- * @param date configuration expire data
+ * @param date configuration expire data
* @return HTTP response
*/
@POST
@@ -131,6 +146,7 @@ public class ConfigurationRegistryResour
public Response setConfiguration(@FormParam("key") String key,
@FormParam("value") String value,
@FormParam("date") String date) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -143,16 +159,21 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update the configuration according to the given config value and expire
* date
- * @param key config key
+ *
+ * @param key config key
* @param value config value
* @param date expiration date
- * @return HTTP response
+ * @return HTTP response
*/
@POST
@Path(ResourcePathConstants.ConfigResourcePathConstants.UPDATE_CONFIGURATION)
@@ -160,6 +181,7 @@ public class ConfigurationRegistryResour
public Response addConfiguration(@FormParam("key") String key,
@FormParam("value") String value,
@FormParam("date") String date) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -172,11 +194,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will delete all configuration of the given config key
+ *
* @param key configuration key
* @return HTTP response
*/
@@ -184,8 +211,8 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_CONFIGURATION)
@Produces(MediaType.TEXT_PLAIN)
public Response removeAllConfiguration(@QueryParam("key") String key) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
airavataRegistry.removeAllConfiguration(key);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity("All configurations with given config key removed successfully...");
@@ -194,12 +221,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will delete the configuration with the given config key and config value
- * @param key configuration key
+ *
+ * @param key configuration key
* @param value configuration value
* @return HTTP response
*/
@@ -207,8 +239,8 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_CONFIGURATION)
@Produces(MediaType.TEXT_PLAIN)
public Response removeConfiguration(@QueryParam("key") String key, @QueryParam("value") String value) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
airavataRegistry.removeConfiguration(key, value);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity("Configuration removed successfully...");
@@ -217,18 +249,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve all the GFac URIs
- * @return HTTP response
+ *
+ * @return HTTP response
*/
@GET
@Path(ResourcePathConstants.ConfigResourcePathConstants.GET_GFAC_URI_LIST)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getGFacURIs() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
List<URI> uris = airavataRegistry.getGFacURIs();
URLList list = new URLList();
@@ -250,18 +287,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve all the workflow interpreter URIs
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.ConfigResourcePathConstants.GET_WFINTERPRETER_URI_LIST)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getWorkflowInterpreterURIs() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
List<URI> uris = airavataRegistry.getWorkflowInterpreterURIs();
URLList list = new URLList();
@@ -283,18 +325,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve eventing URI
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.ConfigResourcePathConstants.GET_EVENTING_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response getEventingServiceURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI eventingServiceURI = airavataRegistry.getEventingServiceURI();
if (eventingServiceURI != null) {
@@ -310,18 +357,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve messagebox URI
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.ConfigResourcePathConstants.GET_MESSAGE_BOX_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response getMessageBoxURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI eventingServiceURI = airavataRegistry.getMessageBoxURI();
if (eventingServiceURI != null) {
@@ -337,11 +389,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will add new GFac URI
+ *
* @param uri gfac URI
* @return HTTP response
*/
@@ -349,7 +406,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response addGFacURI(@FormParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI gfacURI = new URI(uri);
airavataRegistry.addGFacURI(gfacURI);
@@ -360,11 +417,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will add new workflow interpreter URI
+ *
* @param uri workflow interpreter URI
* @return HTTP response
*/
@@ -372,7 +434,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response addWorkflowInterpreterURI(@FormParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI interpreterURI = new URI(uri);
airavataRegistry.addWorkflowInterpreterURI(interpreterURI);
@@ -383,11 +445,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will set a new eventing URI
+ *
* @param uri eventing URI
* @return HTTP response
*/
@@ -395,7 +462,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response setEventingURI(@FormParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI eventingURI = new URI(uri);
airavataRegistry.setEventingURI(eventingURI);
@@ -406,11 +473,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will set message box URI
+ *
* @param uri message box URI
* @return HTTP response
*/
@@ -418,7 +490,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MESSAGE_BOX_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response setMessageBoxURI(@FormParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI msgBoxURI = new URI(uri);
airavataRegistry.setMessageBoxURI(msgBoxURI);
@@ -429,12 +501,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update GFac URI expiring date
- * @param uri GFac URI
+ *
+ * @param uri GFac URI
* @param date Expiration date
* @return HTTP response
*/
@@ -442,7 +519,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI_DATE)
@Produces(MediaType.TEXT_PLAIN)
public Response addGFacURIByDate(@FormParam("uri") String uri, @FormParam("date") String date) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -455,12 +532,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update workflow interpreter URI expiration date
- * @param uri workflow interpreter URI
+ *
+ * @param uri workflow interpreter URI
* @param date workflow interpreter expiration date
* @return HTTP response
*/
@@ -468,7 +550,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI_DATE)
@Produces(MediaType.TEXT_PLAIN)
public Response addWorkflowInterpreterURI(@FormParam("uri") String uri, @FormParam("date") String date) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -481,12 +563,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update Eventing URI expiration date
- * @param uri eventing URI
+ *
+ * @param uri eventing URI
* @param date eventing URI expiration date
* @return HTTP response
*/
@@ -494,7 +581,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI_DATE)
@Produces(MediaType.TEXT_PLAIN)
public Response setEventingURIByDate(@FormParam("uri") String uri, @FormParam("date") String date) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -507,12 +594,17 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
- * This method will update expiration date of Message box URI
- * @param uri message box URI
+ * This method will update expiration date of Message box URI
+ *
+ * @param uri message box URI
* @param date message box expiration date
* @return HTTP response
*/
@@ -520,7 +612,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MSG_BOX_URI_DATE)
@Produces(MediaType.TEXT_PLAIN)
public Response setMessageBoxURIByDate(@FormParam("uri") String uri, @FormParam("date") String date) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date formattedDate = dateFormat.parse(date);
@@ -533,11 +625,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove GFac URI
+ *
* @param uri GFac URI
* @return HTTP response
*/
@@ -545,7 +642,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_GFAC_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response removeGFacURI(@QueryParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI gfacURI = new URI(uri);
airavataRegistry.removeGFacURI(gfacURI);
@@ -556,18 +653,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove all the GFac URIs
+ *
* @return HTTP response
*/
@DELETE
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_GFAC_URIS)
@Produces(MediaType.TEXT_PLAIN)
public Response removeAllGFacURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.removeAllGFacURI();
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -577,11 +679,16 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove workflow interpreter URI
+ *
* @param uri workflow interpreter URI
* @return HTTP response
*/
@@ -589,7 +696,7 @@ public class ConfigurationRegistryResour
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_WFINTERPRETER_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response removeWorkflowInterpreterURI(@QueryParam("uri") String uri) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
URI intURI = new URI(uri);
airavataRegistry.removeWorkflowInterpreterURI(intURI);
@@ -600,18 +707,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove all the workflow interpreter URIs
+ *
* @return HTTP response
*/
@DELETE
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_WFINTERPRETER_URIS)
@Produces(MediaType.TEXT_PLAIN)
public Response removeAllWorkflowInterpreterURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.removeAllWorkflowInterpreterURI();
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -621,18 +733,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove eventing URI
+ *
* @return HTTP response
*/
@DELETE
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_EVENTING_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response unsetEventingURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.unsetEventingURI();
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -642,18 +759,23 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will remove message box URI
+ *
* @return HTTP response
*/
@DELETE
@Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_MSG_BOX_URI)
@Produces(MediaType.TEXT_PLAIN)
public Response unsetMessageBoxURI() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.unsetMessageBoxURI();
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -663,6 +785,10 @@ public class ConfigurationRegistryResour
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
Modified: airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java?rev=1413788&r1=1413787&r2=1413788&view=diff
==============================================================================
--- airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java (original)
+++ airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java Mon Nov 26 19:16:30 2012
@@ -32,7 +32,7 @@ import org.apache.airavata.registry.api.
import org.apache.airavata.rest.mappings.resourcemappings.*;
import org.apache.airavata.rest.mappings.utils.DescriptorUtil;
import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.mappings.utils.RestServicesConstants;
+import org.apache.airavata.services.registry.rest.utils.RegPoolUtils;
import javax.servlet.ServletContext;
import javax.ws.rs.*;
@@ -49,7 +49,6 @@ import java.util.Map;
*/
@Path(ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH)
public class DescriptorRegistryResource {
- private AiravataRegistry2 airavataRegistry;
@Context
ServletContext context;
@@ -61,6 +60,7 @@ public class DescriptorRegistryResource
/**
* This method will check whether the host descriptor exists
+ *
* @param hostDescriptorName host descriptor name
* @return HTTP response
*/
@@ -68,7 +68,7 @@ public class DescriptorRegistryResource
@Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS)
@Produces(MediaType.TEXT_PLAIN)
public Response isHostDescriptorExists(@QueryParam("hostDescriptorName") String hostDescriptorName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
boolean state;
try {
state = airavataRegistry.isHostDescriptorExists(hostDescriptorName);
@@ -85,11 +85,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will save the host descriptor
+ *
* @param host JSON message send according to HostDescriptor class
* @return HTTP response
*/
@@ -98,7 +103,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response addHostDescriptor(HostDescriptor host) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
HostDescription hostDescription = DescriptorUtil.createHostDescription(host);
airavataRegistry.addHostDescriptor(hostDescription);
@@ -113,11 +118,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update the host descriptor
+ *
* @param host JSON message send according to HostDescriptor class
* @return HTTP response
*/
@@ -126,7 +136,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response updateHostDescriptor(HostDescriptor host) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
HostDescription hostDescription = DescriptorUtil.createHostDescription(host);
airavataRegistry.updateHostDescriptor(hostDescription);
@@ -141,21 +151,26 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve host descriptor. Clients will get a JSON message that is generated
* according to HostDescriptor class
+ *
* @param hostName host name
- * @return HTTP response
+ * @return HTTP response
*/
@GET
@Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC)
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getHostDescriptor(@QueryParam("hostName") String hostName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
HostDescription hostDescription = airavataRegistry.getHostDescriptor(hostName);
HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
@@ -172,12 +187,17 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will delete the given host descriptor
+ *
* @param hostName host descriptor name
* @return HTTP response
*/
@@ -185,7 +205,7 @@ public class DescriptorRegistryResource
@Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE)
@Produces(MediaType.TEXT_PLAIN)
public Response removeHostDescriptor(@QueryParam("hostName") String hostName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.removeHostDescriptor(hostName);
Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
@@ -199,11 +219,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve all the host descriptors available.
+ *
* @return HTTP response
*/
@GET
@@ -211,7 +236,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getHostDescriptors() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
List<HostDescription> hostDescriptionList = airavataRegistry.getHostDescriptors();
HostDescriptionList list = new HostDescriptionList();
@@ -234,18 +259,23 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will return all the host descriptor names available
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getHostDescriptorNames() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
List<HostDescription> hostDescriptionList = airavataRegistry.getHostDescriptors();
List<String> hostDescriptorNames = new ArrayList<String>();
@@ -267,11 +297,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will check whether the service descriptor available
+ *
* @param serviceDescriptorName service descriptor name
* @return HTTP response
*/
@@ -279,7 +314,7 @@ public class DescriptorRegistryResource
@Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS)
@Produces(MediaType.TEXT_PLAIN)
public Response isServiceDescriptorExists(@QueryParam("serviceDescriptorName") String serviceDescriptorName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
boolean state;
try {
state = airavataRegistry.isServiceDescriptorExists(serviceDescriptorName);
@@ -296,11 +331,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will save the service descriptor
+ *
* @param service this is a JSON message created according to ServiceDescriptor class
* @return HTTP response
*/
@@ -309,7 +349,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response addServiceDescriptor(ServiceDescriptor service) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(service);
airavataRegistry.addServiceDescriptor(serviceDescription);
@@ -324,11 +364,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update the service descriptor
+ *
* @param service this is a JSON message generated according to Service Descriptor class
* @return HTTP response
*/
@@ -337,7 +382,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response updateServiceDescriptor(ServiceDescriptor service) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(service);
airavataRegistry.updateServiceDescriptor(serviceDescription);
@@ -352,13 +397,18 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve service descriptor for a given service descriptor name. Clients
* will get a JSON message that is generated according to Service Descriptor class
- * @param serviceName service name
+ *
+ * @param serviceName service name
* @return HTTP response
*/
@GET
@@ -366,7 +416,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getServiceDescriptor(@QueryParam("serviceName") String serviceName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(serviceName);
ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
@@ -383,11 +433,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will delete a given service descriptor
+ *
* @param serviceName service descriptor name
* @return HTTP response
*/
@@ -395,7 +450,7 @@ public class DescriptorRegistryResource
@Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE)
@Produces(MediaType.TEXT_PLAIN)
public Response removeServiceDescriptor(@QueryParam("serviceName") String serviceName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.removeServiceDescriptor(serviceName);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
@@ -409,11 +464,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve all the service descriptors
+ *
* @return HTTP response
*/
@GET
@@ -421,7 +481,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getServiceDescriptors() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
List<ServiceDescription> serviceDescriptors = airavataRegistry.getServiceDescriptors();
ServiceDescriptionList list = new ServiceDescriptionList();
@@ -444,14 +504,19 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will check whether the given application descriptor exists
- * @param serviceName service descriptor name
- * @param hostName host descriptor name
+ *
+ * @param serviceName service descriptor name
+ * @param hostName host descriptor name
* @param appDescriptorName application descriptor name
* @return HTTP response
*/
@@ -461,7 +526,7 @@ public class DescriptorRegistryResource
public Response isApplicationDescriptorExists(@QueryParam("serviceName") String serviceName,
@QueryParam("hostName") String hostName,
@QueryParam("appDescName") String appDescriptorName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
boolean state;
try {
state = airavataRegistry.isApplicationDescriptorExists(serviceName, hostName, appDescriptorName);
@@ -478,13 +543,18 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will save given application descriptor
+ *
* @param applicationDescriptor this is a JSON message created according to
- * ApplicationDescriptor class
+ * ApplicationDescriptor class
* @return HTTP response
*/
@POST
@@ -492,7 +562,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response addApplicationDescriptor(ApplicationDescriptor applicationDescriptor) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
String hostdescName = applicationDescriptor.getHostdescName();
if (!airavataRegistry.isHostDescriptorExists(hostdescName)) {
@@ -531,11 +601,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will update the application descriptor
+ *
* @param applicationDescriptor JSON message of ApplicationDescriptor class
* @return HTTP response
*/
@@ -544,7 +619,7 @@ public class DescriptorRegistryResource
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response udpateApplicationDescriptor(ApplicationDescriptor applicationDescriptor) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
String hostdescName = applicationDescriptor.getHostdescName();
if (!airavataRegistry.isHostDescriptorExists(hostdescName)) {
@@ -584,15 +659,20 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve an application descriptor according to given service name, host name
* and application name
- * @param serviceName service name
- * @param hostName host name
- * @param applicationName application name
+ *
+ * @param serviceName service name
+ * @param hostName host name
+ * @param applicationName application name
* @return HTTP response
*/
@GET
@@ -601,7 +681,7 @@ public class DescriptorRegistryResource
public Response getApplicationDescriptor(@QueryParam("serviceName") String serviceName,
@QueryParam("hostName") String hostName,
@QueryParam("applicationName") String applicationName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
ApplicationDeploymentDescription applicationDeploymentDescription = airavataRegistry.getApplicationDescriptor(serviceName, hostName, applicationName);
ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDeploymentDescription);
@@ -623,21 +703,26 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve application descriptors for a given service and host
+ *
* @param serviceName service name
- * @param hostName host name
+ * @param hostName host name
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getApplicationDescriptorPerServiceHost(@QueryParam("serviceName") String serviceName,
- @QueryParam("hostName") String hostName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ @QueryParam("hostName") String hostName) {
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
ApplicationDeploymentDescription applicationDeploymentDescription = airavataRegistry.getApplicationDescriptors(serviceName, hostName);
ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDeploymentDescription);
@@ -659,11 +744,16 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will get all the application descriptors for a given service
+ *
* @param serviceName service name
* @return HTTP response
*/
@@ -671,7 +761,7 @@ public class DescriptorRegistryResource
@Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getApplicationDescriptors(@QueryParam("serviceName") String serviceName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Map<String, ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors(serviceName);
ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
@@ -707,18 +797,23 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will retrieve all the application descriptors available
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getApplicationDescriptors() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors();
ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
@@ -756,18 +851,23 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method will return all the application names available
+ *
* @return HTTP response
*/
@GET
@Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getApplicationDescriptorNames() {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors();
DescriptorNameList descriptorNameList = new DescriptorNameList();
@@ -794,15 +894,20 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
/**
* This method wil remove an application descriptor according to given service name, host name
* and application name
+ *
* @param serviceName service name
- * @param hostName host name
- * @param appName application name
+ * @param hostName host name
+ * @param appName application name
* @return HTTP response
*/
@DELETE
@@ -811,7 +916,7 @@ public class DescriptorRegistryResource
public Response removeApplicationDescriptor(@QueryParam("serviceName") String serviceName,
@QueryParam("hostName") String hostName,
@QueryParam("appName") String appName) {
- airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+ AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry();
try {
airavataRegistry.removeApplicationDescriptor(serviceName, hostName, appName);
Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
@@ -825,6 +930,10 @@ public class DescriptorRegistryResource
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity(e.getMessage());
return builder.build();
+ } finally {
+ if (airavataRegistry != null) {
+ RegPoolUtils.releaseRegistry(airavataRegistry);
+ }
}
}
}