Websphere(和Weblogic / JBoss)中的远程EJB查找(Remote EJB lookup in Websphere (and Weblogic/JBoss))
我有一个用于搜索的EJB类,
@Local(ILuceneEmployeeSearchManagerLocal.class) @Remote(ILuceneEmployeeSearchManagerRemote.class) public class LuceneEmployeeSearchManager implements ILuceneEmployeeSearchManagerLocal, ILuceneEmployeeSearchManagerRemote{ .... }
同一个EAR中的WAR项目中还有另一个类,可以访问它,
public class EmployeeAccessor { private ILuceneEmployeeSearchManagerRemote searcher; public EmployeeMstAccessor() { Context ic = null; try { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "<WHAT_TO_PUT_HERE>"); props.put(Context.PROVIDER_URL, "iiop://127.0.0.1:9083"); ic = new InitialContext(props); this.searcher = (ILuceneEmployeeSearchManagerRemote) ic .lookup("<WHAT_TO_PUT_HERE?>"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } .... }
当我使用JNDI执行本地查找时,这非常有效。 由于某些要求,现在需要在多个AP中部署EAR(在群集和非群集环境中)。 此外,所使用的应用程序服务器在AP之间是相同的,但不一定是Websphere,即所有AP都可能使用JBoss / Websphere / Weblogic。
我的问题是有一种独立于实现的查找和调用远程EJB的方法吗? 适用于Websphere,Weblogic或JBoss环境(同构环境)的东西。
我的第二个问题是假设AP服务器正在运行Websphere(在集群或非集群环境中),比如说我希望所有AP服务器中的EmployeeAccessor都使用部署在AP01中的LuceneEmployeeSearchManager EJB(ip:xxxx,port:yy),我该如何配置? 是否有必要提供完整的JNDI名称(包括websphere的单元名称和节点名称)? INITIAL_CONTEXT_FACTORY的正确值是什么? 什么是正确的JNDI查找语法?
感谢您的任何帮助 :)
I have a EJB class that is used for searching,
@Local(ILuceneEmployeeSearchManagerLocal.class) @Remote(ILuceneEmployeeSearchManagerRemote.class) public class LuceneEmployeeSearchManager implements ILuceneEmployeeSearchManagerLocal, ILuceneEmployeeSearchManagerRemote{ .... }
There is another class in a WAR project in the same EAR, which accesses this,
public class EmployeeAccessor { private ILuceneEmployeeSearchManagerRemote searcher; public EmployeeMstAccessor() { Context ic = null; try { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "<WHAT_TO_PUT_HERE>"); props.put(Context.PROVIDER_URL, "iiop://127.0.0.1:9083"); ic = new InitialContext(props); this.searcher = (ILuceneEmployeeSearchManagerRemote) ic .lookup("<WHAT_TO_PUT_HERE?>"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } .... }
This is working perfectly, when I was performing local lookups using JNDI. Due to some requirements, it is now necessary to deploy the EAR in multiple APs, (both in clustered and non-clustered environments). Also, the application server used will be same across APs, but not necessarily Websphere, i.e all of the APs may be using JBoss/Websphere/Weblogic.
My question is there an implementation independent way of looking up and invoking remote EJBs ? Something that will work for Websphere, Weblogic or JBoss environments (homogeneous environments).
My second question is assuming the AP servers are running Websphere (in clustered or non-clustered environment), say I want EmployeeAccessor in all of the AP servers to be using the LuceneEmployeeSearchManager EJB deployed in AP01 (ip:x.x.x.x, port:yy), how do I configure it ? Is it necessary to give the full JNDI name (including cell name and node name for websphere) ? What are the proper values for INITIAL_CONTEXT_FACTORY ? and what is the correct JNDI lookup syntax ?
Thank you for any help :)
原文:https://stackoverflow.com/questions/26377339
最满意答案
如果字段是固定的,这更简单直接:
$ awk '{for (i=$1+0;i<=$(NF-1);i++){printf "%d ", i};print ""}' list.txt 14 15 16 17 18 19 45 46 47 48 49 50
为了防止尾随空间(感谢@fedorqui):
awk '{for (i=$1+0;i<$3+0;i++){printf "%d ", i};print ""$3}' list.txt
If the fields are fixed, this is much more simple and direct:
$ awk '{for (i=$1+0;i<=$(NF-1);i++){printf "%d ", i};print ""}' list.txt 14 15 16 17 18 19 45 46 47 48 49 50
To prevent trailing space (thanks @fedorqui):
awk '{for (i=$1+0;i<$3+0;i++){printf "%d ", i};print ""$3}' list.txt
相关问答
更多-
标签分隔值在awk中(Tab separated values in awk)[2023-09-14]
您需要将OFS变量(输出字段分隔符)设置为一个选项卡: echo "$line" | awk -v var="$mycol_new" -F $'\t' 'BEGIN {OFS = FS} {$3 = var; print}' (请确保在echo语句中引用$line变量) You need to set the OFS variable (output field separator) to be a tab: echo "$line" | awk -v var="$mycol_new" -F $'\t ... -
要指定字段分隔符,必须使用-F而不是-f ; 要更改输出的字段分隔符,您必须更改OFS变量(输出字段分隔符)。 在字段周围获取引号,您可以遍历所有字段并添加它们: $ awk -F"|" -v OFS="," '{for (i=1; i<=NF; ++i){$i="\""$i"\""}}1' infile "A","B","C","D","E","F" 或者,使用sed: $ sed 's/\([^|]*\)/"\1"/g;y/|/,/' infile "A","B","C","D","E","F" 它 ...
-
使用具有超过3个以空格分隔的单词的awk打印行?(printing lines using awk which have more than 3 space-delimited words?)[2023-07-09]
像这样使用awk: awk 'NF>3' file Use awk like this: awk 'NF>3' file -
只需修复您的代码: awk '($3 != $4) && !($3=="C" && $4=="T")' file just fix your codes: awk '($3 != $4) && !($3=="C" && $4=="T")' file
-
如果您正在寻找一个特定的字符串,请在其上放置引号: awk '$1 == "findtext" {print $3}' 否则,awk会假定它是一个变量名。 If you're looking for a particular string, put quotes around it: awk '$1 == "findtext" {print $3}' Otherwise, awk will assume it's a variable name.
-
您可以使用paste进行并排输出: paste <(echo "$foo") <(echo "$bar") You can use paste for side-by-side output: paste <(echo "$foo") <(echo "$bar")
-
如果字段是固定的,这更简单直接: $ awk '{for (i=$1+0;i<=$(NF-1);i++){printf "%d ", i};print ""}' list.txt 14 15 16 17 18 19 45 46 47 48 49 50 为了防止尾随空间(感谢@fedorqui): awk '{for (i=$1+0;i<$3+0;i++){printf "%d ", i};print ""$3}' list.txt If the fields are fixed, this is mu ...
-
awk打印行问题(awk Print Line Issue)[2022-05-17]
由于评论建议不建议使用grep和cat等使用system函数,因为awk是可以执行大部分这些任务的完整语言。 您可以使用以下awk命令替换您的cat | grep cat | grep功能: awk 'FNR == NR {a[$1]=0; next} {for (i=1; i<=NF; i++) if ($i in a) a[$i]++} END { for (i in a) print i, a[i] }' uniq.txt test.txt test1 2 test2 1 请注意,此输出与计数5 ... -
awk的printf插入多个变量的正确语法是什么?(what is the correct syntax for awk's printf to insert multiple variables?)[2022-04-14]
每个变量都需要一个格式字符串,如%s 。 所以,试试: printf "%s %s\n", a, a_counter 要么: printf "pattern=%s and count=%s\n", a, a_counter %s将任何变量转换为字符串。 如果变量是数字,则其他格式(如%f或%e )可以让您更好地控制数字转换为字符串的方式。 有关详细信息,请参阅man awk 例子 $ awk -v a="genie" -v a_counter=3 'BEGIN{ printf "%s %s\n", a, ... -
Awk列匹配不适用于您通过插入换行符创建的多行。 默认情况下,它适用于基于空白的列。 用空格替换逗号,而不是换行符。 echo "$file"|sed 's/,/ /g' | awk '{print $2}' 或者通过指定分隔符来分隔逗号: echo "$file"| awk -F',' '{print $2}' Awk column matching doesn't work across multiple lines, which you're creating by inserting a lin ...