private String FormatMessage(String key, String dflt, params object[] args) { APIConfigurationImpl apiConfig = Parent.Parent; ConnectorMessages messages = apiConfig.ConnectorInfo.Messages; return(messages.Format(key, dflt, args)); }
public APIConfiguration CreateDefaultAPIConfiguration() { APIConfigurationImpl rv = (APIConfigurationImpl) SerializerUtil.CloneObject(_defaultAPIConfiguration); rv.ConnectorInfo = this; return(rv); }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public AbstractConnectorFacade(APIConfigurationImpl configuration) { Assertions.NullCheck(configuration, "configuration"); //clone in case application tries to modify //after the fact. this is necessary to //ensure thread-safety of a ConnectorFacade //also, configuration is used as a key in the //pool, so it is important that it not be modified. _configuration = (APIConfigurationImpl)SerializerUtil.CloneObject(configuration); //parent ref not included in the clone _configuration.ConnectorInfo = (configuration.ConnectorInfo); }
public override ConnectorFacade NewInstance(APIConfiguration config) { ConnectorFacade ret = null; APIConfigurationImpl impl = (APIConfigurationImpl)config; AbstractConnectorInfo connectorInfo = impl.ConnectorInfo; if (connectorInfo is LocalConnectorInfoImpl) { LocalConnectorInfoImpl localInfo = (LocalConnectorInfoImpl)connectorInfo; // create a new Provisioner.. ret = new LocalConnectorFacadeImpl(localInfo, impl); } else { ret = new RemoteConnectorFacadeImpl(impl); } return(ret); }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public AbstractConnectorFacade(APIConfigurationImpl configuration) { Assertions.NullCheck(configuration, "configuration"); //clone in case application tries to modify //after the fact. this is necessary to //ensure thread-safety of a ConnectorFacade //also, configuration is used as a key in the //pool, so it is important that it not be modified. byte[] bytes = SerializerUtil.SerializeBinaryObject(configuration); _connectorFacadeKey = Convert.ToBase64String(bytes); _configuration = (APIConfigurationImpl)SerializerUtil.DeserializeBinaryObject(bytes); //parent ref not included in the clone _configuration.ConnectorInfo = configuration.ConnectorInfo; _configuration.ChangeListener = configuration.ChangeListener; ; }
public APIConfigurationImpl(APIConfigurationImpl other) { if (null != other._connectorPoolConfiguration) { ConnectorPoolConfiguration = new ObjectPoolConfiguration(other._connectorPoolConfiguration); } if (null != other._resultsHandlerConfiguration) { ResultsHandlerConfiguration = new ResultsHandlerConfiguration(other._resultsHandlerConfiguration); } IsConnectorPoolingSupported = other.IsConnectorPoolingSupported; ConfigurationPropertiesImpl prop = new ConfigurationPropertiesImpl(); prop.Properties = ((ConfigurationPropertiesImpl)other.ConfigurationProperties).Properties; ConfigurationProperties = prop; ProducerBufferSize = other.ProducerBufferSize; TimeoutMap = new Dictionary<SafeType<APIOperation>, int>(other.TimeoutMap); SupportedOperations = new HashSet<SafeType<APIOperation>>(other.SupportedOperations); ConnectorInfo = other.ConnectorInfo; ChangeListener = other.ChangeListener; }
/// <summary> /// Builds up the maps of supported operations and calls. /// </summary> public AbstractConnectorFacade(string configuration, AbstractConnectorInfo connectorInfo, IConfigurationPropertyChangeListener changeListener) { Assertions.NullCheck(configuration, "configuration"); Assertions.NullCheck(connectorInfo, "connectorInfo"); _connectorFacadeKey = configuration; _configuration = (APIConfigurationImpl)SerializerUtil.DeserializeBase64Object(configuration); // parent ref not included in the clone _configuration.ConnectorInfo = connectorInfo; _configuration.ChangeListener = changeListener; }
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 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)); }
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); }
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(configuration) { }
public RemoteOperationInvocationHandler(APIConfigurationImpl configuration, SafeType<APIOperation> operation) { _configuration = configuration; _operation = 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 AbstractConnectorFacade(APIConfigurationImpl configuration) { Assertions.NullCheck(configuration, "configuration"); //clone in case application tries to modify //after the fact. this is necessary to //ensure thread-safety of a ConnectorFacade //also, configuration is used as a key in the //pool, so it is important that it not be modified. _configuration = (APIConfigurationImpl)SerializerUtil.CloneObject(configuration); //parent ref not included in the clone _configuration.ConnectorInfo = (configuration.ConnectorInfo); }