Ticket #6 (assigned task)

Opened 4 years ago

Last modified 10 months ago

Replace singleton-style classes by beans using a registry mechanism

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

Description (last modified by SebastianMarsching) (diff)

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   Changed 4 years ago 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   Changed 4 years ago 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?

  Changed 4 years ago by SebastianMarsching

  • type changed from enhancement to task
  • description modified (diff)

  Changed 3 years ago by SebastianMarsching

  • milestone changed from 0.13.0 to 0.14.0

Moving to milestone 0.14.0.

  Changed 2 years ago by MartinLeidig

  • milestone changed from 1.0.0 to 1.2.0

despite having replaced a lot of singleton classes there's still some work to be done (e.g. extension function classes)

  Changed 10 months ago by MartinLeidig

  • milestone 1.2.0 deleted

Milestone 1.2.0 deleted

Note: See TracTickets for help on using tickets.