2014-07-11 1 views

답변

0

당신은 서버의 루트에 properties 파일을 넣을 수 있습니다. FileInputStream 내에서 액세스하여 MDB 클래스에 설정하십시오. 싱글 톤 클래스를 만들고이 클래스에서 속성을 읽을 수 : JMS에

public class EnvironmentProperties { 

    private static final EnvironmentProperties INSTANCE = new EnvironmentProperties(); 

    private Properties props = null; 
    private Log log = LogFactory.getLog(EnvironmentProperties.class); 

    private EnvironmentProperties() { 
     loadProperties(); 
    } 

    public static EnvironmentProperties getInstance() { 
     return INSTANCE; 
    } 

    public String getJmsName() { 
     return props.getProperty("jms.name"); 
    } 

    public String getJmsQueue() { 
     return props.getProperty("jms.queue"); 
    } 

    private Object readResolve() { 
     return INSTANCE; 
    } 

    private Properties loadProperties() { 
     props = new Properties(); 
     try { 
      String filePath = new File("./config.properties").getCanonicalPath(); 
      FileInputStream fis = new FileInputStream(filePath);   
      props.load(fis); 
      fis.close();    
     } catch (FileNotFoundException e) { 
      log.error(e.getMessage(), e); 
     } catch (IOException e) { 
      log.error(e.getMessage(), e); 
     } 
     return props; 
    } 

} 

GET 액세스/대기열 이름 : EnvironmentProperties.getInstance().getJmsName();

properties 파일이 모든 서버

을에 존재하는지 확인
관련 문제