View Javadoc

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 implements IAgreementContext
50  {
51  
52      private Agreement agreement;
53  
54      /**
55       * Creates a new execution context for an agreement instance.
56       * 
57       * @param agreement
58       *            existing agreement instance
59       */
60      public AgreementContext( Agreement agreement )
61      {
62          this.agreement = agreement;
63      }
64  
65      /**
66       * {@inheritDoc}
67       */
68      public Agreement getAgreement()
69      {
70          return agreement;
71      }
72  
73      /**
74       * Persisted Execution properties map (typed as String/XMLObject) to execution context of the agreement.
75       * This method returns the persisted execution properties of the associated agreement instance.
76       * 
77       * @return the persisted execution properties of the associated agreement instance
78       * 
79       * @see Agreement#getAgreementInstance()
80       * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext()
81       */
82      public Map<String, XmlObject> getExecutionProperties()
83      {
84          return agreement.getAgreementInstance().getExecutionContext();
85      }
86  
87      /**
88       * Persisted Execution properties map (typed as String/XMLObject) to execution context of the agreement.
89       * This method alters the persisted execution properties of the associated agreement instance.
90       * 
91       * @param properties
92       *            the persisted execution properties to set
93       * 
94       * @see Agreement#getAgreementInstance()
95       * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext()
96       */
97      public void setExecutionProperties( Map<String, XmlObject> properties )
98      {
99          synchronized ( agreement.getAgreementInstance().getExecutionContext() )
100         {
101             agreement.getAgreementInstance().getExecutionContext().clear();
102             agreement.getAgreementInstance().getExecutionContext().putAll( properties );
103         }
104     }
105 
106     /**
107      * Transient execution properties map (typed as String/Object) to execution context of the agreement.
108      * This method returns the transient execution properties of the associated agreement instance that are
109      * not persisted.
110      * 
111      * @return the transient execution properties of the associated agreement instance
112      * 
113      * @see Agreement#getAgreementInstance()
114      * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext()
115      */
116     public Map<String, Object> getTransientExecutionProperties()
117     {
118         return agreement.getAgreementInstance().getTransientExecutionContext();
119     }
120 
121     /**
122      * Transient Execution properties map (typed as String/Object) to execution context of the agreement.
123      * This method alters the transient execution properties of the associated agreement instance.
124      * 
125      * @param properties
126      *            the transient execution properties to set
127      * 
128      * @see Agreement#getAgreementInstance()
129      * @see org.ogf.graap.wsag.api.types.AbstractAgreementType#getExecutionContext()
130      */
131     public void setTransientExecutionProperties( Map<String, Object> properties )
132     {
133         synchronized ( agreement.getAgreementInstance().getTransientExecutionContext() )
134         {
135             agreement.getAgreementInstance().getTransientExecutionContext().clear();
136             agreement.getAgreementInstance().getTransientExecutionContext().putAll( properties );
137         }
138     }
139 
140 }