2010-12-01 46 views
1

在Jboss 5.1中,Profile Service执行了Deployment Service在Jboss 4.x中所做的工作。在Jboss 4.x中,我使用Deployment Service创建了一个数据源“on -the-fly“,我想知道是否可以使用Profile Service来做同样的事情(因为Deployment Service在Jboss 5.x中不再存在)。 有没有人知道使用ProfileService的实用指导?从DeploymentService升级到JBoss 5.1.0中的ProfileService GA

谢谢,

问候。

回答

3

我不知道任何指南,但我可以使用Profile Service和几个指向此主题的JBoss wiki页面的链接向您提供我的经验。我想发布更多链接,但垃圾邮件防护不允许发布两个以上的链接,但您应该可以在ProfileService上的wiki中轻松找到其他页面。如果你找不到多少,不要惊讶,没有更多。

在那里,你可以找到关于ProfileService但没有详细的信息可以在JBoss的维基可据我可以告诉有用的信息。

为了即时创建数据源,您可以使用DeploymentTemplates(也用于创建消息队列和主题)最后一个链接为您提供有关如何使用模板但不包含所有模板名称及其属性的信息。您可以通过编程方式列出它们。

// Get all Templates 
for(String template : mgtView.getTemplateNames()) 
{ 
    System.out.println("========================================="); 
    System.out.println("Listing properties for template: "+template); 
    DeploymentTemplateInfo info = mgtView.getTemplate(template);  
    for(String prop : info.getProperties().keySet()) 
    System.out.println("- "+prop); 
} 

为了从外部Java PROGRAMM您可以使用类似的东西来此得到ManagementView(mgtView):

// set security policy 
System.setProperty("java.security.policy", "<path_to_policy_file>"); 
System.setSecurityManager(new RMISecurityManager()) ; 

// set initial context properties 
Hashtable<String, String> env = new Hashtable<String, String>(); 
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 
env.put("java.naming.provider.url","jnp://localhost:1099"); 
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); 

ctx = new InitialContext(env); 

// login to JBoss 
SecurityClient client = SecurityClientFactory.getSecurityClient(); 
client.setSimple("admin", "admin"); 
client.login(); 

// get ProfileService and ViewManager 
ProfileService ps = (ProfileService) ctx.lookup("ProfileService"); 
mgtView = ps.getViewManager(); 

你想获得什么是Java命名Conext(InitialContext的)。为了做到这一点,您需要一个安全策略(您可以使用位于JBOSS_HOME/server/SERVER_DIR/conf /中的java.policy文件),安全管理器和环境属性来获取上下文。 java.naming.provider.url指定JBoss命名服务的位置(默认端口为1099)。

通常您必须在此时通过SecurityClient进行身份验证。

最后,您可以使用上下文来抓取ProfileService。

在这一点上,大多数厌烦的东西都完成了,你可以开始玩。 getViewManager()返回ViewManager,您可以在其中随时创建数据源,getDeploymentManager()将为您提供DeploymentManager,您可以使用该DeploymentManager部署,取消部署,启动,停止应用程序和其他部署。

你需要做的是位于

  • JBOSS_HOME /客户端
  • JBOSS_HOME/lib目录
  • JBOSS_HOME/common/lib下

我读过几本库在客户端目录中包含jbossall-client.jar的次数应该足够了,但实际上并非如此。据我所知,你需要从所有三个目录中得到的库(如果不引用所有这些目录,至少不能这样做)。我还没有想出你需要它的确切罐子虽然...

重要:在JBoss中,5个社区版有一些错误的ProfileService虽然它得到了固定的JBoss 6.我想无论是建议使用较新的JBoss版本或企业版。