Changes for page Component Module

Last modified by Thomas Mortagne on 2024/03/21 15:07

<
From version < 40.1 >
edited by Thomas Mortagne
on 2014/09/25 09:38
To version < 41.1 >
edited by Vincent Massol
on 2014/11/20 12:36
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.ThomasMortagne
1 +xwiki:XWiki.VincentMassol
ExtensionCode.ExtensionClass[0]
Description
... ... @@ -376,6 +376,28 @@
376 376  See the {{scm project="xwiki-commons" path="xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/logging/Logger.java"}}Logger interface{{/scm}} for more details on the logging API.
377 377  {{/info}}
378 378  
379 +== Component Metadata ==
380 +
381 +{{info}}XWiki 6.4{{/info}} If your Component implementation needs to get access to its component metadata (i.e. its ##ComponentDescriptor##) then it can get it injected automatically. For example:
382 +
383 +{{code language="java"}}
384 +import org.xwiki.component.descriptor.ComponentDescriptor;
385 +...
386 +@Component
387 +@Singleton
388 +public class MyComponentImpl implements MyComponent
389 +{
390 + @Inject
391 + private ComponentDescriptor<MyComponent> descriptor;
392 +
393 + public void doSomething()
394 + {
395 + String hint = this.descriptor.getRoleHint();
396 + ...
397 + }
398 +}
399 +{{/code}}
400 +
379 379  == Component Manager Initialization ==
380 380  
381 381  If you're running your code inside an XWiki Enterprise environment (for example) then you won't need to bother about initializing the Component Manager since [[this is done automatically by the Container Module>>Extension.Container Module||anchor="HContainerInitialization"]].

Get Connected