コード例 #1
0
  public static Object getRuntimeAdapter(
      org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime,
      Class<?> adapterClass) {

    String runtimeId = facetRuntime.getProperty("id");

    for (org.eclipse.wst.server.core.IRuntime runtime : ServerCore.getRuntimes()) {
      if (runtime.getId().equals(runtimeId)) {

        if (IRuntime.class.equals(adapterClass)) {
          return runtime;
        }

        IRuntimeWorkingCopy runtimeWC = null;

        if (!runtime.isWorkingCopy()) {
          runtimeWC = runtime.createWorkingCopy();
        } else {
          runtimeWC = (IRuntimeWorkingCopy) runtime;
        }

        return (ILiferayRuntime) runtimeWC.loadAdapter(adapterClass, null);
      }
    }

    return null;
  }
コード例 #2
0
  public static ILiferayRuntime getLiferayRuntime(IRuntime runtime) {
    if (runtime != null) {
      return (ILiferayRuntime) runtime.createWorkingCopy().loadAdapter(ILiferayRuntime.class, null);
    }

    return null;
  }
コード例 #3
0
  public static IRuntimeWorkingCopy getRuntime(String runtimeTypeId, IPath location) {
    IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeId);

    try {
      IRuntime runtime = runtimeType.createRuntime("runtime", null);

      IRuntimeWorkingCopy runtimeWC = runtime.createWorkingCopy();
      runtimeWC.setName("Runtime");
      runtimeWC.setLocation(location);

      return runtimeWC;
    } catch (CoreException e) {
      e.printStackTrace();
    }

    return null;
  }