blob: 59413a09da83e1f7bf3191473580baf8d55c00da [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2018 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
* generated by Xtext 2.11.0
*
*/
package org.eclipse.osbp.xtext.signal.jvmmodel
import java.io.IOException
import java.nio.file.Path
import java.nio.file.WatchEvent
import javax.inject.Inject
import org.eclipse.e4.core.contexts.IEclipseContext
import org.eclipse.osbp.core.api.persistence.IPersistenceService
import org.eclipse.osbp.datainterchange.api.IDataInterchange
import org.eclipse.osbp.dsl.common.xtext.extensions.AnnotationExtension
import org.eclipse.osbp.runtime.common.event.IEventDispatcher
import org.eclipse.osbp.ui.api.customfields.IBlobService
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService
import org.eclipse.osbp.ui.api.user.IUser
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService
import org.eclipse.osbp.xtext.datainterchange.DataInterchange
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileCSV
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileEDI
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileXML
import org.eclipse.osbp.xtext.datainterchange.DataInterchangePackage
import org.eclipse.osbp.xtext.signal.SignalDSLPackage
import org.eclipse.osbp.xtext.signal.SignalHandling
import org.eclipse.osbp.xtext.signal.SignalPackage
import org.eclipse.osbp.xtext.signal.SignalTypeEnum
import org.eclipse.osbp.xtext.signal.SignalWatcher
import org.eclipse.osbp.xtext.signal.common.IOSBPSignalWatcher
import org.eclipse.osbp.xtext.signal.common.OSBPSignalWatcher
import org.eclipse.xtext.common.types.JvmField
import org.eclipse.xtext.common.types.JvmGenericType
import org.eclipse.xtext.common.types.JvmVisibility
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
import org.osgi.service.component.annotations.Component
import org.osgi.service.component.annotations.Reference
import org.osgi.service.component.annotations.ReferenceCardinality
import org.osgi.service.component.annotations.ReferencePolicy
import org.slf4j.Logger
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
class SignalDSLJvmModelInferrer extends AbstractModelInferrer {
/**
* convenience API to build and initialize JVM types and their members.
*/
@Inject extension JvmTypesBuilder
@Inject extension IQualifiedNameProvider
@Inject extension SignalModelGenerator sg
@Inject extension AnnotationExtension
var public static String pckgName = null
var String binderClassName = ""
/**
* infer model on package base. Will be called for every defined package.
*
* @param dataInterchangePackage
* An instance of {@link SignalDSLPackage}
* @param acceptor
* the xtext acceptor interface
* @param isPreIndexingPhase
* true if in preindexing phase
*/
def dispatch void infer(SignalPackage signalPackage, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
pckgName = signalPackage.name;
binderClassName = signalPackage.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"
var cls = signalPackage.toClass(pckgName)
cls.simpleName = cls.simpleName.toFirstUpper
//create watchers
for(watcher : signalPackage.watchers){
var watcherClass = watcher.fullyQualifiedName
acceptor.accept(watcher.toClass(watcherClass), [
superTypes += _typeReferenceBuilder.typeRef(OSBPSignalWatcher)
var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Component))
// annotationRef.addAnnAttr(signalPackage, "service", _typeReferenceBuilder.typeRef(IOSBPSignalWatcher))
annotations += annotationRef
it.toWatcherFields(watcher)
it.toWatcherConstructor(watcher)
it.toWatcherOperations(watcher)
it.fileHeader = signalPackage.documentation
//create all handlers
for(signalhandler : signalPackage.handlers){
if(watcher == signalhandler.watcher){
it.toHandlerOperations(watcher, signalhandler.handler)
}
}
])
}
//create the service binder class
cls = signalPackage.toClass(pckgName.concat("ServiceBinder"))
cls.simpleName = cls.simpleName.toFirstUpper
acceptor.accept(cls,[
annotations += _annotationTypesBuilder.annotationRef(SuppressWarnings, "serial")
annotations += _annotationTypesBuilder.annotationRef(typeof(Component))
it.fileHeader = signalPackage.documentation
it.toBinderFields(signalPackage)
it.toBinderOperations(signalPackage)
])
}
def void toBinderFields(JvmGenericType type, SignalPackage signal){
var JvmField field = null
//creat logger
field = signal.toField("log", _typeReferenceBuilder.typeRef(Logger))[setInitializer([append('''org.slf4j.LoggerFactory.getLogger("servicebinder")''')])]
field.static = true
field.visibility = JvmVisibility::PRIVATE
type.members += field
// // create eventdispatcher service field
// field = signal.toField("eventDispatcher", _typeReferenceBuilder.typeRef(IEventDispatcher))
// field.static = true
// field.visibility = JvmVisibility::PRIVATE
// type.members += field
// create persistence service field
field = signal.toField("persistenceService", _typeReferenceBuilder.typeRef(IPersistenceService))
field.static = true
field.visibility = JvmVisibility::PRIVATE
type.members += field
// create datainterchange service field
field = signal.toField("dataInterchange", _typeReferenceBuilder.typeRef(IDataInterchange))
field.static = true
field.visibility = JvmVisibility::PRIVATE
type.members += field
// create user service field
field = signal.toField("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
field.static = true
field.visibility = JvmVisibility::PRIVATE
type.members += field
// // create dsl metadata service field
// field = signal.toField("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService))
// field.static = true
// field.visibility = JvmVisibility::PRIVATE
// type.members += field
// create blob service field
field = signal.toField("blobService", _typeReferenceBuilder.typeRef(IBlobService))
field.static = true
field.visibility = JvmVisibility::PRIVATE
type.members += field
}
def void toBinderOperations(JvmGenericType type, SignalPackage signal){
type.members += signal.toMethod("getDataInterchange", _typeReferenceBuilder.typeRef(IDataInterchange), [
visibility = JvmVisibility.PUBLIC
static = true
body = [append('''return dataInterchange;''')]
])
type.members += signal.toMethod("getBlobService", _typeReferenceBuilder.typeRef(IBlobService), [
visibility = JvmVisibility.PUBLIC
static = true
body = [append('''return blobService;''')]
])
type.members += signal.toMethod("getPersistenceService", _typeReferenceBuilder.typeRef(IPersistenceService), [
visibility = JvmVisibility.PUBLIC
static = true
body = [append('''return persistenceService;''')]
])
type.members += signal.toMethod("getUserAccessService", _typeReferenceBuilder.typeRef(IUserAccessService), [
visibility = JvmVisibility.PUBLIC
static = true
body = [append('''return userAccessService;''')]
])
// type.members += signal.toMethod("getDSLMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService), [
// visibility = JvmVisibility.PUBLIC
// static = true
// body = [append('''return dslMetadataService;''')]
// ])
// bind datainterchange service
type.members += signal.toMethod("bindDataInterchangeMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
annotationRef.addAnnAttr(signal, "cardinality", ReferenceCardinality.MANDATORY)
annotationRef.addAnnAttr(signal, "policy", ReferencePolicy.STATIC)
annotations += annotationRef
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("dataInterchange", _typeReferenceBuilder.typeRef(IDataInterchange))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».dataInterchange = dataInterchange;
log.debug("Signal DataInterchange bound");
''')]
])
// unbind datainterchange service
type.members += signal.toMethod("unbindDataInterchangeMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("dataInterchange", _typeReferenceBuilder.typeRef(IDataInterchange))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».dataInterchange = null;
log.debug("Signal DataInterchange unbound");
''')]
])
// bind blob service
type.members += signal.toMethod("bindBlobMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
annotationRef.addAnnAttr(signal, "cardinality", ReferenceCardinality.MANDATORY)
annotationRef.addAnnAttr(signal, "policy", ReferencePolicy.STATIC)
annotations += annotationRef
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("blobService", _typeReferenceBuilder.typeRef(IBlobService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».blobService = blobService;
log.debug("Signal BlobService bound");
''')]
])
// unbind blob service
type.members += signal.toMethod("unbindBlobMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("blobService", _typeReferenceBuilder.typeRef(IBlobService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».blobService = null;
log.debug("Signal BlobService unbound");
''')]
])
// bind persistence service
type.members += signal.toMethod("bindPersistenceMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
annotationRef.addAnnAttr(signal, "cardinality", ReferenceCardinality.MANDATORY)
annotationRef.addAnnAttr(signal, "policy", ReferencePolicy.STATIC)
annotations += annotationRef
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("persistenceService", _typeReferenceBuilder.typeRef(IPersistenceService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».persistenceService = persistenceService;
log.debug("Signal PersistenceService bound");
''')]
])
// unbind persistence service
type.members += signal.toMethod("unbindPersistenceMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("persistenceService", _typeReferenceBuilder.typeRef(IPersistenceService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».persistenceService = null;
log.debug("Signal PersistenceService unbound");
''')]
])
// bind userAccessService
type.members += signal.toMethod("bindUserAccessMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
annotationRef.addAnnAttr(signal, "cardinality", ReferenceCardinality.MANDATORY)
annotationRef.addAnnAttr(signal, "policy", ReferencePolicy.STATIC)
annotations += annotationRef
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».userAccessService = userAccessService;
log.debug("Signal UserAccessService bound");
''')]
])
// unbind userAccessService
type.members += signal.toMethod("unbindUserAccessMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
visibility = JvmVisibility.PUBLIC
synchronized = true
parameters += signal.toParameter("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
body = [append(
'''
«signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».userAccessService = null;
log.debug("Signal UserAccessService unbound");''')]
])
// // bind dslMetadataService
// type.members += signal.toMethod("bindDSLMetadataService", _typeReferenceBuilder.typeRef(Void::TYPE), [
// var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
// annotationRef.addAnnAttr(signal, "cardinality", ReferenceCardinality.MANDATORY)
// annotationRef.addAnnAttr(signal, "policy", ReferencePolicy.STATIC)
// annotations += annotationRef
// visibility = JvmVisibility.PUBLIC
// synchronized = true
// parameters += signal.toParameter("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService))
// body = [append(
// '''
// «signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».dslMetadataService = dslMetadataService;
// log.debug("Signal DSLMetadataService bound");''')]
// ])
// // unbind dslMetadataService
// type.members += signal.toMethod("unbindDSLMetadataService", _typeReferenceBuilder.typeRef(Void::TYPE), [
// visibility = JvmVisibility.PUBLIC
// synchronized = true
// parameters += signal.toParameter("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService))
// body = [append(
// '''
// «signal.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».dslMetadataService = null;
// log.debug("Signal DSLMetadataService unbound");''')]
// ])
}
def void toHandlerOperations(JvmGenericType type, SignalWatcher watcher, SignalHandling handling){
//create handler operation based on the handling type
type.members += watcher.toMethod("executeImport", _typeReferenceBuilder.typeRef(Void::TYPE), [
val ref = handling.dataRef as DataInterchange
body = [append('''«ref.executeImport»''')]
])
}
def String executeImport(DataInterchange dataInterchange){
return
'''
«getBasicRunConfiguration(dataInterchange, true, getFileURL(dataInterchange), "IMPORT")»
«dataInterchange.getDefaultVariableName()».setDirection(WorkerThreadRunnable.Direction.IMPORT);
// later for notification in the dialog
//Notification.show(dslMetadataService.translate(user.getLocale().toLanguageTag(), "datainterchangeStarted"),Notification.Type.HUMANIZED_MESSAGE);
//execution of code now
«dataInterchange.getDefaultVariableName()».run();
'''
}
def String getFileURL(DataInterchange dataInterchange) {
switch(dataInterchange.fileEndpoint) {
DataInterchangeFileXML: return (dataInterchange.fileEndpoint as DataInterchangeFileXML).fileURL
DataInterchangeFileCSV: return (dataInterchange.fileEndpoint as DataInterchangeFileCSV).fileURL
DataInterchangeFileEDI: return (dataInterchange.fileEndpoint as DataInterchangeFileEDI).fileURL
}
return ""
}
def String getDefaultVariableName(DataInterchange dataInterchange) {
return dataInterchange.name.toFirstLower
}
def String getBasicRunConfiguration(DataInterchange dataInterchange, boolean fqClass, String fileURL, String direction) {
var className = ""
if (fqClass) {
className = dataInterchange.fullyQualifiedName.toString
}
else {
className = dataInterchange.name
}
return
'''
«className» «dataInterchange.getDefaultVariableName» = new «className»();
String url = ""; //ProductConfiguration.getDatainterchangeConfiguration();
//if(url.isEmpty()) {
// url = System.getProperty("user.home")+"/.osbee/"+"«(dataInterchange.eContainer as DataInterchangePackage).title»Config.xml";
//}
File file = new File(url);
if(file.exists()) {
FileInputStream fileInput;
try {
fileInput = new FileInputStream(file);
Properties properties = new Properties();
properties.loadFromXML(fileInput);
fileInput.close();
if(properties.getProperty("«dataInterchange.name»-«direction.toLowerCase()»") == null) {
«dataInterchange.getDefaultVariableName».setFileURL("«fileURL»");
} else {
«dataInterchange.getDefaultVariableName».setFileURL(properties.getProperty("«dataInterchange.name»-«direction.toLowerCase()»"));
}
} catch (IOException e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
log.error("{}", sw.toString());
return;
}
} else {
«dataInterchange.getDefaultVariableName».setFileURL("«fileURL»");
}
«dataInterchange.getDefaultVariableName».setPersistenceService(persistenceService);
«dataInterchange.getDefaultVariableName».setDataInterchange(dataInterchange);
«dataInterchange.getDefaultVariableName».setEventDispatcher(eventDispatcher);
«dataInterchange.getDefaultVariableName».setBlobService(blobService);
'''
}
def void toWatcherOperations(JvmGenericType type, SignalWatcher watcher){
// create watcher registerPathtoWacher
type.members += watcher.toMethod("registerPathToWatcher", _typeReferenceBuilder.typeRef(Void::TYPE), [
annotations += _annotationTypesBuilder.annotationRef(Override)
parameters += watcher.toParameter("directory", _typeReferenceBuilder.typeRef(Path))
parameters += watcher.toParameter("signals", _typeReferenceBuilder.typeRef(String))
exceptions += _typeReferenceBuilder.typeRef(IOException)
body = [ append('''«watcher.registerPathToWatcher»''')]
])
// create watcher registerAll
type.members += watcher.toMethod("registerAll", _typeReferenceBuilder.typeRef(Void::TYPE), [
annotations += _annotationTypesBuilder.annotationRef(Override)
parameters += watcher.toParameter("rootpath", _typeReferenceBuilder.typeRef(Path))
parameters += watcher.toParameter("signals", _typeReferenceBuilder.typeRef(String))
exceptions += _typeReferenceBuilder.typeRef(IOException)
body = [ append('''«watcher.registerAll»''')]
])
// create watcher handleEvent
type.members += watcher.toMethod("handleEvent", _typeReferenceBuilder.typeRef(Void::TYPE), [
annotations += _annotationTypesBuilder.annotationRef(Override)
parameters += watcher.toParameter("event", _typeReferenceBuilder.typeRef(WatchEvent))
body = [ append('''«watcher.handleEvent»''')]
])
// create watcher processEvents
type.members += watcher.toMethod("processEvents", _typeReferenceBuilder.typeRef(Void::TYPE), [
annotations += _annotationTypesBuilder.annotationRef(Override)
body = [ append('''«watcher.processEvents»''')]
])
// create watcher start operation
type.members += watcher.toMethod("start", _typeReferenceBuilder.typeRef(Void::TYPE), [
exceptions += _typeReferenceBuilder.typeRef(IOException)
body = [ append('''«watcher.start»''')]
])
// create watcher stop operation
type.members += watcher.toMethod("stop", _typeReferenceBuilder.typeRef(Void::TYPE), [
exceptions += _typeReferenceBuilder.typeRef(IOException)
body = [ append('''«watcher.stop»''')]
])
}
def void toWatcherFields(JvmGenericType type, SignalWatcher watcher){
var JvmField field = null
// create Service injectatbles eventDispatcher
field = watcher.toField("eventDispatcher", _typeReferenceBuilder.typeRef(IEventDispatcher))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles eventDispatcher
field = watcher.toField("persistenceService", _typeReferenceBuilder.typeRef(IPersistenceService))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles eventDispatcher
field = watcher.toField("dataInterchange", _typeReferenceBuilder.typeRef(IDataInterchange))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles eventDispatcher
field = watcher.toField("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles eventDispatcher
field = watcher.toField("blobService", _typeReferenceBuilder.typeRef(IBlobService))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles user
field = watcher.toField("user", _typeReferenceBuilder.typeRef(IUser))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create Service injectatbles eclipseContext
field = watcher.toField("eclipseContext", _typeReferenceBuilder.typeRef(IEclipseContext))[
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create logger
field = watcher.toField("log", _typeReferenceBuilder.typeRef(Logger)) [
setInitializer([append('''LoggerFactory.getLogger("watcher")''')])
visibility = JvmVisibility::PRIVATE
// static = true
]
type.members += field
// create directory field
field = watcher.toField("path", _typeReferenceBuilder.typeRef(String))[
setInitializer([append('''"«watcher.directory»"''')])
visibility = JvmVisibility::PRIVATE
]
type.members += field
// create target signal
field = watcher.toField("signal", _typeReferenceBuilder.typeRef(SignalTypeEnum))[
setInitializer([append('''SignalTypeEnum.«watcher.signal.literal.toUpperCase»''')])
visibility = JvmVisibility::PRIVATE
]
type.members += field
}
def void toWatcherConstructor(JvmGenericType type, SignalWatcher watcher){
type.members += watcher.toConstructor[
exceptions += _typeReferenceBuilder.typeRef(IOException)
body = [append('''super();''')]
]
}
def String registerAll(SignalWatcher watcher){
return
'''
//TODO enter the register logic here
super.registerAll(rootpath, signals);
'''
}
def String registerPathToWatcher(SignalWatcher watcher){
return
'''
if (signals != null && !signals.isEmpty()) {
boolean iscreate = signals.contains(StandardWatchEventKinds.ENTRY_CREATE.toString());
boolean isdelete = signals.contains(StandardWatchEventKinds.ENTRY_DELETE.toString());
boolean ismodify = signals.contains(StandardWatchEventKinds.ENTRY_MODIFY.toString());
// create one key for all kind of changes
// and save the key for later use
// TODO only applicable with xtext generation
// keys.put(directory.register(watcher, iscreate ? StandardWatchEventKinds.ENTRY_CREATE :
// null,
// isdelete ? StandardWatchEventKinds.ENTRY_DELETE : null, ismodify ? StandardWatchEventKinds.ENTRY_MODIFY : null),
// directory);
getRegisteredKeysAndPaths().put(directory.register(getWatcher(), StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY), directory);
} else {
// if none signals have been given by the user,
// create a default key for all kind of changes
// and save the key for later use
getRegisteredKeysAndPaths().put(directory.register(getWatcher(), StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY), directory);
}
'''
}
def String getHandleEvent(SignalWatcher watcher){
return
'''
//super.handleEvent(event);
Path filename = ((WatchEvent<Path>) event).context().getFileName();
// get what to do based on the filename
SignalActionEnum action = super.checkFileMask(filename.toString());
if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE && !action.equals(SignalActionEnum.NONE)) {
switch (action) {
case DATAIMPORT:
executeImport();
break;
««« case PRINT:
««« printFile();
««« break;
««« case PDFPRINT:
««« printPdfFile();
««« break;
««« case MAIL:
««« sendEmail();
««« break;
««« case MESSAGEPROMPT:
««« showNotification();
««« break;
default: // do nothing
break;
}
}
'''
}
def String getStart(SignalWatcher watcher){
return
'''
super.startWatcher(path, signal);
'''
}
def String getStop(SignalWatcher watcher){
return
'''
// stop the service
super.getWatcher().close();
'''
}
def String getProcessEvents(SignalWatcher watcher){
return
'''
super.processEvents();
'''
}
}