[ 
https://issues.apache.org/jira/browse/WHIRR-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202125#comment-13202125
 ] 

David Alves commented on WHIRR-505:
-----------------------------------

Sound like you need to use a handler factory:

public class JBossDeployWarHandlerFactory extends ClusterActionHandlerFactory {

  @Override
  public String getRolePrefix() {
    return "jboss-war";
  }

  @Override
  public ClusterActionHandler create(String roleName) {
    return new JBossDeployWarHandler(roleName);
  }
}

then you could use specific templates and assign config variables for a 
particular handler for: jboss-war:alex jboss-war:pass

see the chef service for more info.

For bonus points you could create a generic file copier: file-copy:filea 
file-copy:fileb where each file's url would be specified by config and 
contribute it back :)
                
> alias mechanism for services
> ----------------------------
>
>                 Key: WHIRR-505
>                 URL: https://issues.apache.org/jira/browse/WHIRR-505
>             Project: Whirr
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 0.7.0
>            Reporter: Gerrit Germis
>            Priority: Minor
>              Labels: alias, role, service
>
> Currently I have these services defined:
> * JBossNodeHandler  (role = "jboss")
> * JBossDeployHandler (abstract)
> ** JBossDeployPassHandler (role = "pass")
> ** JBossDeployAlexHandler (role = "alex")
> This allows me to use the folowing .properties file:
> {noformat}
> whirr.cluster-name=jbosstest
> whirr.instance-templates=2 jboss+alex,2 jboss+pass
> whirr.hardware-min-ram=1024
> whirr.firewall-rules.jboss=8080
> # For EC2 set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment 
> variables.
> whirr.provider=aws-ec2
> whirr.identity=${env:AWS_ACCESS_KEY_ID}
> whirr.credential=${env:AWS_SECRET_ACCESS_KEY}
> # Apps to deploy
> whirr.alex.tarball.url=http://x.y.org/wastebin/alex-1.0.war
> whirr.pass.tarball.url=http://x.y.org/wastebin/pass-1.0.war
> {noformat}
> If I want to add a new service, I would need to create another subclass of 
> JBossDeployHandler to create a new role which i can then use in the 
> .properties file. Since all application deploys on jboss typically need the 
> same procedure to deploy, it would be handy if I could just have 1 
> implementation (eg: JBossDeployHandler) that I can give multiple role names, 
> so that i can just add new applications to the .properties file without 
> needing to create new subclasses.
> My subclasses currently are just dummy classes like:
> {code}
> public class JBossDeployAlexHandler extends JBossDeployHandler {
>     public static final String ROLE = "alex";
>     @Override
>     public String getRole() {
>         return ROLE;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to