<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<project name="hello-jsp" default="default" basedir=".">
<property file="build.properties"/>
<property file="${ws.root}/gfproject/${deploy.platform}-config.properties"/>
<description>
Builds, tests, and runs an integration test to verify that the way
glassfish uses JSR-303 Bean Validation is correctly supported by the
implementation of Bean Validation provided in glassfish.
The following classes were examined for usage patterns for JSR 303 Bean
Validation.
connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/module/ConnectorDeployer.java
- This class loads validation mappings from an XML file so it can obtain
ConnectorRegistry.
In method registerBeanValidator(),
Validator beanValidator = null;
ValidatorFactory validatorFactory = null;
GenericBootstrap bootstrap = Validation.byDefaultProvider();
Configuration config = bootstrap.configure();
InputStream inputStream = null;
for (String fileName : mappingsList) {
inputStream = archive.getEntry(fileName);
config.addMapping(inputStream);
}
validatorFactory = config.buildValidatorFactory();
ValidatorContext validatorContext = validatorFactory.usingContext();
beanValidator = validatorContext.getValidator();
fileName is the name of a file conforming to
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
If we don't have a Validator instance after the above, we get a default one:
if (beanValidator == null) {
validatorFactory = Validation.byDefaultProvider().configure().buildValidatorFactory();
beanValidator = validatorFactory.getValidator();
}
ConnectorRegistry registry = ConnectorRegistry.getInstance();
registry.addBeanValidator(rarName, beanValidator);
This validator is used in
connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorJavaBeanValidator.java method validateJavaBean().
public void validateJavaBean(Object bean, String rarName) {
if (bean != null) {
Validator validator = ConnectorRegistry.getInstance().getBeanValidator(rarName);
if (validator != null) {
BeanDescriptor bd =
Class array[] = new Class[]{};
Set constraintViolations = validator.validate(bean, array);
if (constraintViolations != null AND.size() > 0) {
ConstraintViolationException cve = new ConstraintViolationException(constraintViolations);
StringBuffer msg = new StringBuffer();
Iterator it = constraintViolations.iterator();
while (it.hasNext()) {
ConstraintViolation cv = (ConstraintViolation) it.next();
msg.append("\n Bean Class : ").append(cv.getRootBeanClass());
msg.append("\n Bean : ").append(cv.getRootBean());
msg.append("\n Property path : " ).append(cv.getPropertyPath());
msg.append("\n Violation Message : " ).append(cv.getMessage());
}
Object[] args = new Object[]{bean.getClass(), rarName, msg.toString()};
throw cve;
}
} else {
_logger.log(Level.FINEST, "No Bean Validator is available for RAR [ " + rarName + " ]");
}
}
}
</description>
<import file="${ws.root}/gfproject/build-impl.xml"/>
<import file="${ws.root}/gfproject/${deploy.platform}-targets.xml"/>
<target name="all" depends="build,deploy,runtest,undeploy" />
<target name="build-deploy" depends="build,deploy" />
<target name="build" depends="compile-tests">
<antcall target="build-impl"/>
</target>
<target name="deploy">
<antcall target="deploy-${deploy.platform}-impl"/>
</target>
<target name="runtest">
<antcall target="runtest-impl">
<param name="contextroot" value="${contextroot}"/>
</antcall>
</target>
<target name="undeploy">
<antcall target="undeploy-${deploy.platform}-impl"/>
</target>
</project>