/// <summary> /// Get a object pool for this connector if it supports connector pooling. /// </summary> public static ObjectPool <PoolableConnector> GetPool(APIConfigurationImpl impl, LocalConnectorInfoImpl localInfo) { ObjectPool <PoolableConnector> pool = null; // determine if this connector wants generic connector pooling.. if (impl.IsConnectorPoolingSupported) { ConnectorPoolKey key = new ConnectorPoolKey( impl.ConnectorInfo.ConnectorKey, (ConfigurationPropertiesImpl)impl.ConfigurationProperties, impl.ConnectorPoolConfiguration); lock (_pools) { // get the pool associated.. pool = CollectionUtil.GetValue(_pools, key, null); // create a new pool if it doesn't exist.. if (pool == null) { Trace.TraceInformation("Creating new pool: " + impl.ConnectorInfo.ConnectorKey); // this instance is strictly used for the pool.. pool = new ObjectPool <PoolableConnector>( new ConnectorPoolHandler(impl, localInfo), impl.ConnectorPoolConfiguration); // add back to the map of _pools.. _pools[key] = pool; } } } return(pool); }
public void TestOperationRequest() { ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List <ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); IList <object> args = new List <object>(); args.Add("my arg"); OperationRequest v1 = new OperationRequest(new ConnectorKey("my bundle", "my version", "my connector"), SerializerUtil.SerializeBase64Object(apiImpl), SafeType <APIOperation> .Get <CreateApiOp>(), "mymethodName", args); OperationRequest v2 = (OperationRequest)CloneObject(v1); Assert.AreEqual("my bundle", v2.ConnectorKey.BundleName); Assert.AreEqual("my version", v2.ConnectorKey.BundleVersion); Assert.AreEqual("my connector", v2.ConnectorKey.ConnectorName); Assert.IsNotNull(v2.ConnectorFacadeKey); Assert.AreEqual(SafeType <APIOperation> .Get <CreateApiOp>(), v2.Operation); Assert.AreEqual("mymethodName", v2.OperationMethodName); Assert.IsTrue( CollectionUtil.Equals( args, v2.Arguments)); }
/// <summary> /// Method for convenient testing of local connectors. /// </summary> public APIConfiguration CreateTestConfiguration(SafeType <Connector> clazz, Configuration config) { LocalConnectorInfoImpl info = new LocalConnectorInfoImpl(); info.ConnectorConfigurationClass = SafeType <Configuration> .Get(config); info.ConnectorClass = (clazz); info.ConnectorDisplayNameKey = ("DUMMY_DISPLAY_NAME"); info.ConnectorKey = ( new ConnectorKey(clazz.RawType.Name + ".bundle", "1.0", clazz.RawType.Name)); info.Messages = (this.CreateDummyMessages()); APIConfigurationImpl rv = new APIConfigurationImpl(); rv.IsConnectorPoolingSupported = ( IsConnectorPoolingSupported(clazz)); ConfigurationPropertiesImpl properties = CSharpClassProperties.CreateConfigurationProperties(config); rv.ConfigurationProperties = (properties); rv.ConnectorInfo = (info); rv.SupportedOperations = ( FrameworkUtil.GetDefaultSupportedOperations(clazz)); info.DefaultAPIConfiguration = ( rv); return(rv); }
public void TestRemoteConnectorInfo() { RemoteConnectorInfoImpl v1 = new RemoteConnectorInfoImpl(); v1.Messages = (new ConnectorMessagesImpl()); v1.ConnectorKey = (new ConnectorKey("my bundle", "my version", "my connector")); ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List <ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); v1.DefaultAPIConfiguration = (apiImpl); v1.ConnectorDisplayNameKey = ("mykey"); v1.ConnectorCategoryKey = ("LDAP"); RemoteConnectorInfoImpl v2 = (RemoteConnectorInfoImpl) CloneObject(v1); Assert.IsNotNull(v2.Messages); Assert.AreEqual("my bundle", v2.ConnectorKey.BundleName); Assert.AreEqual("my version", v2.ConnectorKey.BundleVersion); Assert.AreEqual("my connector", v2.ConnectorKey.ConnectorName); Assert.AreEqual("mykey", v2.ConnectorDisplayNameKey); Assert.AreEqual("LDAP", v2.ConnectorCategoryKey); Assert.IsNotNull(v2.DefaultAPIConfiguration); }
public void TestHelloResponse() { Exception ex = new Exception("foo"); IDictionary <string, object> serverInfo = new Dictionary <string, object>(1); serverInfo.Add(HelloResponse.SERVER_START_TIME, DateTimeUtil.GetCurrentUtcTimeMillis()); ConnectorKey key = new ConnectorKey("my bundle", "my version", "my connector"); RemoteConnectorInfoImpl info = new RemoteConnectorInfoImpl(); info.Messages = (new ConnectorMessagesImpl()); info.ConnectorKey = (key); ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List <ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); info.DefaultAPIConfiguration = (apiImpl); info.ConnectorDisplayNameKey = ("mykey"); info.ConnectorCategoryKey = (""); HelloResponse v1 = new HelloResponse(ex, serverInfo, CollectionUtil.NewReadOnlyList <ConnectorKey>(key), CollectionUtil.NewReadOnlyList <RemoteConnectorInfoImpl>(info)); HelloResponse v2 = (HelloResponse)CloneObject(v1); Assert.IsNotNull(v2.Exception); Assert.IsNotNull(v2.ServerInfo[HelloResponse.SERVER_START_TIME]); Assert.IsNotNull(v2.ConnectorKeys.First()); Assert.IsNotNull(v2.ConnectorInfos.First()); }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public RemoteConnectorFacadeImpl(APIConfigurationImpl configuration) : base(GenerateRemoteConnectorFacadeKey(configuration), configuration.ConnectorInfo) { // Restore the original configuration settings GetAPIConfiguration().ProducerBufferSize = configuration.ProducerBufferSize; GetAPIConfiguration().TimeoutMap = configuration.TimeoutMap; remoteConnectorFacadeKey = ConnectorFacadeKey; }
private static string GenerateRemoteConnectorFacadeKey(APIConfigurationImpl configuration) { APIConfigurationImpl copy = new APIConfigurationImpl(configuration); copy.ProducerBufferSize = 0; copy.TimeoutMap = new Dictionary <SafeType <APIOperation>, int>(); return(SerializerUtil.SerializeBase64Object(copy)); }
public OperationRequest(ConnectorKey key, APIConfigurationImpl apiConfiguration, SafeType <APIOperation> operation, string operationMethodName, IList <Object> arguments) { _connectorKey = key; _configuration = apiConfiguration; _operation = operation; _operationMethodName = operationMethodName; _arguments = CollectionUtil.NewReadOnlyList <object>(arguments); }
CreateDefaultAPIConfiguration(LocalConnectorInfoImpl localInfo) { SafeType <Connector> connectorClass = localInfo.ConnectorClass; APIConfigurationImpl rv = new APIConfigurationImpl(); Configuration config = localInfo.ConnectorConfigurationClass.CreateInstance(); bool pooling = IsPoolingSupported(connectorClass); rv.IsConnectorPoolingSupported = pooling; rv.ConfigurationProperties = (CSharpClassProperties.CreateConfigurationProperties(config)); rv.ConnectorInfo = (localInfo); rv.SupportedOperations = (FrameworkUtil.GetDefaultSupportedOperations(connectorClass)); return(rv); }
public void TestAPIConfiguration() { ConfigurationPropertyImpl prop1 = new ConfigurationPropertyImpl(); prop1.Order = (1); prop1.IsConfidential = (true); prop1.Name = ("foo"); prop1.HelpMessageKey = ("help key"); prop1.DisplayMessageKey = ("display key"); prop1.GroupMessageKey = ("group key"); prop1.Value = ("bar"); prop1.ValueType = (typeof(string)); prop1.Operations = null; ConfigurationPropertiesImpl props1 = new ConfigurationPropertiesImpl(); props1.Properties = (CollectionUtil.NewReadOnlyList <ConfigurationPropertyImpl>(prop1)); APIConfigurationImpl v1 = new APIConfigurationImpl(); v1.ConnectorPoolConfiguration = (new ObjectPoolConfiguration()); v1.ConfigurationProperties = (props1); v1.IsConnectorPoolingSupported = (true); v1.ProducerBufferSize = (200); v1.SupportedOperations = (FrameworkUtil.AllAPIOperations()); IDictionary <SafeType <APIOperation>, int> map = CollectionUtil.NewDictionary <SafeType <APIOperation>, int>(SafeType <APIOperation> .Get <CreateApiOp>(), 6); v1.TimeoutMap = (map); APIConfigurationImpl v2 = (APIConfigurationImpl) CloneObject(v1); Assert.IsTrue(!Object.ReferenceEquals(v1, v2)); Assert.IsNotNull(v2.ConnectorPoolConfiguration); Assert.IsNotNull(v2.ConfigurationProperties); Assert.AreEqual(v1.ConnectorPoolConfiguration, v2.ConnectorPoolConfiguration); Assert.AreEqual(v1.ConfigurationProperties, v2.ConfigurationProperties); Assert.IsTrue(v2.IsConnectorPoolingSupported); Assert.AreEqual(200, v2.ProducerBufferSize); Assert.IsTrue(CollectionUtil.SetsEqual( FrameworkUtil.AllAPIOperations(), v2.SupportedOperations)); Assert.AreEqual(map, v2.TimeoutMap); }
private APIOperation GetAPIOperation(OperationRequest request) { ConnectorInfoManager manager = GetConnectorInfoManager(); ConnectorInfo info = manager.FindConnectorInfo( request.ConnectorKey); if (info == null) { throw new Exception("No such connector: " + request.ConnectorKey); } APIConfigurationImpl config = request.Configuration; //re-wire the configuration with its connector info config.ConnectorInfo = (AbstractConnectorInfo)info; ConnectorFacade facade = ConnectorFacadeFactory.GetInstance().NewInstance(config); return(facade.GetOperation(request.Operation)); }
public void TestHelloResponse() { RemoteConnectorInfoImpl info = new RemoteConnectorInfoImpl(); info.Messages = (new ConnectorMessagesImpl()); info.ConnectorKey = (new ConnectorKey("my bundle", "my version", "my connector")); ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List <ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); info.DefaultAPIConfiguration = (apiImpl); info.ConnectorDisplayNameKey = ("mykey"); Exception ex = new Exception("foo"); HelloResponse v1 = new HelloResponse(ex, CollectionUtil.NewReadOnlyList <RemoteConnectorInfoImpl>(info)); HelloResponse v2 = (HelloResponse)CloneObject(v1); Assert.IsNotNull(v2.Exception); Assert.IsNotNull(v2.ConnectorInfos.First()); }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public LocalConnectorFacadeImpl(LocalConnectorInfoImpl connectorInfo, APIConfigurationImpl apiConfiguration) : base(apiConfiguration) { this.connectorInfo = connectorInfo; }
public OperationRequest(ConnectorKey key, APIConfigurationImpl apiConfiguration, SafeType<APIOperation> operation, string operationMethodName, IList<Object> arguments) { _connectorKey = key; _configuration = apiConfiguration; _operation = operation; _operationMethodName = operationMethodName; _arguments = CollectionUtil.NewReadOnlyList<object>(arguments); }
/// <summary> /// Method for convenient testing of local connectors. /// </summary> public APIConfiguration CreateTestConfiguration(SafeType <Connector> connectorClass, PropertyBag configData, string prefix) { Debug.Assert(null != connectorClass); Type rawConnectorClass = connectorClass.RawType; Object[] attributes = connectorClass.RawType.GetCustomAttributes( typeof(ConnectorClassAttribute), false); if (attributes.Length > 0) { ConnectorClassAttribute attribute = (ConnectorClassAttribute)attributes[0]; Assembly assembly = IOUtil.GetAssemblyContainingType(rawConnectorClass.FullName); String fileName = assembly.Location; SafeType <Configuration> connectorConfigurationClass = attribute.ConnectorConfigurationType; if (connectorConfigurationClass == null) { String MSG = ("File " + fileName + " contains a ConnectorInfo attribute " + "with no connector configuration class."); throw new ConfigurationException(MSG); } String connectorDisplayNameKey = attribute.ConnectorDisplayNameKey; if (connectorDisplayNameKey == null) { String MSG = ("File " + fileName + " contains a ConnectorInfo attribute " + "with no connector display name."); throw new ConfigurationException(MSG); } LocalConnectorInfoImpl rv = new LocalConnectorInfoImpl(); rv.ConnectorClass = connectorClass; rv.ConnectorConfigurationClass = connectorConfigurationClass; rv.ConnectorDisplayNameKey = connectorDisplayNameKey; rv.ConnectorCategoryKey = attribute.ConnectorCategoryKey; rv.ConnectorKey = ( new ConnectorKey(rawConnectorClass.Name + ".bundle", "1.0", rawConnectorClass.Name));; APIConfigurationImpl impl = LocalConnectorInfoManagerImpl.CreateDefaultAPIConfiguration(rv); rv.DefaultAPIConfiguration = impl; // if (false) // { // rv.Messages = CreateDummyMessages(); // } // else { rv.Messages = LocalConnectorInfoManagerImpl.LoadMessages(assembly, rv, attribute.MessageCatalogPaths); } ConfigurationPropertiesImpl configProps = (ConfigurationPropertiesImpl)impl.ConfigurationProperties; string fullPrefix = StringUtil.IsBlank(prefix) ? null : prefix + "."; foreach (ConfigurationPropertyImpl property in configProps.Properties) { object value = configData.GetProperty(null != fullPrefix ? fullPrefix + property.Name : property.Name, property.ValueType, property.Value); if (value != null) { property.Value = value; } } return(impl); } throw new ArgumentException("ConnectorClass does not define ConnectorClassAttribute"); }
private static string GenerateRemoteConnectorFacadeKey(APIConfigurationImpl configuration) { APIConfigurationImpl copy = new APIConfigurationImpl(configuration); copy.ProducerBufferSize = 0; copy.TimeoutMap = new Dictionary<SafeType<APIOperation>, int>(); return SerializerUtil.SerializeBase64Object(copy); }
public RemoteOperationInvocationHandler(APIConfigurationImpl configuration, SafeType <APIOperation> operation) { _configuration = configuration; _operation = operation; }
public ConnectorPoolHandler(APIConfigurationImpl apiConfiguration, LocalConnectorInfoImpl localInfo) { _apiConfiguration = apiConfiguration; _localInfo = localInfo; }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public RemoteConnectorFacadeImpl(APIConfigurationImpl configuration) : base(configuration) { }