org.qedeq.kernel.bo.service.internal
Class DefaultInternalKernelServices

java.lang.Object
  extended by org.qedeq.kernel.bo.service.internal.DefaultInternalKernelServices
All Implemented Interfaces:
Kernel, KernelProperties, KernelServices, InternalKernelServices, Service

public class DefaultInternalKernelServices
extends java.lang.Object
implements Kernel, InternalKernelServices, Service

This class provides a default implementation for the QEDEQ module services.

Author:
Michael Meyling

Constructor Summary
DefaultInternalKernelServices(QedeqConfig config, KernelProperties kernel, QedeqFileDao loader)
          Constructor.
 
Method Summary
 void addPlugin(java.lang.String pluginClass)
          Add plugin to services.
 boolean checkFormallyProved(InternalServiceJob process, KernelQedeqBo qedeq)
          Check if all propositions of this and all required modules have correct formal proofs.
 boolean checkFormallyProved(ModuleAddress address)
          Check if all propositions of this and all required modules have correct formal proofs.
 boolean checkWellFormedness(InternalServiceJob process, KernelQedeqBo qedeq)
          Check if all formulas of a QEDEQ module and its required modules are well formed.
 boolean checkWellFormedness(ModuleAddress address)
          Check if all formulas of a QEDEQ module and its required modules are well formed.
 void clearAllPluginResults(ModuleAddress address)
          Clear all plugin warnings and errors for given module.
 boolean clearLocalBuffer()
          Clear local file buffer and all loaded QEDEQ modules.
 SourceFileExceptionList createSourceFileExceptionList(int code, java.lang.String message, java.lang.String address, java.lang.Exception e)
          Creates a list with a SourceFileException with dummy position.
 SourceFileExceptionList createSourceFileExceptionList(int code, java.lang.String message, java.lang.String address, java.io.IOException e)
          Creates a list with a SourceFileException with dummy position.
 SourceFileExceptionList createSourceFileExceptionList(int code, java.lang.String message, java.lang.String address, java.lang.RuntimeException e)
          Creates a list with a SourceFileException with dummy position.
 java.lang.Object executePlugin(InternalServiceJob process, java.lang.String id, KernelQedeqBo qedeq, java.lang.Object data)
          Execute plugin on given QEDEQ module.
 java.lang.Object executePlugin(java.lang.String id, ModuleAddress address, java.lang.Object data)
          Execute plugin on given QEDEQ module.
 ModuleAddress[] getAllLoadedModules()
          Get list of all currently loaded QEDEQ modules.
 java.io.File getBufferDirectory()
          Get buffer directory for QEDEQ module files.
 java.lang.String getBuildId()
          Get build information.
 QedeqConfig getConfig()
          Get access to configuration parameters.
 ContextChecker getContextChecker()
          Get context checker.
 java.lang.String getDedication()
          Get dedication for this kernel.
 java.lang.String getDescriptiveKernelVersion()
          Get descriptive version information of this kernel.
 java.io.File getGenerationDirectory()
          Get directory for generated files.
 java.lang.String getKernelCodeName()
          Get code name of this kernel.
 KernelQedeqBo getKernelQedeqBo(ModuleAddress address)
          Get KernelQedeqBo for an address.
 java.lang.String getKernelVersion()
          Get version of this kernel.
 java.lang.String getKernelVersionDirectory()
          Get relative version directory of this kernel.
 java.io.File getLocalFilePath(ModuleAddress address)
          Transform an URL address into a local file path where the QEDEQ module is buffered.
 java.lang.String getMaximalRuleVersion()
          Get maximal supported rule version of this kernel.
 ModuleAddress getModuleAddress(java.io.File file)
          Get module address from URL.
 ModuleAddress getModuleAddress(java.lang.String url)
          Get module address from URL.
 ModuleAddress getModuleAddress(java.net.URL url)
          Get module address from URL.
 ModuleService[] getPlugins()
          Get all installed plugins.
 QedeqBo getQedeqBo(ModuleAddress address)
          Get QedeqBo for an address.
 QedeqFileDao getQedeqFileDao()
          Get DAO for reading and writing QEDEQ modules from or to a file.
 ServiceJob[] getRunningServiceProcesses()
          Get all running service processes.
 java.lang.String getServiceAction()
          Get service action name.
 java.lang.String getServiceDescription()
          Get service description.
 java.lang.String getServiceId()
          Get service id.
 ServiceJob[] getServiceProcesses()
          Get information about all service processes.
 java.lang.String getSource(ModuleAddress address)
          Get source of an QEDEQ module.
 java.lang.String[] getSourceFileExceptionList(ModuleAddress address)
          Get description of source file exception list.
 boolean isRuleVersionSupported(java.lang.String ruleVersion)
          Is a given rule version supported?
 boolean isSetConnectionTimeOutSupported()
          Does URLConnection support the method setConnectionTimeOut in the currently running JVM.
 boolean isSetReadTimeoutSupported()
          Does URLConnection support the method setReadTimeOut in the currently running JVM.
 boolean loadAllModulesFromQedeq()
          Load all QEDEQ modules from project web directory for current kernel.
 KernelQedeqBo loadKernelModule(InternalServiceJob process, ModuleAddress address)
          Load QEDEQ module.
 KernelQedeqBo loadKernelModule(InternalServiceJob process, ModuleAddress parent, Specification spec)
          Load specified QEDEQ module from QEDEQ parent module.
 QedeqBo loadModule(ModuleAddress address)
          Get a certain module.
 boolean loadPreviouslySuccessfullyLoadedModules()
          Load all previously checked QEDEQ modules.
 boolean loadRequiredModules(InternalServiceJob process, KernelQedeqBo qedeq)
          Get required modules of given module.
 boolean loadRequiredModules(ModuleAddress address)
          Get required modules of given module.
 boolean removeAllModules()
          Remove all modules from memory.
 void removeModule(ModuleAddress address)
          Remove a QEDEQ module from memory.
 void setContextChecker(ContextChecker contextChecker)
          Set the context checker.
 void shutdownServices()
          Shutdown of services.
 void startupServices()
          Initialization of services.
 void terminateAllServiceProcesses()
          Stop all currently running service executions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInternalKernelServices

public DefaultInternalKernelServices(QedeqConfig config,
                                     KernelProperties kernel,
                                     QedeqFileDao loader)
Constructor.

Parameters:
config - For config access.
kernel - For kernel properties.
loader - For loading QEDEQ modules.
Method Detail

startupServices

public void startupServices()
Description copied from interface: Kernel
Initialization of services. This method should be called from the kernel directly after switching into ready state. Calling this method in ready state is not supported.

Specified by:
startupServices in interface Kernel

shutdownServices

public void shutdownServices()
Description copied from interface: Kernel
Shutdown of services.

Specified by:
shutdownServices in interface Kernel

removeAllModules

public boolean removeAllModules()
Description copied from interface: KernelServices
Remove all modules from memory.

Specified by:
removeAllModules in interface KernelServices
Returns:
Was removal successful?

removeModule

public void removeModule(ModuleAddress address)
Description copied from interface: KernelServices
Remove a QEDEQ module from memory.

Specified by:
removeModule in interface KernelServices
Parameters:
address - Remove module identified by this address.

clearLocalBuffer

public boolean clearLocalBuffer()
Clear local file buffer and all loaded QEDEQ modules.

Specified by:
clearLocalBuffer in interface KernelServices
Returns:
Successful?

loadKernelModule

public KernelQedeqBo loadKernelModule(InternalServiceJob process,
                                      ModuleAddress address)
                               throws InterruptException
Description copied from interface: InternalKernelServices
Load QEDEQ module.

Specified by:
loadKernelModule in interface InternalKernelServices
Parameters:
process - Working process.
address - Load module from this address.
Returns:
BO for QEDEQ module. Loading still might have failed. Check status.
Throws:
InterruptException - User canceled request.

loadModule

public QedeqBo loadModule(ModuleAddress address)
Description copied from interface: KernelServices
Get a certain module. You can check the status to know if the loading was successful.

Specified by:
loadModule in interface KernelServices
Parameters:
address - Address of module.
Returns:
Wanted module.

loadKernelModule

public KernelQedeqBo loadKernelModule(InternalServiceJob process,
                                      ModuleAddress parent,
                                      Specification spec)
                               throws SourceFileExceptionList,
                                      InterruptException
Load specified QEDEQ module from QEDEQ parent module.

Specified by:
loadKernelModule in interface InternalKernelServices
Parameters:
process - Our service process we run within.
parent - Parent module address.
spec - Specification for another QEDEQ module.
Returns:
Loaded module.
Throws:
SourceFileExceptionList - Loading failed.
InterruptException - User canceled request.

getAllLoadedModules

public ModuleAddress[] getAllLoadedModules()
Description copied from interface: KernelServices
Get list of all currently loaded QEDEQ modules.

Specified by:
getAllLoadedModules in interface KernelServices
Returns:
All currently loaded QEDEQ modules.

loadPreviouslySuccessfullyLoadedModules

public boolean loadPreviouslySuccessfullyLoadedModules()
Load all previously checked QEDEQ modules.

Returns:
Successfully reloaded all modules.

loadAllModulesFromQedeq

public boolean loadAllModulesFromQedeq()
Description copied from interface: KernelServices
Load all QEDEQ modules from project web directory for current kernel.

Specified by:
loadAllModulesFromQedeq in interface KernelServices
Returns:
Successful loading.

getLocalFilePath

public final java.io.File getLocalFilePath(ModuleAddress address)
Description copied from interface: InternalKernelServices
Transform an URL address into a local file path where the QEDEQ module is buffered. If the QEDEQ module is a local file the path to that file is given.

Specified by:
getLocalFilePath in interface InternalKernelServices
Parameters:
address - Get local address for this QEDEQ module address.
Returns:
Local file path for that address.

getBufferDirectory

public java.io.File getBufferDirectory()
Description copied from interface: InternalKernelServices
Get buffer directory for QEDEQ module files.

Specified by:
getBufferDirectory in interface InternalKernelServices
Returns:
buffer directory.

getGenerationDirectory

public java.io.File getGenerationDirectory()
Description copied from interface: InternalKernelServices
Get directory for generated files.

Specified by:
getGenerationDirectory in interface InternalKernelServices
Returns:
Generation directory.

getKernelQedeqBo

public KernelQedeqBo getKernelQedeqBo(ModuleAddress address)
Description copied from interface: InternalKernelServices
Get KernelQedeqBo for an address.

Specified by:
getKernelQedeqBo in interface InternalKernelServices
Parameters:
address - Look for this address.
Returns:
Existing or new KernelQedeqBo. Never null.

getQedeqBo

public QedeqBo getQedeqBo(ModuleAddress address)
Description copied from interface: KernelServices
Get QedeqBo for an address.

Specified by:
getQedeqBo in interface KernelServices
Parameters:
address - Look for this address.
Returns:
Existing or new QedeqBo.

getModuleAddress

public ModuleAddress getModuleAddress(java.net.URL url)
                               throws java.io.IOException
Description copied from interface: KernelServices
Get module address from URL.

Specified by:
getModuleAddress in interface KernelServices
Parameters:
url - URL for QEDEQ module.
Returns:
Module address.
Throws:
java.io.IOException - URL has not the correct format for referencing a QEDEQ module.

getModuleAddress

public ModuleAddress getModuleAddress(java.lang.String url)
                               throws java.io.IOException
Description copied from interface: KernelServices
Get module address from URL.

Specified by:
getModuleAddress in interface KernelServices
Parameters:
url - URL for QEDEQ module.
Returns:
Module address.
Throws:
java.io.IOException - URL has not the correct format for referencing a QEDEQ module.

getModuleAddress

public ModuleAddress getModuleAddress(java.io.File file)
                               throws java.io.IOException
Description copied from interface: KernelServices
Get module address from URL.

Specified by:
getModuleAddress in interface KernelServices
Parameters:
file - Local QEDEQ module.
Returns:
Module address.
Throws:
java.io.IOException - URL has not the correct format for referencing a QEDEQ module.

getSource

public java.lang.String getSource(ModuleAddress address)
                           throws java.io.IOException
Description copied from interface: KernelServices
Get source of an QEDEQ module. If the module was not yet not buffered null is returned.

Specified by:
getSource in interface KernelServices
Parameters:
address - Address for QEDEQ module address.
Returns:
Contents of locally buffered QEDEQ module.
Throws:
java.io.IOException - Loading failed.

loadRequiredModules

public boolean loadRequiredModules(ModuleAddress address)
Description copied from interface: KernelServices
Get required modules of given module. You can check the status to know if the loading was successful.

Specified by:
loadRequiredModules in interface KernelServices
Parameters:
address - Address of module.
Returns:
Successful loading.

loadRequiredModules

public boolean loadRequiredModules(InternalServiceJob process,
                                   KernelQedeqBo qedeq)
                            throws InterruptException
Description copied from interface: InternalKernelServices
Get required modules of given module. You can check the status to know if the loading was successful.

Specified by:
loadRequiredModules in interface InternalKernelServices
Parameters:
process - Working process.
qedeq - Module to check.
Returns:
Successful loading.
Throws:
InterruptException - User canceled request.

checkWellFormedness

public boolean checkWellFormedness(ModuleAddress address)
Description copied from interface: KernelServices
Check if all formulas of a QEDEQ module and its required modules are well formed.

Specified by:
checkWellFormedness in interface KernelServices
Parameters:
address - Module to check.
Returns:
Was check successful?

checkWellFormedness

public boolean checkWellFormedness(InternalServiceJob process,
                                   KernelQedeqBo qedeq)
                            throws InterruptException
Description copied from interface: InternalKernelServices
Check if all formulas of a QEDEQ module and its required modules are well formed.

Specified by:
checkWellFormedness in interface InternalKernelServices
Parameters:
process - Working process.
qedeq - Module to check.
Returns:
Was check successful?
Throws:
InterruptException - User canceled request.

checkFormallyProved

public boolean checkFormallyProved(ModuleAddress address)
Description copied from interface: KernelServices
Check if all propositions of this and all required modules have correct formal proofs.

Specified by:
checkFormallyProved in interface KernelServices
Parameters:
address - Module to check.
Returns:
Was check successful?

checkFormallyProved

public boolean checkFormallyProved(InternalServiceJob process,
                                   KernelQedeqBo qedeq)
                            throws InterruptException
Description copied from interface: InternalKernelServices
Check if all propositions of this and all required modules have correct formal proofs.

Specified by:
checkFormallyProved in interface InternalKernelServices
Parameters:
process - Working process.
qedeq - Module to check.
Returns:
Was check successful?
Throws:
InterruptException - Process execution was canceled by user.

addPlugin

public void addPlugin(java.lang.String pluginClass)
Add plugin to services.

Parameters:
pluginClass - Plugin class to instantiate.
Throws:
java.lang.RuntimeException - Addition failed.

getPlugins

public ModuleService[] getPlugins()
Description copied from interface: KernelServices
Get all installed plugins.

Specified by:
getPlugins in interface KernelServices
Returns:
Installed plugins.

executePlugin

public java.lang.Object executePlugin(java.lang.String id,
                                      ModuleAddress address,
                                      java.lang.Object data)
Description copied from interface: KernelServices
Execute plugin on given QEDEQ module.

Specified by:
executePlugin in interface KernelServices
Parameters:
id - Plugin id.
address - QEDEQ module address.
data - Process data. Additional data beside module.
Returns:
Plugin specific resulting object. Might be null.

executePlugin

public java.lang.Object executePlugin(InternalServiceJob process,
                                      java.lang.String id,
                                      KernelQedeqBo qedeq,
                                      java.lang.Object data)
                               throws InterruptException
Description copied from interface: InternalKernelServices
Execute plugin on given QEDEQ module.

Specified by:
executePlugin in interface InternalKernelServices
Parameters:
process - Parent service process. Must not be null
id - Plugin id.
qedeq - QEDEQ module.
data - Process data. Additional data beside module.
Returns:
Plugin specific resulting object. Might be null.
Throws:
InterruptException - Process execution was canceled by user.

clearAllPluginResults

public void clearAllPluginResults(ModuleAddress address)
Description copied from interface: KernelServices
Clear all plugin warnings and errors for given module.

Specified by:
clearAllPluginResults in interface KernelServices
Parameters:
address - QEDEQ module address.

getServiceProcesses

public ServiceJob[] getServiceProcesses()
Description copied from interface: KernelServices
Get information about all service processes.

Specified by:
getServiceProcesses in interface KernelServices
Returns:
Result.

getRunningServiceProcesses

public ServiceJob[] getRunningServiceProcesses()
Description copied from interface: KernelServices
Get all running service processes. But remember a running process might currently be blocked.

Specified by:
getRunningServiceProcesses in interface KernelServices
Returns:
All service running processes.

terminateAllServiceProcesses

public void terminateAllServiceProcesses()
Description copied from interface: KernelServices
Stop all currently running service executions.

Specified by:
terminateAllServiceProcesses in interface KernelServices

createSourceFileExceptionList

public SourceFileExceptionList createSourceFileExceptionList(int code,
                                                             java.lang.String message,
                                                             java.lang.String address,
                                                             java.io.IOException e)
Description copied from interface: InternalKernelServices
Creates a list with a SourceFileException with dummy position.

Specified by:
createSourceFileExceptionList in interface InternalKernelServices
Parameters:
code - Failure code.
message - Textual description of failure.
address - This source had a problem.
e - Wrapped exception.
Returns:
Created list.

createSourceFileExceptionList

public SourceFileExceptionList createSourceFileExceptionList(int code,
                                                             java.lang.String message,
                                                             java.lang.String address,
                                                             java.lang.RuntimeException e)
Description copied from interface: InternalKernelServices
Creates a list with a SourceFileException with dummy position.

Specified by:
createSourceFileExceptionList in interface InternalKernelServices
Parameters:
code - Failure code.
message - Textual description of failure.
address - This source had a problem.
e - Wrapped exception.
Returns:
Created list.

createSourceFileExceptionList

public SourceFileExceptionList createSourceFileExceptionList(int code,
                                                             java.lang.String message,
                                                             java.lang.String address,
                                                             java.lang.Exception e)
Description copied from interface: InternalKernelServices
Creates a list with a SourceFileException with dummy position.

Specified by:
createSourceFileExceptionList in interface InternalKernelServices
Parameters:
code - Failure code.
message - Textual description of failure.
address - This source had a problem.
e - Wrapped exception.
Returns:
Created list.

getSourceFileExceptionList

public java.lang.String[] getSourceFileExceptionList(ModuleAddress address)
Get description of source file exception list.

Parameters:
address - Get description for this module exceptions.
Returns:
Error description and location.

getServiceId

public java.lang.String getServiceId()
Description copied from interface: Service
Get service id.

Specified by:
getServiceId in interface Service
Returns:
Service id.

getServiceAction

public java.lang.String getServiceAction()
Description copied from interface: Service
Get service action name. This is what the service does.

Specified by:
getServiceAction in interface Service
Returns:
Service action name.

getQedeqFileDao

public QedeqFileDao getQedeqFileDao()
Description copied from interface: InternalKernelServices
Get DAO for reading and writing QEDEQ modules from or to a file.

Specified by:
getQedeqFileDao in interface InternalKernelServices
Returns:
DAO.

getServiceDescription

public java.lang.String getServiceDescription()
Description copied from interface: Service
Get service description.

Specified by:
getServiceDescription in interface Service
Returns:
Description of service.

getConfig

public QedeqConfig getConfig()
Description copied from interface: InternalKernelServices
Get access to configuration parameters.

Specified by:
getConfig in interface InternalKernelServices
Returns:
Configuration access.

getKernelVersionDirectory

public java.lang.String getKernelVersionDirectory()
Description copied from interface: KernelProperties
Get relative version directory of this kernel.

Specified by:
getKernelVersionDirectory in interface KernelProperties
Returns:
Version sub directory.

getBuildId

public java.lang.String getBuildId()
Description copied from interface: KernelProperties
Get build information.

Specified by:
getBuildId in interface KernelProperties
Returns:
Implementation-version.

getDedication

public java.lang.String getDedication()
Description copied from interface: KernelProperties
Get dedication for this kernel.

Specified by:
getDedication in interface KernelProperties
Returns:
Kernel code dedication.

getDescriptiveKernelVersion

public java.lang.String getDescriptiveKernelVersion()
Description copied from interface: KernelProperties
Get descriptive version information of this kernel.

Specified by:
getDescriptiveKernelVersion in interface KernelProperties
Returns:
Version Information.

getKernelCodeName

public java.lang.String getKernelCodeName()
Description copied from interface: KernelProperties
Get code name of this kernel.

Specified by:
getKernelCodeName in interface KernelProperties
Returns:
Kernel code name.

getKernelVersion

public java.lang.String getKernelVersion()
Description copied from interface: KernelProperties
Get version of this kernel.

Specified by:
getKernelVersion in interface KernelProperties
Returns:
Kernel version.

getMaximalRuleVersion

public java.lang.String getMaximalRuleVersion()
Description copied from interface: KernelProperties
Get maximal supported rule version of this kernel.

Specified by:
getMaximalRuleVersion in interface KernelProperties
Returns:
Maximal supported rule version.

isRuleVersionSupported

public boolean isRuleVersionSupported(java.lang.String ruleVersion)
Description copied from interface: KernelProperties
Is a given rule version supported?

Specified by:
isRuleVersionSupported in interface KernelProperties
Parameters:
ruleVersion - Check this one.
Returns:
Is the given rule version supported?

isSetConnectionTimeOutSupported

public boolean isSetConnectionTimeOutSupported()
Description copied from interface: KernelProperties
Does URLConnection support the method setConnectionTimeOut in the currently running JVM. This should be true since version 1.5 but false for 1.4.2.

Specified by:
isSetConnectionTimeOutSupported in interface KernelProperties
Returns:
Method is supported?

isSetReadTimeoutSupported

public boolean isSetReadTimeoutSupported()
Description copied from interface: KernelProperties
Does URLConnection support the method setReadTimeOut in the currently running JVM. This should be true since version 1.5 but false for 1.4.2.

Specified by:
isSetReadTimeoutSupported in interface KernelProperties
Returns:
Method is supported?

getContextChecker

public ContextChecker getContextChecker()
Description copied from interface: InternalKernelServices
Get context checker.

Specified by:
getContextChecker in interface InternalKernelServices
Returns:
Checker for testing if context is valid.

setContextChecker

public void setContextChecker(ContextChecker contextChecker)
Set the context checker. This is useful especially for test classes.

Parameters:
contextChecker - We check the context with this checker now.


Copyright © 2014. All Rights Reserved.