Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

You can then use the container to access ServiceMix internals, such as creating a client, activating a component dynamically, or any other feature you need.

Note that in ServiceMix 3.1, components sometime uses a wrapped ComponentContext. In such a case (for example, from a POJO inside the JSR181 component), you can use:

Code Block
langjava

public JBIContainer getContainer(ComponentContext context) {
     try {
         Field field = context.getClass().getDeclaredField("context");
         field.setAccessible(true);
         context = field.get(context);
     } catch (Exception e) {
     }
     try {
         Field field = context.getClass().getDeclaredField("container");
         field.setAccessible(true);
         JBIContainer container = (JBIContainer) field.get(context);
         return container;
     } catch (Exception e) {
         return null;
     }
 }

See also this JIRA issue.