Ticket #6 (assigned task)

Opened 1 year ago

Last modified 5 months ago

Replace singleton-style classes by beans using a registry mechanism

Reported by: SebastianMarsching Assigned to: SebastianMarsching (accepted)
Priority: major Milestone: 1.0.0
Component: Core (general) Version:
Keywords: refactoring modularization spring factories singleton Cc:

Description (Last modified by SebastianMarsching)

At the moment the Pustefix core uses many classes that implement the singleton pattern by using static fields and methods.

This mechanism causes two major problems:

  • Initialization and usage of this classes can hardly be traced throughout the code.
  • The scope of the instances of these classes is always tied to the class loader.

In order to solve these issues all (or at least most of) these classes should be rewritten to use a single registry instead of static fields for life-cycle management. This central registry could be provided by a Spring ApplicationContext.

These issue is related to ticket:5. This ticket depends on ticket:7.

Change History

(follow-up: ↓ 2 ) 02/01/08 18:53:28 changed by SebastianMarsching

  • status changed from new to assigned.

After inspecting the source code for non-final static fields and changing log4j Logger fields to be final, the following classes are still using non-final static fields:

de.schlund.pfixcore.editor2.frontend.util.ContextStore? de.schlund.pfixcore.editor2.frontend.util.EditorApplicationContext? de.schlund.pfixcore.editor2.frontend.util.SpringBeanLocator? de.schlund.pfixcore.example.bank.AuthTokenManager? de.schlund.pfixcore.example.bank.BankApplication? de.schlund.pfixcore.example.webservices.chat.ChatServer? de.schlund.pfixcore.example.webservices.ContextDataImpl? de.schlund.pfixcore.generator.casters.ToPerl?5Pattern de.schlund.pfixcore.generator.iwrpgen.IWrapperAnnotationProcessor de.schlund.pfixcore.generator.iwrpgen.IWrapperRuntimeGenerator de.schlund.pfixcore.generator.iwrpgen.IWrapper.ToBean? de.schlund.pfixcore.generator.prechecks.RegexpCheck? de.schlund.pfixcore.generator.IHandlerFactory de.schlund.pfixcore.generator.IWrapperInfo de.schlund.pfixcore.lucefix.ContextSearchImpl? de.schlund.pfixcore.lucefix.PfixQueueManager? de.schlund.pfixcore.lucefix.PfixReadjustment? de.schlund.pfixcore.oxm.impl.MarshallerFactory? de.schlund.pfixcore.testsuite.util.TargetGeneratorBenchmarkFactory? de.schlund.pfixcore.util.basicapp.basics.CreateProjectSettings? de.schlund.pfixcore.util.basicapp.objects.Project de.schlund.pfixcore.util.Cleanup de.schlund.pfixcore.util.DelLang? de.schlund.pfixcore.util.DumpText? de.schlund.pfixcore.util.ImportText? de.schlund.pfixcore.util.Meminfo de.schlund.pfixcore.util.MultiTransform? de.schlund.pfixcore.util.TokenUtils? de.schlund.pfixcore.util.TransformerCallback? de.schlund.pfixcore.webservice.fault.EmailNotifier? de.schlund.pfixcore.webservice.generate.Wsdl2Js de.schlund.pfixcore.webservice.json.JSONParser de.schlund.pfixcore.webservice.json.JSONObject de.schlund.pfixcore.webservice.utils.XMLFormatter de.schlund.pfixcore.webservice.ServiceRuntime? de.schlund.pfixcore.webservice.WebServiceServlet? de.schlund.pfixcore.workflow.app.DefaultIWrapperState de.schlund.pfixcore.workflow.app.FileDownloadDOState de.schlund.pfixcore.workflow.app.IHandlerContinerManager de.schlund.pfixcore.workflow.app.ResdocFinalizerFactory? de.schlund.pfixcore.workflow.ContextInterceptorFactory? de.schlund.pfixcore.workflow.DirectOutputStateFactory? de.schlund.pfixcore.workflow.FlowStepActionFactory? de.schlund.pfixcore.workflow.NavigationFactory? de.schlund.pfixcore.workflow.StateFactory? de.schlund.pfixcore.workflow.StateImpl? de.schlund.pfixxml.config.BuildTimeProperties? de.schlund.pfixxml.config.GlobalConfig? de.schlund.pfixxml.multipart.MultipartHandler? de.schlund.pfixxml.perflogging.AdditionalTrailInfoFactory? de.schlund.pfixxml.perflogging.IntervalFactory? de.schlund.pfixxml.perflogging.PerfEventPut? de.schlund.pfixxml.perflogging.PerfEventTakeThread? de.schlund.pfixxml.perflogging.PerfLogging? de.schlund.pfixxml.perflogging.PerfStatistic? de.schlund.pfixxml.serverutil.SessionAdmin? de.schlund.pfixxml.targets.cachestat.SPCacheStatistic de.schlund.pfixxml.targets.AuxDependencyFactory? de.schlund.pfixxml.targets.AuxDependencyManager? de.schlund.pfixxml.targets.PageInfoFactory? de.schlund.pfixxml.targets.SharedLeafFactory? de.schlund.pfixxml.targets.SPCacheFactory de.schlund.pfixxml.targets.TargetFactory? de.schlund.pfixxml.targets.TargetGenerator? de.schlund.pfixxml.targets.TargetGeneratorFactory? de.schlund.pfixxml.testrecording.TestRecording? de.schlund.pfixxml.testrecording.TrailLogger? de.schlund.pfixxml.util.logging.ProxyLogUtil? de.schlund.pfixxml.util.xsltimpl.Saxon1TraceListener de.schlund.pfixxml.util.xsltimpl.XsltSaxon?1 de.schlund.pfixxml.util.xsltimpl.XsltSaxon?2 de.schlund.pfixxml.util.ExtensionFunctionUtils? de.schlund.pfixxml.util.XPath de.schlund.pfixxml.util.XsltProvider? de.schlund.pfixxml.AbstractXMLServlet de.schlund.pfixxml.CacheStatisticServlet? de.schlund.pfixxml.DerefServlet? de.schlund.pfixxml.FactoryInitServler? de.schlund.pfixxml.FactoryInitUtil? de.schlund.pfixxml.ImageGeometry? de.schlund.pfixxml.IncludeDocumentFactory? de.schlund.pfixxml.PathFactory? de.schlund.pfixxml.PfixServletRequestImpl? de.schlund.pfixxml.ProjectInitFactory? de.schlund.pfixxml.PropertyObjectManager? de.schlund.pfixxml.ServletManager? de.schlund.pfixxml.SessionCleaner?

Some of these classes might be easy to fix by just making the fields final, other ones have to be completely refactored.

(in reply to: ↑ 1 ) 03/07/08 10:37:09 changed by SebastianMarsching

Replying to SebastianMarsching:

Some more problems could be solved by making fields final. The following classes still need attention:

de.schlund.pfixcore.editor2.frontend.util.ContextStore? de.schlund.pfixcore.editor2.frontend.util.EditorApplicationContext? de.schlund.pfixcore.editor2.frontend.util.SpringBeanLocator? de.schlund.pfixcore.example.bank.AuthTokenManager? de.schlund.pfixcore.example.bank.BankApplication? de.schlund.pfixcore.example.webservices.chat.ChatServer? de.schlund.pfixcore.generator.iwrpgen.IWrapperAnnotationProcessor de.schlund.pfixcore.generator.iwrpgen.IWrapperRuntimeGenerator de.schlund.pfixcore.generator.iwrpgen.IWrapperToBean de.schlund.pfixcore.generator.IHandlerFactory de.schlund.pfixcore.generator.IWrapperInfo de.schlund.pfixcore.lucefix.PfixQueueManager? de.schlund.pfixcore.lucefix.PfixReadjustment? de.schlund.pfixcore.oxm.impl.MarshallerFactory? de.schlund.pfixcore.testsuite.util.TargetGeneratorBenchmarkFactory? de.schlund.pfixcore.util.basicapp.objects.Project de.schlund.pfixcore.util.Meminfo de.schlund.pfixcore.util.MultiTransform? de.schlund.pfixcore.util.TransformerCallback? de.schlund.pfixcore.webservice.fault.EmailNotifier? de.schlund.pfixcore.webservice.utils.XMLFormatter de.schlund.pfixcore.webservice.ServiceRuntime? de.schlund.pfixcore.webservice.WebServiceServlet? de.schlund.pfixcore.workflow.app.IHandlerContinerManager de.schlund.pfixcore.workflow.app.ResdocFinalizerFactory? de.schlund.pfixcore.workflow.ContextInterceptorFactory? de.schlund.pfixcore.workflow.DirectOutputStateFactory? de.schlund.pfixcore.workflow.FlowStepActionFactory? de.schlund.pfixcore.workflow.NavigationFactory? de.schlund.pfixcore.workflow.StateFactory? de.schlund.pfixxml.config.BuildTimeProperties? de.schlund.pfixxml.config.GlobalConfig? de.schlund.pfixxml.perflogging.AdditionalTrailInfoFactory? de.schlund.pfixxml.perflogging.IntervalFactory? de.schlund.pfixxml.perflogging.PerfEventPut? de.schlund.pfixxml.perflogging.PerfLogging? de.schlund.pfixxml.perflogging.PerfStatistic? de.schlund.pfixxml.serverutil.SessionAdmin? de.schlund.pfixxml.targets.cachestat.SPCacheStatistic de.schlund.pfixxml.targets.AuxDependencyFactory? de.schlund.pfixxml.targets.PageInfoFactory? de.schlund.pfixxml.targets.SharedLeafFactory? de.schlund.pfixxml.targets.SPCacheFactory de.schlund.pfixxml.targets.TargetFactory? de.schlund.pfixxml.targets.TargetGenerator? de.schlund.pfixxml.targets.TargetGeneratorFactory? de.schlund.pfixxml.testrecording.TestRecording? de.schlund.pfixxml.testrecording.TrailLogger? de.schlund.pfixxml.util.logging.ProxyLogUtil? de.schlund.pfixxml.util.xsltimpl.Saxon1TraceListener de.schlund.pfixxml.util.xsltimpl.XsltSaxon?1 de.schlund.pfixxml.util.xsltimpl.XsltSaxon?2 de.schlund.pfixxml.util.ExtensionFunctionUtils? de.schlund.pfixxml.util.XPath de.schlund.pfixxml.util.XsltProvider? de.schlund.pfixxml.FactoryInitServlet? de.schlund.pfixxml.FactoryInitUtil? de.schlund.pfixxml.ImageGeometry? de.schlund.pfixxml.IncludeDocumentFactory? de.schlund.pfixxml.PathFactory? de.schlund.pfixxml.ProjectInitFactory? de.schlund.pfixxml.PropertyObjectManager? de.schlund.pfixxml.ServletManager? de.schlund.pfixxml.SessionCleaner?

03/18/08 17:35:05 changed by SebastianMarsching

  • type changed from enhancement to task.
  • description changed.

08/25/08 12:15:03 changed by SebastianMarsching

  • milestone changed from 0.13.0 to 0.14.0.

Moving to milestone 0.14.0.