aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.oracle.webservices.internal.api.message; aoqi@0: aoqi@0: import java.lang.annotation.ElementType; aoqi@0: import java.lang.annotation.Inherited; aoqi@0: import java.lang.annotation.Retention; aoqi@0: import java.lang.annotation.RetentionPolicy; aoqi@0: import java.lang.annotation.Target; aoqi@0: import java.util.Map; aoqi@0: aoqi@0: import javax.xml.ws.handler.MessageContext; aoqi@0: aoqi@0: /** aoqi@0: * A set of "properties" that can be accessed via strongly-typed fields aoqi@0: * as well as reflexibly through the property name. aoqi@0: * aoqi@0: * @author Kohsuke Kawaguchi aoqi@0: */ aoqi@0: public interface PropertySet { aoqi@0: aoqi@0: /** aoqi@0: * Marks a field on {@link PropertySet} as a aoqi@0: * property of {@link MessageContext}. aoqi@0: * aoqi@0: *

aoqi@0: * To make the runtime processing easy, this annotation aoqi@0: * must be on a public field (since the property name aoqi@0: * can be set through {@link Map} anyway, you won't be aoqi@0: * losing abstraction by doing so.) aoqi@0: * aoqi@0: *

aoqi@0: * For similar reason, this annotation can be only placed aoqi@0: * on a reference type, not primitive type. aoqi@0: * aoqi@0: * @author Kohsuke Kawaguchi aoqi@0: */ aoqi@0: @Inherited aoqi@0: @Retention(RetentionPolicy.RUNTIME) aoqi@0: @Target({ElementType.FIELD,ElementType.METHOD}) aoqi@0: public @interface Property { aoqi@0: /** aoqi@0: * Name of the property. aoqi@0: */ aoqi@0: String[] value(); aoqi@0: } aoqi@0: aoqi@0: public boolean containsKey(Object key); aoqi@0: aoqi@0: /** aoqi@0: * Gets the name of the property. aoqi@0: * aoqi@0: * @param key aoqi@0: * This field is typed as {@link Object} to follow the {@link Map#get(Object)} aoqi@0: * convention, but if anything but {@link String} is passed, this method aoqi@0: * just returns null. aoqi@0: */ aoqi@0: public Object get(Object key); aoqi@0: aoqi@0: /** aoqi@0: * Sets a property. aoqi@0: * aoqi@0: *

Implementation Note

aoqi@0: * This method is slow. Code inside JAX-WS should define strongly-typed aoqi@0: * fields in this class and access them directly, instead of using this. aoqi@0: * aoqi@0: * @see Property aoqi@0: */ aoqi@0: public Object put(String key, Object value); aoqi@0: aoqi@0: /** aoqi@0: * Checks if this {@link PropertySet} supports a property of the given name. aoqi@0: */ aoqi@0: public boolean supports(Object key); aoqi@0: aoqi@0: public Object remove(Object key); aoqi@0: aoqi@0: /** aoqi@0: * Creates a {@link Map} view of this {@link PropertySet}. aoqi@0: * aoqi@0: *

aoqi@0: * This map is partially live, in the sense that values you set to it aoqi@0: * will be reflected to {@link PropertySet}. aoqi@0: * aoqi@0: *

aoqi@0: * However, this map may not pick up changes made aoqi@0: * to {@link PropertySet} after the view is created. aoqi@0: * aoqi@0: * @deprecated use newer implementation {@link com.sun.xml.internal.ws.api.PropertySet#asMap()} which produces aoqi@0: * readwrite {@link Map} aoqi@0: * aoqi@0: * @return aoqi@0: * always non-null valid instance. aoqi@0: */ aoqi@0: @Deprecated aoqi@0: public Map createMapView(); aoqi@0: aoqi@0: /** aoqi@0: * Creates a modifiable {@link Map} view of this {@link PropertySet}. aoqi@0: *

aoqi@0: * Changes done on this {@link Map} or on {@link PropertySet} object work in both directions - values made to aoqi@0: * {@link Map} are reflected to {@link PropertySet} and changes done using getters/setters on {@link PropertySet} aoqi@0: * object are automatically reflected in this {@link Map}. aoqi@0: *

aoqi@0: * If necessary, it also can hold other values (not present on {@link PropertySet}) - aoqi@0: * {@see PropertySet#mapAllowsAdditionalProperties} aoqi@0: * aoqi@0: * @return always non-null valid instance. aoqi@0: */ aoqi@0: public Map asMap(); aoqi@0: }