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