]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
ac9a4e76ff9a8e8c57f84078a2f54abdaec36c2d
[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.collectionspace.services.common.ResourceMap;\r
32 \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                 ResourceMap resourceMap,\r
85                 MultivaluedMap<String, String> queryParams) throws Exception {\r
86         ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
87                         theInput,\r
88                         resourceMap,\r
89                         queryParams);\r
90         \r
91         return ctx;\r
92     }\r
93 \r
94     @Override\r
95     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
96                 IT input,\r
97                 ResourceMap resourceMap,\r
98                 MultivaluedMap<String, String> queryParams,\r
99                 String documentType,\r
100                 String entityName) throws Exception {\r
101         ServiceContext<IT, OT> ctx = createServiceContext(\r
102                         serviceName,\r
103                         input,\r
104                         resourceMap,\r
105                         queryParams);\r
106         ctx.setDocumentType(documentType); //persistence unit\r
107         ctx.setProperty(ServiceContextProperties.ENTITY_NAME, entityName);\r
108         return ctx;\r
109     }\r
110     \r
111 }\r