2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.common.context;
26 import java.lang.reflect.Constructor;
27 import org.collectionspace.services.common.security.UnauthorizedException;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * RemoteServiceContextImpl
34 * $LastChangedRevision: $
37 public class RemoteServiceContextImpl<IT, OT>
38 extends AbstractServiceContext<IT, OT>
39 implements RemoteServiceContext<IT, OT> {
41 final Logger logger = LoggerFactory.getLogger(RemoteServiceContextImpl.class);
42 //input stores original content as received over the wire
46 public RemoteServiceContextImpl(String serviceName) throws UnauthorizedException {
51 public IT getInput() {
56 public void setInput(IT input){
61 public OT getOutput() {
66 public void setOutput(OT output){
72 public ServiceContext getLocalContext(String localContextClassName) throws Exception {
73 ClassLoader cloader = Thread.currentThread().getContextClassLoader();
74 Class ctxClass = cloader.loadClass(localContextClassName);
75 if(!ServiceContext.class.isAssignableFrom(ctxClass)) {
76 throw new IllegalArgumentException("getLocalContext requires " +
77 " implementation of " + ServiceContext.class.getName());
80 Constructor ctor = ctxClass.getConstructor(java.lang.String.class);
81 ServiceContext ctx = (ServiceContext)ctor.newInstance(getServiceName());