The Payload returned ConfigRefConstraint can any class or interface
that implements the Payload interface that is in the same Java package
as ConfigRefConstraint. Can you just make the
ConfigRegConstraintValidator implement Payload and return that?
Tom
On 12/20/2010 2:25 PM, Jennifer Chou wrote:
> Thanks Tom for the suggestion! The cluster devtests that were
> failing are now passing. The behavior is different for set and
> _register-instance. See below....
>
> On 12/20/2010 9:56 AM, Tom Mueller wrote:
>> 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.
> For _register-instance (create-local-instance --cluster c1 i1) the
> above is true. getClusterForInstance(serverName).getConfigRef() =
> "c1-config"
> Server.getConfigRef() ="c1-config"
>
> For set (set servers.server.i1.config-ref=i2-config), the above is
> false. getClusterForInstance(serverName).getConfigRef() = "c1-config"
> Server.getConfigRef() ="i2-config"
>
> So this does seem to work.....
>
> // cannot change config ref of a clustered instance
> Cluster cluster = domain.getClusterForInstance(serverName);
> if (cluster != null) { // cluster is not null during
> create-local-instance --cluster c1 i1
> if (!cluster.getConfigRef().equals(configRef)) {
> // During set when trying to change config-ref of a clustered
> instance,
> // the value of desired config-ref will be different than the
> current config-ref.
> // During _register-instance, (create-local-instance --cluster
> c1 i1)
> // cluster.getConfigRef().equals(configRef) will be true
> // and not come here.
>
> logger.warning(localStrings.getLocalString("configref.clusteredinstance",
> "Cannot change a config-ref when the instance is part
> of a cluster"));
> return false;
> }
> }
>>
>> 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.
> Thanks I was going to ask you about that. I tried your suggestion, bu
> it doesn't let me since ConfigRefConstaint does not extend Payload,
> and I couldn't extend Payload because ConfigRefConstraint is an
> interface. Do you know if the MessageIntepolatorImpl will be fixed?
> Thanks,
> Jennifer
>> 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
>