コード例 #1
0
  /*
   * (non-Javadoc)
   *
   * @see org.dresdenocl.modelbus.IModelProvider#getModel(java.net.URL)
   */
  public IModel getModel(URL modelURL) throws ModelAccessException {

    /* Eventually log the entry into this method. */
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("getModel(modelURL=" + modelURL + ") - enter"); // $NON-NLS-1$ //$NON-NLS-2$
    }
    // no else.

    URI modelURI;
    Resource resource;
    IModel model;

    /* Try to create an URI. */
    try {
      modelURI = URI.createURI(modelURL.toString());
    } catch (IllegalArgumentException e) {
      throw new ModelAccessException("Invalid URL: " + modelURL, e); // $NON-NLS-1$
    }

    /* Get the resource. */
    resource = getResourceSet().getResource(modelURI, true);

    /* Check if the resource has already been created. */
    if (resource == null) {
      /* We only want to create the resource, not load it. */
      resource = getResourceSet().createResource(modelURI);
    }
    // no else.

    /* Create the model from the resource. */
    model =
        new EcoreModel(
            getResourceSet().getResource(modelURI, false),
            ModelBusPlugin.getMetamodelRegistry().getMetamodel(EcoreMetamodelPlugin.ID));

    /* Eventually log the exit from this method. */
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("getModel() - exit - return value=" + model); // $NON-NLS-1$
    }
    // no else.

    return model;
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.dresdenocl.model.base.AbstractModelProvider#getModel(org.eclipse
   * .emf.ecore.resource.Resource)
   */
  public IModel getModel(Resource resource) {
    /* Eventually log the entry into this method. */
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("getModel(reosurce=" + resource + ") - enter"); // $NON-NLS-1$ //$NON-NLS-2$
    }
    // no else.

    IModel model =
        new EcoreModel(
            resource, ModelBusPlugin.getMetamodelRegistry().getMetamodel(EcoreMetamodelPlugin.ID));

    /* Eventually log the exit from this method. */
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("getModel() - exit - return value=" + model); // $NON-NLS-1$
    }
    // no else.

    return model;
  }