[jboss-dev-forums] [Design of POJO Server] - Re: ProfileService equiv to ServiceBindingManager

bstansberry@jboss.com do-not-reply at jboss.com
Fri Aug 8 19:18:37 EDT 2008


Carlo raised a good point that having all the bindings in a centralized bindings.xml file is clumsy.  It should be possible to add basic bindings on the fly. To support this I'm adding two things:

1) ServiceBindingStore has additional methods to allow addition of a binding to all of the named sets it knows about:


  |    /** 
  |     * Add a ServiceBinding to all binding sets in the store. For each binding 
  |     * set, a new ServiceBinding is added whose serviceName and bindingName
  |     * properties match the passed binding. The new binding's hostName matches
  |     * the target set's {@link #getDefaultHostName(String) default host name}.
  |     * The new binding's port is derived by taking the port from the passed 
  |     * binding and incrementing it by the target set's 
  |     * {@link #getDefaultPortOffset(String) default port offset}.
  |     *
  |     * @param serviceName the JMX ObjectName of the service
  |     * @param serviceConfig the configuration to add
  |     * 
  |     * @throws DuplicateServiceException thrown if a configuration for the
  |     *    <serverName, serviceName> pair already exists.
  |     */
  |    void addServiceBinding(ServiceBinding binding)
  |       throws DuplicateServiceException;
  | 
  |    /** 
  |     * Remove a service configuration from all binding sets in the store.
  |     *
  |     * @param serviceBinding the binding
  |     */
  |    void removeServiceBinding(ServiceBinding binding);
  | 
  |    /** 
  |     * Remove a service configuration from all binding sets in the store.
  |     *
  |     * @param serviceBinding the binding
  |     */
  |    void removeServiceBinding(String serviceName, String bindingName);
  |    
  |    /**
  |     * Gets the offset from a base value that by default should be added to
  |     * port values for a given serverName.
  |     * 
  |     * @param serverName the name of the binding set
  |     * @return the offset
  |     */
  |    int getDefaultPortOffset(String serverName);
  |    
  |    /**
  |     * Gets the default value to use as the host name for the given serverName.
  |     * 
  |     * @param serverName the name of the binding set
  |     * @return the host name
  |     */
  |    String getDefaultHostName(String serverName);
  |    
  |    /**
  |     * Value of <code>InetAddress.getByHost({@link #getDefaultHostName(String) getDefaultHost(serverName)})</code>.
  |     * 
  |     * @param serverName the name of the binding set
  |     * @return the host name
  |     */
  |    InetAddress getDefaultBindAddress(String serverName);

With that, a newly deployed service could easily enough register its bindings by including a bean whose purpose is to do that.

Having to include such a bean is clumsy though, A simpler mechanism is to have the ServiceBindingManager methods include overloaded versions that take a base port value.  If there is no matching binding, the SBM then uses that base value and adds the above defaultPortOffset to calculate the binding port.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4169702#4169702

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4169702



More information about the jboss-dev-forums mailing list