1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* 
18  
19   */
20  
21  package org.apache.wsrp4j.consumer.driver;
22  
23  import java.net.MalformedURLException;
24  import java.net.URL;
25  
26  import oasis.names.tc.wsrp.v1.intf.WSRP_v1_Markup_PortType;
27  import oasis.names.tc.wsrp.v1.wsdl.WSRPServiceLocator;
28  
29  import org.apache.wsrp4j.consumer.InitCookieInfo;
30  import org.apache.wsrp4j.exception.ErrorCodes;
31  import org.apache.wsrp4j.exception.WSRPException;
32  import org.apache.wsrp4j.exception.WSRPXHelper;
33  import org.apache.wsrp4j.log.LogManager;
34  import org.apache.wsrp4j.log.Logger;
35  
36  public class InitCookieInfoImpl implements InitCookieInfo {
37  
38      private Logger logger = null;;
39  
40      private String markupInterfaceURL = null;
41  
42      private boolean initCookieRequired;
43  
44      private boolean initCookieDone;
45  
46      private WSRP_v1_Markup_PortType markupInterface;
47  
48      public InitCookieInfoImpl(String markupURL) throws WSRPException {
49          final String MN = "init";
50  
51          logger = LogManager.getLogManager().getLogger(getClass());
52  
53          this.initCookieDone = false;
54          this.initCookieRequired = false;
55          this.markupInterfaceURL = markupURL;
56  
57          try {
58              WSRPServiceLocator serviceLocator = new WSRPServiceLocator();
59              serviceLocator.setMaintainSession(true);
60  
61              markupInterface = serviceLocator.getWSRPBaseService(new URL(
62                      markupURL));
63  
64          }
65          catch (javax.xml.rpc.ServiceException xmlEx) {
66              WSRPXHelper.throwX(logger, Logger.ERROR, MN,
67                      ErrorCodes.INIT_OF_MARKUP_PORT_FAILED, xmlEx);
68          }
69          catch (MalformedURLException urlEx) {
70              WSRPXHelper.throwX(logger, Logger.ERROR, MN,
71                      ErrorCodes.INVALID_URL_OF_MARKUP_PORT, urlEx);
72          }
73      }
74  
75      public boolean isInitCookieRequired() {
76          return initCookieRequired;
77      }
78  
79      public void setInitCookieRequired(boolean initCookieRequired) {
80          this.initCookieRequired = initCookieRequired;
81      }
82  
83      public boolean isInitCookieDone() {
84          return initCookieDone;
85      }
86  
87      public void setInitCookieDone(boolean initCookieDone) {
88          this.initCookieDone = initCookieDone;
89      }
90  
91      public String getMarkupInterfaceURL() {
92          return markupInterfaceURL;
93      }
94  
95      public WSRP_v1_Markup_PortType getWSRPBaseService() {
96          return markupInterface;
97      }
98  
99      public void setWSRPBaseService(WSRP_v1_Markup_PortType markupPortType) {
100         if (markupPortType != null) {
101             this.markupInterface = markupPortType;
102         }
103     }
104 
105 }