ECF Shared Object Factory

Identifier:
org.eclipse.ecf.sharedObjectFactory

Since:
0.6.0

Description:
ECF Shared Object Factory extension point (org.eclipse.ecf.sharedObjectFactory. This extension point allows implmenters to define an org.eclipse.ecf.core.sharedobject.provider.ISharedObjectInstantiator that will be responsible for creating org.eclipse.ecf.core.sharedobject.ISharedObject instances when requested by clients. Here is the ISharedObjectInstantiator that extensions must implement:

public interface ISharedObjectInstantiator {
 /**
  * Create instance of ISharedObject. This is the interface that plugin
  * implementations must implement for the sharedObjectFactory extension
  * point. The caller may optionally specify both argument types and
  * arguments that will be passed into this method (and therefore to the
  * provider implementation implementing this method). For example:
  * <p>
  * </p>
  * <p>
  * <b>
  * SharedObjectFactory.getDefault().createSharedObject("foosharedobject",new
  * String [] { java.lang.String }, new Object { "hello" });</b>
  * </p>
  * <p>
  * </p>
  * 
  * @param typeDescription
  *            the SharedObjectTypeDescription associated with the registered
  *            shared object provider implementation plugin
  * @param args
  *            arguments specified by the caller. May be null if no arguments
  *            are passed in by caller to
  *            SharedObjectFactory.getDefault().createSharedObject(...)
  * @return ISharedObject instance. The provider implementation must return a
  *         valid object implementing ISharedObject OR throw a
  *         SharedObjectCreateException
  * @throws SharedObjectCreateException
  *             if shared object instance cannot be created
  */
 public ISharedObject createInstance(
   SharedObjectTypeDescription typeDescription, Object[] args)
   throws SharedObjectCreateException;
}

Configuration Markup:

<!ELEMENT extension (sharedObjectFactory+)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT sharedObjectFactory (property*)>

<!ATTLIST sharedObjectFactory

class       CDATA #REQUIRED

name        CDATA #IMPLIED

description CDATA #IMPLIED>


<!ELEMENT property EMPTY>

<!ATTLIST property

name  CDATA #REQUIRED

value CDATA #REQUIRED>

Property (name,value) associated with SharedObjectTypeDescription



Examples:
Here's an example of an extension point declaration:

   <extension
         point="org.eclipse.ecf.sharedobject.sharedObjectFactory">
      <sharedObjectFactory
            class="org.eclipse.ecf.tests.provider.TestSharedObjectInstantiator"
            name="ecf.test.sharedobjectfactory"/>
   </extension>
and the TestSharedObjectInstantiator is defined:

public class TestSharedObjectInstantiator implements ISharedObjectInstantiator {

 public ISharedObject createInstance(SharedObjectTypeDescription description, Object[] args) throws SharedObjectCreateException {
  System.out.println("createInstance("+description+","+((args==null)?"null":Arrays.asList(args).toString()));
  return new TestSharedObject();
 }
}

Example Usage of Container by Clients

Clients may use the extension via calls such as:

ISharedObject obj = SharedObjectFactory.getDefault().createSharedObject("ecf.test.sharedobjectfactory");


Copyright (c) 2004 Composent, Inc. and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: Composent, Inc. - initial API and implementation