blob: 3f8230547cebf76266d13841e4fb9177373b7b94 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Knibb initial implementation
* Matthew Webster Eclipse 3.2 changes
* Martin Lippert minor changes and bugfixes
*******************************************************************************/
package org.eclipse.equinox.weaving.hooks;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.eclipse.equinox.weaving.adaptors.IAspectJAdaptor;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
public class AspectJBundleEntry extends BundleEntry {
private final IAspectJAdaptor adaptor;
private final URL bundleFileURL;
private byte[] bytes;
private final BundleEntry delegate;
private final boolean dontWeave;
private String name;
public AspectJBundleEntry(final IAspectJAdaptor aspectjAdaptor,
final BundleEntry delegate, final String name, final byte[] bytes,
final URL url) {
this(aspectjAdaptor, delegate, url, true);
this.name = name;
this.bytes = bytes;
}
public AspectJBundleEntry(final IAspectJAdaptor aspectjAdaptor,
final BundleEntry delegate, final URL url, final boolean dontWeave) {
this.adaptor = aspectjAdaptor;
this.bundleFileURL = url;
this.delegate = delegate;
this.dontWeave = dontWeave;
}
public boolean dontWeave() {
return dontWeave;
}
public IAspectJAdaptor getAdaptor() {
return adaptor;
}
public URL getBundleFileURL() {
return bundleFileURL;
}
public byte[] getBytes() throws IOException {
if (bytes == null) return delegate.getBytes();
return bytes;
}
public URL getFileURL() {
if (bytes == null)
return delegate.getFileURL();
else
return null;
}
public InputStream getInputStream() throws IOException {
// this always returns the original stream of the delegate to
// allow getResourceAsStream to be used even in the context of
// caching with J9 class sharing
//
// class loading uses getBytes instead (where the caching is considered)
return delegate.getInputStream();
}
public URL getLocalURL() {
if (bytes == null)
return delegate.getLocalURL();
else
return null;
}
public String getName() {
if (bytes == null)
return delegate.getName();
else
return name;
}
public long getSize() {
if (delegate != null)
return delegate.getSize();
else
return bytes.length;
}
public long getTime() {
if (delegate != null)
return delegate.getTime();
else
return 0;
}
}
|