Analysis
Overview
The WS connector should represent the client facade implementation. It is actually the logic, which connects the client to the web services.
Task requirements
The connector must be able to:
- Send requests to a concrete server. For now, the possible requests are:
- login()
- getUserGroups()
- userExists()
- Receive responses from the web services.
- Convert the XML response to a concrete object.
- Return the object as a result.
Implement this initial model of the connector, do not forget to write unit tests.
Task result
Source code.
Implementation idea
There is already a module named org.sophie2.server.connector, so there is no need of creating a new module for this. Also, the package facade.mock in there could be useful.
A class diagram representing the purpose of the connector:
Related
S2S_WEB_SERVICES_R0
S2S_CORE_MOCK_SERVER_R0
How to demo
Show the class(es), run the test.
Design
- A new module is needed, named org.sophie2.base.connectivity. This will be the place, where various connectors will be able to be attached. This means it will contain interface Connector, provided as extension point. Also the interfaces Facade, UserManager and GroupManager will be placed there. With the Resource refactoring of the facade, other interfaces will have to be added. Both client and server facades will implement these.
- Connector will initialy have method getSupportedProtocol (will return string - the supported protocol) and a method connect(). The first one will be used from the client to search for a registered module, supporting particular protocol, and the second one should be able to instantiate a client facade for this connection.
- The module will also have class ServerConnection, which holds URL of a particular server (final property), status of the connection (ValueProperty, holding ConnectionStatus object), method connect(username, password) and method getFacade() for accessing the current facade (if present).
- For the resource changes, something for authentication of the current connection will be used. So, create also a class Session, which holds sessionID and a reference to the ServerConnection. Other needed things for the sessions will be added there and described in the appropriate tasks.
- Another module - org.sophie2.main.connectivity.ws_connector will provide a concrete implementation of Connector as extension. It must also hold an implementation of the Facade (every protocol could communicate in its own way with the server facade, so every connector must have own facade implementation). The concrete implementation should have mostly XML parsing functions, for now a very basic one should be enough, since there is not a stable WS provider. In the next revision of this task, the web services will be refactored and the parsing will be developed.
- For visualization purposes, make a third module - org.sophie2.main.func.servers, for example. Put there a ServersTab and ServersPalette, listing sophie2 servers and their statuses. Provide a way to connect to them (for example, put a button "connect"). If the connection status can be changed, then the connector has succeeded to invoke the login() method of the server facade. This one should be prototypical, there is a task for it.
- NOTES:
- If this task is implemented carefully, the related DC_CONNECTOR and APP_CONNECTIVITY tasks should be almost trivial.
- Unit tests should be put in the corresponding modules, which are not present now, so they will be provided with the implementation.
Implementation
New modules have been created as follows:
- org.sophie2.base.connectivity - provides Connector as extension point, no extensions.
- enum ConnectionStatus, interface Connector, classes ServerConnection and Session have been created
- Interfaces facade, UserManager and GroupManager have been moved from org.sophie2.server
- org.sophie2.main.servers - provides extensions for the ServersTab and ConnectionsPalette, no extension points.
- classes ServersTab and ConnectionsPalette have been created.
- org.sophie2.main.ws_connector - provides extension for the WSConnector, no extension points.
- implementations of the Connector, Facade and UserManager (WSConnector, WSFacade, WSUserManager) have been created. The GroupManager is not implemented, since it is meaningless without having a server-side implementation in the Web Services.
Package org.sophie2.server.facade.impl has been removed and its content is moved to org.sophie2.server.facade.
Project POMs were fixed, the new modules were added to author.bundles.config and FakeAuthorMain.
Changesets: 2019, 2021, 2023, 2024
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)