org.apache.geronimo.kernel.repository.Artifact.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.geronimo.kernel.repository.Artifact.<init>()方法的一些代码示例,展示了Artifact.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Artifact.<init>()方法的具体详情如下:
包路径:org.apache.geronimo.kernel.repository.Artifact
类名称:Artifact
方法名:<init>

Artifact.<init>介绍

暂无

代码示例

代码示例来源:origin: org.apache.geronimo.framework/geronimo-deployment

/**
 * Creates a new artifact using entirely default values.
 *
 * @param defaultArtifact  The artifactId to use for the new Artifact
 * @param defaultType      The type to use for the new Artifact
 */
public Artifact createDefaultArtifact(String defaultArtifact, String defaultType) {
  return new Artifact(defaultGroup, defaultArtifact, defaultVersion, defaultType);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-plugin-farm

public Artifact toArtifact() {
    return new Artifact(groupId, artifactId, version, type);
  }
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-bundle-recorder

private Artifact getArtifactFromMvnLocation(String mvnLocation) {
  if (!mvnLocation.startsWith("mvn:")) return null;
  
  String artifactString = mvnLocation.substring(4);
  String[] parts = artifactString.split("/");
  
  if (parts==null || parts.length < 3) return null;
  
  String groupId = parts[0];
  String artifactId = parts[1];
  String version = parts[2];
  String type = "jar";
  
  return new Artifact(groupId, artifactId, version, type);        
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static Artifact create(String id) {
  String[] parts = id.split("/", -1);
  if (parts.length != 4) {
    throw new IllegalArgumentException("Invalid id: " + id);
  }
  for (int i = 0; i < parts.length; i++) {
    if (parts[i].equals("")) {
      parts[i] = null;
    }
  }
  return new Artifact(parts[0], parts[1], parts[2], parts[3]);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-upgrade

private static Artifact toArtifact(String attrValue) {
  try {
    return Artifact.create(attrValue);
  } catch (Exception e) {
    return new Artifact(DEFAULT_GROUPID, attrValue.replace('/', '_'), DEFAULT_VERSION, "car");
  }
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-plugin

public Artifact calculateArtifact(File file, String fileName, String groupId) throws IOException  {
  if (groupId == null || groupId.isEmpty()) groupId = Artifact.DEFAULT_GROUP_ID;
  if (fileName == null || fileName.isEmpty()) fileName = file.getName();
  
  String artifactId = null;
  String version = null;
  String fileType = null;
  
  
  String[] bundleKey = identifyOSGiBundle(file);
  if (bundleKey != null){ //try calculate if it is an OSGi bundle
    artifactId = bundleKey[0]; //Bundle-SymbolicName
    version = bundleKey[1]; //Bundle-Version
    fileType = "jar";
    return new Artifact(groupId, artifactId, version, fileType);
    
  } else { // not an OSGi bundle, try calculate artifact string from the file name
    Matcher matcher = MAVEN_1_PATTERN_PART.matcher(fileName);
    if (matcher.matches()) {
      artifactId = matcher.group(1);
      version = matcher.group(2);
      fileType = matcher.group(3);
      return new Artifact(groupId,artifactId,version,fileType);
      
    }else{
      return null;
    }
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public SortedSet list() {
  SortedSet artifacts = new TreeSet();
  String[] names = getFiles(rootFile, "");
  Matcher matcher = MAVEN_1_PATTERN.matcher("");
  for (int i = 0; i < names.length; i++) {
    matcher.reset(names[i]);
    if (matcher.matches()) {
      String groupId = matcher.group(1);
      String artifactId = matcher.group(3);
      String version = matcher.group(4);
      String type = matcher.group(2);
      if(groupId.indexOf('/') > -1 || artifactId.indexOf('/') > -1 || type.indexOf('/') > -1 ||
        version.indexOf('/') > -1) {
        log.warn("could not resolve URI for malformed repository entry: " + names[i] +
        " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type>   "+
        "Perhaps you put in a file without a version number in the name?");
      } else {
        artifacts.add(new Artifact(groupId, artifactId, version, type));
      }
    } else {
      log.warn("could not resolve URI for malformed repository entry: " + names[i] +
      " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type>   "+
      "Perhaps you put in a file without a version number in the name?");
    }
  }
    return artifacts;
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-naming-builder

public static AbstractNameQuery buildAbstractNameQueryFromPattern(GerPatternType pattern, String artifactType, String type, String moduleType, Set interfaceTypes)  {
  String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
  String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
  String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
  String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
  String name = pattern.getName().trim();
  Artifact artifact = artifactid != null ? new Artifact(groupId, artifactid, version, artifactType) : null;
  Map nameMap = new HashMap();
  nameMap.put("name", name);
  if (type != null) {
    nameMap.put("j2eeType", type);
  }
  if (module != null && moduleType != null) {
    nameMap.put(moduleType, module);
  }
  if (interfaceTypes != null) {
    Set trimmed = new HashSet();
    for (Iterator it = interfaceTypes.iterator(); it.hasNext();) {
      String intf = (String) it.next();
      trimmed.add(intf == null ? null : intf.trim());
    }
    interfaceTypes = trimmed;
  }
  return new AbstractNameQuery(artifact, nameMap, interfaceTypes);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-deploy-farm

protected Artifact newArtifact(Artifact configId, String artifactId) {
  return new Artifact(configId.getGroupId(), artifactId, configId.getVersion(), configId.getType());
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-plugin

public static Artifact toArtifact(ArtifactType moduleId) {
  String groupId = moduleId.getGroupId();
  String artifactId = moduleId.getArtifactId();
  String version = moduleId.getVersion();
  String type = moduleId.getType();
  return new Artifact(groupId, artifactId, version, type);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb-builder

private static Artifact toArtifact(ArtifactType artifactType, String defaultType) {
  String groupId = artifactType.getGroupId();
  String type = artifactType.getType();
  if (type == null) type = defaultType;
  String artifactId = artifactType.getArtifactId();
  String version = artifactType.getVersion();
  return new Artifact(groupId, artifactId, version, type);
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-service-builder

public static AbstractNameQuery buildAbstractNameQuery(PatternType pattern, String nameTypeName, Set interfaceTypes) {
  String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
  String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
  String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
  String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
  String type = pattern.isSetType() ? pattern.getType().trim() : null;
  String name = pattern.isSetName() ? pattern.getName().trim() : null;
  Artifact artifact = artifactid != null? new Artifact(groupId, artifactid, version, "car"): null;
  //get the type from the gbean info if not supplied explicitly
  if (type == null) {
    type = nameTypeName;
  }
  Map nameMap = new HashMap();
  if (name != null) {
    nameMap.put("name", name);
  }
  if (type != null) {
    nameMap.put("j2eeType", type);
  }
  if (module != null) {
    nameMap.put("J2EEModule", module);
  }
  return new AbstractNameQuery(artifact, nameMap, interfaceTypes);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public Artifact generateArtifact(Artifact source, String defaultType) {
  if(source.isResolved()) {
    Artifact deAliased = (Artifact) explicitResolution.get(source);
    if (deAliased !=  null) {
      return deAliased;
    }
    return source;
  }
  String groupId = source.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID : source.getGroupId();
  String artifactId = source.getArtifactId();
  String type = source.getType() == null ? defaultType : source.getType();
  Version version = source.getVersion() == null ? new Version(Long.toString(System.currentTimeMillis())) : source.getVersion();
  return new Artifact(groupId, artifactId, version, type);
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-deployment

private Artifact resolve(Artifact configID) throws DeploymentException {
  String group = configID.getGroupId();
  if (group == null) {
    group = Artifact.DEFAULT_GROUP_ID;
  }
  String artifactId = configID.getArtifactId();
  if (artifactId == null) {
    throw new DeploymentException("Every configuration to deploy must have a ConfigID with an ArtifactID (not " + configID + ")");
  }
  Version version = configID.getVersion();
  if (version == null) {
    version = new Version(Long.toString(System.currentTimeMillis()));
  }
  String type = configID.getType();
  if (type == null) {
    type = "car";
  }
  return new Artifact(group, artifactId, version, type);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb-builder

private static AbstractNameQuery getResourceAdapterNameQuery(ResourceLocatorType resourceLocator) {
  if (resourceLocator.getResourceLink() != null) {
    Map<String, String> nameMap = new HashMap<String, String>();
    nameMap.put("name", resourceLocator.getResourceLink());
    nameMap.put("j2eeType", NameFactory.JCA_RESOURCE_ADAPTER);
    return new AbstractNameQuery(null, nameMap);
  }
  //construct name from components
  PatternType pattern = resourceLocator.getPattern();
  Artifact artifact = null;
  if (pattern.getArtifactId() != null) {
    artifact = new Artifact(pattern.getGroupId(), pattern.getArtifactId(), pattern.getVersion(), "car");
  }
  Map<String, String> nameMap = new HashMap<String, String>();
  nameMap.put("name", pattern.getName());
  nameMap.put("j2eeType", NameFactory.JCA_RESOURCE_ADAPTER);
  if (pattern.getModule() != null) {
    nameMap.put(NameFactory.RESOURCE_ADAPTER_MODULE, pattern.getModule());
  }
  return new AbstractNameQuery(artifact, nameMap, (Set) null);
}

代码示例来源:origin: org.apache.geronimo.plugins/plancreator-portlets

public EnvironmentConfigData(EnvironmentType environment) {
  this.environment = environment;
  DependenciesType dependencies = environment.getDependencies();
  if(dependencies != null) {
    DependencyType[] depArray = dependencies.getDependencyArray();
    for(int i = 0; i < depArray.length; i++) {
      DependencyType d = depArray[i];
      Artifact artifact = new Artifact(d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType());
      dependenciesSet.add(artifact.toString());
    }
  }
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-deployment

/**
 * Translates the argument Artifact to a fully-resolved Artifact, which is
 * returned.  If the argument was fully-resolved to begin with it is
 * returned as is.  Otherwise, a new Artifact is returned with any missing
 * values populated.
 *
 * @param argument     The artifact to review
 * @param defaultType  The type to use if the artifact to review has no
 *                     type specified
 *
 * @return A fully resolved Artifact
 *
 * @throws IllegalArgumentException Occurs when the argument artifact does
 *                                  not have an artifactId
 */
public Artifact resolve(Artifact argument, String defaultType) {
  if(argument.isResolved()) {
    return argument;
  }
  if(argument.getArtifactId() == null || argument.getArtifactId().equals("")) {
    throw new IllegalArgumentException("Incoming Artifact must have an ArtifactID (not "+argument+")");
  }
  return new Artifact(argument.getGroupId() == null || argument.getGroupId().equals("") ? defaultGroup : argument.getGroupId(),
      argument.getArtifactId(),
      argument.getVersion() == null ? defaultVersion : argument.getVersion(),
      argument.getType() == null || argument.getType().equals("") ? defaultType : argument.getType());
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-upgrade

private static void extractDependency(XmlCursor cursor, Environment environment) {
  cursor.push();
  cursor.toFirstChild();
  Artifact artifact;
  if (cursor.getName().getLocalPart().equals("uri")) {
    String uri = cursor.getTextValue();
    artifact = toArtifact(uri);
  } else {
    checkName(cursor, "groupId");
    String groupId = cursor.getTextValue();
    cursor.toNextSibling();
    String type = "jar";
    if (cursor.getName().getLocalPart().equals("type")) {
      type = cursor.getTextValue();
      cursor.toNextSibling();
    }
    checkName(cursor, "artifactId");
    String artifactId = cursor.getTextValue();
    cursor.toNextSibling();
    checkName(cursor, "version");
    String version = cursor.getTextValue();
    artifact = new Artifact(groupId, artifactId, version, type);
  }
  environment.addDependency(artifact, ImportType.ALL);
  cursor.pop();
  cursor.removeXml();
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-deployment

/**
   * Guarantees that the argument Environment will have a present and fully
   * qualified module ID when this method returns. If the Environment is
   * missing a module ID, or has a partial module ID (isResolved() == false)
   * then this method will fill in any missing values.  If the module ID is
   * present and resolved, then this method does nothing.
   *
   * @param environment        The Environment to check and populate
   * @param defaultArtifactId  The artifactId to use if the Envrionment does
   *                           not have a module ID at all
   * @param defaultType        The type to use if the Environment is lacking
   *                           a module ID or the module ID is lacking a type
   */
  public void resolve(Environment environment, String defaultArtifactId, String defaultType) {
    if(environment.getConfigId() == null) {
      environment.setConfigId(resolve(new Artifact(null, defaultArtifactId, (Version)null, defaultType), defaultType));
    } else if(!environment.getConfigId().isResolved()) {
      environment.setConfigId(resolve(environment.getConfigId(), defaultType));
    }
  }
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-service-builder

private static Artifact toArtifact(ArtifactType artifactType, String defaultType) {
  String groupId = artifactType.isSetGroupId() ? trim(artifactType.getGroupId()) : null;
  String type = artifactType.isSetType() ? trim(artifactType.getType()) : defaultType;
  String artifactId = trim(artifactType.getArtifactId());
  String version = artifactType.isSetVersion() ? trim(artifactType.getVersion()) : null;
  return new Artifact(groupId, artifactId, version, type);
}

相关文章