Changeset 4398


Ignore:
Timestamp:
Aug 20, 2008, 2:12:05 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1057: Make it possible to access and change web service options on client side

Location:
trunk/src
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/test/TestWebservices.java

    r4301 r4398  
    5050import net.sf.basedb.ws.client.ArrayDesignClient;
    5151import net.sf.basedb.ws.client.BioAssaySetClient;
     52import net.sf.basedb.ws.client.ConfigurableServiceFactory;
    5253import net.sf.basedb.ws.client.ExperimentClient;
    5354import net.sf.basedb.ws.client.ProjectClient;
    5455import net.sf.basedb.ws.client.RawBioAssayClient;
    5556import net.sf.basedb.ws.client.ReporterClient;
     57import net.sf.basedb.ws.client.ServiceFactory;
    5658import net.sf.basedb.ws.client.SessionClient;
    5759
     
    6264import java.util.ArrayList;
    6365import java.util.Arrays;
     66
     67import org.apache.axis2.client.Options;
     68import org.apache.axis2.transport.http.HTTPConstants;
    6469
    6570/**
     
    8792   
    8893    //Tests
    89     SessionClient client = test_SessionClient();
     94    SessionClient client = test_SessionClient(null);
    9095    if (client == null) return ok;
    9196   
     
    551556  }
    552557 
    553   static SessionClient test_SessionClient()
     558  static SessionClient test_SessionClient(ServiceFactory serviceFactory)
    554559  {
    555560    SessionClient client = null;
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/AbstractRPCClient.java

    r3964 r4398  
    4747{
    4848  private final String serviceUrl;
     49  private ServiceFactory serviceFactory;
    4950 
    5051  protected AbstractRPCClient(String url, String service)
    5152  {
    52     this.serviceUrl = url + "/" + service;
     53    this(url, service, null);
    5354  }
    5455 
    55   @SuppressWarnings("unchecked")
     56  /**
     57   
     58    @since 2.8
     59  */
     60  protected AbstractRPCClient(String url, String service, ServiceFactory serviceFactory)
     61  {
     62    this.serviceUrl = url + "/" + service;
     63    this.serviceFactory = serviceFactory == null ?
     64      Factories.getDefaultServiceFactory() : serviceFactory;
     65  }
     66 
     67  /**
     68    Get the factory that is used to create {@link RPCServiceClient}
     69    objects for this web service.
     70    @since 2.8
     71  */
     72  public ServiceFactory getServiceFactory()
     73  {
     74    return serviceFactory;
     75  }
     76 
     77  /**
     78    Sets the factory that is used to create {@link RPCServiceClient}
     79    objects for this web service.
     80    @since 2.8
     81  */
     82  public void setServiceFactory(ServiceFactory serviceFactory)
     83  {
     84    this.serviceFactory = serviceFactory;
     85  }
     86 
    5687  protected Object[] invokeBlocking(String operation, Object[] args, Class[] returnTypes)
    5788    throws AxisFault
     
    89120    throws AxisFault
    90121  {
    91     RPCServiceClient service = new RPCServiceClient();
     122    EndpointReference target = new EndpointReference(serviceUrl);
     123    RPCServiceClient service = serviceFactory.createService(target);
    92124    Options options = service.getOptions();
    93     EndpointReference targetEPR = new EndpointReference(serviceUrl);
    94     options.setTo(targetEPR);
     125    if (options.getTo() == null) options.setTo(target);
    95126    return service;
    96127  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/AnnotationTypeClient.java

    r4011 r4398  
    4646  public AnnotationTypeClient(SessionClient session)
    4747  {
    48     super(session.getUrl(), "AnnotationType");
     48    super(session.getUrl(), "AnnotationType", session.getServiceFactory());
    4949    this.session = session;
    5050  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/ArrayDesignClient.java

    r4011 r4398  
    5555  public ArrayDesignClient(SessionClient session)
    5656  {
    57     super(session.getUrl(), "ArrayDesign");
     57    super(session.getUrl(), "ArrayDesign", session.getServiceFactory());
    5858    this.session = session;
    5959  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/BioAssaySetClient.java

    r3964 r4398  
    4949  public BioAssaySetClient(SessionClient session)
    5050  {
    51     super(session.getUrl(), "BioAssaySet");
     51    super(session.getUrl(), "BioAssaySet", session.getServiceFactory());
    5252    this.session = session;
    5353  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/ExperimentClient.java

    r4011 r4398  
    5050  public ExperimentClient(SessionClient session)
    5151  {
    52     super(session.getUrl(), "Experiment");
     52    super(session.getUrl(), "Experiment", session.getServiceFactory());
    5353    this.session = session;
    5454  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/ProjectClient.java

    r4011 r4398  
    4646  public ProjectClient(SessionClient session)
    4747  {
    48     super(session.getUrl(), "Project");
     48    super(session.getUrl(), "Project", session.getServiceFactory());
    4949    this.session = session;
    5050  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/RawBioAssayClient.java

    r4011 r4398  
    5858  public RawBioAssayClient(SessionClient session)
    5959  {
    60     super(session.getUrl(), "RawBioAssay");
     60    super(session.getUrl(), "RawBioAssay", session.getServiceFactory());
    6161    this.session = session;
    6262  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/ReporterClient.java

    r3993 r4398  
    5252  public ReporterClient(SessionClient session)
    5353  {
    54     super(session.getUrl(), "Reporter");
     54    super(session.getUrl(), "Reporter", session.getServiceFactory());
    5555    this.session = session;
    5656  }
  • trunk/src/webservices/client/java/net/sf/basedb/ws/client/SessionClient.java

    r3960 r4398  
    4141 
    4242  /**
    43     Creates a new SessionClient to a certain URL.
     43    Creates a new SessionClient using the default service factory.
     44   
    4445      @param url The url where web services are located.
    4546      @param ID Session id of a logged in session. A new session will be created if this is NULL.
    4647      @param externalClientId External id of the client that is registered in BASE.
    4748      @throws AxisFault If communication with the web service fails.
    48    */
     49  */
    4950  public SessionClient(String url, String ID, String externalClientId)
    5051    throws AxisFault
    5152  {
    52     super(url, "Session");
     53    this(url, ID, externalClientId, null);
     54  }
     55
     56  /**
     57    Creates a new SessionClient using a specific service factory.
     58      @param url The url where web services are located.
     59      @param ID Session id of a logged in session. A new session will be created if this is NULL.
     60      @param externalClientId External id of the client that is registered in BASE.
     61      @param serviceFactory The service factory to use, or null to
     62        use the default: {@link Factories#getDefaultServiceFactory()}
     63      @throws AxisFault If communication with the web service fails
     64      @since 2.8
     65  */
     66  public SessionClient(String url, String ID, String externalClientId, ServiceFactory serviceFactory)
     67    throws AxisFault
     68  {
     69    super(url, "Session", serviceFactory);
    5370    this.url = url;
    5471    this.ID = ID != null ? ID : invokeBlocking("newSession", String.class, externalClientId);
    5572  }
     73
    5674 
    5775  /**
     
    6785    Gets the id of the session.
    6886      @return Session ID as a String
    69    */
     87  */
    7088  public String getId()
    7189  {
Note: See TracChangeset for help on using the changeset viewer.