From 4cd93730318f63e5b47f4e8781b0472c1fa4ddf2 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Wed, 12 May 2010 09:02:17 +0000 Subject: [PATCH] LMS-1527 Added rpc-name-server to openBIS. SVN: 15930 --- .../generic/server/NameServerServlet.java | 60 +++++++++++++++++++ .../server/api/v1/QueryServiceServer.java | 16 ++++- .../query/shared/api/v1/IQueryApiServer.java | 14 +++-- .../source/java/genericApplicationContext.xml | 2 + 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/NameServerServlet.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/NameServerServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/NameServerServlet.java new file mode 100644 index 00000000000..5476119b7a1 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/NameServerServlet.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed 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 ch.systemsx.cisd.openbis.generic.server; + +import javax.annotation.Resource; + +import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import ch.systemsx.cisd.common.api.IRpcServiceNameServer; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; +import ch.systemsx.cisd.common.api.server.RpcServiceNameServer; +import ch.systemsx.cisd.common.spring.ServiceExceptionTranslator; + +/** + * A servlet that exports the name server via the HttpInvoker interface. + * + * @author Chandrasekhar Ramakrishnan + */ +@Controller +@RequestMapping( + { NameServerServlet.NAME_SERVER_URL, "/openbis" + NameServerServlet.NAME_SERVER_URL }) +public class NameServerServlet extends HttpInvokerServiceExporter +{ + private final static String NAME_SERVER_URL = IRpcServiceNameServer.PREFFERED_URL_SUFFIX; + + private final static String NAME_SERVER_SERVICE_NAME = + IRpcServiceNameServer.PREFFERED_SERVICE_NAME; + + @Resource(name = IRpcServiceNameServer.PREFFERED_BEAN_NAME) + private RpcServiceNameServer nameServer; + + @Override + public void afterPropertiesSet() + { + setServiceInterface(IRpcServiceNameServer.class); + setService(nameServer); + setInterceptors(new Object[] + { new ServiceExceptionTranslator() }); + RpcServiceInterfaceVersionDTO ifaceVersion = + new RpcServiceInterfaceVersionDTO(NAME_SERVER_SERVICE_NAME, NAME_SERVER_URL, 1, 0); + nameServer.addSupportedInterfaceVersion(ifaceVersion); + super.afterPropertiesSet(); + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryServiceServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryServiceServer.java index 6743ccac5d7..9eec0044e34 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryServiceServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryServiceServer.java @@ -22,12 +22,13 @@ import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import ch.systemsx.cisd.common.api.IRpcServiceNameServer; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; +import ch.systemsx.cisd.common.api.server.RpcServiceNameServer; import ch.systemsx.cisd.common.spring.ServiceExceptionTranslator; import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer; /** - * - * * @author Franz-Josef Elmer */ @Controller @@ -38,12 +39,21 @@ public class QueryServiceServer extends HttpInvokerServiceExporter @Resource(name = ResourceNames.QUERY_PLUGIN_SERVER) private IQueryApiServer server; + @Resource(name = IRpcServiceNameServer.PREFFERED_BEAN_NAME) + private RpcServiceNameServer nameServer; + @Override public void afterPropertiesSet() { setServiceInterface(IQueryApiServer.class); setService(server); - setInterceptors(new Object[] {new ServiceExceptionTranslator()}); + setInterceptors(new Object[] + { new ServiceExceptionTranslator() }); + + RpcServiceInterfaceVersionDTO ifaceVersion = + new RpcServiceInterfaceVersionDTO("query", ResourceNames.QUERY_PLUGIN_SERVER_URL, + 1, 0); + nameServer.addSupportedInterfaceVersion(ifaceVersion); super.afterPropertiesSet(); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/IQueryApiServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/IQueryApiServer.java index 95ffe2bc974..7f2b24ad6b1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/IQueryApiServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/IQueryApiServer.java @@ -25,8 +25,8 @@ import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryDescription; import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; /** - * Public API interface to query server (version 1). - * + * Public API interface to query server (version 1). + * * @author Franz-Josef Elmer */ // DO NOT CHANGE THE INTERFACE CONTRACT IN A NON-BACKWARD COMPATIBLE WAY! @@ -36,15 +36,16 @@ public interface IQueryApiServer * Tries to authenticate specified user with specified password. Returns session token if * succeeded otherwise <code>null</code> is returned. */ - @Transactional // this is not a readOnly transaction - it can create new users + @Transactional + // this is not a readOnly transaction - it can create new users public String tryToAuthenticateAtQueryServer(String userID, String userPassword); - + /** * Logout the session with the specified session token. */ @Transactional(readOnly = true) public void logout(String sessionToken); - + /** * Lists all queries available for the user of the specified session. */ @@ -55,6 +56,7 @@ public interface IQueryApiServer * Executes specified query using specified parameter bindings. */ @Transactional(readOnly = true) - public QueryTableModel executeQuery(String sessionToken, long queryID, Map<String, String> parameterBindings); + public QueryTableModel executeQuery(String sessionToken, long queryID, + Map<String, String> parameterBindings); } diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index c62308fd3a4..42472381e62 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -98,6 +98,8 @@ <property name="onlineHelpSpecificPageTemplate" value="${onlinehelp.specific.page-template}"/> </bean> + <bean id="rpc-name-server" class="ch.systemsx.cisd.common.api.server.RpcServiceNameServer" /> + <!-- // Tracking --> -- GitLab