The easiest way to access the JBIContainer, which is the main point to use ServiceMix internals, is to cast the ComponentContext to its implementation.
JBIContainer container = ((ComponentContextImpl) getContext()).getContainer();
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:
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.
2 Comments
Anonymous
ionolsen42 Best site I see. Thanks. http://www_3_1.gmail.com/ www_3_1
http://www_3_2.gmail.com/ www_3_2
http://www_3_3.gmail.com/ www_3_3
http://www_3_4.gmail.com/ www_3_4
http://www_3_5.gmail.com/ www_3_5
http://www_3_6.gmail.com/ www_3_6
http://www_3_7.gmail.com/ www_3_7
http://www_3_8.gmail.com/ www_3_8
http://www_3_9.gmail.com/ www_3_9
http://www_3_10.gmail.com/ www_3_10
http://www_3_11.gmail.com/ www_3_11
Anonymous
ionolsen43 I am really impressed! http://wiki.cubic.uni-koeln.de/cdkwiki/media/carinsurance.html car insurance rate
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:autoinsurancecompany.html auto insurance rbc
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:lifeinsurance.html insurance life
http://wiki.cubic.uni-koeln.de/cdkwiki/media/healthinsurancequote.html health insurance nj
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:wholelifeinsurance.html whole life medical
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:terminsurance.html term car insurance