cdi telco framework & arquillian presentation at mobicents summit, sochi 2011
TRANSCRIPT
CDI Telco Framework and Aquillianto the Sip Servlets platform
Annual Mobicents Community Summit
Sochi-Russia, December 4-9, 2011 George VagenasCDI Telco Framework project lead
Agenda
● CDI Telco Framework○ Few words about CDI JSR-299
○ CTF Introduction
○ Examples
○ Sip Servlets 2.0
● Sip Servlets Arquillian Container○ Introduction to Arquillian
○ MSS Arquillian container
○ Examples
CDI Telco FrameworkCDI JSR299, is the Java standard for dependency injection and contextual lifecycle management. The CDI services provide: ● an improved lifecycle for stateful objects, bound to well-
defined contexts● a typesafe approach to dependency injection● object interaction via an event notification facility
CDI Telco FrameworkCTF brings the power and productivity benefits of CDI into the Mobicents Sip Servlets platform providing dependency injection and contextual lifecycle management for converged HTTP/SIP applications.Mission Statement
● Simplify SipServlets development by introducing a clean programming model
● Extensibility is a major concern● The framework will stand as an extension to the CDI core, thus
making integration with other Java EE 6 technologies a breeze Project's home: CDI Telco Framework
CDI Telco Framework
CDI Telco Framework
Benefits ● Loose coupling with strong typing● Portable extensions● Reusable components● Enhanced event notifications mechanism● Out of the box integration with the rest of the
Java EE ecosystem
CDI Telco Framework
CTF Bean public class SimpleSipServlet {
@Injectprivate SipFactory sipFactory; protected void doInvite(@Observes @Invite SipServletRequest req){ ... } protected void doSuccessResponse(@Observes @SuccessResponse SipServletResponse resp){ ... }
}
CDI Telco Frameworkpublic class SimpleSipServlet {
@InjectSipRegistarComponent sipRegistar;@Injectjavax.enterprise.event.Event<String> event;
protected void doRegister(@Observes @Register SipServletRequest req) {
sipRegistar.doRegister(req);event.fire("Received Register event");
}}
CDI Telco Framework
Current State and future plans Currenlty CTF Core in Alpha version providing● Injection of Sip Servlet tools● Sip Event notification mechanism Whats coming next● Provide extensions with high level abstraction
components● Integration with Media Server
CDI Telco FrameworkResources
● CDI-Telco-Framework web site - http://www.mobicents.org/mss/ctf/mss-ctf.html
● CDI-Telco-Framework introduction & Click2Call Example- http://blog.devrealm.org/2011/04/19/cdi-telco-framework/
● CDI-Telco-Framework documentation - http://docs.jboss.org/mobicents/frameworks/ctf/1.0.0.ALPHA1/user_guide/en-US/html_single/
CDI Telco Framework
Sip Servlets 2.0 The new JSR proposal for Sip Servlets 2.0 aims for enhancements and simplifications over the existing API. CDI Telco Framework could be a candidate technology to be adopted in the new specification since the simplified programming model and the extensibility of the framework will foster innovation and bring new ideas to the technology.
MSS Arquillian container
Arquillian testing framework, seeks to minimize the burden on the developer to author integration tests by handling all aspects of test execution, including:● managing the lifecycle of the container (start/stop),● bundling the test class with dependent classes and
resources into a deployable archive,● enhancing the test class (e.g., resolving @Inject, @EJB
and @Resource injections),● deploying the archive to test (deploy/undeploy) and
capturing results and failures.
MSS Arquillian container
Mobicents brings the Sip Servlets Arquillian container for testing converged applications. ● Container is based on Tomcat 6.x● Using SipUnit as SIP client
○ We are collaborating with CafeSip developers on the SipUnit project in order to provide new features, fix bugs etc.
MSS Arquillian container
Extras● Annotations
○ @ContextParam○ @ContextParamMap○ @ConcurrencyControlMode
● Helper classes○ ContextParamTool○ SipStackTool
● Lifecycle extension to provide finer grained control over container's and test's lifecycle
MSS Arquillian container
● Finer grained control over the test's lifecycle and the container's lifecycle
● Override container configuration as needed● The integration is completely transparent,
which means you can launch the tests and get the test results using existing IDE, Ant and Maven test plugins without any add-ons.
MSS Arquillian container
● CTF can be optionally enabled in order to enrich the test or the test archive.
● On the same test we can have○ Multiple test archives○ Multiple container configuration
MSS Arquillian container
<container qualifier="mss-tomcat-embedded-6" default="true" mode="manual">
<configuration><property name="tomcatHome">target/mss-tomcat-embedded-
6</property><property name="workDir">work</property><property name="bindHttpPort">8888</property><property name="unpackArchive">true</property><property name="sipConnectors">:5070,:5070/TCP</property><property name="bindAddress">127.0.0.1</property><property name="sipApplicationRouterProviderClassName">org.
mobicents.servlet.sip.router.DefaultApplicationRouterProvider</property></configuration>
</container>
MSS Arquillian container@RunWith(Arquillian.class)public class ShootistSipServletTest extends SipTestCase {@Deployment(name="simpleArchive", managed=false)
public static WebArchive createTestArchive(){WebArchive webArchive = ShrinkWrap.create(WebArchive.class,"shootistsipservlet.war");webArchive.addClasses(ShootistSipServlet.class);webArchive.addAsWebInfResource("in-container-sip.xml", "sip.xml");return webArchive;}
MSS Arquillian container@Test @ContextParam(name="cancel", value="true")public void testShootist() throws Exception {
SipStackTool sipStackTool = new SipStackTool();receiver = sipStackTool.initializeSipStack(SipStack.PROTOCOL_UDP,
"127.0.0.1", "5080", "127.0.0.1:5070");sipPhone = receiver.createSipPhone("127.0.0.1", SipStack.
PROTOCOL_UDP, 5070, "sip:[email protected]");sipCall = sipPhone.createSipCall();sipCall.listenForIncomingCall();deployer.deploy("simpleArchive");assertTrue(sipCall.waitForIncomingCall(timeout));assertTrue(sipCall.sendIncomingCallResponse(Response.TRYING,"
Trying", timeout));
MSS Arquillian container
What comes next:● Will be released soon in order to get community
feedback for missing features or bugs● Work on a Tomcat 7.x based container● Mobicents Sip Servlets testsuite will migrate to
the new container