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 */
018
019package org.jppf.node.protocol;
020
021import java.io.Serializable;
022
023import org.jppf.location.Location;
024
025/**
026 * Instances of this class represent classpath elements that can be added dynamically to a JPPF class loader.
027 * The actual classpath element is a jar or zip file wrapped into, or pointed to by, a {@link Location} object.
028 * They are intended to be transported along with a job SLA.
029 * @author Laurent Cohen
030 */
031public interface ClassPathElement extends Serializable {
032  /**
033   * Get the name of this classpath element.
034   * @return the name as a string.
035   * @deprecated the {@code name} attribute has no clearly definied, consistent semantics. It can be bypassed entirely.
036   */
037  String getName();
038
039  /**
040   * Get the location of this element, pointing to or embedding the underlying jar or zip file in the client environment.
041   * @return a {@link Location} object.
042   */
043  Location<?> getSourceLocation();
044
045  /**
046   * Get the location of this element, pointing to or embedding the underlying jar or zip file in the client environment.
047   * @return a {@link Location} object.
048   * @deprecated use {@link #getSourceLocation()} instead.
049   * @exclude
050   */
051  Location<?> getLocalLocation();
052
053  /**
054   * Get the location of this element, pointing to or embedding the underlying jar or zip file in the node environment.
055   * @return a {@link Location} object.
056   */
057  Location<?> getTargetLocation();
058
059  /**
060   * Get the location of this element, pointing to or embedding the underlying jar or zip file in the client environment.
061   * @return a {@link Location} object.
062   * @deprecated use {@link #getTargetLocation()} instead.
063   * @exclude
064   */
065  Location<?> getRemoteLocation();
066
067  /**
068   * Perform a validation of this classpath element.
069   * If validation fails, if will not be added to the node's classpath and its classes will not be loaded nor executed.
070   * <p>An example use is to check that a jar file is signed and that it is secure to use it.
071   * @return {@code true} if the validation issuccessful, {@code false} if it fails.
072   */
073  boolean validate();
074
075  /**
076   * Determine whether to copy the source to the target if the target is a file and if it already exists on the file system.
077   * <br>This applies to instances of {@link org.jppf.location.FileLocation FileLocation} and instances of {@link org.jppf.location.URLLocation URLLocation}
078   * whose URL protocol is "{@code file}".
079   * <br>This is an optimization that can avoid unnecessary netword and/or disk I/O.
080   * @return {@code false} if the target is a file and should not be copied into, {@code true} otherwise.
081   */
082  boolean isCopyToExistingFile();
083}