You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by co...@apache.org on 2007/09/21 18:26:00 UTC

[CONF] Apache Tuscany: Standalone SCA Domain (page created)

Standalone SCA Domain (TUSCANY) created by Simon Laws
   http://cwiki.apache.org/confluence/display/TUSCANY/Standalone+SCA+Domain

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

{section:border=true}
{column:width=15%}
{include: SCA Java Subproject Menu}
{include: Java SCA Menu New}
{column}
{column:width=85%}

{note:title:Notification}{center}This page is under construction\- You are welcome to help and complete it{center}{note}

!single-node-abstract.png!

Using a domain in a single JVM is very easy. You simply create an instance of

{code}
org.apache.tuscany.sca.host.embedded.SCADomain.
{code}

Using one of the provided newInstance() methods. Note the package name. You will see a different package name when we look at the multiple JVM case. For now this indicates that the SCA Domain is going to be completely embedded in the Java application that you write. 

This is what the different newInstance() operations mean. 

{code}
public static SCADomain newInstance() 
{code}

Starts a standalone domain with a default domain URI and will treat the classpath as the contribution to this domain.  All .composite files on the classpath will will read any deployable components created accordingly. 

Deployable components are defined by either

# placing the .composite file in the  META-INF/sca-deployables/directory

# By specifying the composite as deployable in the META-INF/sca-contribution.xml file
    
{code}
public static SCADomain newInstance(String composite)
{code}

Starts a standalone domain with a default domain URI and will try and find the named composite file in the classpath and use it's location as the contribution location. It will deploy the named composite. 
    
{code}
public static SCADomain newInstance(String domainURI, String contributionLocation, String... composites) 
{code}

Will start a standalone domain with the specified domain URI and will load the contribution at the contributionLocation. Any named composites will be deployed. As there are both contributionLocation and composite name parameters there are some rules about what happens when you specifier one the other, both or neither as follows.


contributionLocation - an absolute path to a contribution in URL form, e.g 

  file://C:/mydirA 
  jar:file://C:/myjar.jar 

composite(s) - the name of a composite file(s) e.g. 

  mycomposite.composite 
  somedir/mycomposite.composite 

So the various combinations give rise to 

contributionLocation set / composite null 
   loads all contributions under the contribution location identified 

contributionLocation null / composite set 
   finds the location of your compsite on the classpath and uses that as the contribution location. It loads the named composite from there 

contributionLocation / composite 
  loads the named composite from the specified contribution path 

contributionLocation null / composite null 
  This option is also used if the above rules don't identify a contribution URL for whatever reason. 
  No contribution has been specified so look for the following in order and use the location of the first one found as the contribution location 
  META-INF/sca-contribution.xml 
  META-INF/sca-contribution-generated.xml 
  META-INF/sca-deployables directory

For example, in our calculator sample we could do 

{code}
scaDomain = SCADomain.newInstance("Calculator.composite");
{code}

Once created the SCA Domain will have loaded a contribution based on the rules set out above. 

!calculator-standalone.png!

You can now use services in the domain either directly from your Java application or remotely over the service instance that the SCA application exposes. 

To use services directly you can use the following SCA Domain interfaces to create a service proxy

{code}
public abstract <B> B getService(Class<B> businessInterface, String serviceName);
{code}

Returns a type safe reference to the named service

{code}
public abstract <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName);
{code}

returns an SCA service reference to the named service. You can use the SCA service reference to manipulate various aspects of the referece. 

{code}
public abstract <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException;
{code}

Casts a service (callable) reference to a typesafe reference . 

For example, in our calculator sample we could do

{code}
calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent");
{code}

Once you have a service proxy you can call methods on it like any other Java object. 

{code}
Double result = calculatorService.add(3, 2)
{code}

When you a finished with the domain you need to close it down.

{code}
scaDomain.close();
{code}

{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



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org