Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.as.host.controller;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
 import static org.jboss.as.host.controller.HostControllerMessages.MESSAGES;
 
 import java.io.File;
 import java.util.List;
 import java.util.Set;
 
Configuration persister that can delegate to a domain or host persister depending what needs to be persisted.

Author(s):
Brian Stansberry (c) 2011 Red Hat Inc.
 
 
     private final HostControllerEnvironment environment;
     private final LocalHostControllerInfo hostControllerInfo;
     private final ExecutorService executorService;
     private final ExtensionRegistry extensionRegistry;
     private Boolean slave;
 
     public HostControllerConfigurationPersister(final HostControllerEnvironment environmentfinal LocalHostControllerInfo localHostControllerInfo,
                                                 final ExecutorService executorServicefinal ExtensionRegistry extensionRegistry) {
         this. = environment;
         this. = localHostControllerInfo;
         this. = executorService;
         this. = extensionRegistry;
         final ConfigurationFile configurationFile = environment.getHostConfigurationFile();
         if (environment.getRunningModeControl().isReloaded()) {
             configurationFile.resetBootFile(environment.getRunningModeControl().isUseCurrentConfig());
         }
         this. = ConfigurationPersisterFactory.createHostXmlConfigurationPersister(configurationFileenvironment.getHostControllerName());
     }
 
     public void initializeDomainConfigurationPersister(boolean slave) {
         if ( != null) {
             throw .configurationPersisterAlreadyInitialized();
         }
 
         final File configDir = .getDomainConfigurationDir();
         ConfigurationFile domainConfigurationFile = null;
         if (slave) {
             if (.isBackupDomainFiles()) {
                 // --backup
                 domainConfigurationFile = getBackupDomainConfigurationFile();
                  = ConfigurationPersisterFactory.createRemoteBackupDomainXmlConfigurationPersister(configDir);
             } else if(.isUseCachedDc()) {
                 // --cached-dc
                 domainConfigurationFile = getBackupDomainConfigurationFile();
                  = ConfigurationPersisterFactory.createCachedRemoteDomainXmlConfigurationPersister(configDir);
             } else {
                  = ConfigurationPersisterFactory.createTransientDomainXmlConfigurationPersister();
             }
         } else {
             domainConfigurationFile = getStandardDomainConfigurationFile();
             if (.getRunningModeControl().isReloaded()) {
                 if (.isBackupDomainFiles()) {
                     // We may have been promoted to master and reloaded.
                     // See if we should still use the domain-cached-remote.xml.
                     // If the standard file is newer or same age, we assume the user has either moved
                     // the cached-remote file to the standard file location, or has copied in the
                    // standard file from elsewhere. Prior to WFLY-3108 doing one of these was required,
                    // so we must support people who continue to do so. Plus it's valid to want to
                    // use the standard file name.
                    ConfigurationFile cachedRemote = getBackupDomainConfigurationFile();
                    File cachedRemoteFile = cachedRemote.getBootFile();
                    if (cachedRemoteFile.exists()
                            && cachedRemoteFile.lastModified() > domainConfigurationFile.getBootFile().lastModified()) {
                        domainConfigurationFile = cachedRemote;
                    }
                }
                domainConfigurationFile.resetBootFile(.getRunningModeControl().isUseCurrentDomainConfig());
            }
             = ConfigurationPersisterFactory.createDomainXmlConfigurationPersister(domainConfigurationFile);
        }
        // Store this back to environment so mgmt api that exposes it can still work
        .setDomainConfigurationFile(domainConfigurationFile);
        this. = slave;
    }
    public boolean isSlave() {
        if ( == null) {
            throw .mustInvokeBeforeCheckingSlaveStatus("initializeDomainConfigurationPersister");
        }
        return ;
    }
        if ( == null) {
            throw .mustInvokeBeforePersisting("initializeDomainConfigurationPersister");
        }
        return ;
    }
        return ;
    }
    @Override
    public PersistenceResource store(ModelNode modelSet<PathAddressaffectedAddressesthrows ConfigurationPersistenceException {
        final PersistenceResource[] delegates = new PersistenceResource[2];
        for (PathAddress addr : affectedAddresses) {
            if (delegates[0] == null && addr.size() > 0 && .equals(addr.getElement(0).getKey()) && addr.getElement(0).getValue().equals(.getLocalHostName())) {
                ModelNode hostModel = new ModelNode();
                hostModel.set(model.get(.getLocalHostName()));
                delegates[0] = .store(hostModelaffectedAddresses);
            } else if (delegates[1] == null && (addr.size() == 0 || !.equals(addr.getElement(0).getKey()))) {
                delegates[1] = getDomainPersister().store(modelaffectedAddresses);
            }
            if (delegates[0] != null && delegates[1] != null) {
                break;
            }
        }
        return new PersistenceResource() {
            @Override
            public void commit() {
                if (delegates[0] != null) {
                    delegates[0].commit();
                }
                if (delegates[1] != null) {
                    delegates[1].commit();
                }
            }
            @Override
            public void rollback() {
                if (delegates[0] != null) {
                    delegates[0].rollback();
                }
                if (delegates[1] != null) {
                    delegates[1].rollback();
                }
            }
        };
    }
    @Override
    public void marshallAsXml(ModelNode modelOutputStream outputthrows ConfigurationPersistenceException {
        throw new UnsupportedOperationException();
    }
    @Override
        return .load();
    }
    @Override
    public void successfulBoot() throws ConfigurationPersistenceException {
        .successfulBoot();
        if ( != null) {
            .successfulBoot();
        }
    }
    @Override
        throw new UnsupportedOperationException();
    }
    @Override
    public SnapshotInfo listSnapshots() {
        throw new UnsupportedOperationException();
    }
    @Override
    public void deleteSnapshot(String name) {
        throw new UnsupportedOperationException();
    }
    @Override
        .registerSubsystemWriter(namewriter);
    }
    @Override
    public void unregisterSubsystemWriter(String name) {
    }
    @Override
    @Deprecated
    @SuppressWarnings("deprecation")
    }
    @Override
    @Deprecated
    @SuppressWarnings("deprecation")
    public void unregisterSubsystemDeploymentWriter(String name) {
    }
        final String defaultDomainConfig = WildFlySecurityManager.getPropertyPrivileged(."domain.xml");
        final String initialDomainConfig = .getInitialDomainConfig();
        return new ConfigurationFile(.getDomainConfigurationDir(), defaultDomainConfig,
                initialDomainConfig == null ? .getDomainConfig() : initialDomainConfiginitialDomainConfig == null);
    }
                null.getInitialDomainConfig() == null);
    }
New to GrepCode? Check out our FAQ X