org.apache.tuscany.sca.core.context
Class CallableReferenceImpl<B>

java.lang.Object
  extended by org.apache.tuscany.sca.core.context.CallableReferenceImpl<B>
Type Parameters:
B - the type of the business interface
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, org.osoa.sca.CallableReference<B>
Direct Known Subclasses:
CallbackReferenceImpl, ServiceReferenceImpl

public class CallableReferenceImpl<B>
extends java.lang.Object
implements org.osoa.sca.CallableReference<B>, java.io.Externalizable

Base class for implementations of service and callback references.

See Also:
Serialized Form

Field Summary
protected  Binding binding
           
protected  java.lang.Class<B> businessInterface
           
protected  java.lang.Object callbackID
           
protected  RuntimeComponent component
           
protected  CompositeActivator compositeActivator
           
protected  ExtendedConversation conversation
           
protected  java.lang.Object conversationID
           
protected  ConversationManager conversationManager
           
protected  java.lang.Object proxy
           
protected  ProxyFactory proxyFactory
           
protected  RuntimeComponentReference reference
           
protected  java.lang.String scdl
           
 
Constructor Summary
  CallableReferenceImpl()
           
protected CallableReferenceImpl(java.lang.Class<B> businessInterface, RuntimeComponent component, RuntimeComponentReference reference, Binding binding, ProxyFactory proxyFactory, CompositeActivator compositeActivator)
           
  CallableReferenceImpl(java.lang.Class<B> businessInterface, RuntimeWire wire, ProxyFactory proxyFactory)
           
  CallableReferenceImpl(javax.xml.stream.XMLStreamReader xmlReader)
           
 
Method Summary
 void attachCallbackID(java.lang.Object callbackID)
           
 void attachConversation(ExtendedConversation conversation)
           
 void attachConversation(java.lang.Object conversationID)
           
 void attachConversationID(java.lang.Object conversationID)
           
protected  void bind(RuntimeWire wire)
           
protected  java.lang.Object createProxy()
           
 java.lang.Class<B> getBusinessInterface()
          Returns the Java class for the business interface associated with this reference.
 java.lang.Object getCallbackID()
          Returns the callback ID.
 org.osoa.sca.Conversation getConversation()
          Returns the conversation associated with this reference.
 EndpointReference getEndpointReference()
           
 B getProxy()
           
protected  ReferenceParameters getReferenceParameters()
           
 RuntimeWire getRuntimeWire()
           
 B getService()
          Returns a type-safe reference to the target of this reference.
 javax.xml.stream.XMLStreamReader getXMLReader()
           
protected  void initCallbackID()
           
 boolean isConversational()
          Returns true if this reference is conversational.
 void readExternal(java.io.ObjectInput in)
           
protected  Component resolveComponentURI(java.lang.String componentURI)
          Resolves the specified URI to a Component using the compositeActivator.
protected  ComponentService resolveServiceURI(java.lang.String bindingURI, Component targetComponent)
          Examines the Services on the specified Component and returns the Service that matches the specified Binding URI.
 void setProxy(java.lang.Object proxy)
           
 java.lang.String toXMLString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compositeActivator

protected transient CompositeActivator compositeActivator

proxyFactory

protected transient ProxyFactory proxyFactory

businessInterface

protected transient java.lang.Class<B> businessInterface

proxy

protected transient java.lang.Object proxy

conversationManager

protected transient ConversationManager conversationManager

conversation

protected transient ExtendedConversation conversation

conversationID

protected transient java.lang.Object conversationID

callbackID

protected java.lang.Object callbackID

component

protected transient RuntimeComponent component

reference

protected transient RuntimeComponentReference reference

binding

protected transient Binding binding

scdl

protected java.lang.String scdl
Constructor Detail

CallableReferenceImpl

public CallableReferenceImpl()

CallableReferenceImpl

public CallableReferenceImpl(javax.xml.stream.XMLStreamReader xmlReader)
                      throws java.lang.Exception
Throws:
java.lang.Exception

CallableReferenceImpl

protected CallableReferenceImpl(java.lang.Class<B> businessInterface,
                                RuntimeComponent component,
                                RuntimeComponentReference reference,
                                Binding binding,
                                ProxyFactory proxyFactory,
                                CompositeActivator compositeActivator)

CallableReferenceImpl

public CallableReferenceImpl(java.lang.Class<B> businessInterface,
                             RuntimeWire wire,
                             ProxyFactory proxyFactory)
Method Detail

getRuntimeWire

public RuntimeWire getRuntimeWire()

bind

protected void bind(RuntimeWire wire)

initCallbackID

protected void initCallbackID()

getProxy

public B getProxy()
           throws ObjectCreationException
Throws:
ObjectCreationException

setProxy

public void setProxy(java.lang.Object proxy)

createProxy

protected java.lang.Object createProxy()
                                throws java.lang.Exception
Throws:
java.lang.Exception

getService

public B getService()
Description copied from interface: org.osoa.sca.CallableReference
Returns a type-safe reference to the target of this reference. The instance returned is guaranteed to implement the business interface for this reference but may not be a proxy as defined by java.lang.reflect.Proxy.

Specified by:
getService in interface org.osoa.sca.CallableReference<B>
Returns:
a proxy to the target that implements the business interface associated with this reference

getBusinessInterface

public java.lang.Class<B> getBusinessInterface()
Description copied from interface: org.osoa.sca.CallableReference
Returns the Java class for the business interface associated with this reference.

Specified by:
getBusinessInterface in interface org.osoa.sca.CallableReference<B>
Returns:
the Class for the business interface associated with this reference

isConversational

public boolean isConversational()
Description copied from interface: org.osoa.sca.CallableReference
Returns true if this reference is conversational.

Specified by:
isConversational in interface org.osoa.sca.CallableReference<B>
Returns:
true if this reference is conversational

getConversation

public org.osoa.sca.Conversation getConversation()
Description copied from interface: org.osoa.sca.CallableReference
Returns the conversation associated with this reference. Returns null if no conversation is currently active.

Specified by:
getConversation in interface org.osoa.sca.CallableReference<B>
Returns:
the conversation associated with this reference; may be null

getCallbackID

public java.lang.Object getCallbackID()
Description copied from interface: org.osoa.sca.CallableReference
Returns the callback ID.

Specified by:
getCallbackID in interface org.osoa.sca.CallableReference<B>
Returns:
the callback ID

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
Externalizable.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException
See Also:
Externalizable.writeExternal(java.io.ObjectOutput)

toXMLString

public java.lang.String toXMLString()
                             throws java.io.IOException
Throws:
java.io.IOException

attachCallbackID

public void attachCallbackID(java.lang.Object callbackID)

attachConversationID

public void attachConversationID(java.lang.Object conversationID)

attachConversation

public void attachConversation(ExtendedConversation conversation)

attachConversation

public void attachConversation(java.lang.Object conversationID)

getReferenceParameters

protected ReferenceParameters getReferenceParameters()

getEndpointReference

public EndpointReference getEndpointReference()

getXMLReader

public javax.xml.stream.XMLStreamReader getXMLReader()

resolveComponentURI

protected Component resolveComponentURI(java.lang.String componentURI)
Resolves the specified URI to a Component using the compositeActivator. There are two cases that we need to handle:

Parameters:
componentURI - The URI of the Component to resolve
Returns:
The Component for the specified URI or null if not founds

resolveServiceURI

protected ComponentService resolveServiceURI(java.lang.String bindingURI,
                                             Component targetComponent)
Examines the Services on the specified Component and returns the Service that matches the specified Binding URI.

Parameters:
bindingURI - The Binding URI to resolve on the Component
targetComponent - The Component containing the Services
Returns:
The Service with the specified serviceName or null if no such Service found.