0

我需要我的应用程序从数据库源读取它的配置,但我必须应用我自己的缓存机制来满足更新配置和性能的灵活性(在需要值时不访问数据库)

执行缓存机制的服务是SymbolSourceImpl. 因为我需要挂毯来缓存可缓存的值,例如 JVM 选项。我需要提供另一个符号源。但是SymbolObjectProvider(Contributed to MasterObjectProvider) 只包含一个实例,SymbolSource并且我不能覆盖SymbolSource默认绑定,所以我考虑将另一个符号对象提供程序贡献给 ,MasterObjectProvider就像 Tapestry 对 default 所做的那样SymbolObjectProvider

但是当我尝试贡献自己的符号对象提供者时,出现了一个问题:

@Contribute(MasterObjectProvider.class)
public static void setupDBSYmbolObjectProviders(OrderedConfiguration<ObjectProvider> configuration) {
    configuration.addInstance("DBSymbol", **DBSymbolObjectProvider**.class, OrderConstraintBuilder.before("Symbol").build());
}

我的DBSymbolObjectProvider构造函数如下所示:

public DBSymbolObjectProvider(IDBSymbolSource symbolSource, @Builtin TypeCoercer typeCoercer) {
    this.symbolSource = symbolSource;
    this.typeCoercer = typeCoercer;
}

Tapestry 已解决TypeCoercer,但无法解决IDBSymbolSource并抛出以下异常,这是合乎逻辑的,因为MasterObjectProvider尚未构造为 resolve IDBSymbolSource

java.lang.RuntimeException: Exception constructing service 'RegistryStartup': Unable to instantiate class com.skycomm.IpKaizenTAModule as a module: Exception constructing service 'MasterObjectProvider': Error invoking service contribution method com.skycomm.ipkaizen.services.CoreModule.setupDBSYmbolObjectProviders(OrderedConfiguration): Exception constructing service 'MasterObjectProvider': Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:54)
    at $Runnable_440ab1f4dbb6.delegate(Unknown Source)
    at $Runnable_440ab1f4dbb6.run(Unknown Source)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.performRegistryStartup(RegistryImpl.java:325)
    at org.apache.tapestry5.ioc.internal.RegistryWrapper.performRegistryStartup(RegistryWrapper.java:80)
    at com.skycomm.IpKaizenTA.main(IpKaizenTA.java:25)
Caused by: java.lang.RuntimeException: Unable to instantiate class com.skycomm.IpKaizenTAModule as a module: Exception constructing service 'MasterObjectProvider': Error invoking service contribution method com.skycomm.ipkaizen.services.CoreModule.setupDBSYmbolObjectProviders(OrderedConfiguration): Exception constructing service 'MasterObjectProvider': Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.ModuleImpl.instantiateModuleInstance(ModuleImpl.java:447)
    at org.apache.tapestry5.ioc.internal.ModuleImpl.access$1200(ModuleImpl.java:39)
    at org.apache.tapestry5.ioc.internal.ModuleImpl$6$1.invoke(ModuleImpl.java:355)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.ModuleImpl$6.run(ModuleImpl.java:350)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:200)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:197)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:140)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:206)
    at org.apache.tapestry5.ioc.internal.ModuleImpl$7.invoke(ModuleImpl.java:366)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
    at org.apache.tapestry5.ioc.internal.ModuleImpl.getModuleBuilder(ModuleImpl.java:374)
    at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:113)
    at org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:80)
    at org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:633)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:51)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:48)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.run(OperationTrackerImpl.java:47)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.run(PerThreadOperationTracker.java:76)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.addToOrderedConfiguration(RegistryImpl.java:629)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.getOrderedConfiguration(RegistryImpl.java:483)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$2.invoke(ServiceResourcesImpl.java:110)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$2.invoke(ServiceResourcesImpl.java:107)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getOrderedConfiguration(ServiceResourcesImpl.java:105)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.getOrderedConfiguration(AbstractServiceCreator.java:123)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.access$200(AbstractServiceCreator.java:35)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator$1.findResource(AbstractServiceCreator.java:103)
    at org.apache.tapestry5.ioc.internal.util.DelegatingInjectionResources.findResource(DelegatingInjectionResources.java:38)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:231)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:50)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:289)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:286)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:293)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1488)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1483)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.createConstructorConstructionPlan(InternalUtils.java:1480)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.getPlan(ConstructorServiceCreator.java:52)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:61)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
    at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
    at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:46)
    at org.apache.tapestry5.ioc.internal.AdvisorStackBuilder.createObject(AdvisorStackBuilder.java:63)
    at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:54)
    at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:66)
    ... 6 more
Caused by: java.lang.RuntimeException: Exception constructing service 'MasterObjectProvider': Error invoking service contribution method com.skycomm.ipkaizen.services.CoreModule.setupDBSYmbolObjectProviders(OrderedConfiguration): Exception constructing service 'MasterObjectProvider': Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:54)
    at $MasterObjectProvider_440ab1f4dbb7.delegate(Unknown Source)
    at $MasterObjectProvider_440ab1f4dbb7.provide(Unknown Source)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:871)
    at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:57)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$6.run(InternalUtils.java:371)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:51)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:48)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.run(OperationTrackerImpl.java:47)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.run(PerThreadOperationTracker.java:76)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.run(RegistryImpl.java:1119)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.injectIntoFields(InternalUtils.java:338)
    at org.apache.tapestry5.ioc.internal.ModuleImpl.instantiateModuleInstance(ModuleImpl.java:433)
    ... 71 more
Caused by: java.lang.RuntimeException: Error invoking service contribution method com.skycomm.ipkaizen.services.CoreModule.setupDBSYmbolObjectProviders(OrderedConfiguration): Exception constructing service 'MasterObjectProvider': Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:130)
    at org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:80)
    at org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:633)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:51)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:48)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.run(OperationTrackerImpl.java:47)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.run(PerThreadOperationTracker.java:76)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.addToOrderedConfiguration(RegistryImpl.java:629)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.getOrderedConfiguration(RegistryImpl.java:483)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$2.invoke(ServiceResourcesImpl.java:110)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$2.invoke(ServiceResourcesImpl.java:107)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getOrderedConfiguration(ServiceResourcesImpl.java:105)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.getOrderedConfiguration(AbstractServiceCreator.java:123)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.access$200(AbstractServiceCreator.java:35)
    at org.apache.tapestry5.ioc.internal.AbstractServiceCreator$1.findResource(AbstractServiceCreator.java:103)
    at org.apache.tapestry5.ioc.internal.util.DelegatingInjectionResources.findResource(DelegatingInjectionResources.java:38)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:231)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:50)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:289)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:286)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:293)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1488)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1483)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.createConstructorConstructionPlan(InternalUtils.java:1480)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.getPlan(ConstructorServiceCreator.java:52)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:61)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
    at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
    at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:46)
    at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:66)
    ... 85 more
Caused by: java.lang.RuntimeException: Exception constructing service 'MasterObjectProvider': Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:54)
    at $MasterObjectProvider_440ab1f4dbb7.delegate(Unknown Source)
    at $MasterObjectProvider_440ab1f4dbb7.provide(Unknown Source)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:871)
    at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:57)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:257)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:50)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:289)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:286)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:293)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1488)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1483)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.util.InternalUtils.createConstructorConstructionPlan(InternalUtils.java:1480)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.getPlan(ConstructorServiceCreator.java:52)
    at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:61)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4.invoke(ServiceResourcesImpl.java:160)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:146)
    at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:170)
    at org.apache.tapestry5.ioc.internal.AbstractConfigurationImpl.instantiate(AbstractConfigurationImpl.java:45)
    at org.apache.tapestry5.ioc.internal.ValidatingOrderedConfigurationWrapper.addInstance(ValidatingOrderedConfigurationWrapper.java:95)
    at com.skycomm.ipkaizen.services.CoreModule.setupDBSYmbolObjectProviders(CoreModule.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:120)
    ... 134 more
Caused by: org.apache.tapestry5.ioc.internal.OperationException: Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
    at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
    at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:66)
    ... 169 more
Caused by: java.lang.IllegalStateException: Construction of service 'MasterObjectProvider' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl(List, OperationTracker) (at MasterObjectProviderImpl.java:33) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'MasterObjectProvider'.
    at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:52)
    at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
    ... 173 more

谢谢你。

4

1 回答 1

1

我不认为你可以有一个可更新的符号,即使你让你的自定义SymbolSource工作(我会回到你如何做到这一点)。原因是符号如何插入到服务中。它们被插入到字段中,并且不会转换为间接访问器方法。因此,即使您更改了值,SymbolSource也不会再次调用您的自定义来获取该值。

如何贡献自己的SymbolSource 只需装饰 SymbolSource 服务

public class AppModule {

    public SymbolSource decorateSymbolSource(
        final SymbolSource symbolSource) {
        return new MyCustomSymbolSource(symbolSource);
    }

}

有了MasterObjectProvider,它就不再是一个服务,它被称为一个对象。不过,如果您想MasterObjectProvider始终使用@Local有助于解析服务和防止递归的本地服务。

于 2012-12-31T17:35:20.967 回答