/// <summary> /// Returns the CAO proxy using the /// argument list to call the constructor. /// </summary> /// <remarks> /// The matching of arguments to call the constructor is done /// by type. The alternative ways, by index and by constructor /// name are not supported. /// </remarks> /// <param name="constructorArguments">Constructor /// arguments used to create the object.</param> /// <returns>The remote object.</returns> public object GetObject(object[] constructorArguments) { RootObjectDefinition mergedObjectDefinition = objectFactory.GetMergedObjectDefinition(targetName, false); if (typeof(IFactoryObject).IsAssignableFrom(mergedObjectDefinition.ObjectType)) { throw new NotSupportedException( "Client activated objects with constructor arguments is not supported with IFactoryObject implementations."); } remoteObjectFactory.Target = objectFactory.GetObject(targetName, constructorArguments); return(remoteObjectFactory.GetObject()); }
/// <summary> /// Resolves an inner object definition. /// </summary> /// <param name="name"> /// The name of the object that surrounds this inner object definition. /// </param> /// <param name="innerObjectName"> /// The name of the inner object definition... note: this is a synthetic /// name assigned by the factory (since it makes no sense for inner object /// definitions to have names). /// </param> /// <param name="argumentName"> /// The name of the property the value of which is being resolved. /// </param> /// <param name="definition"> /// The definition of the inner object that is to be resolved. /// </param> /// <param name="singletonOwner"> /// <see langword="true"/> if the owner of the property is a singleton. /// </param> /// <returns> /// The resolved object as defined by the inner object definition. /// </returns> protected virtual object ResolveInnerObjectDefinition(string name, string innerObjectName, string argumentName, IObjectDefinition definition, bool singletonOwner) { RootObjectDefinition mod = objectFactory.GetMergedObjectDefinition(innerObjectName, definition); // Check given bean name whether it is unique. If not already unique, // add counter - increasing the counter until the name is unique. String actualInnerObjectName = innerObjectName; if (mod.IsSingleton) { actualInnerObjectName = AdaptInnerObjectName(innerObjectName); } mod.IsSingleton = singletonOwner; object instance; object result; try { //SPRNET-986 ObjectUtils.EmptyObjects -> null instance = objectFactory.InstantiateObject(actualInnerObjectName, mod, null, false, false); result = objectFactory.GetObjectForInstance(instance, actualInnerObjectName, actualInnerObjectName, mod); } catch (ObjectsException ex) { throw ObjectCreationException.GetObjectCreationException(ex, name, argumentName, definition.ResourceDescription, innerObjectName); } if (singletonOwner && instance is IDisposable) { // keep a reference to the inner object instance, to be able to destroy // it on factory shutdown... objectFactory.DisposableInnerObjects.Add(instance); } return(result); }