コード例 #1
0
ファイル: HelloWorldTemplateUI.java プロジェクト: heps/SORCER
 /**
  * Returns a service UI descriptor of this service. Usually this method is used as an entry in
  * provider configuration files when smart proxies are deployed with a standard off the shelf
  * {@link sorcer.core.provider.ServiceProvider}.
  *
  * @return service UI descriptor
  */
 public static UIDescriptor getUIDescriptor() {
   UIDescriptor uiDesc = null;
   try {
     URL uiUrl = new URL(Sorcer.getWebsterUrl() + "/" + "");
     uiDesc =
         UIDescriptorFactory.getUIDescriptor(
             MainUI.ROLE,
             new UIComponentFactory(new URL[] {uiUrl}, HelloWorldTemplateUI.class.getName()));
   } catch (Exception ex) {
     logger.severe("HelloWorldImplUI, Problem loading SUI: " + ex.getMessage());
   }
   return uiDesc;
 }
コード例 #2
0
ファイル: SortView.java プロジェクト: piotrsobecki/SORCER
 /**
  * Returns a service UI descriptorfor this service. Usally this method is used as an entry in
  * provider configuration files when smart proxies are deployed with a standard off the shelf
  * {@link sorcer.core.provider.ServiceProvider}.
  *
  * @return service UI descriptor
  */
 public static UIDescriptor getUIDescriptor() {
   UIDescriptor uiDesc = null;
   try {
     uiDesc =
         UIDescriptorFactory.getUIDescriptor(
             MainUI.ROLE,
             new UIComponentFactory(
                 new URL[] {new URL(Sorcer.getWebsterUrl() + "/ssu1-mvc-ui.jar")},
                 SortView.class.getName()));
   } catch (Exception ex) {
     logger.throwing(SortView.class.getName(), "getUIDescriptor", ex);
   }
   return uiDesc;
 }
コード例 #3
0
  static ServiceElement create(
      final ServiceDetails serviceDetails, final ServiceDeployment deployment) throws IOException {
    ServiceElement service = new ServiceElement();

    String websterUrl;
    if (serviceDetails.webster == null) {
      if (deployment.getWebsterUrl() == null) {
        websterUrl = Sorcer.getWebsterUrl();
        if (logger.isDebugEnabled())
          logger.debug("Set code base derived from Sorcer.getWebsterUrl: " + websterUrl);
      } else {
        websterUrl = deployment.getWebsterUrl();
        if (logger.isDebugEnabled())
          logger.debug("Set code base derived from Deployment: " + websterUrl);
      }
    } else {
      websterUrl = serviceDetails.webster;
    }
    /* Create client (export) ClassBundle */
    List<ClassBundle> exports = new ArrayList<ClassBundle>();
    for (String s : serviceDetails.interfaces) {
      ClassBundle export = new ClassBundle(s);
      if (serviceDetails.codebaseJars.length == 1
          && Artifact.isArtifact(serviceDetails.codebaseJars[0])) {
        export.setArtifact(serviceDetails.codebaseJars[0]);
      } else {
        export.setJARs(appendJars(commonDLJars, serviceDetails.codebaseJars));
        export.setCodebase(websterUrl);
      }
      exports.add(export);
    }

    /* Create service implementation ClassBundle */
    ClassBundle main =
        new ClassBundle(
            serviceDetails.providerClass == null
                ? deployment.getImpl()
                : serviceDetails.providerClass);
    if (serviceDetails.implJars.length == 1 && Artifact.isArtifact(serviceDetails.implJars[0])) {
      main.setArtifact(serviceDetails.implJars[0]);
    } else {
      main.setJARs(serviceDetails.implJars);
      main.setCodebase(websterUrl);
    }

    /* Set ClassBundles to ServiceElement */
    service.setComponentBundle(main);
    service.setExportBundles(exports.toArray(new ClassBundle[exports.size()]));

    String serviceName;
    if (serviceDetails.name == null) {
      /* Get the (simple) name from the fully qualified interface */
      if (deployment.getName() == null) {
        StringBuilder nameBuilder = new StringBuilder();
        for (String s : serviceDetails.interfaces) {
          String value;
          int ndx = s.lastIndexOf(".");
          if (ndx > 0) {
            value = s.substring(ndx + 1);
          } else {
            value = s;
          }
          if (nameBuilder.length() > 0) {
            nameBuilder.append(" | ");
          }
          nameBuilder.append(value);
        }
        serviceName = nameBuilder.toString();
      } else {
        serviceName = deployment.getName();
      }
    } else {
      serviceName = serviceDetails.name;
    }

    if (serviceDetails.maxPerNode > 0) {
      service.setMaxPerMachine(serviceDetails.maxPerNode);
    }
    if (serviceDetails.architecture != null || serviceDetails.operatingSystems.length > 0) {
      ServiceLevelAgreements slas = new ServiceLevelAgreements();
      SystemRequirements systemRequirements = new SystemRequirements();
      if (serviceDetails.architecture != null) {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        attributeMap.put(ProcessorArchitecture.ARCHITECTURE, serviceDetails.architecture);
        SystemComponent systemComponent =
            new SystemComponent("Processor", ProcessorArchitecture.class.getName(), attributeMap);
        systemRequirements.addSystemComponent(systemComponent);
      }
      for (String s : serviceDetails.operatingSystems) {
        String opSys = checkAndMaybeFixOpSys(s);
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        attributeMap.put(OperatingSystem.NAME, opSys);
        SystemComponent operatingSystem =
            new SystemComponent("OperatingSystem", OperatingSystem.class.getName(), attributeMap);
        systemRequirements.addSystemComponent(operatingSystem);
      }
      slas.setServiceRequirements(systemRequirements);
      service.setServiceLevelAgreements(slas);
    }
    if (serviceDetails.ips.length > 0) {
      SystemRequirements systemRequirements =
          service.getServiceLevelAgreements().getSystemRequirements();
      systemRequirements.addSystemComponent(getSystemComponentAddresses(false, serviceDetails.ips));
    }

    if (serviceDetails.excludeIps.length > 0) {
      SystemRequirements systemRequirements =
          service.getServiceLevelAgreements().getSystemRequirements();
      systemRequirements.addSystemComponent(
          getSystemComponentAddresses(true, serviceDetails.excludeIps));
    }

    /* Create simple ServiceBeanConfig */
    Map<String, Object> configMap = new HashMap<String, Object>();
    configMap.put(ServiceBeanConfig.NAME, serviceName);
    configMap.put(ServiceBeanConfig.GROUPS, Sorcer.getLookupGroups());
    ServiceBeanConfig sbc = new ServiceBeanConfig(configMap, new String[] {deployment.getConfig()});
    sbc.addAdditionalEntries(
        new DeployInfo(
            deployment.getType().name(), deployment.getUnique().name(), deployment.getIdle()));
    service.setServiceBeanConfig(sbc);
    service.setPlanned(deployment.getMultiplicity());

    /* If the service is to be forked, create an ExecDescriptor */
    if (serviceDetails.fork) {
      service.setFork(true);
      if (serviceDetails.jvmArgs != null) {
        ExecDescriptor execDescriptor = new ExecDescriptor();
        execDescriptor.setInputArgs(serviceDetails.jvmArgs);
        service.setExecDescriptor(execDescriptor);
      }
    }
    if (logger.isDebugEnabled()) logger.debug("Generated Service Element :" + service);
    return service;
  }