]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
570df2274f3679cde0eaacc5260e111bcc4e656c
[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 \r
32 /**\r
33  * A factory for creating RemoteServiceContext objects.\r
34  */\r
35 public class RemoteServiceContextFactory<IT, OT>\r
36         implements ServiceContextFactory<IT, OT>{\r
37         \r
38         // create a Factory singleton\r
39         /** The Constant self. */\r
40         final private static RemoteServiceContextFactory self = new RemoteServiceContextFactory();\r
41         \r
42         /**\r
43          * Instantiates a new remote service context factory.\r
44          */\r
45         private RemoteServiceContextFactory() {} // private constructor\r
46     \r
47     /**\r
48      * Gets the.\r
49      * \r
50      * @return the remote service context factory\r
51      */\r
52     public static RemoteServiceContextFactory get() {\r
53         return self;\r
54     }\r
55 \r
56     /* (non-Javadoc)\r
57      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String)\r
58      */\r
59     @Override\r
60     public ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception {\r
61         RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName);\r
62         return ctx;\r
63     }\r
64     \r
65     /* (non-Javadoc)\r
66      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object)\r
67      */\r
68     @Override\r
69     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
70                 IT theInput) throws Exception {\r
71         RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName, theInput);\r
72         return ctx;\r
73     }\r
74     \r
75     /* (non-Javadoc)\r
76      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)\r
77      */\r
78     @Override\r
79     public ServiceContext<IT, OT> createServiceContext(\r
80                 String serviceName,\r
81                 IT theInput, \r
82                 MultivaluedMap<String, String> queryParams) throws Exception {\r
83         ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
84                         theInput,\r
85                         queryParams);\r
86         \r
87         return ctx;\r
88     }\r
89 \r
90     @Override\r
91     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
92                 IT input, \r
93                 MultivaluedMap<String, String> queryParams,\r
94                 String documentType,\r
95                 String entityName) throws Exception {\r
96         ServiceContext<IT, OT> ctx = createServiceContext(\r
97                         serviceName,\r
98                         input,\r
99                         queryParams);\r
100         ctx.setDocumentType(documentType); //persistence unit\r
101         ctx.setProperty(ServiceContextProperties.ENTITY_NAME, entityName);\r
102         return ctx;\r
103     }\r
104     \r
105 }\r