1/* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.xml.internal.ws.developer; 27 28import com.sun.xml.internal.ws.api.FeatureConstructor; 29import com.sun.xml.internal.ws.server.DraconianValidationErrorHandler; 30 31import javax.xml.ws.WebServiceFeature; 32 33import com.sun.org.glassfish.gmbal.ManagedAttribute; 34import com.sun.org.glassfish.gmbal.ManagedData; 35 36/** 37 * {@link WebServiceFeature} for schema validation. 38 * 39 * @since JAX-WS 2.1.3 40 * @author Jitendra Kotamraju 41 * @see SchemaValidation 42 */ 43@ManagedData 44public class SchemaValidationFeature extends WebServiceFeature { 45 /** 46 * Constant value identifying the SchemaValidationFeature 47 */ 48 public static final String ID = "http://jax-ws.dev.java.net/features/schema-validation"; 49 50 private final Class<? extends ValidationErrorHandler> clazz; 51 private final boolean inbound; 52 private final boolean outbound; 53 54 public SchemaValidationFeature() { 55 this(true, true, DraconianValidationErrorHandler.class); 56 } 57 58 /** 59 * Create an <code>SchemaValidationFeature</code>. 60 * The instance created will be enabled. 61 */ 62 public SchemaValidationFeature(Class<? extends ValidationErrorHandler> clazz) { 63 this(true, true, clazz); 64 } 65 66 /** 67 * @since JAX-WS RI 2.2.2 68 */ 69 public SchemaValidationFeature(boolean inbound, boolean outbound) { 70 this(inbound, outbound, DraconianValidationErrorHandler.class); 71 } 72 73 /** 74 * @since JAX-WS RI 2.2.2 75 */ 76 @FeatureConstructor({"inbound", "outbound", "handler"}) 77 public SchemaValidationFeature(boolean inbound, boolean outbound, Class<? extends ValidationErrorHandler> clazz) { 78 this.enabled = true; 79 this.inbound = inbound; 80 this.outbound = outbound; 81 this.clazz = clazz; 82 } 83 84 @ManagedAttribute 85 @Override 86 public String getID() { 87 return ID; 88 } 89 90 /** 91 * Invalid schema instances are rejected, a SOAP fault message is created 92 * for any invalid request and response message. If it is set to false, schema 93 * validation messages are just logged. 94 */ 95 @ManagedAttribute 96 public Class<? extends ValidationErrorHandler> getErrorHandler() { 97 return clazz; 98 } 99 100 /** 101 * Turns validation on/off for inbound messages 102 * 103 * @since JAX-WS RI 2.2.2 104 */ 105 public boolean isInbound() { 106 return inbound; 107 } 108 109 /** 110 * Turns validation on/off for outbound messages 111 * 112 * @since JAX-WS RI 2.2.2 113 */ 114 public boolean isOutbound() { 115 return outbound; 116 } 117} 118