Ads

Saturday, October 9, 2010

How to write CDR + OpenCloud Rhino + JAIN-SLEE

My first post on OpenCloud's plateform, well quit a while have started exploring OpenCloud's Rhino.
So this is how it goes....

Follow defined steps.

1) RA Type binding in sbb-jar.xml


<resource-adaptor-type-binding>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>CDR Generation</resource-adaptor-type-name>
<resource-adaptor-type-vendor>OpenCloud</resource-adaptor-type-vendor>
<resource-adaptor-type-version>2.1</resource-adaptor-type-version>
</resource-adaptor-type-ref>

<resource-adaptor-entity-binding>
<resource-adaptor-object-name>slee/resources/cdr/provider</resource-adaptor-object-name>
<resource-adaptor-entity-link>slee/resources/cdr</resource-adaptor-entity-link>
</resource-adaptor-entity-binding>
</resource-adaptor-type-binding>



Normal binding, nothing strange!

2) Declaration and lookup in your sbb

private CDRProvider cdrProvider;

lookup at setSbbContext()
this.cdrProvider = (CDRProvider) new InitialContext().lookup("java:comp/env/slee/resources/cdr/provider");

3) Instantiate CallDetailRecord and fillup the details,

CallDetailRecord cdr = new CallDetailRecord();
cdr.setStartTime(getStartTime());
cdr.setEndTime(System.currentTimeMillis());
cdr.setCallingPartyPublicNumber("00641111111");
cdr.setCalledPartyPublicNumber("00642222222");
cdr.setRedirectingNumber("00643333333");
cdr.setServiceAccessType(ServiceAccessType.BOTH);
cdr.setTerminationReason("ENDED");
cdrProvider.writeCDR(cdr); // you are done here

These are the default fields which is defined in CallDetailRecord, you can extend it in your own defined class with your customized fields.

4) @ build.properties


# CDR properties
cdr.directory=d:/cdr/
cdr.encoding=ISO-8859-1
cdr.maxsize=10000
cdr.maxlines=0
cdr.maxinterval=600000
cdr.archivecommand=H:/open cloud/cdr-ra-2[1].1/cdr-ra-2.1.0/examples/archive-cdr-log.sh {0}

cdr.ra.du.jar=cdr-ra-2.1.0.du.jar
cdr.ra.entityname=cdr
cdr.ra.linkname=slee/resources/cdr
cdr.ra.name=CDR Generation
cdr.ra.vendor=OpenCloud
cdr.ra.version=2.1
cdr.ra.properties=Directory=${cdr.directory},Encoding=${cdr.encoding},MaxSize=${cdr.maxsize},MaxLines=${cdr.maxlines},MaxInterval=${cdr.maxinterval},ArchiveCommand="${cdr.archivecommand}"
cdr.ratype.jar=cdr-ra.ratype-2.1.0.jar

Things to note here is cdr.directory, directory where you are looking your CDRs to go.
By default CDR RA comes with a permission to write CDRs in your Rhino home folder.

For more detail on this look at resource-adaptor-jar.xml's security-permissions tag, which defines permisions

grant {
permission java.io.FilePermission "${rhino.dir.home}${/}cdr", "read, write";
permission java.io.FilePermission "${rhino.dir.home}${/}cdr${/}*", "read, write";
permission java.io.FilePermission "${rhino.dir.home}${/}archive-cdr-log.sh", "execute";
permission java.io.FilePermission "${rhino.dir.home}${/}cdr-ra-2.1.0${/}examples${/}archive-cdr-log.sh", "execute";
};

if you are want your CDRs should go to a location where you want it to be, then open rhino.home/conf/rhino.policy

add write permissions for java.io.FilePermission for a specified path like this

#Permission for respective folder
permission java.io.FilePermission "d:${/}cdr", "read, write";
#Permission for the contents in that folder
permission java.io.FilePermission "d:${/}cdr${/}*", "read, write";

For more detail on it you can look into the example comes along with CDR-RA.

No comments:

Post a Comment