일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
- Database
- 고전역학
- 리눅스
- kotlin
- 역학
- python
- GIT
- 자바
- Spring Batch
- oracle
- 웹 크롤링
- 유닉스
- write by GPT-4
- android
- 파이썬
- GPT-4's answer
- Spring boot
- JVM
- 코틀린
- 자바네트워크
- chatGPT's answer
- lombok
- write by chatGPT
- 소프트웨어공학
- 시스템
- 뉴턴역학
- 인프라
- Java
- 자바암호
- NIO
- Today
- Total
Akashic Records
Getting all EJB home interface object from a HashMap 본문
Getting all EJB home interface object from a HashMap
Andrew's Akashic Records 2018. 4. 19. 15:03public class SingleHome{
private String ref="java:comp/env/ejb";
//EJB reference name use ejb/remote interface name
private static HashMap homeMap;
private SingleHome(){}
public static SingleHome getSingleHome(){
if (homeMap==null){
homeMap=new HashMap();
}
return SingleHome();
}
public Object getDestHome(String remoteInterfaceName){
String strLookup="ref"+remoteInterfaceName;
String strClass=remoteInterfaceName+"Home";
if (homeMap.containsKey(remoteInterfaceName))
return homeMap.get(remoteInterfaceName);
else {
try{
Context ctx=new InitialContext();
Object obj=ctx.lookup(strLookup);
Class clss=Class.forName(strClass);
Object home=PortableRemoteObject.narrow(obj,clss);
}catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("you must guaranty EJB remote interface name as parameter.");
}
homemap.put(remoteInterfaceName,home);
return home;
}
}
//A class to invoke business methods in remote interface object
public class ABC{
...
SingleHome sHome=SingleHome.getSingleHome();
XXX eHome=(XXX)sHome.sHome.getDestHome("YYY");
//XXX is home interface name, YYY is remote interface name
//Getting remote interface object with mothods in home interface object
...
}
http://www.theserverside.com/patterns/thread.tss?thread_id=24494
'오래된글 > Articles' 카테고리의 다른 글
당신의 개발팀에 동기부여하는 5가지 방법 (0) | 2018.04.19 |
---|---|
Android Inter-App Communication (0) | 2018.04.19 |
안정성 패턴 (0) | 2018.04.19 |
Android Thread 내에서 UI 핸들링 (0) | 2018.04.19 |
Java VM Core Dump 분석 (0) | 2018.04.19 |