01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.core.event.publish;
19:
20: import java.io.File;
21:
22: import org.apache.ivy.core.event.IvyEvent;
23: import org.apache.ivy.core.module.descriptor.Artifact;
24: import org.apache.ivy.plugins.resolver.DependencyResolver;
25:
26: /**
27: * Base class for events fired during {@link DependencyResolver#publish(Artifact, File, boolean)}.
28: *
29: * @see StartArtifactPublishEvent
30: * @see EndArtifactPublishEvent
31: */
32: public abstract class PublishEvent extends IvyEvent {
33:
34: private final DependencyResolver resolver;
35:
36: private final Artifact artifact;
37:
38: private final File data;
39:
40: private final boolean overwrite;
41:
42: protected PublishEvent(String name, DependencyResolver resolver,
43: Artifact artifact, File data, boolean overwrite) {
44: super (name);
45: this .resolver = resolver;
46: this .artifact = artifact;
47: this .data = data;
48: this .overwrite = overwrite;
49:
50: addMridAttributes(artifact.getModuleRevisionId());
51: addAttributes(artifact.getAttributes());
52: addAttribute("resolver", resolver.getName());
53: addAttribute("file", data.getAbsolutePath());
54: addAttribute("overwrite", String.valueOf(overwrite));
55: }
56:
57: /** @return the resolver into which the artifact is being published */
58: public DependencyResolver getResolver() {
59: return resolver;
60: }
61:
62: /** @return a local file containing the artifact data */
63: public File getData() {
64: return data;
65: }
66:
67: /** @return metadata about the artifact being published */
68: public Artifact getArtifact() {
69: return artifact;
70: }
71:
72: /** @return true iff this event overwrites existing resolver data for this artifact */
73: public boolean isOverwrite() {
74: return overwrite;
75: }
76:
77: }
|