Bug 84106. Actually pass a cache key to web browser persist so that POST result...
[mozilla-central.git] / rdf / build / nsRDFModule.cpp
blobc3b92312d414a0a2c712bf2123f317c684e51aad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Benjamin Smedberg <benjamin@smedbergs.us>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
38 #include "nsCOMPtr.h"
39 #include "nsIGenericFactory.h"
40 #include "nsIModule.h"
42 #include "nsRDFModule.h"
43 #include "nsIFactory.h"
44 #include "nsRDFService.h"
45 #include "nsIRDFContainer.h"
46 #include "nsIRDFContainerUtils.h"
47 #include "nsIRDFCompositeDataSource.h"
48 #include "nsIRDFContentSink.h"
49 #include "nsISupports.h"
50 #include "nsRDFBaseDataSources.h"
51 #include "nsRDFBuiltInDataSources.h"
52 #include "nsFileSystemDataSource.h"
53 #include "nsRDFCID.h"
54 #include "nsIComponentManager.h"
55 #include "rdf.h"
56 #include "nsIServiceManager.h"
57 #include "nsILocalStore.h"
58 #include "nsRDFXMLParser.h"
59 #include "nsRDFXMLSerializer.h"
61 #include "rdfISerializer.h"
63 //----------------------------------------------------------------------
65 // Functions used to create new instances of a given object by the
66 // generic factory.
68 #define MAKE_CTOR(_func,_new,_ifname) \
69 static NS_IMETHODIMP \
70 CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
71 { \
72 if (!aResult) { \
73 return NS_ERROR_INVALID_POINTER; \
74 } \
75 if (aOuter) { \
76 *aResult = nsnull; \
77 return NS_ERROR_NO_AGGREGATION; \
78 } \
79 nsI##_ifname* inst; \
80 nsresult rv = NS_New##_new(&inst); \
81 if (NS_FAILED(rv)) { \
82 *aResult = nsnull; \
83 return rv; \
84 } \
85 rv = inst->QueryInterface(aIID, aResult); \
86 if (NS_FAILED(rv)) { \
87 *aResult = nsnull; \
88 } \
89 NS_RELEASE(inst); /* get rid of extra refcnt */ \
90 return rv; \
93 extern nsresult
94 NS_NewDefaultResource(nsIRDFResource** aResult);
96 MAKE_CTOR(RDFXMLDataSource,RDFXMLDataSource,RDFDataSource)
97 MAKE_CTOR(RDFCompositeDataSource,RDFCompositeDataSource,RDFCompositeDataSource)
98 MAKE_CTOR(RDFContainer,RDFContainer,RDFContainer)
100 MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
102 MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
103 MAKE_CTOR(RDFDefaultResource,DefaultResource,RDFResource)
105 #define MAKE_RDF_CTOR(_func,_new,_ifname) \
106 static NS_IMETHODIMP \
107 CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
109 if (!aResult) { \
110 return NS_ERROR_INVALID_POINTER; \
112 if (aOuter) { \
113 *aResult = nsnull; \
114 return NS_ERROR_NO_AGGREGATION; \
116 rdfI##_ifname* inst; \
117 nsresult rv = NS_New##_new(&inst); \
118 if (NS_FAILED(rv)) { \
119 *aResult = nsnull; \
120 return rv; \
122 rv = inst->QueryInterface(aIID, aResult); \
123 if (NS_FAILED(rv)) { \
124 *aResult = nsnull; \
126 NS_RELEASE(inst); /* get rid of extra refcnt */ \
127 return rv; \
130 extern nsresult
131 NS_NewTriplesSerializer(rdfISerializer** aResult);
133 MAKE_RDF_CTOR(TriplesSerializer, TriplesSerializer, Serializer)
135 // The list of components we register
136 static const nsModuleComponentInfo components[] =
137 { // register our build-in datasources:
139 "RDF Composite Data Source",
140 NS_RDFCOMPOSITEDATASOURCE_CID,
141 NS_RDF_DATASOURCE_CONTRACTID_PREFIX "composite-datasource",
142 CreateNewRDFCompositeDataSource
146 "RDF File System Data Source",
147 NS_RDFFILESYSTEMDATASOURCE_CID,
148 NS_RDF_DATASOURCE_CONTRACTID_PREFIX "files",
149 FileSystemDataSource::Create
152 { "RDF In-Memory Data Source",
153 NS_RDFINMEMORYDATASOURCE_CID,
154 NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource",
155 NS_NewRDFInMemoryDataSource
158 { "RDF XML Data Source",
159 NS_RDFXMLDATASOURCE_CID,
160 NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource",
161 CreateNewRDFXMLDataSource
164 // register our built-in resource factories:
165 { "RDF Default Resource Factory",
166 NS_RDFDEFAULTRESOURCE_CID,
167 // Note: default resource factory has no name= part
168 NS_RDF_RESOURCE_FACTORY_CONTRACTID,
169 CreateNewRDFDefaultResource
172 // register all the other rdf components:
173 { "RDF Content Sink",
174 NS_RDFCONTENTSINK_CID,
175 NS_RDF_CONTRACTID "/content-sink;1",
176 CreateNewRDFContentSink
179 { "RDF Container",
180 NS_RDFCONTAINER_CID,
181 NS_RDF_CONTRACTID "/container;1",
182 CreateNewRDFContainer
185 { "RDF Container Utilities",
186 NS_RDFCONTAINERUTILS_CID,
187 NS_RDF_CONTRACTID "/container-utils;1",
188 CreateNewRDFContainerUtils
191 { "RDF Service",
192 NS_RDFSERVICE_CID,
193 NS_RDF_CONTRACTID "/rdf-service;1",
194 RDFServiceImpl::CreateSingleton
197 { "RDF/XML Parser",
198 NS_RDFXMLPARSER_CID,
199 NS_RDF_CONTRACTID "/xml-parser;1",
200 nsRDFXMLParser::Create
203 { "RDF/XML Serializer",
204 NS_RDFXMLSERIALIZER_CID,
205 NS_RDF_CONTRACTID "/xml-serializer;1",
206 nsRDFXMLSerializer::Create
209 { "RDF/NTriples Serializer",
210 NS_RDFNTRIPLES_SERIALIZER_CID,
211 NS_RDF_SERIALIZER "ntriples",
212 CreateNewTriplesSerializer
215 // XXX move this to XPFE at some point.
216 { "Local Store", NS_LOCALSTORE_CID,
217 NS_LOCALSTORE_CONTRACTID, NS_NewLocalStore },
220 static nsresult
221 StartupRDFModule(nsIModule* unused)
223 if (RDFServiceImpl::gRDFService) {
224 NS_ERROR("Leaked the RDF service from a previous startup.");
225 RDFServiceImpl::gRDFService = nsnull;
228 return NS_OK;
231 static void
232 ShutdownRDFModule(nsIModule* unused)
234 if (RDFServiceImpl::gRDFService) {
235 // XXX make this an assertion!
236 NS_WARNING("Leaking the RDF Service.");
240 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsRDFModule, components,
241 StartupRDFModule, ShutdownRDFModule)