001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jppf.classloader;
019
020import java.util.List;
021
022import org.slf4j.*;
023
024/**
025 * JPPF class loader implementation for remote standalone nodes.
026 * @author Laurent Cohen
027 */
028public class JPPFClassLoader extends AbstractJPPFClassLoader {
029  /**
030   * Logger for this class.
031   */
032  private static Logger log = LoggerFactory.getLogger(JPPFClassLoader.class);
033
034  /**
035   * Initialize this class loader with a parent class loader.
036   * @param connection the connection to the driver.
037   * @param parent a ClassLoader instance.
038   */
039  public JPPFClassLoader(final ClassLoaderConnection<?> connection, final ClassLoader parent) {
040    super(connection, parent);
041    init();
042  }
043
044  /**
045   * Initialize this class loader with a parent class loader.
046   * @param connection the connection to the driver.
047   * @param parent a ClassLoader instance.
048   * @param uuidPath unique identifier for the submitting application.
049   */
050  public JPPFClassLoader(final ClassLoaderConnection<?> connection, final ClassLoader parent, final List<String> uuidPath) {
051    super(connection, parent, uuidPath);
052  }
053
054  /**
055   * {@inheritDoc}
056   * @exclude
057   */
058  @Override
059  protected void reset() {
060    if (!isOffline()) {
061      try {
062        connection.reset();
063      } catch (final Exception e) {
064        log.error(e.getMessage(), e);
065      }
066    }
067  }
068
069  /**
070   * Terminate this classloader and clean the resources it uses.
071   * @see org.jppf.classloader.AbstractJPPFClassLoader#close()
072   */
073  @Override
074  public void close() {
075    try {
076      if (!dynamic && !isOffline()) connection.close();
077    } catch (final Exception e) {
078      log.error(e.getMessage(), e);
079    }
080    super.close();
081  }
082}