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.client.local;
36  
37  import java.util.Properties;
38  
39  import org.ogf.graap.wsag.api.WsagConstants;
40  import org.ogf.graap.wsag.api.client.WsClient;
41  import org.ogf.graap.wsag.api.security.ISecurityProperties;
42  import org.ogf.graap.wsag.api.security.SecurityProperties;
43  import org.w3.x2005.x08.addressing.EndpointReferenceType;
44  
45  /**
46   * Default implementation of a WS client for local access. Internal use only.
47   * 
48   * @author Oliver Waeldrich
49   * 
50   */
51  public class LocalWsClient implements WsClient
52  {
53  
54      private EndpointReferenceType epr;
55  
56      private Properties properties;
57  
58      private ISecurityProperties securityProperties;
59  
60      private boolean trace = false;
61  
62      /**
63       * Default constructor
64       */
65      public LocalWsClient()
66      {
67          //
68          // initialize agreement epr
69          //
70          epr = EndpointReferenceType.Factory.newInstance();
71          epr.addNewAddress().setStringValue( "http://127.0.0.1:8080/wsag4j"
72                                                  + WsagConstants.AGREEMENT_SERVICE_URI );
73  
74          //
75          // initialize properties
76          //
77          properties = new Properties();
78  
79          //
80          // initialize security properties
81          //
82          securityProperties = new SecurityProperties( null );
83      }
84  
85      /**
86       * returns a dummy EPR for this agreement.
87       * 
88       * {@inheritDoc}
89       */
90      public EndpointReferenceType getEndpoint()
91      {
92          return epr;
93      }
94  
95      /**
96       * {@inheritDoc}
97       */
98      public Properties getProperties()
99      {
100         return properties;
101     }
102 
103     /**
104      * {@inheritDoc}
105      */
106     public ISecurityProperties getSecurityProperties()
107     {
108         return securityProperties;
109     }
110 
111     /**
112      * {@inheritDoc}
113      */
114     public boolean isUsingTrace()
115     {
116         return trace;
117     }
118 
119     /**
120      * {@inheritDoc}
121      */
122     public void setProperties( Properties properties )
123     {
124         this.properties = properties;
125     }
126 
127     /**
128      * {@inheritDoc}
129      */
130     public void setTrace( boolean trace )
131     {
132         this.trace = trace;
133     }
134 
135     /**
136      * @return this WS client instance
137      */
138     public WsClient getWebServiceClient()
139     {
140         return this;
141     }
142 
143 }