일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 고전역학
- 코틀린
- android
- NIO
- Java
- 역학
- 웹 크롤링
- spring data jpa
- 리눅스
- 파이썬
- chatGPT's answer
- python
- 소프트웨어공학
- 유닉스
- JVM
- 자바
- spring integration
- 자바네트워크
- jpa
- write by GPT-4
- 시스템
- flet
- 자바암호
- write by chatGPT
- kotlin
- oracle
- GPT-4's answer
- 데이터베이스
- Today
- Total
기억을 지배하는 기록
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 |