Single instance as argument to multiple constructors #75
-
Hey all, I have a component ( I'm trying to make sure that only one instance of the My config file is: "args_operationHandler": {
"@type": "AnonymizingHttpHandler",
"args_credentialsExtractor": { "@id": "urn:solid-server:default:CredentialsExtractor" },
"args_modesExtractor": { "@id": "urn:solid-server:default:ModesExtractor" },
"args_permissionReader": { "@id": "urn:solid-server:default:PermissionReader" },
"args_authorizer": { "@id": "urn:solid-server:default:Authorizer" },
"args_operationHandler": { "@id": "urn:solid-server:default:OperationHandler" },
"args_dataTreatmentHandler": {
"@id": "urn:pepsa-component:default:DataTreatmentHandler",
"@type": "DataTreatmentHandler",
"configMgr": { "@id": "urn:pepsa-component:default:ConfigurationManager" },
"ruleEncapsulator": {
"@id": "urn:pepsa-component:default:RuleEncapsulator",
"@type": "RuleEncapsulator",
"configMgr": { "@id": "urn:pepsa-component:default:ConfigurationManager" }
},
"parserSelector": {
"@id": "urn:pepsa-component:default:ParserSelector",
"@type": "ParserSelector"
}
},
"args_configurationManager": {
"@id": "urn:pepsa-component:default:ConfigurationManager",
"@type": "ConfigurationManager"
}
} Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This will indeed only create 1 instance of your The wrong way to do it would have been to replace those |
Beta Was this translation helpful? Give feedback.
This will indeed only create 1 instance of your
ConfigurationManager
. You could put aconsole.log
call in the constructor to see how many times it is called. Identical@id
s always corresponds to the same instance of a class. Components.js reads out all the JSON-LD files and interprets them as RDF, so from its point of view there is just a singleurn:pepsa-component:default:ConfigurationManager
subject that has theConfigurationManager
type, and some other triples referencing that same URI.The wrong way to do it would have been to replace those
{ "@id": "urn:pepsa-component:default:ConfigurationManager" }
blocks with{ "@type": "ConfigurationManager" }
. This would have created several bla…