Skip to content
Snippets Groups Projects
Commit 6316830d authored by Patient NTUMBA's avatar Patient NTUMBA
Browse files

Update vsb chorevolution architecture

parent d72476cf
No related branches found
No related tags found
No related merge requests found
Showing
with 205 additions and 366 deletions
......@@ -5,17 +5,28 @@ import java.io.File;
import eu.chorevolution.vsb.bc.manager.VsbOutput;
import eu.chorevolution.vsb.compiler.RunTimeCompiler;
import eu.chorevolution.vsb.gmdl.utils.Constants;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
import eu.chorevolution.vsb.gmdl.utils.enums.ProtocolType;
public class Generator {
public Generator(){}
public void compileGeratedClasses(Class[] classesOptions){
public void compileGeneratedClasses(Class[] classesOptions){
String sourceFilesPath = Constants.generatedCodePath + File.separator+ Constants.target_namespace_path;
RunTimeCompiler compiler = new RunTimeCompiler(sourceFilesPath,Constants.generatedCodePath,classesOptions);
compiler.compile();
File sourceDir = new File(sourceFilesPath);
// for(File f: sourceDir.listFiles()){
//
// if(f.getName().endsWith("java")){
//
// f.delete();
// }
//
// }
PathResolver.setClassPath(Constants.generatedCodePath);
}
......
{
}
\ No newline at end of file
{
"host_address": "",
"host_address": ""
}
......@@ -20,7 +20,7 @@ import org.restlet.representation.StringRepresentation;
import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
import eu.chorevolution.vsb.bindingcomponent.generated.eclipse.BindingComponent;
import eu.chorevolution.vsb.bindingcomponent.generated.BindingComponent;
import eu.chorevolution.vsb.gm.protocols.Manageable;
public class BcManagerRestService implements Manageable {
......@@ -39,13 +39,17 @@ public class BcManagerRestService implements Manageable {
this.component.getDefaultHost().attach("/setconfiguration", SetConfiguration.class);
try {
this.component.start();
} catch (Exception e) {
} catch (Exception e){
e.printStackTrace();
}
}
public void runBC() {
public void runBC(){
System.out.println("BCMgrRestSvc calling run!");
bc.run();
System.out.println("BCMgrRestSvc finished run!");
......@@ -238,9 +242,13 @@ public class BcManagerRestService implements Manageable {
@Override
public void start() {
try {
try{
this.component.start();
} catch (Exception e) {
}
catch (Exception e){
e.printStackTrace();
}
}
......
......@@ -94,7 +94,28 @@ public class Base implements BaseService {
File dir2 = new File(dir.getAbsolutePath() + File.separator + "config");
String setinvaddrPath = dir2.getAbsolutePath()+File.separator+"config_block1_interface_1";
System.out.println(" setinvaddrPath "+setinvaddrPath);
System.out.println("Set invocation address into first file conf "+setinvaddrPath);
try {
jsonObject = (JSONObject) parser.parse(new FileReader(setinvaddrPath));
} catch (IOException | ParseException e) {
e.printStackTrace();
}
jsonObject.put("invocation_address", endpoints.get(0));
try (FileWriter file = new FileWriter(setinvaddrPath)) {
file.write(jsonObject.toJSONString());
} catch (IOException e){
e.printStackTrace();
}
setinvaddrPath = dir2.getAbsolutePath()+File.separator+"config_block2_interface_1";
System.out.println("Set invocation address into second file conf "+setinvaddrPath);
try {
jsonObject = (JSONObject) parser.parse(new FileReader(setinvaddrPath));
......
package eu.chorevolution.vsb.bindingcomponent.generated.eclipse;
package eu.chorevolution.vsb.bindingcomponent.generated;
import java.io.File;
import eu.chorevolution.vsb.bc.manager.BcManagerRestService;
import eu.chorevolution.vsb.gm.protocols.primitives.BcGmSubcomponent;
import eu.chorevolution.vsb.gm.protocols.rest.BcRestSubcomponent;
import eu.chorevolution.vsb.gm.protocols.soap.BcSoapSubcomponent;
import eu.chorevolution.vsb.gmdl.tools.serviceparser.ServiceDescriptionParser;
import eu.chorevolution.vsb.gmdl.utils.BcConfiguration;
import eu.chorevolution.vsb.gmdl.utils.GmServiceRepresentation;
import eu.chorevolution.vsb.gmdl.utils.Interface;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
import eu.chorevolution.vsb.gmdl.utils.enums.RoleType;
import eu.chorevolution.vsb.websocket.BcWebsocketSubcomponent;
public class BindingComponent{
public class BindingComponent {
BcGmSubcomponent[][] subcomponent;
GmServiceRepresentation gmServiceRepresentation = null;
......@@ -24,10 +24,8 @@ public class BindingComponent{
intOne = Integer.parseInt("1");
java.lang.Integer intNine;
intNine = Integer.parseInt("9");
PathResolver pathResolver = new PathResolver();
String interfaceDescFilePath;
interfaceDescFilePath = pathResolver.myFilePath(BindingComponent.class, ((new String("config")+ File.separator)+ new String("serviceDescription.gxdl")));
System.out.println(interfaceDescFilePath);
interfaceDescFilePath = ((((new File(BcManagerRestService.class.getClassLoader().getResource("example.json").toExternalForm().substring(intNine)).getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath()+ File.separator)+ new String("config"))+ File.separator)+ new String("serviceDescription.gxdl"));
gmServiceRepresentation = ServiceDescriptionParser.getRepresentationFromGIDL(interfaceDescFilePath);
int num_interfaces = gmServiceRepresentation.getInterfaces().size();
subcomponent = new BcGmSubcomponent[num_interfaces][2];
......@@ -45,20 +43,19 @@ public class BindingComponent{
BcConfiguration bcConfiguration2 = new BcConfiguration();
bcConfiguration1 .setSubcomponentRole(inter.getRole());
bcConfiguration2 .setSubcomponentRole(busRole);
String config_block1_interfacePath;
config_block1_interfacePath = pathResolver.myFilePath(BindingComponent.class, (((new String("config")+ File.separator)+ new String("config_block1_interface_"))+ String.valueOf((i + intOne))));
bcConfiguration1 .parseFromJSON(gmServiceRepresentation, new String(config_block1_interfacePath));
String config_block2_interfacePath;
config_block2_interfacePath = pathResolver.myFilePath(BindingComponent.class, (((new String("config")+ File.separator)+ new String("config_block2_interface_"))+ String.valueOf((i + intOne))));
bcConfiguration2 .parseFromJSON(gmServiceRepresentation, new String(config_block2_interfacePath));
subcomponent[i][0] = new BcWebsocketSubcomponent(bcConfiguration1, gmServiceRepresentation);
bcConfiguration1 .parseFromJSON(gmServiceRepresentation, (((((new File(BcManagerRestService.class.getClassLoader().getResource("example.json").toExternalForm().substring(intNine)).getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath()+ File.separator)+ new String("config"))+ File.separator)+ new String("config_block1_interface_"))+ String.valueOf((i + intOne))));
bcConfiguration2 .parseFromJSON(gmServiceRepresentation, (((((new File(BcManagerRestService.class.getClassLoader().getResource("example.json").toExternalForm().substring(intNine)).getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath()+ File.separator)+ new String("config"))+ File.separator)+ new String("config_block2_interface_"))+ String.valueOf((i + intOne))));
subcomponent[i][0] = new BcSoapSubcomponent(bcConfiguration1, gmServiceRepresentation);
subcomponent[i][1] = new BcRestSubcomponent(bcConfiguration2, gmServiceRepresentation);
BcGmSubcomponent block1Component = subcomponent[i][0];
BcGmSubcomponent block2Component = subcomponent[i][1];
block1Component.setNextComponent(block2Component);
block2Component.setNextComponent(block1Component);
System.out.println("Befor starting BcGmSubcomponentVar1 and BcGmSubcomponentVar2");
block1Component.start();
System.out.println("Starting BcGmSubcomponentVar1");
block2Component.start();
System.out.println("Starting BcGmSubcomponentVar2");
}
}
......
{
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
......@@ -2,5 +2,5 @@
"target_namespace": "",
"service_name": "",
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
{}
\ No newline at end of file
{
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
{
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
......@@ -2,5 +2,5 @@
"target_namespace": "",
"service_name": "",
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
{
"subcomponent_address": "",
"subcomponent_port": "",
"subcomponent_port": ""
}
......@@ -2,5 +2,5 @@
"target_namespace": "",
"service_name": "",
"subcomponent_address": "",
"service_address": "",
"service_address": ""
}
......@@ -11,14 +11,14 @@ public class BaseServiceClient {
public static void main(String[] args) {
String bd_wsdl = "http://localhost:8861/BaseService/setinvaddr?wsdl";
String bc = "http://localhost:8861/BaseService/setinvaddr";
String bd_wsdl = "http://localhost:8825/BaseService/setinvaddr?wsdl";
String bc = "http://localhost:8825/BaseService/setinvaddr";
List<String> urls = new ArrayList<String>();
BaseService service;
try{
service = (BaseService) (Base.getPort("BaseService", bd_wsdl, bc, BaseService.class));
urls.add("coap://127.0.0.1:9082");
urls.add("http://127.0.0.1:9082");
service.setInvocationAddress("dest_role_test", "dest_name_test", urls);
}catch (IOException e){
......
......@@ -93,12 +93,11 @@ public class PathResolver {
try{
java.io.InputStream input = className.getClassLoader().getResourceAsStream(fileName);
System.out.println(" fileNameExtension "+fileNameExtension);
if(fileNameExtension.contains("/")){
fileNameExtension = "conf";
}
System.out.println(" fileNameExtension "+fileNameExtension);
// if(fileNameExtension.contains("/")){
//
// fileNameExtension = "conf";
// }
// System.out.println(" fileNameExtension "+fileNameExtension);
file = File.createTempFile("tempfile", "." + fileNameExtension);
......
......@@ -37,6 +37,7 @@ import eu.chorevolution.vsb.gmdl.utils.Data;
import eu.chorevolution.vsb.gmdl.utils.GmServiceRepresentation;
import eu.chorevolution.vsb.gmdl.utils.Operation;
import eu.chorevolution.vsb.gmdl.utils.enums.OperationType;
import eu.chorevolution.vsb.java2wsdl.Java2WSDL;
// TODO: refactor, clean & clear as much as possible...
public class BcSoapGenerator extends BcSubcomponentGenerator {
......@@ -104,7 +105,7 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
// generate getters
definitionClass.method(JMod.PUBLIC, attrField.type(), "get" + attr.getName()).body()._return(attrField);
// generate setters
JMethod setterMethod = definitionClass.method(JMod.PUBLIC, codeModel.VOID, "set" + attr.getName());
setterMethod.param(attrField.type(), attr.getName());
......
......@@ -27,9 +27,11 @@ public class BcSoapSubcomponent extends BcGmSubcomponent {
private GmServiceRepresentation serviceRepresentation;
public BcSoapSubcomponent(BcConfiguration bcConfiguration,
GmServiceRepresentation serviceRepresentation) {
GmServiceRepresentation serviceRepresentation){
super(bcConfiguration);
this.serviceRepresentation = serviceRepresentation;
}
@Override
......@@ -67,14 +69,15 @@ public class BcSoapSubcomponent extends BcGmSubcomponent {
soapConnectionFactory = SOAPConnectionFactory.newInstance();
} catch (UnsupportedOperationException | SOAPException e) {
}catch (UnsupportedOperationException | SOAPException e){
e.printStackTrace();
}
try{
soapConnection = soapConnectionFactory.createConnection();
} catch (SOAPException e){
}catch(SOAPException e){
e.printStackTrace();
}
......
......@@ -9,12 +9,12 @@ public class VsbManagerTest{
public static void main(String[] args){
// String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/urban-traffic-coordination/bindingcomponents/bcDTS-ACCIDENTS/model/dts-accidents.gidl";
String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/urban-traffic-coordination/bindingcomponents/bcDTS-ACCIDENTS/model/dts-accidents.gidl";
// String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/urban-traffic-coordination/bindingcomponents/bcDTS-WEATHER/model/dts-weather.gidl";
// String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/urban-traffic-coordination/bindingcomponents/bcDTS-BRIDGE/model/dts-bridge.gidl";
// String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/urban-traffic-coordination/bindingcomponents/bcDTS-CONGESTION/model/dts-congestion.gidl";
String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/evolution-service-bus/bc-manager/src/main/resources/bridge.gidl";
// String interfaceDescriptionPath = "/home/pntumba/inria_code/repositories/evolution-service-bus/bc-manager/src/main/resources/bridge.gidl";
VsbManager vsbm = new VsbManager();
vsbm.generateWar(interfaceDescriptionPath, ProtocolType.MQTT, "bridge");
vsbm.generateWar(interfaceDescriptionPath, ProtocolType.SOAP, "accidents");
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment