1 /* 2 * Copyright (c) 2007, Fraunhofer-Gesellschaft 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * (1) Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the disclaimer at the end. 11 * Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * (2) Neither the name of Fraunhofer nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * DISCLAIMER 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 */ 35 package org.ogf.graap.wsag.server.api.impl; 36 37 import java.util.Map; 38 39 import org.apache.xmlbeans.XmlObject; 40 import org.ogf.graap.wsag.api.Agreement; 41 import org.ogf.graap.wsag.server.api.IAgreementContext; 42 43 /** 44 * SimpleActionContext 45 * 46 * @author Oliver Waeldrich 47 * 48 */ 49 public class AgreementContext 50 implements IAgreementContext 51 { 52 53 private final Agreement agreement; 54 55 /** 56 * Creates a new execution context for an agreement instance. 57 * 58 * @param agreement 59 * existing agreement instance 60 */ 61 public AgreementContext( Agreement agreement ) 62 { 63 this.agreement = agreement; 64 } 65 66 /** 67 * {@inheritDoc} 68 */ 69 @Override 70 public Agreement getAgreement() 71 { 72 return agreement; 73 } 74 75 /** 76 * Persisted Execution properties map (typed as String/XMLObject) to execution context of the agreement. 77 * This method returns the persisted execution properties of the associated agreement instance. 78 * 79 * @return the persisted execution properties of the associated agreement instance 80 * 81 * @see Agreement#getAgreementInstance() 82 * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext() 83 */ 84 @Override 85 public Map<String, XmlObject> getExecutionProperties() 86 { 87 return agreement.getExecutionContext(); 88 } 89 90 /** 91 * Persisted Execution properties map (typed as String/XMLObject) to execution context of the agreement. 92 * This method alters the persisted execution properties of the associated agreement instance. 93 * 94 * @param properties 95 * the persisted execution properties to set 96 * 97 * @see Agreement#getAgreementInstance() 98 * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext() 99 */ 100 @Override 101 public void setExecutionProperties( Map<String, XmlObject> properties ) 102 { 103 synchronized ( agreement.getExecutionContext() ) 104 { 105 agreement.getExecutionContext().clear(); 106 agreement.getExecutionContext().putAll( properties ); 107 } 108 } 109 110 /** 111 * Transient execution properties map (typed as String/Object) to execution context of the agreement. This 112 * method returns the transient execution properties of the associated agreement instance that are not 113 * persisted. 114 * 115 * @return the transient execution properties of the associated agreement instance 116 * 117 * @see Agreement#getAgreementInstance() 118 * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext() 119 */ 120 @Override 121 public Map<String, Object> getTransientExecutionProperties() 122 { 123 return agreement.getTransientExecutionContext(); 124 } 125 126 /** 127 * Transient Execution properties map (typed as String/Object) to execution context of the agreement. This 128 * method alters the transient execution properties of the associated agreement instance. 129 * 130 * @param properties 131 * the transient execution properties to set 132 * 133 * @see Agreement#getAgreementInstance() 134 * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext() 135 */ 136 @Override 137 public void setTransientExecutionProperties( Map<String, Object> properties ) 138 { 139 synchronized ( agreement.getTransientExecutionContext() ) 140 { 141 agreement.getTransientExecutionContext().clear(); 142 agreement.getTransientExecutionContext().putAll( properties ); 143 } 144 } 145 146 }