public static ServiceController<String> addService(final ServiceName name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget) { return addService(name, relativePath, false, relativeTo, serviceTarget, null); }
public RelativePathService(final String relativePath) { this.relativePath = convertPath(relativePath); }
public static ServiceController<String> addService(final String name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget, final List<ServiceController<?>> newControllers, final ServiceListener... listeners) { return addService(pathNameOf(name), relativePath, false, relativeTo, serviceTarget, newControllers, listeners); }
/** * Installs a path service. * * @param name the name to use for the service * @param path the relative portion of the path * @param possiblyAbsolute {@code true} if {@code path} may be an {@link #isAbsoluteUnixOrWindowsPath(String) absolute path} * and should be {@link AbsolutePathService installed as such} if it is, with any * {@code relativeTo} parameter ignored * @param relativeTo the name of the path that {@code path} may be relative to * @param serviceTarget the {@link ServiceTarget} to use to install the service * @return the ServiceController for the path service */ public static ServiceController<String> addService(final ServiceName name, final String path, boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget); } RelativePathService service = new RelativePathService(path); ServiceBuilder<String> builder = serviceTarget.addService(name, service) .addDependency(pathNameOf(relativeTo), String.class, service.injectedPath); ServiceController<String> svc = builder.install(); return svc; }
@Override public String resolvePath(String name, String path, String relativeTo, PathResolver resolver) { PathEntry relativeEntry; synchronized (pathEntries) { relativeEntry = pathEntries.get(relativeTo); if (relativeEntry == null) { throw new IllegalStateException("Could not find relativeTo path '" + relativeTo + "' for relative path '" + name); } } return RelativePathService.doResolve(relativeEntry.resolvePath(), path); }
static String convertPath(String relativePath) { Assert.checkNotNullParam("relativePath", relativePath); Assert.checkNotEmptyParam("relativePath", relativePath); if (relativePath.charAt(0) == '/') { if (relativePath.length() == 1) { throw ControllerLogger.ROOT_LOGGER.invalidRelativePathValue(relativePath); } return relativePath.substring(1); } else if (relativePath.indexOf(":\\") == 1) { throw ControllerLogger.ROOT_LOGGER.pathIsAWindowsAbsolutePath(relativePath); } else { if(isWindows()) { return relativePath.replace("/", File.separator); } else { return relativePath.replace("\\", File.separator); } } }
/** * Installs a path service. * * @param name the name to use for the service * @param path the relative portion of the path * @param possiblyAbsolute {@code true} if {@code path} may be an {@link #isAbsoluteUnixOrWindowsPath(String) absolute path} * and should be {@link AbsolutePathService installed as such} if it is, with any * {@code relativeTo} parameter ignored * @param relativeTo the name of the path that {@code path} may be relative to * @param serviceTarget the {@link ServiceTarget} to use to install the service * @return the ServiceController for the path service */ public static ServiceController<String> addService(final ServiceName name, final String path, boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget); } RelativePathService service = new RelativePathService(path); ServiceBuilder<String> builder = serviceTarget.addService(name, service) .addDependency(pathNameOf(relativeTo), String.class, service.injectedPath); ServiceController<String> svc = builder.install(); return svc; }
@Override public String resolvePath(String name, String path, String relativeTo, PathResolver resolver) { PathEntry relativeEntry; synchronized (pathEntries) { relativeEntry = pathEntries.get(relativeTo); if (relativeEntry == null) { throw new IllegalStateException("Could not find relativeTo path '" + relativeTo + "' for relative path '" + name); } } return RelativePathService.doResolve(relativeEntry.resolvePath(), path); }
static String convertPath(String relativePath) { Assert.checkNotNullParam("relativePath", relativePath); Assert.checkNotEmptyParam("relativePath", relativePath); if (relativePath.charAt(0) == '/') { if (relativePath.length() == 1) { throw ControllerLogger.ROOT_LOGGER.invalidRelativePathValue(relativePath); } return relativePath.substring(1); } else if (relativePath.indexOf(":\\") == 1) { throw ControllerLogger.ROOT_LOGGER.pathIsAWindowsAbsolutePath(relativePath); } else { if(isWindows()) { return relativePath.replace("/", File.separator); } else { return relativePath.replace("\\", File.separator); } } }
public static ServiceController<String> addService(final ServiceName name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget) { return addService(name, relativePath, false, relativeTo, serviceTarget); }
public static ServiceController<String> addService(final String name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget) { return addService(pathNameOf(name), relativePath, false, relativeTo, serviceTarget, null); }
final ServiceListener... listeners) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget, newControllers, listeners); RelativePathService service = new RelativePathService(path); ServiceBuilder<String> builder = serviceTarget.addService(name, service) .addDependency(pathNameOf(relativeTo), String.class, service.injectedPath); if (listeners != null) { for (ServiceListener listener : listeners) {
@Override protected String resolvePath() { return doResolve(injectedPath.getValue(), relativePath); }
public RelativePathService(final String relativePath) { this.relativePath = convertPath(relativePath); }
static String convertPath(String relativePath) { if (relativePath == null) { throw MESSAGES.nullVar("relativePath"); } if (relativePath.length() == 0) { throw MESSAGES.emptyVar("relativePath"); } if (relativePath.charAt(0) == '/') { if (relativePath.length() == 1) { throw MESSAGES.invalidRelativePathValue(relativePath); } return relativePath.substring(1); } else if (relativePath.indexOf(":\\") == 1) { throw MESSAGES.pathIsAWindowsAbsolutePath(relativePath); } else { if(isWindows()) { return relativePath.replace("/", File.separator); } else { return relativePath.replace("\\", File.separator); } } }
public static ServiceController<String> addService(final ServiceName name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget) { return addService(name, relativePath, false, relativeTo, serviceTarget, null); }
public static ServiceController<String> addService(final String name, final String relativePath, final String relativeTo, final ServiceTarget serviceTarget) { return addService(pathNameOf(name), relativePath, false, relativeTo, serviceTarget); }
final ServiceListener... listeners) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget, newControllers, listeners); RelativePathService service = new RelativePathService(path); ServiceBuilder<String> builder = serviceTarget.addService(name, service) .addDependency(pathNameOf(relativeTo), String.class, service.injectedPath); if (listeners != null) { for (ServiceListener listener : listeners) {
@Override public String resolvePath(String name, String path, String relativeTo, PathResolver resolver) { PathEntry relativeEntry; synchronized (pathEntries) { relativeEntry = pathEntries.get(relativeTo); if (relativeEntry == null) { throw new IllegalStateException("Could not find relativeTo path '" + relativeTo + "' for relative path '" + name); } } return RelativePathService.doResolve(relativeEntry.resolvePath(), path); }
public RelativePathService(final String relativePath) { this.relativePath = convertPath(relativePath); }