Custom telnet Groovy shells – version with shared context

A follow-up to the previous postcustom Telnet shared Groovy shells. This time having shared context for all shells, i.e. shared variables!

The trick was to get Binding object from current Groovy shell Interpreter and pass it in constructor to Groovy shells that we instantiate programmatically on socket connections. Not sure if it’s thread safe BTW (this isn’t production ready (-: ).

The code is based on Groovy Shell internals a bit, so should probably be run only from Groovy shell. (And just in case – I’m using version 1.8.4 of Groovy).

In any case, here’s again some demo video:

UPD: Also there’s the thread-safe version.
In it each shell will have it’s own Binding object, i.e. separate variables context.
But on creating shell we’ll inject two variables into that context:
sharedConcurrentMap – an instance of ConcurrentHashMap which will serve as thread-safe shared context for all shells, and is pre-populated with “server” and “sockets” (the latter are also made thread-safe);
thisShellSocket – a socket that is used for this child shell.

See source code at the end of the post.

As usual, a little demo video:

The source code Continue reading

Advertisements

Liferay dictionary

When I started working with Liferay some things took me a while to figure out due to a certain difference in names used for Liferay features in user documentation and interface (Control Panel in particular) and names used internally in Java APIs, database tables etc. So I though a little table of correspondence might come handy for someone starting with Liferay or getting from user to developer level.

Let’s start with an extended example – Web Content, the base of Liferay CMS features.
It is actually mentioned on Liferay Wiki that some time ago Web Content was called Journal or something like this, but at a certain point all related portlets, control panel sections etc got renamed. Yet internally you will find no sings of “Web Content”.
The Java APIs for working with webcontent as well as DB tables are all still using old naming.

Web Content item is JournalArticle, Structure is JournalStructure and template is JournalTemplate.
To manipulate those you would use classes like JournalArticle(Local)ServiceUtil, JournalStructure(Local)ServiceUtil, JournalTemplate(Local)ServiceUtil, and to see them in database you’d have to look up tables also called “journalarticle”, “journalstructure” and “journaltemplate”.

So, let’s move on to our vocabulary: Continue reading