Browse Source

https

master
hzzz 6 years ago
parent
commit
f419e51eca
  1. 29
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  2. 7
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

29
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -4,21 +4,11 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.third.guava.base.Optional;
import com.fr.third.guava.primitives.Ints;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.util.EntityUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.connector.FineWorkspaceConnector;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import io.socket.client.IO;
import io.socket.client.Socket;
@ -71,7 +61,7 @@ public class DesignerSocketIO {
private static String getSocketUri(Workspace current) throws IOException {
URL url = new URL(current.getPath());
int port = getPort(current);
int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort();
return String.format("http://%s:%s%s?%s=%s",
url.getHost(),
port,
@ -79,21 +69,4 @@ public class DesignerSocketIO {
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
RemoteCallClient.getInstance().getToken());
}
private static int getPort(Workspace current) throws IOException {
String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT;
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(url);
response = FineWorkspaceConnector.getInstance().currentHttpClient().execute(httpGet);
HttpEntity entity = response.getEntity();
JSONObject jsonObject = new JSONObject(EntityUtils.toString(entity));
return Ints.tryParse(jsonObject.optString("data"));
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw new RuntimeException(e);
} finally {
ResourceIOUtils.close(response);
}
}
}

7
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -51,6 +51,8 @@ import com.fr.design.mainframe.loghandler.DesignerLogAppender;
import com.fr.design.mainframe.loghandler.DesignerLogImpl;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.socketio.DesignerSocketIO;
import com.fr.design.mainframe.socketio.FineSocketInfoOperator;
import com.fr.design.mainframe.socketio.SocketInfoOperator;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.FormParameterReader;
import com.fr.design.parameter.ParameterPropertyPane;
@ -98,6 +100,8 @@ import com.fr.stable.script.ValueConverter;
import com.fr.stable.xml.ObjectTokenizer;
import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider;
import com.fr.workspace.base.WorkspaceKey;
import com.fr.workspace.pool.WorkPRCRegister;
import com.fr.xml.ReportXMLUtils;
import java.awt.Image;
@ -409,5 +413,8 @@ public class DesignerActivator extends Activator implements Prepare {
public void prepare() {
addMutable(InterMutableKey.Path, "com/fr/design/i18n/main", "com/fr/design/i18n/chart");
addMutable(WorkspaceKey.RPC, WorkPRCRegister.wrap(SocketInfoOperator.class, new FineSocketInfoOperator()));
}
}
Loading…
Cancel
Save