{
switch (object.getType())
{
case PROCESSING_ELEMENT_TYPE:
{
ProcessingElementDescriptor descriptor =
(ProcessingElementDescriptor) object.getMetadata();
// add the annotations
Map<String, String> metadata = descriptor.getMetadata();
if (metadata == null)
{
metadata = new HashMap<String, String>();
descriptor.setMetadata(metadata);
}
for (Entry<String, Object> entry : object.getAnnotations().entrySet())
{
metadata.put(entry.getKey(), String.valueOf(entry.getValue()));
}
URI uri = null;
try
{
uri = storeImplementation(object.getDispel());
descriptor.setLocation(uri);
mProcessingElementRegistry.registerProcessingElement(
descriptor, RegistryConstants.PE_TYPE);
}
catch (Throwable e)
{
if (uri != null)
{
removeImplementation(uri);
}
throw new RegistrationFailedException(object, e);
}
}
break;
case FUNCTION:
{
SimpleFunctionDescriptor descriptor =
new SimpleFunctionDescriptor(object.getName());
Function function = (Function)object.getMetadata();
for (Entry<Integer, String> index : function.getIndices().entrySet())
{
Type type = function.getParameters().get(index.getValue());
Parameter parameter = getDescriptor(
type,
function.getArrayDimensions().get(index.getValue()));
parameter.setIndex(index.getKey());
descriptor.addParameter(index.getValue(), parameter);
}
descriptor.setReturnType(
getDescriptor(
function.getReturnType(),
function.getReturnTypeArray()));
URI uri = null;
try
{
uri = storeImplementation(object.getDispel());
descriptor.setLocation(uri);
mFunctionRegistry.registerFunction(descriptor);
}
catch (Throwable e)
{
if (uri != null)