03 December 2019

Pipeline Pattern

Many times we need to implement a workflow/pipeline in our code (i.e.: Java) this brings us bad design by using too many nested loops, if/switch, etc.

One way is to use a BPM however this has boilerplate config/code, a leaner solution is to implement Pipeline Pattern:

Definition of the Pipeline Pattern

 Each of the sequence of calculations is performed by having the first stage of the pipeline perform the first step, and then the second stage the second step, and so on.
 As each stage completes a step of a calculation, it passes the calculation-in-progress to the next stage and begins work on the next calculation.”


https://www.cise.ufl.edu/research/ParallelPatterns/PatternLanguage/AlgorithmStructure/Pipeline.htm



gist:
https://stackoverflow.com/questions/39947155/pipeline-design-pattern-implementation

Spring contexts and Servlets


applicationContext.xml defines the beans for the "root webapp context", i.e. the context associated with the webapp. This means is transversal.

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
 


The spring-servlet.xml (or whatever else you call it) defines the beans for one servlet's app context. There can be many of these in a webapp, one per Spring servlet (e.g. spring1-servlet.xml for servlet spring1, spring2-servlet.xml for servlet spring2).

Therefore resources that need to be injected transversal can be set in applicationContext.xml, ie:

  <import resource="classpath*:spring/jwt-security-context.xml"/>
  

from: https://stackoverflow.com/questions/3652090/difference-between-applicationcontext-xml-and-spring-servlet-xml-in-spring-frame



Also Servelts using Spring DI:

- https://stackoverflow.com/questions/35255052/spring-service-not-injected-in-web-servlet
- http://www.javavillage.in/spring-ioc-on-servlets.php

26 November 2019

Debugging Linux Tools

A good summary of debugging Linux tools:

  1. 'print' statements
  2. Querying (/proc, /sys etc)
  3. Tracing (strace/ltrace)
  4. Valgrind (memwatch)
  5. GDB

at: https://linoxide.com/linux-how-to/user-space-debugging-tools-linux/

22 November 2019

Spring Classpath

SIMPLE DEFINITION

The classpath*:conf/appContext.xml simply means that all appContext.xml files under conf folders in all your jars on the classpath will be picked up and joined into one big application context.

In contrast, classpath:conf/appContext.xml will load only one such file... the first one found on your classpath.

12 November 2019

TAOCP: Volume 4B, Fascicle 5

The Art of Computer Programming, Volume 4B, Fascicle 5: Mathematical Preliminaries Redux; Introduction to Backtracking; Dancing Links

This fascicle covers three separate topics:
  1.  Mathematical Preliminaries. Knuth writes that this portion of fascicle 5 "extends the ‘Mathematical Preliminaries’ of Section 1.2 in Volume 1 to things that I didn't know about in the 1960s. Most of this new material deals with probabilities and expectations of random events; there's also an introduction to the theory of martingales."
  2.  Backtracking: this section is the counterpart to section 7.2.1 which covered the generation of basic combinatorial patterns. This section covers non-basic patterns, ones where the developer needs to make tentative choices and then may need to backtrack when those choices need revision.
  3.  Dancing Links: this section is related to 2 above. It develops an important data structure technique that is suitable for backtrack programming described above.




06 November 2019

Eclipse - spaces instead of tabs

Usually when using a new eclipse version or AnyEdit Tools.

Always I forget to change this and the impact is huge in git.



04 November 2019

BEA-141297

Cuando se baja de forma incorrecta el AdminServer:

<Info> <Management> <BEA-141297> <Could not get the server file lock. Ensure that another server is not running in the same directory. Retrying for another 60 seconds.>

Hay que borrar :

/mdw/domains/base_domain/servers/AdminServer/tmp/AdminServer.lok


08 October 2019

Parsing tools


Many times I've seen the necessity for parser creation. There are many examples where we need a parser for automation of analysis, diagram creation, etc.

Most common libraries for it :

  1. antlr
  2. javaparser
  3. eclipse jdt
  4. custom

Own example: https://github.com/devwebcl/eclipse-cdt-poc


Examples :


  1. Documenting your architecture: Wireshark, PlantUML and a REPL to glue them all
  2. Your Program as a Transpiler
  3. Federico Tomassetti has several DSL examples.



My Blog List

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.