달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
2011. 12. 29. 13:07

ECF 개요 OSGi 이야기2011. 12. 29. 13:07

Instance Creation
Container instance를 만들고 싶으면 다음과 같이 생성한다
IContainer container = getContainerFactory().createContainer(<Container Type>);

getContainerFactory() 메소드는 IContainerFactory instance를 리턴하고 이것은 Singleton이다.

Container Types Available at dev.eclipse.org

Conatainer Instance Disposal
IContainer.dispose() 메소드는 자원을 해제하기 위해 반드시 호출되어야 한다. 

 

Connection/Disconnection

The IContainer interface exposes two key methods: connect(ID targetID, IConnectContext connectContext) and disconnect(). As is obvious, these two methods allow container implementations to initiate communication with remote services, either server-based or group-based communications.

IConatiner 인터페이스는 2개의 메소드를 사용할 수 있도록 했다.
- connect(ID targetID, IConnnectContext context) 
- disconnect()

remote services 와 서버 기반 또는 그룹 기반의 커뮤니케이션를 초기화하기 위해 구현한다. 

The targetID parameter identifies the target server or group for the connect operation. 

connect메소드에서 ID type은 서버나 그룹의 타켓을 식별하기 위해 사용하는 함수이다. 

 It is of type ID so that the to allow the target communications service to be of many kinds...e.g. client-server or peer-to-peer. For example, for http communication the targetID would consist of the URL specifying a particular file at a particular path on a particular server...e.g:http://www.eclipse.org/ecf. For some other communications protocol the ID provided would be different...e.g:sip:someone@example.com;transport=tcp. All such targets for connect may be represented via an instance of the ID interface. 

type ID는 많은 종류의  target communications service를 위해 필요하다.
peer to peer, server - client

targetID는 URL로 구성되어있다. 특정서버에서 어떤 경로를 가리키는 파일에, 즉 local transparency
ID interface를 통해서 추상화된다.

Namespaces and ID Construction

The org.eclipse.ecf core plugin defines a namespace extension point, so that ECF provider plugins can provide their own Namespace implementations. For example, here is the namespace extension definition for the org.eclipse.ecf.provider.xmpp plugin:
   <extension point="org.eclipse.ecf.namespace">
      <namespace
            class="org.eclipse.ecf.provider.xmpp.identity.XMPPNamespace"
            description="XMPP Namespace"
            name="ecf.xmpp"/>
   </extension>
       
This assigns the name "ecf.xmpp" to the class org.eclipse.ecf.provider.xmpp.identity.XMPPNamespace. Notice that this class must be a subclass of org.eclipse.ecf.core.identity.Namespace. The XMPPNamespace class provides the XMPP namespace implementation and as described above implements the XMPP namespace restrictions. It is also responsible for constructing new ID instances via the ECF IDFactory. For example, to construct an instance of and XMPP ID, a client could use the following code:
       ID newID = IDFactory.getDefault().createID("ecf.xmpp","slewis@foo.com");
       
Underneath the covers of the IDFactory.createID method the following occurs:
  1. The name "ecf.xmpp" is used to lookup it's associated Namespace class (in this case XMPPNamespace). This lookup is done via the Eclipse extension registry.
  2. The XMPPNamespace.createInstance method is called to manufacture an ID that is in the XMPPNamespace from the string "slewis@foo.com"
  3. The new ID is returned to the caller
Note that there are other IDFactory.createID(...) methods that allow parameters other than Strings to be used for ID construction (e.g. URIs). 

Container Extensibility through Adapters

To support run-time extensibility, the IContainer interface inherits from org.eclipse.core.runtime.IAdaptable. This interface exposes a single method: the 'getAdapter(Class intf)' method. In the case of IContainer instances, this allows client applications to query the IContainer instance at runtime about it's exposed capabilities, and get access to those capabilities if they are available. So, for example, perhaps we're interested in creating an instant messaging application and wish to use the capabilities exposed by the IPresenceContainer interface. To do this, we simply query the IContainer instance at runtime to see if it provides access to IPresenceContainer capabilities:
       IPresenceContainer pc = (IPresenceContainer) cont.getAdapter(IPresenceContainer.class);
       if (pc != null) {
           // The container DOES expose IPresenceContainer capabilities, so we can use them!
       } else {
           // The container does not expose IPresenceContainer capabilities...we're out of luck
       }
       
Among other positive characteristics, this adapter mechanism provides a consistent-yet-simple way for a wide variety of container types to be defined and used without the need to update the ECF IContainer abstractions.

See the documentation for the IContainer.getAdapter() method. See also a terrific article on EclipseZone about usage of IAdaptable for runtime extensibility

Identity

In ECF, identity of local or remote entities such as users, remote services, and groups are all represented via the ID interface. This interface provides the basic contract for addressing uniquely identified entities. ID instances belong to a given Namespace Namespaces define the range of allowable values of the ID instances belonging to that Namespace. So, for example, the Namespace of XMPP (Jabber) user identities is defined by XMPP RFC3920 as having the following structure
      jid             = [ node "@" ] domain [ "/" resource ]
      domain          = fqdn / address-literal
      fqdn            = (sub-domain 1*("." sub-domain))
      sub-domain      = (internationalized domain label)
      address-literal = IPv4address / IPv6address
      example         = slewis@foo.com/ecf
       
The ECF XMPP provider implementation restricts jids to this syntax by providing a Namespace subclass responsible for constructing ID instances that follow the rules defined by the protocol specification. Other communications protocols and their associated service identities have their own Namespaces (e.g. ftp, http, sip, irc, etc, etc), each with it's own requirements for addressing and identity. The ID contract is not bound to any specific protocol, and makes it possible to create client applications that are insensitive to the addressing differences between protocols while still guaranteeing basic uniqueness requirements within a given namespace.

Example: Container creation, ID creation, container adapter, and connection

         // Create the new container 
		IContainer client = ContainerFactory
				.getDefault().createContainer(containerType);
		// Create the targetID 
		ID targetID = IDFactory.getDefault().createID(client.getConnectNamespace(), uri);
	    // Check for IPresenceContainer....if it is, setup presence UI, if not setup shared object container
		IPresenceContainer pc = (IPresenceContainer) client
				.getAdapter(IPresenceContainer.class);
		if (pc != null) {
			// Setup presence UI
			presenceContainerUI = new PresenceContainerUI(pc);
			presenceContainerUI.setup(client, targetID, username);
		} else throw new NullPointerException("IPresenceContainer interface not exposed by client with type "+containerType);
		// connect
		client.connect(targetID, getJoinContext(username, connectData));

 

'OSGi 이야기' 카테고리의 다른 글

OGEMA - ogema.sample.deviceSim.devices  (0) 2011.12.29
OGEMA - DeviceSimulationV2.impl  (0) 2011.12.29
OSGi WebBundle  (0) 2011.12.27
OSGi Extender  (0) 2011.12.27
OGEMA_SOURCE_URL  (0) 2011.12.20
:
Posted by НooпeУ


Code Start Code End