admin@glassfish.java.net

Re: custom validator for configRef

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Mon, 20 Dec 2010 08:56:56 -0600

  Jennifer,

Would it work to change this so that the check makes sure that the
server's config is the same as its cluster's config?
i.e.,

domain.getClusterForInstance(serverName).getConfigRef().equals(Server.getConfigRef())


This has to be true for both a set and a _register-instance.

BTW, the configref.invalid key being used in the custom validator might
cause some problems with the new MessageInterpolatorImpl that went in
for MS7. To fix this, try adding ConfigRefConstraint.class to the
default value for the payload method. Also, the configref.invalid
message string should go in the LocalStrings.properties file that is in
the com.sun.enterprise.config.serverbeans.customvalidators package.

Tom

On 12/19/2010 4:53 PM, Jennifer Chou wrote:
> I'm trying to create a custom constraint/validator for configRef on
> the Server config bean.
> There are 2 cases:
> 1) cannot change config ref of a clustered instance
> 2) cannot use a non-existent config
>
> which only need to be validated when the server instance already
> exists in domain.xml, like when using the set command.
> And should not be validated during _register-instance when the server
> hasn't been created yet. So the following commands should NOT fail
> create-local-instance --cluster c1 i1
> create-local-instance i1
>
> but these should fail
> set servers.server.i2.config-ref=c1-config (if i2 is a clustered
> instance)
> set servers.server.i2.config-ref=xxx
>
> Anybody know if there's maybe a way I can tell inside the custom
> validator if the server already exists in domain.xml?
>
> Issues:
> http://java.net/jira/browse/GLASSFISH-15087
> http://java.net/jira/browse/GLASSFISH-15218
>
>
> Thanks,
> Jennifer