问题标签 [service-factory]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
859 浏览

php - PHP Magic Methods - __get and __set not working in php MVC framework serviceFactory

I created an instance of serviceFactory in index.php which simply gets/stores (private) variables in itself. But, the __get and __set magic methods for some reason are not working. Doing a var_dump($serviceFactory->language) in the index returns false. When I create an instance of serviceFactory, I pass the $router instance to the $serviceFactory constructor. The router is working (otherwise it would not display controller or view), but for some reason, when I try to __get the language from the $serviceFactory instance, it returns false and I'm confused as to why.

index.php

serviceFactory

0 投票
1 回答
1229 浏览

php - ZF2:从外部类调用服务?

在我的 Zend Framework 2 项目中,我有一个外部库,我想将我的信息与模型一起保存在基础中。

……………………

编辑信息:

我再次解释了我的需求:在我的控制器中,我在数据库中进行插入和删除,并且我想将所有操作记录在“t_log”表中。为此,我想创建一个外部类。

我的问题是:如何从外部类调用模型方法?

我的模型:

谢谢 !

0 投票
1 回答
633 浏览

angularjs - Datepicker 作为服务工厂 Angular

我犯了经典的初学者错误,把我所有的业务逻辑都放到了我的控制器中,而不是使用服务。

我有一堆功能,现在我想将它们放入服务中并将其注入到我的控制器中。一般来说,有没有一种好的方法可以做到这一点以及如何做到这一点?

例如,我有一个日期选择器,它作为默认日期设置为从今天起两周内。我在控制器中解决了这个问题

而在我的 htmlng-model='dt'中。我现在想采用这种逻辑并将其放入服务中。我考虑过使用工厂,我做了这样的事情:

并在控制器中

这不像我预期的那样工作。这里有什么问题?

干杯

0 投票
1 回答
378 浏览

c# - 使用工厂抛出异常进行实例化

我将首先说我是新手,所以我可能会犯一个非常简单的错误,但我只是没有看到它。我有以下工厂:

以及如下界面:

以及以下实现:

我正在尝试运行以下单元测试:

我得到以下异常:

我不完全理解正在发生的事情,我觉得我在追逐各种可能性,而每一种可能性都在引发更多问题。有人可以帮我理解为什么我很难创建 CreateCollectionImpl 的实例,以便我可以对创建集合并将其写入磁盘的能力进行单元测试吗?先感谢您。

0 投票
1 回答
83 浏览

java - OSGi ServiceFactory 返回一个不可转换的对象

我一整天都在努力完成这项工作,这令人沮丧,因为我没有看到我的代码有任何问题。

这是我的课程:

DisplayerServiceFactory.java

这是包含 DisplayerServiceFactory 的捆绑包的 Activator.java

这是运行 previus 包的嵌入式 osgi 容器的代码的一部分

当我运行这段代码时,它给了我这个异常

为什么会这样?很明显 DisplayerImplementation 是 Displayer 的一个实例。

我也做了一些调试,并且在 ServiceFactory 类(DisplayerImplementation instanceof Displayer)中返回 true,但是,当我从注册为服务的 ServiceFactory 获得显示实现时,(DisplayerImplementation instanceof Displayer)返回 false。

这可能是我正在使用的框架实现中的错误吗?我正在使用费利克斯顺便说一句。

如果你来到这里,谢谢你的阅读!如果您尝试帮助我,我会非常感激。祝你今天过得愉快!或者晚上!

0 投票
1 回答
442 浏览

c# - Correct WCF service handling using a factory and service proxies in C#

I have a part of my program that sends me an email and/or a push message to my iphone when something occurs. This is done through calls to two seperate WCF services using MSMQ. I followed this guide (model 4.0) in order to make it generic and test friendly. I like the generic channel creation, but my question is wether the proxies and channel factories are really closed/disposed correctly, or if this will blow up when it reaches a 10000 user environment (which it eventually will). The code works perfectly in my 50 user test environment.

Therefore, please review the following code:

Service Proxy

Service Proxy Factory

Making a service call (without return type for simplicity)

The questions are:

Should I close the ServiceProxy after the Execute?

Is it wise to create a ChannelFactory every time I call GetProxy(), and should this ChannelFactory then be closed again if so?

Is it really performance friendly to generate a ServiceProxy for every call? (it seems really heavy to me, but maybe someone can prove me wrong).

I left the interfaces out from this post, but they are really simple, and this whole setup with proxies and interfaces works really well with unit and integration testing.

I hope some of you coding wizards have an opinion about this, and will share this.

Thanks in advance!

0 投票
1 回答
535 浏览

java - OSGI 工厂实现中@Component 的目的是什么?

我正在尝试使用 apache felix scr 注释来实现 servicefactory。

上面的代码工作正常。但是@Component 的目的是什么?因为我试图将它公开为服务而不是组件和服务。如果我删除 @Component 状态不满意。工厂真的必须同时使用组件和服务吗?pom.xml

0 投票
0 回答
65 浏览

java - 从 OSGI 中的组件工厂访问的服务工厂

我正在使用组件工厂来创建多个唯一实例,而这些实例又使用服务工厂来创建多个实例。我的结构看起来像 TInterface - 接口/服务 TInterfaceInline - 它实现了 TInterface 还包括另一个服务的@Reference。
Tinterfaceimpl1 - 扩展了 TInterfaceInline,它是一个具有过滤器属性的服务工厂。TConsumer - 通过在@Reference 中获取 TInterfaceInline 来使用它的组件工厂。

消费者

TinterfaceImpl

Tinterface内联

父类

除此之外,剩下的就是标记接口。如果我尝试在 karaf 中安装,则 Tinterfaceimpl1 的状态为 REGISTERED。即)我正在使用服务工厂并从组件工厂访问服务工厂。Servicefactory 类扩展了一个实现接口的类。Tinterfaceimpl1 注册的原因是什么。

0 投票
1 回答
227 浏览

java - 在 OSGI 中不使用 servicefactory 使用 Componentfactory 创建唯一的服务实例

我正在尝试在 OSGi 中使用组件工厂。我的意图是使用作为工厂管理器的 Class B 创建作为工厂公开的 Class A 的实例。A 类包含一些带有@Reference 注释的服务,这些服务可以正常工作。相同的方法用于 C 类工厂(类似于 A 类),具有与 @Reference 相同的服务引用。

  1. 它会向 A 类和 C 类返回相同的服务对象吗?
  2. 如果是(对于问题1),服务工厂是否会为A类和C类的服务工作?(组件工厂内具有servicefactory属性的服务(A类和C类)
  3. 如果不是(对于问题 1),在使用 @Reference 时,是否有任何方法可以在 A 类和 C 类中获取唯一的服务对象,而不是工厂?
  4. 我可以分别对 A 类和 C 类中的那些服务使用 new 运算符来实现相同的目的,但我期待某种 DI 方法。在 DS 中是否可能/可实现?
0 投票
1 回答
883 浏览

c# - 在 Azure 中收集 Service Fabric 群集日志

我是 Service Fabric 群集的新手,我正在尝试从 Azure 中的群集收集日志。

基本上,我在 ServiceEventSource.cs 中定义了一个事件源“XXXXX”。在本地,当我在 VS2015 的诊断事件视图中将此源添加到 ETW 提供程序时,它会正确显示日志。

在 Azure 中,我无法收集任何日志。当我创建集群时,添加了 5 个存储帐户,但我无法在存储的 blob 中看到日志。我尝试根据这篇文章编辑 template.json 文件。我添加了一个条目EtwEventSourceProviderConfiguration

然后我部署了这个修改后的模板,但我仍然无法收集日志。

任何帮助将不胜感激!谢谢