How to substitute environment value in JBoss naming subsystem - jboss

I have configured my init.cli script like this:
set abc=sometext
/subsystem=naming/binding=java\:global\/ABC:add(binding-type=object-factory, module=net.flexoptix.jbossTools, class=net.flexoptix.jbossTools.PropertiesFactory,\
environment=[ABC=$abc])
The problem is that value ABC in the brackets is not substituted by value sometext.
I tried to find something useful but without success. Do you have any idea how to solve it?
I have found this post https://access.redhat.com/solutions/321513 (second method) but I am not sure if it's great solution.

I have found that the problem is the property substitution isn't being performed. To enable this, you need to edit the jboss-cli.xml, in the bin directory, and change the following property to "true":
<resolve-parameter-values>true</resolve-parameter-values>
By default, this is false, and must be enabled when trying to use the --properties option for property substitution when running CLI scripts.
So I have changed the following code:
/subsystem=naming/binding=java\:global\/ABC:add(binding-type=object-factory, module=net.flexoptix.jbossTools, class=net.flexoptix.jbossTools.PropertiesFactory,\
environment=[ABC=${abc}])
And it works!

Related

Turn off XPCE in SWI-Prolog

I'd like to get the output of apropos/1 and help/1 etc. inside my Emacs buffer, instead of an XPCE window. I'm using SWI-Prolog under Linux.
What I have tried:
Setting flags in the init file (~/.plrc):
:- set_prolog_flag(gui, false).
:- set_prolog_flag(xpce, false).
Calling swipl with the --nopce flag (a wild guess looking at /usr/lib/swi-prolog/xpce.rc)
ssh localhost, effectively emulating a terminal-only machine, which worked, but there must be a better solution...
And yes, I could just uninstall the swi-prolog-x package, but I may want to write GUI programs in the future. Ideally I would like to turn off the GUI only for the documentation / debugging.
EDIT:
I've found out part of the solution: the goals online_help:give_help/1 and online_help:give_apropos seem to be what I need. I just need to re-hook these onto help and apropos, maybe via prolog:help_hook/1. Any ideas?
[~]# unset DISPLAY
swipl --nopce
This a an undocumented flag... Normally it is only used when building the system/

Specify empty variable on make command line

I have some Makefiles that are flexible based on the existence of certain variables by using ifdef to check for them. It is a bit annoying that I have to actually set the variable equal to something on the command line. make all DEBUG does not trigger the ifdef but make all DEBUG=1 does. Perhaps I am just using the C pre-processor approach where it does not belong.
Q1) Is it possible to specify a variable on the command line to be empty? Without even more characters?
Q2) What is the preferred approach for such boolean parameters to a make?
I assume you mean make all DEBUG= here, right? Without the = make will consider DEBUG to be a target to build, not a variable assignment.
The manual specifies that a variable that has a non-empty value causes ifdef to return true. A variable that does not exist or exists but contains the empty string, causes ifdef to return false. Note ifdef does not expand the variable, it just tests whether the variable has any value.
You can use the $(origin ...) function to test whether a variable is really not defined at all, or is defined but empty, like this:
ifeq ($(origin DEBUG),undefined)
$(info Variable DEBUG is not defined)
else
$(info Variable DEBUG is defined)
endif
As #MadScientist explained few minutes ago,
make all DEBUG
adds a target DEBUG to your make. Luckily, there is a workaround:
ifneq (,$(filter DEBUG,$(MAKECMDGOALS)))
DEBUG:=1 # or do whatever you want
DEBUG: all; #echo -n
endif
It is essential to supply a dummy rule (e.g. echo nothing, as above) to the dummy target. And either put this statement at the bottom of your makefile, or specify the prerequisite target explicitly as in the example. Otherwise, make may wrongly choose DEBUG target instead of all.
Note that this is not a preferred approach; the convention is like using V=1 to turn echo on.
Another caveat is that make processes the command-line goals sequentially, e.g. make A B will first take care of A target, then of B target, whether these targets are independent, or depend one on the other. Therefore writing make DEBUG PERFECT and make PERFECT DEBUG could produce different results. But the order of parameters is irrelevant, therefore make PERFECT=1 DEBUG=1 and make DEBUG=1 PERFECT=1 are equivalent.
It is already clarified why you can't use just DEBUG. But I would like to add something.
You can use shell script before running make that setup all variables you need, so, for example in linux shell it will look like this:
$source debug_setup.sh
$make all
Make is starting...
Debug is enabled
...
where debug_setup.sh contains all environment variables you need to set up:
export DEBUG=1
export DEBUG_OPTION=some_option
This is nice since you can make comments there, you can comment out if you don't need something at the moment and would like to keep for the future, etc.
Then you can have several setup scripts that must/can be used as a part of standard routine. This all depends on how many variables you need to set up, how many sets of variables you would like to have, etc.
Note that it is a good idea to notify user somehow which set of variables is selected.

Mutt macros: How to set and then use a variable in one macro?

I'm trying to write a small mutt macro that will set a variable, and then re-use that variable in the same macro.
What I'm really trying to do is compose a message and sub in the To: address (which later I will populate dynamically).
This is in my .muttrc
set my_to = "bobby#test.com"
macro index E "<enter-command> set my_to = barry#test.com<enter>mn\$my_to"
My problem is the variable my_to never changes from bobby#... to barry#...
I believe it has to do with the $ being interpreted during the config parsing, and the manual recommends using an escape . But if I do that, only the literal "$my_to" shows up.
What am I doing wrong?
update:
I still haven't been able to set/get variables as above, but I'd missed an obvious Mutt solution to my problem ESC-e will create a new email based on the existing. Similar to the edit-as-new in Thunderbird.

Eclipse code completion problem

why doesn't eclipse match the argument while doing code completion. In the following example it should have automatically matched the throwable. In stead it shows arg1 as the first option.
The autocomplete options in Eclipse for auto-completed method arguments, start with the parameter names found in the source distribution (that contains the class with the method). If no source distribution is available, then it will use the parameter names as indicated in the binary distributions i.e. in the compiled byte code. This is the default behavior
If you want to change this behavior of inserting parameter names from source code or binaries to inserting the best guessed arguments (including local variables), then you can configure the auto-complete options of Eclipse to do so, as shown in the following screenshot:
This will produce the desired result of automatically displaying the options containing the list of best-guessed arguments. This also seems to avoid suggesting parameter names:
I guess arg1 is thing you already typed. So the proposal eclipse can provide is trying to find something which start from arg1.
So it puts it as the first choice.
You can type t , and try Alt+/ , to see if this is the reason.

Emacs: can I change the name of a started process?

I can use process-name to get the name of the process, but can I change the name after starting it? I looked in the manual, and even in the source and haven't found anything that seems like it would do this.
There's only one line in Emacs' process.c source file where p->name is set for a process p, and that is in the function make_process. All other functions just read that value, they never (re-)set it. So it seems the answer to your question is "no".
You could, of course, try to implement your own function that changes the name of a process. See here
for more information.