YourKit Java Profiler |
JFacets /
UsingFacetsUsing facets from Java code is very simple. You simply have to :
Obtaining the JFacets top-level objectThe JFacets bean is the top-level object that you use in JFacets applications. It allows retrievement and execution of facets (see below). It's a Spring Bean, so if you're familiar with Spring, you can get a reference to it directly from the JFacets Application Context. It also proposes static methods in order to use it without dealing with Spring. Depending on your project, you can choose one or the other option. The "Spring" way : // get the jFacets bean from the Spring context ApplicationContext c = ... ; JFacets jFacets = (JFacets)c.getBean("jFacets"); The "static method" way : // get the jFacets bean using a static method // using the default app context name JFacets jFacets = JFacets.get(); // or specifying another app context JFacets jFacets = JFacets.get("/myAppCtx.xml"); Retrieving and Executing facetsOnce you have a reference on the JFacets bean, you can use it to retrieve and use facets : // get the jFacets bean JFacets jFacets = JFacets.get(); // the profile ID String profileId = ... ; // the target object MyClass o = ... ; // retrieve a facet and use it MyFacet f = (MyFacet)jFacets.getFacet("doSomething", profileId, o); f.doStuff(); If your facet implements // get the jFacets bean JFacets jFacets = JFacets.get(); // the profile ID String profileId = ... ; // the target object MyClass o = ... ; // retrieve and execute a facet MyResult result = (MyResult)jFacets.execFacet("doSomething", profileId, o); result.xyz();
|