Skip to content

Commit

Permalink
Merge pull request #235 from cristal-ise/feature/Issue99-UseSLF4JInLo…
Browse files Browse the repository at this point in the history
…gger

#99 use slf4 j in Logger
  • Loading branch information
kovax committed Jan 5, 2020
2 parents 2535a16 + bc6dc9b commit 6ed5a4f
Show file tree
Hide file tree
Showing 244 changed files with 2,230 additions and 1,955 deletions.
Expand Up @@ -34,13 +34,14 @@
import org.cristalise.kernel.persistency.outcome.Viewpoint;
import org.cristalise.kernel.process.Gateway;
import org.cristalise.kernel.utils.DescriptionObject;
import org.cristalise.kernel.utils.Logger;

import lombok.extern.slf4j.Slf4j;


/**
* Creates empty object for Activities and StateMachine or loads empty one from Factory
*
*/
@Slf4j
public class DevObjectOutcomeInitiator implements OutcomeInitiator {

@Override
Expand All @@ -64,8 +65,7 @@ public String initOutcome(Job job) throws InvalidDataException {
return Gateway.getMarshaller().marshall(emptyObj);
}
catch (Exception e) {
Logger.error("Error creating empty "+type);
Logger.error(e);
log.error("Error creating empty "+type, e);
return null;
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ else if (type.equals("Script")) {
return newInstance.getOutcome().getData();
}
catch (Exception e) {
Logger.error(e);
log.error("Error loading new "+schema, e);
throw new InvalidDataException("Error loading new "+schema);
}
}
Expand Down
1 change: 1 addition & 0 deletions dsl/pom.xml
Expand Up @@ -283,6 +283,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Expand Up @@ -35,15 +35,15 @@ import org.cristalise.kernel.process.resource.BuiltInResources
import org.cristalise.kernel.process.resource.DefaultResourceImportHandler
import org.cristalise.kernel.property.PropertyDescriptionList
import org.cristalise.kernel.test.utils.KernelXMLUtility
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j

/**
* Utility class to implement ALL methods required to manage (create/edit)
* CRISTAL-iSE Resources and Items defined in the dev module: https://github.com/cristal-ise/dev
*/
@CompileStatic
@CompileStatic @Slf4j
class DevItemUtility {

AgentProxy agent = null
Expand Down Expand Up @@ -93,7 +93,7 @@ class DevItemUtility {
* @return
*/
public Job getDoneJob(ItemProxy proxy, String actName) {
Logger.msg("DevItemUtility.getDoneJob() - proxy:$proxy.name actName:$actName")
log.info('getDoneJob() - proxy:{} actName:{}', proxy.name, actName)
Job j = proxy.getJobByName(actName, agent)
assert j && j.getStepName() == actName && j.transition.name == "Done"
return j
Expand Down
Expand Up @@ -30,15 +30,15 @@ import org.cristalise.kernel.lookup.Path
import org.cristalise.kernel.process.Gateway
import org.cristalise.kernel.process.resource.BuiltInResources
import org.cristalise.kernel.property.PropertyDescriptionList
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j

/**
*
*
*/
@CompileStatic
@CompileStatic @Slf4j
class DependencyDelegate {
Dependency dependency
String moduleNs
Expand Down Expand Up @@ -87,7 +87,7 @@ class DependencyDelegate {
assert iPathStr, "'itemPath' variable shall not be blank"

if (checkItemExists(iPathStr))
Logger.msg 5, "Unable to resolve the Item for '$iPathStr' - perhaps Item was not created yet"
log.debug "Unable to resolve the Item for '$iPathStr' - perhaps Item was not created yet"

//HACK: iPathStr is very likely contains a domainPath. itemPath is created 'manually' because of addMember()
ItemPath itemPath = new ItemPath()
Expand Down
Expand Up @@ -36,7 +36,6 @@ import org.cristalise.kernel.lookup.Path
import org.cristalise.kernel.lookup.RolePath
import org.cristalise.kernel.process.Gateway
import org.cristalise.kernel.property.PropertyArrayList
import org.cristalise.kernel.utils.Logger


/**
Expand Down
Expand Up @@ -20,22 +20,19 @@
*/
package org.cristalise.dsl.entity

import groovy.transform.CompileStatic

import java.util.ArrayList;

import org.cristalise.kernel.common.InvalidDataException
import org.cristalise.kernel.entity.imports.ImportItem;
import org.cristalise.kernel.property.Property
import org.cristalise.kernel.property.PropertyArrayList
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j


/**
* Wrapper/Delegate class of PropertyArrayList used for Item and Agent Properties
*
*/
@CompileStatic
@CompileStatic @Slf4j
class PropertyDelegate {

PropertyArrayList itemProps = new PropertyArrayList();
Expand All @@ -54,7 +51,7 @@ class PropertyDelegate {
attrs.each { k, v ->
if(!v) throw new InvalidDataException("Inmutable EntityProperty '$k' must have valid value")

Logger.msg 5, "InmutableProperty - name/Value: $k/$v"
log.info "InmutableProperty - name/value: $k/$v"

if(v instanceof String) itemProps.put(new Property(k, (String)v, false))
else throw new InvalidDataException("Property '$k' value must be String")
Expand All @@ -69,7 +66,7 @@ class PropertyDelegate {
assert attrs, "Mutable EntityProperty must have the name and value pair set"

attrs.each { k, v ->
Logger.msg 0, "Property - name/value: $k/$v"
log.info "Property - name/value: $k/$v"

if(v instanceof String) itemProps.put(new Property(k, (String)v, true))
else throw new InvalidDataException("EntityProperty '$k' value must be String")
Expand Down
Expand Up @@ -23,23 +23,23 @@ package org.cristalise.dsl.entity
import org.cristalise.kernel.entity.imports.ImportRole
import org.cristalise.kernel.lookup.AgentPath
import org.cristalise.kernel.lookup.RolePath
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j


/**
*
*/
@CompileStatic
@CompileStatic @Slf4j
class RoleBuilder {

public static ArrayList<ImportRole> build(Closure cl) {
def roleDelegate = new RoleDelegate()

roleDelegate.processClosure(cl)

Logger.msg 5, "RoleBuilder.build() - Done"
log.debug "RoleBuilder.build() - Done"

return roleDelegate.roles
}
Expand Down
Expand Up @@ -24,8 +24,6 @@ import static org.cristalise.kernel.graph.model.BuiltInVertexProperties.ROUTING_
import static org.cristalise.kernel.graph.model.BuiltInVertexProperties.ROUTING_SCRIPT_NAME
import static org.cristalise.kernel.graph.model.BuiltInVertexProperties.ROUTING_SCRIPT_VERSION

import groovy.transform.CompileStatic

import org.cristalise.kernel.common.InvalidDataException
import org.cristalise.kernel.lifecycle.instance.Activity
import org.cristalise.kernel.lifecycle.instance.AndSplit
Expand All @@ -37,13 +35,15 @@ import org.cristalise.kernel.lifecycle.instance.Split
import org.cristalise.kernel.lifecycle.instance.WfVertex
import org.cristalise.kernel.lifecycle.instance.XOrSplit
import org.cristalise.kernel.lifecycle.instance.WfVertex.Types
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j


/**
* Block is a group of WfVertices, it should only be used within Splits
*/
@CompileStatic
@CompileStatic @Slf4j
public class BlockDelegate {
String name = ""

Expand Down Expand Up @@ -125,7 +125,7 @@ public class BlockDelegate {
protected static void setRoutingScript(WfVertex aSplit, String name, String version) {
assert aSplit instanceof Split, "BlockDelegate.setRoutingScript() - Vertex '$aSplit.name' must be instance of Split"

Logger.msg 5, "BlockDelegate.setRoutingScript() - splitName: $aSplit.name, name: '$name' version: '$version'"
log.debug "setRoutingScript() - splitName: $aSplit.name, name: '$name' version: '$version'"

aSplit.getProperties().setBuiltInProperty(ROUTING_SCRIPT_NAME, name, false);
aSplit.getProperties().setBuiltInProperty(ROUTING_SCRIPT_VERSION, version, false)
Expand All @@ -152,7 +152,7 @@ public class BlockDelegate {
* @return
*/
public static String getAutoName(String n, Types t, int i) {
Logger.msg(5, "getAutoName() - name:'$n', type: $t, index: $i")
log.debug "getAutoName() - name:'$n', type: $t, index: $i"

String namePrefix = getNamePrefix(t)

Expand All @@ -176,7 +176,7 @@ public class BlockDelegate {
public WfVertex addVertex(Types t, String name) {
WfVertex v = parentCABlock.createVertex(t, name)

Logger.msg 1, "Block.addVertex() - type: '$t'; id: '$v.ID'; name: '$name;' path: '$v.path'"
log.debug "addVertex() - type: '$t'; id: '$v.ID'; name: '$name;' path: '$v.path'"

if(!firstVertex) firstVertex = v
if(lastVertex) lastVertex.addNext(v)
Expand All @@ -193,13 +193,9 @@ public class BlockDelegate {
public void processClosure(Closure cl) {
assert cl, "Block only works with a valid Closure"

Logger.msg 1, "Block(start) ---------------------------------------"

cl.delegate = this
cl.resolveStrategy = Closure.DELEGATE_FIRST
cl()

Logger.msg 1, "Block(end) +++++++++++++++++++++++++++++++++++++++++"
}

/**
Expand All @@ -208,7 +204,7 @@ public class BlockDelegate {
* @param childBlock the child Block to be linked with
*/
protected void linkWithChild(BlockDelegate childBlock) {
Logger.msg 1, "Block.linkWithChild() - class:'${childBlock.getClass()}', name: '$childBlock.name'"
log.debug "linkWithChild() - class:'${childBlock.getClass()}', name: '$childBlock.name'"

if(!firstVertex) firstVertex = childBlock.firstVertex
else lastVertex.addNext(childBlock.firstVertex)
Expand All @@ -233,7 +229,7 @@ public class BlockDelegate {
* @param props Map containing properties
*/
public void Property(Map<String, Object> props) {
Logger.msg 5, "BlockDelegate.Property() - adding props: $props"
log.debug "Property() - adding props: $props"
properties << props
}

Expand Down
Expand Up @@ -20,22 +20,22 @@
*/
package org.cristalise.dsl.lifecycle.instance

import groovy.transform.CompileStatic

import org.cristalise.kernel.common.InvalidDataException
import org.cristalise.kernel.graph.model.GraphPoint
import org.cristalise.kernel.lifecycle.LifecycleVertexOutlineCreator
import org.cristalise.kernel.lifecycle.instance.CompositeActivity
import org.cristalise.kernel.lifecycle.instance.Next
import org.cristalise.kernel.lifecycle.instance.WfVertex
import org.cristalise.kernel.lifecycle.instance.WfVertex.Types
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j


/**
*
*/
@CompileStatic
@CompileStatic @Slf4j
public class CompActDelegate extends BlockDelegate {
public static final Types type = Types.Composite

Expand Down Expand Up @@ -64,7 +64,7 @@ public class CompActDelegate extends BlockDelegate {
WfVertex v = currentCA.newChild(t, name, firstFlag, (GraphPoint)null)
LifecycleVertexOutlineCreator lifecycleVertexOutlineCreator = new LifecycleVertexOutlineCreator();
lifecycleVertexOutlineCreator.setOutline(v)
Logger.msg 1, "CA.createVertex(path: $currentCA.path) - type: '$t'; id: '$v.ID'; name: '$name;' path: '$v.path'"
log.info "createVertex(path: $currentCA.path) - type: '$t'; id: '$v.ID'; name: '$name;' path: '$v.path'"

firstFlag = false
updateVertexCache(t, name, v)
Expand All @@ -84,8 +84,6 @@ public class CompActDelegate extends BlockDelegate {
public void processClosure(BlockDelegate parentBlock, Closure cl) {
assert cl, "CompAct only works with a valid Closure"
assert parentBlock, "CA must belong to Block/CA"

Logger.msg 1, "CompAct(start) ---------------------------------------"

currentCA = (CompositeActivity)parentBlock.addVertex(Types.Composite, name)

Expand All @@ -94,8 +92,6 @@ public class CompActDelegate extends BlockDelegate {
cl()

setVertexProperties(currentCA)

Logger.msg 1, "CompAct(end) +++++++++++++++++++++++++++++++++++++++++"
}

public void Block(Closure cl) {
Expand Down
Expand Up @@ -21,16 +21,16 @@
package org.cristalise.dsl.lifecycle.instance

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j

import org.cristalise.kernel.lifecycle.instance.WfVertex
import org.cristalise.kernel.lifecycle.instance.WfVertex.Types
import org.cristalise.kernel.utils.Logger


/**
*
*/
@CompileStatic
@CompileStatic @Slf4j
class ElemActDelegate {
public static final Types type = Types.Atomic

Expand All @@ -45,7 +45,7 @@ class ElemActDelegate {
}

public void Property(Map<String, Object> props) {
Logger.msg 5, "ElemActDelegate.Property() - props: $props"
log.debug "Property() - props: $props"
props.each { key, value ->
currentVertex.properties.put(key, (value instanceof String) ? (String)value : value, false)
}
Expand Down
@@ -1,5 +1,3 @@


/**
* This file is part of the CRISTAL-iSE kernel.
* Copyright (c) 2001-2015 The CRISTAL Consortium. All rights reserved.
Expand Down Expand Up @@ -29,15 +27,15 @@ import org.cristalise.kernel.lifecycle.instance.Next
import org.cristalise.kernel.lifecycle.instance.Split
import org.cristalise.kernel.lifecycle.instance.WfVertex
import org.cristalise.kernel.lifecycle.instance.WfVertex.Types
import org.cristalise.kernel.utils.Logger

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j


/**
*
*/
@CompileStatic
@CompileStatic @Slf4j
class LoopDelegate extends BlockDelegate {
Types type = Types.LoopSplit

Expand Down Expand Up @@ -66,8 +64,6 @@ class LoopDelegate extends BlockDelegate {
public void processClosure(Closure cl) {
assert cl, "Split only works with a valid Closure"

Logger.msg 1, "$name -----------------------------------------"

String joinName = name.replace('Split', 'Join')

def joinFirst = parentCABlock.createVertex(Types.Join, "${joinName}_first")
Expand Down Expand Up @@ -101,7 +97,5 @@ class LoopDelegate extends BlockDelegate {

firstVertex = joinFirst
lastVertex = joinLast

Logger.msg 1, "$name(end) +++++++++++++++++++++++++++++++++++++++"
}
}

0 comments on commit 6ed5a4f

Please sign in to comment.