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.persistence.impl;
36  
37  import java.util.UUID;
38  
39  import org.apache.log4j.Logger;
40  import org.ogf.graap.wsag.api.Agreement;
41  import org.ogf.graap.wsag.api.AgreementFactory;
42  import org.ogf.graap.wsag.server.persistence.PersistedResourceException;
43  import org.ogf.graap.wsag.server.persistence.PersistentAgreement;
44  import org.ogf.graap.wsag.server.persistence.PersistentAgreementFactory;
45  
46  /**
47   * SimplePersistentAgreementFactory. Agreement factories are persisted by the WSAG4J engine configuration
48   * files. Each engine instance is treated as an agreement factory configuration. Therefore, for each engine
49   * instance one {@link SimplePersistentAgreementFactory} instance is created and initialized.
50   * 
51   * {@link SimplePersistentAgreementFactory} is an adapter between the {@link PersistentAgreementFactory} and
52   * the {@link AgreementFactory} interfaces (between persistence layer and factory implementation).
53   * 
54   * @author Oliver Waeldrich
55   * 
56   */
57  public class SimplePersistentAgreementFactory extends AbstractPersistentAgreementFactory
58      implements PersistentAgreementFactory
59  {
60      private static final Logger LOG = Logger.getLogger( SimplePersistentAgreementFactory.class );
61  
62      /**
63       * 
64       * @param factory
65       *            the delegation target
66       */
67      public SimplePersistentAgreementFactory( AgreementFactory factory )
68      {
69          super( factory );
70  
71          if ( LOG.isDebugEnabled() )
72          {
73              LOG.debug( "Create a new SimplePersistentAgreementFactory instance." );
74          }
75  
76          //
77          // replaced MUSE RandomUuidFactory with default Java implementation for uuid's
78          //
79          // this.resourceId = RandomUuidFactory.getInstance().createUUID();
80          this.resourceId = UUID.randomUUID().toString();
81      }
82  
83      /**
84       * This agreement factory does not support persistence. Calls to this method will have no effect.
85       * 
86       * {@inheritDoc}
87       */
88      protected PersistentAgreement[] doLoad() throws PersistedResourceException
89      {
90          return new PersistentAgreement[0];
91      }
92  
93      /**
94       * This agreement factory does not support persistence. Calls to this method will return a
95       * {@link SimplePersistentAgreement}.
96       * 
97       * @param agreement
98       *            the agreement to persist
99       * 
100      * @throws {@inheritDoc}
101      */
102     protected PersistentAgreement persistAgreement( Agreement agreement ) throws PersistedResourceException
103     {
104         return new SimplePersistentAgreement( agreement, null );
105     }
106 
107     /**
108      * This agreement factory does not support persistence. Calls to this method will have no effect.
109      * 
110      * @param agreement
111      *            the agreement to remove
112      * 
113      * @throws PersistedResourceException
114      *             {@inheritDoc}
115      * 
116      * @see org.ogf.graap.wsag.server.persistence.IAgreementHome#remove(java.lang.String)
117      */
118     protected void doRemove( PersistentAgreement agreement ) throws PersistedResourceException
119     {
120     }
121 
122 }