SCA Java binding.corba (TUSCANY) edited by Wojtek Janiszewski
      Page: 
http://cwiki.apache.org/confluence/display/TUSCANY/SCA+Java+binding.corba
   Changes: 
http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=91234&originalVersion=7&revisedVersion=8






Content:
---------------------------------------------------------------------

{section:border=false}
{column:width=15%}
{include: SCA Java Subproject Menu}
{include: Java SCA Menu New}
{column}
{column:width=85%}
{note:title=Under development}
Note that binding.corba is under development and may not be yet available in 
Tuscany releases.
{note}

h3. &nbsp;<binding.corba>

The Tuscany Java SCA runtime supports CORBA using the <binding.corba> SCDL 
extension. New CORBA based service can be provided using a <binding.corba> 
element within a SCA <service>, existing CORBA object can be accessed using a 
<binding.corba> element within a SCA <reference>.

h3. Using CORBA binding


h4. Configuring CORBA service/reference

Both service and reference CORBA binding can be configured by:

1. *Name*, *host*, *port* parameters, where *host* and *port* points to name 
service, and *name* points to object within name service.

(i) Example service declaration:
{code}
<service name="ScenarionOneServiceGenerated" 
promote="ScenarionOneServiceGenerated">

    <interface.java 
interface="org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations"/>

    <tuscany:binding.corba host="localhost" port="5060" 
name="ScenarioOne/TuscanyGenerated"/>

</service>
{code}
2. Corbaname URI.

(i) Example reference declaration:
{code}
<reference name="scenarioOne">

    <tuscany:binding.corba uri="corbaname::localhost:5060#NamedWithURI"/>

</reference>
{code}

h4. Providing interface

For both service and reference side you can use one of two types of Java 
interface:

1. Generated by idlj compiler from \*.idl file.

2. Created by user according to rules for Java to CORBA mapping.

In both cases interfaces are almost the same. Difference is that generated 
interfaces extends/implements CORBA types which are ignored by binding. Mapping 
rules are available under: 
[Java2IDL|http://www.omg.org/docs/formal/08-01-14.pdf], 
[IDL2Java|http://www.omg.org/docs/formal/08-01-11.pdf]. Samples of CORBA 
bindings can be found in *sca/itest/corba* module.
&nbsp;
{note:title=Overloading, case collisions}
When using Tuscany service/reference binding to communicate with traditional 
CORBA objects:

1. Don't overload method names in Java interface.

2. Don't create methods with names which differs only by case, ie. you 
shouldn't declare both methods: caseSensitive() and CaseSensitive().

You can ignore above rules if you are using Tuscany CORBA binding&nbsp; to 
communicate with other Tuscany CORBA binding. Those constraints results from 
differences between IDL and Java. More details can be found in 
"*Method/operation mapping rules"* section.
{note}
{note:title=Declaring exceptions}still

Exceptions declared by user should be named to match remote exception ID.

Example: if in reference binding remote object throws exception with ID 
"IDL:org/apache/tuscany/sca/test/corba/generated/WrongColor:1.0" then you 
should declare exception class named 
"org.apache.tuscany.sca.test.corba.generated.WrongColor".

The same in service bindings. SCA component exception will be thrown with ID 
created from Java name.
{note}

h4. Method/operation mapping rules

IDL rules are different than rules in Java programming language - Java method 
names can't be always directly mapped to CORBA operations. Following table 
shows used mapping rules:
|| Mapping type \\ || Description&nbsp; \\ || Examples: Java method - 
translated CORBA operation ||
| 1. Getters and setters \\ | If user declared valid pair of getter and setter 
then those methods wouldbe translated to operations which are responsible for 
getting/setting objects attribute. \\ | 1. getName() - \_get_name \\
2. setName(String newName) - \_set_name \\
3. isName() - \_get_name&nbsp; |
| 2. Overloaded names \\ | CORBA does not support overloading method names - 
Java does.. Some mapping rules were applied to allow using overloaded names in 
Java interfaces using CORBA binding. Final operation name is created by taking 
method name and appending it by CORBA parameters type names separated by '_' 
chars. \\ | 1. overloadedMethod() - overloadedMethod_\_ \\
2. overloadedMethod(String arg1) - overloadedMethod__CORBA_WStringValue \\
3. overloadedMethod(String arg1, int arg2) - 
overloadedMethod\__CORBA_WStringValue_\_long |
| 3. Names with case collisions | CORBA is not case sensitive - Java is. CORBA 
ie. doesn't distinguish methods caseDifferent() and CaseDifferent(), so some 
mapping rules are fixing it. Final operation name is created by taking method 
name and appending it by indexes of characters which are capitals. | 1. 
caseDifferent() - caseDifferent_4 \\
2. CaseDifferent() - CaseDifferent_0_4 |

h4. Usage of additional "id" attribute in CORBA service bindings

User can also provide *id* attribute for service binding. It's not required, 
but helpfull if we want to publish service which will be consumed by some idlj 
generated code. This generated code contains \*Helper classes with narrow(...) 
methods. Narrow(...) method compares obtained CORBA reference ID to some local 
(which was generated). CORBA service binding provide this ID automatically 
basing on user provided Java interface name. Providing *id* attribute is the 
only way to provide custom identifier.

(i) Example of using "id" attribute:
{code}
<service name="ScenarionOneServiceGenerated" 
promote="ScenarionOneServiceGenerated">

    <interface.java 
interface="org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations"/>

    <tuscany:binding.corba host="localhost" port="5060" 
name="ScenarioOneTuscanyGenerated" 
id="IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0"/>

</service>
{code}

h3. Host environment types

CORBA binding supports two hosting environments.

h4. host-corba-jdk

It is the standalone hosting environment where various ORBs could be used. You 
should provide accessible name service and configure service/reference to point 
onto desired ORB.

(i) Usage: add *tuscany-host-jdk-<version>.jar* module to your class path.

h4. host-corba-jee

It is the JEE application server environment. In this case ORB is obtained from 
JNDI by *java:comp/ORB* name and you do not need to provide name service.

(i) Usage: add *tuscany-host-jee-<version>.jar* module to your class path.
{column}
{section}

---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence

Unsubscribe or edit your notifications preferences
   http://cwiki.apache.org/confluence/users/viewnotifications.action

If you think it was sent incorrectly contact one of the administrators
   http://cwiki.apache.org/confluence/administrators.action

If you want more information on Confluence, or have a bug to report see
   http://www.atlassian.com/software/confluence


Reply via email to