@Override public void stop(StopContext context) { callbackHandle.remove(); }
@Override public void registerOperations(final ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); if (pathManager != null) { final ResolvePathHandler resolvePathHandler = ResolvePathHandler.Builder.of(pathManager) .setPathAttribute(PATH) .setRelativeToAttribute(RELATIVE_TO) .build(); resourceRegistration.registerOperationHandler(resolvePathHandler.getOperationDefinition(), resolvePathHandler); } } }
@Override public void start(StartContext startContext) { String relativeToPath = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeTo; String dirPath = pathManager.get().resolveRelativePathEntry(path, relativeToPath); File dir = new File(dirPath); MicroProfileConfigLogger.ROOT_LOGGER.loadConfigSourceFromDir(dir.getAbsolutePath()); configSource = new DirConfigSource(dir, ordinal); }
@Override public synchronized void start(StartContext startContext) throws StartException { super.start(startContext); if (pathRelativeTo != null) { callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); } baseDir = new File(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo)); if (!baseDir.exists()) { if (!baseDir.mkdirs()) { throw UndertowLogger.ROOT_LOGGER.failedToCreatePersistentSessionDir(baseDir); } } if (!baseDir.isDirectory()) { throw UndertowLogger.ROOT_LOGGER.invalidPersistentSessionDir(baseDir); } }
@Override public void accept(SingleFileStoreConfigurationBuilder builder) { builder.location(this.pathManager.get().resolveRelativePathEntry(this.relativePath, this.relativeTo)); } }
final ServiceController<?> addRelativePathService(final ServiceTarget serviceTarget, final String pathName, final String path, final boolean possiblyAbsolute, final String relativeTo, final ServiceVerificationHandler verificationHandler) { if (possiblyAbsolute && AbstractPathService.isAbsoluteUnixOrWindowsPath(path)) { return addAbsolutePathService(serviceTarget, pathName, path, verificationHandler); } else { if (verificationHandler == null) { return RelativePathService.addService(AbstractPathService.pathNameOf(pathName), path, possiblyAbsolute, relativeTo, serviceTarget, null, NO_LISTENERS); } else { return RelativePathService.addService(AbstractPathService.pathNameOf(pathName), path, possiblyAbsolute, relativeTo, serviceTarget, null, verificationHandler); } } }
File tempDir = new File(pathManager.getPathEntry(TEMP_DIR).resolvePath(), deploymentName); tempDir.mkdirs(); warMetaData.setTempDir(tempDir);
final void changePath(String pathName, String path) { PathEntry pathEntry = findPathEntry(pathName); pathEntry.setPath(path); triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
@Override public void handleRollback(OperationContext context, ModelNode operation) { if (pathEventContext.isInstallServices()) { // Re-add entry to the path manager pathManager.addPathEntry(name, path, relativeTo, false); } } });
private void doStart() { final RiverMarshallerFactory factory = new RiverMarshallerFactory(); final MarshallingConfiguration configuration = new MarshallingConfiguration(); configuration.setClassResolver(ModularClassResolver.getInstance(moduleLoader.getValue())); configuration.setVersion(3); this.configuration = configuration; this.factory = factory; if (pathRelativeTo != null) { callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); } baseDir = new File(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo)); if (!baseDir.exists()) { if (createIfNotExists) { if (!baseDir.mkdirs()) { throw EJB3_TIMER_LOGGER.failToCreateTimerFileStoreDir(baseDir); } } else { throw EJB3_TIMER_LOGGER.timerFileStoreDirNotExist(baseDir); } } if (!baseDir.isDirectory()) { throw EJB3_TIMER_LOGGER.invalidTimerFileStoreDir(baseDir); } }
@Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); PathManager pathManager = registration.getPathManager().orElse(null); if (pathManager != null) { ResolvePathHandler pathHandler = ResolvePathHandler.Builder.of(pathManager) .setPathAttribute(Attribute.RELATIVE_PATH.getDefinition()) .setRelativeToAttribute(Attribute.RELATIVE_TO.getDefinition()) .build(); registration.registerOperationHandler(pathHandler.getOperationDefinition(), pathHandler); } return registration; } }
String resolve(PathManager pathManager, String path, String relativeToPath) { // discard the relativeToPath if the path is absolute and must not be resolved according // to the default relativeToPath value String relativeTo = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeToPath; return pathManager.resolveRelativePathEntry(path, relativeTo); }
@Override public void stop(final StopContext context) { locks.clear(); directories.clear(); if (callbackHandle != null) { callbackHandle.remove(); } factory = null; configuration = null; }
final ServiceController<?> addRelativePathService(final ServiceTarget serviceTarget, final String pathName, final String path, final boolean possiblyAbsolute, final String relativeTo, final ServiceVerificationHandler verificationHandler) { if (possiblyAbsolute && AbstractPathService.isAbsoluteUnixOrWindowsPath(path)) { return addAbsolutePathService(serviceTarget, pathName, path, verificationHandler); } else { if (verificationHandler == null) { return RelativePathService.addService(AbstractPathService.pathNameOf(pathName), path, possiblyAbsolute, relativeTo, serviceTarget, null, NO_LISTENERS); } else { return RelativePathService.addService(AbstractPathService.pathNameOf(pathName), path, possiblyAbsolute, relativeTo, serviceTarget, null, verificationHandler); } } }
final void changePath(String pathName, String path) { PathEntry pathEntry = findPathEntry(pathName); pathEntry.setPath(path); triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
} else { if (pathRelativeTo != null) { callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); directory = Paths.get(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo)); if (!Files.exists(directory)) { try {
/** * {@inheritDoc} */ public void initialize(ExtensionContext context) { TransactionLogger.ROOT_LOGGER.debug("Initializing Transactions Extension"); final LogStoreResource resource = new LogStoreResource(); final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid(); final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION); final TransactionSubsystemRootResourceDefinition rootResourceDefinition = new TransactionSubsystemRootResourceDefinition(registerRuntimeOnly); final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(rootResourceDefinition); registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); // Create the path resolver handlers if (context.getProcessType().isServer()) { // It's less than ideal to create a separate operation here, but this extension contains two relative-to attributes final ResolvePathHandler objectStorePathHandler = ResolvePathHandler.Builder.of(RESOLVE_OBJECT_STORE_PATH, context.getPathManager()) .setPathAttribute(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH) .setRelativeToAttribute(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO) .build(); registration.registerOperationHandler(objectStorePathHandler.getOperationDefinition(), objectStorePathHandler); } ManagementResourceRegistration logStoreChild = registration.registerSubModel(new LogStoreDefinition(resource, registerRuntimeOnly)); if (registerRuntimeOnly) { ManagementResourceRegistration transactionChild = logStoreChild.registerSubModel(new LogStoreTransactionDefinition(resource)); transactionChild.registerSubModel(LogStoreTransactionParticipantDefinition.INSTANCE); } subsystem.registerXMLElementWriter(TransactionSubsystemXMLPersister.INSTANCE); }
@Override public synchronized void stop(StopContext stopContext) { super.stop(stopContext); if (callbackHandle != null) { callbackHandle.remove(); } }
@Override public void start(StartContext context) throws StartException { callbackHandle = pathManagerInjector.getValue().registerCallback(pathRef, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); String objectStoreDir = pathManagerInjector.getValue().resolveRelativePathEntry(path, pathRef);
@Override public void stop(StopContext context) { host.getValue().setAccessLogService(null); if (callbackHandle != null) { callbackHandle.remove(); callbackHandle = null; } if( logReceiver instanceof DefaultAccessLogReceiver ) { IoUtils.safeClose((DefaultAccessLogReceiver) logReceiver); } logReceiver = null; }