]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
46be9f728030e864054d3cc994e776a985a49ee0
[tmp/jakarta-migration.git] /
1 /**     \r
2  * RemoteServiceContextFactory.java\r
3  *\r
4  * {Purpose of This Class}\r
5  *\r
6  * {Other Notes Relating to This Class (Optional)}\r
7  *\r
8  * $LastChangedBy: $\r
9  * $LastChangedRevision: $\r
10  * $LastChangedDate: $\r
11  *\r
12  * This document is a part of the source code and related artifacts\r
13  * for CollectionSpace, an open source collections management system\r
14  * for museums and related institutions:\r
15  *\r
16  * http://www.collectionspace.org\r
17  * http://wiki.collectionspace.org\r
18  *\r
19  * Copyright © 2009 {Contributing Institution}\r
20  *\r
21  * Licensed under the Educational Community License (ECL), Version 2.0.\r
22  * You may not use this file except in compliance with this License.\r
23  *\r
24  * You may obtain a copy of the ECL 2.0 License at\r
25  * https://source.collectionspace.org/collection-space/LICENSE.txt\r
26  */\r
27 package org.collectionspace.services.common.context;\r
28 \r
29 import javax.ws.rs.core.MultivaluedMap;\r
30 \r
31 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
32 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
33 \r
34 /**\r
35  * A factory for creating RemoteServiceContext objects.\r
36  */\r
37 public class RemoteServiceContextFactory<IT, OT>\r
38         implements ServiceContextFactory<IT, OT>{\r
39         \r
40         // create a Factory singleton\r
41         /** The Constant self. */\r
42         final private static RemoteServiceContextFactory self = new RemoteServiceContextFactory();\r
43         \r
44         /**\r
45          * Instantiates a new remote service context factory.\r
46          */\r
47         private RemoteServiceContextFactory() {} // private constructor\r
48     \r
49     /**\r
50      * Gets the.\r
51      * \r
52      * @return the remote service context factory\r
53      */\r
54     public static RemoteServiceContextFactory get() {\r
55         return self;\r
56     }\r
57 \r
58     /* (non-Javadoc)\r
59      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String)\r
60      */\r
61     @Override\r
62     public ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception {\r
63         RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName);\r
64         return ctx;\r
65     }\r
66     \r
67     /* (non-Javadoc)\r
68      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object)\r
69      */\r
70     @Override\r
71     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
72                 IT theInput) throws Exception {\r
73         RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName, theInput);\r
74         return ctx;\r
75     }\r
76     \r
77     /* (non-Javadoc)\r
78      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)\r
79      */\r
80     @Override\r
81     public ServiceContext<IT, OT> createServiceContext(\r
82                 String serviceName,\r
83                 IT theInput, \r
84                 MultivaluedMap<String, String> queryParams) throws Exception {\r
85         ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
86                         theInput,\r
87                         queryParams);\r
88         \r
89         return ctx;\r
90     }\r
91 \r
92     @Override\r
93     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
94                 IT input, \r
95                 MultivaluedMap<String, String> queryParams,\r
96                 String documentType,\r
97                 String entityName) throws Exception {\r
98         ServiceContext<IT, OT> ctx = createServiceContext(\r
99                         serviceName,\r
100                         input,\r
101                         queryParams);\r
102         ctx.setDocumentType(documentType); //persistence unit\r
103         ctx.setProperty("entity-name", entityName);\r
104         \r
105         return ctx;\r
106     }\r
107     \r
108 }\r