Plugins using this extension point can define a new implementation of any desired communications protocol, and expose that protocol as an instance of an IContainer. When client requests are made to ECF ContainerFactory to create IContainer instances, those requests will be re-directed to the given IContainer implementer.
<!ELEMENT extension (containerFactory+)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!ELEMENT containerFactory EMPTY>
<!ATTLIST containerFactory
class CDATA #REQUIRED
name CDATA #IMPLIED
description CDATA #IMPLIED
server (true | false)
hidden (true | false) >
The container factory extension point. Can optionally contain a list of 'defaultargument' elements that describe the arguments to be passed to provider implementation
<extension point="org.eclipse.ecf.containerFactory"> <containerFactory name="foo" class="org.eclipse.ecf.test.FooInstantiator" description="My container factory"/> </extension>Here is some example code to implement this class:
package org.eclipse.ecf.test;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.ContainerInstantiationException;
import org.eclipse.ecf.core.provider.IContainerInstantiator;
public class FooInstantiator implements IContainerInstantiator {
public FooInstantiator() {
super();
}
public IContainer createInstance(ContainerTypeDescription description, Class[] argTypes, Object[] args)
throws ContainerInstantiationException {
// Create/return instance of FooContainer
// Note that FooContainer class must
// implement IContainer
return new FooContainer();
}
}
In this example, the given class implements the IContainerInstantiator.createInstance method by creating and returning a new instance of FooInstantiator, a class also defined in the extension plugin. As noted in the code, this class must implement IContainer, so that it can successfully be returned from createInstance.
IContainer newContainer = ContainerFactory.getDefault().createContainer('foo');
// Further use of newContainer instance here
/**
* Container factory contract {@link ContainerFactory} for default
* implementation.
*/
public interface IContainerFactory {
/**
* Add a ContainerTypeDescription to the set of known ContainerDescriptions.
*
* @param description
* the ContainerTypeDescription to add to this factory. Must not
* be null.
* @return ContainerTypeDescription the old description of the same name,
* null if none found
*/
public ContainerTypeDescription addDescription(ContainerTypeDescription description);
/**
* Get a collection of the ContainerDescriptions currently known to this
* factory. This allows clients to query the factory to determine what if
* any other ContainerDescriptions are currently registered with the
* factory, and if so, what they are.
*
* @return List of ContainerTypeDescription instances
*/
public List /* ContainerTypeDescription */ getDescriptions();
/**
* Check to see if a given named description is already contained by this
* factory
*
* @param description
* the ContainerTypeDescription to look for
* @return true if description is already known to factory, false otherwise
*/
public boolean containsDescription(ContainerTypeDescription description);
/**
* Get the known ContainerTypeDescription given it's name.
*
* @param name
* the name to use as key to find ContainerTypeDescription
* @return ContainerTypeDescription found. Null if not found.
*/
public ContainerTypeDescription getDescriptionByName(String name);
/**
* Make IContainer instance. Given a ContainerTypeDescription object, a
* String [] of argument types, and an Object [] of parameters, this method
* will
* <p>
* <ul>
* <li>lookup the known ContainerDescriptions to find one of matching name</li>
* <li>if found, will retrieve or create an IContainerInstantiator for that
* description</li>
* <li>Call the IContainerInstantiator.createInstance method to return an
* instance of IContainer</li>
* </ul>
*
* @param description
* the ContainerTypeDescription to use to create the instance
* @param parameters
* an Object [] of parameters passed to the createInstance method
* of the IContainerInstantiator
* @return a valid instance of IContainer
* @throws ContainerCreateException
*/
public IContainer createContainer(ContainerTypeDescription description,
Object[] parameters) throws ContainerCreateException;
/**
* Make IContainer instance. Given a ContainerTypeDescription name, this
* method will
* <p>
* <ul>
* <li>lookup the known ContainerDescriptions to find one of matching name</li>
* <li>if found, will retrieve or create an IContainerInstantiator for that
* description</li>
* <li>Call the IContainerInstantiator.createInstance method to return an
* instance of IContainer</li>
* </ul>
*
* @param descriptionName
* the ContainerTypeDescription name to lookup
* @return a valid instance of IContainer
* @throws ContainerCreateException
*/
public IContainer createContainer(String descriptionName)
throws ContainerCreateException;
/**
* Make IContainer instance. Given a ContainerTypeDescription name, this
* method will
* <p>
* <ul>
* <li>lookup the known ContainerDescriptions to find one of matching name</li>
* <li>if found, will retrieve or create an IContainerInstantiator for that
* description</li>
* <li>Call the IContainerInstantiator.createInstance method to return an
* instance of IContainer</li>
* </ul>
*
* @param descriptionName
* the ContainerTypeDescription name to lookup
* @param parameters
* the Object [] of parameters passed to the
* IContainerInstantiator.createInstance method
* @return a valid instance of IContainer
* @throws ContainerCreateException
*/
public IContainer createContainer(String descriptionName, Object[] parameters)
throws ContainerCreateException;
/**
* Remove given description from set known to this factory.
*
* @param description
* the ContainerTypeDescription to remove
* @return the removed ContainerTypeDescription, null if nothing removed
*/
public ContainerTypeDescription removeDescription(
ContainerTypeDescription description);
}
Copyright (c) 2004 Composent, Inc. and others. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ SPDX-License-Identifier: EPL-2.0