Class WovenClassImpl
- java.lang.Object
-
- org.apache.felix.framework.WovenClassImpl
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.String>
,java.util.Collection<java.lang.String>
,java.util.List<java.lang.String>
,WovenClass
class WovenClassImpl extends java.lang.Object implements WovenClass, java.util.List<java.lang.String>
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
m_bytes
private java.lang.String
m_className
private java.lang.Class
m_definedClass
private java.util.List<java.lang.String>
m_imports
private boolean
m_isComplete
private int
m_state
private BundleWiring
m_wiring
-
Fields inherited from interface org.osgi.framework.hooks.weaving.WovenClass
DEFINE_FAILED, DEFINED, TRANSFORMED, TRANSFORMING, TRANSFORMING_FAILED
-
-
Constructor Summary
Constructors Constructor Description WovenClassImpl(java.lang.String className, BundleWiring wiring, byte[] bytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) byte[]
_getBytes()
void
add(int i, java.lang.String s)
boolean
add(java.lang.String s)
boolean
addAll(int i, java.util.Collection<? extends java.lang.String> collection)
boolean
addAll(java.util.Collection<? extends java.lang.String> collection)
private void
checkImport(java.lang.String s)
void
clear()
(package private) void
complete(java.lang.Class definedClass, byte[] bytes, java.util.List<java.lang.String> imports)
(package private) void
completeDefine(java.lang.Class definedClass)
(package private) void
completeImports(java.util.List<java.lang.String> imports)
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> collection)
java.lang.String
get(int i)
BundleWiring
getBundleWiring()
Returns the bundle wiring whose class loader will define the woven class.byte[]
getBytes()
Returns the class file bytes to be used to define thenamed
class.java.lang.String
getClassName()
Returns the fully qualified name of the class being woven.java.lang.Class<?>
getDefinedClass()
Returns the class defined by this woven class.java.util.List<java.lang.String>
getDynamicImports()
Returns the list of dynamic import package descriptions to add to thebundle wiring
for this woven class.(package private) java.util.List<java.lang.String>
getDynamicImportsInternal()
java.security.ProtectionDomain
getProtectionDomain()
Returns the protection domain to which the woven class will be assigned when it is defined.int
getState()
Returns the current state of this woven class.int
indexOf(java.lang.Object o)
boolean
isEmpty()
boolean
isWeavingComplete()
Returns whether weaving is complete in this woven class.java.util.Iterator<java.lang.String>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<java.lang.String>
listIterator()
java.util.ListIterator<java.lang.String>
listIterator(int i)
java.lang.String
remove(int i)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> collection)
boolean
retainAll(java.util.Collection<?> collection)
java.lang.String
set(int i, java.lang.String s)
void
setBytes(byte[] bytes)
Set the class file bytes to be used to define thenamed
class.void
setState(int state)
int
size()
java.util.List<java.lang.String>
subList(int i, int i1)
java.lang.Object[]
toArray()
<T> T[]
toArray(T[] ts)
-
-
-
Field Detail
-
m_className
private final java.lang.String m_className
-
m_wiring
private final BundleWiring m_wiring
-
m_bytes
private byte[] m_bytes
-
m_imports
private java.util.List<java.lang.String> m_imports
-
m_definedClass
private java.lang.Class m_definedClass
-
m_isComplete
private boolean m_isComplete
-
m_state
private int m_state
-
-
Constructor Detail
-
WovenClassImpl
WovenClassImpl(java.lang.String className, BundleWiring wiring, byte[] bytes)
-
-
Method Detail
-
complete
void complete(java.lang.Class definedClass, byte[] bytes, java.util.List<java.lang.String> imports)
-
completeImports
void completeImports(java.util.List<java.lang.String> imports)
-
completeDefine
void completeDefine(java.lang.Class definedClass)
-
getBytes
public byte[] getBytes()
Description copied from interface:WovenClass
Returns the class file bytes to be used to define thenamed
class.While in the
WovenClass.TRANSFORMING
state, this method returns a reference to the class files byte array contained in this object. After leaving theWovenClass.TRANSFORMING
state, this woven class can no longer be transformed and a copy of the class file byte array is returned.- Specified by:
getBytes
in interfaceWovenClass
- Returns:
- The bytes to be used to define the
named
class.
-
setBytes
public void setBytes(byte[] bytes)
Description copied from interface:WovenClass
Set the class file bytes to be used to define thenamed
class. This method must not be called outside invocations of theweave
method by the framework.While in the
WovenClass.TRANSFORMING
state, this method replaces the reference to the array contained in this object with the specified array. After leaving theWovenClass.TRANSFORMING
state, this woven class can no longer be transformed and this method will throw anIllegalStateException
.- Specified by:
setBytes
in interfaceWovenClass
- Parameters:
bytes
- The new classfile that will be used to define thenamed
class. The specified array is retained by this object and the caller must not modify the specified array.
-
getDynamicImportsInternal
java.util.List<java.lang.String> getDynamicImportsInternal()
-
getDynamicImports
public java.util.List<java.lang.String> getDynamicImports()
Description copied from interface:WovenClass
Returns the list of dynamic import package descriptions to add to thebundle wiring
for this woven class. Changes made to the returned list will be visible to laterweaving hooks
called with this object. The returned list must not be modified outside invocations of theweave
method by the framework.After leaving the
WovenClass.TRANSFORMING
state, this woven class can no longer be transformed and the returned list will be unmodifiable.If the Java runtime environment supports permissions, any modification to the returned list requires
AdminPermission[bundle,WEAVE]
. Additionally, any add or set modification requiresPackagePermission[package,IMPORT]
.- Specified by:
getDynamicImports
in interfaceWovenClass
- Returns:
- A list containing zero or more dynamic import package
descriptions to add to the bundle wiring for this woven class.
This list must throw
IllegalArgumentException
if a malformed dynamic import package description is added. - See Also:
- "Core Specification, Dynamic Import Package, for the syntax of a dynamic import package description."
-
isWeavingComplete
public boolean isWeavingComplete()
Description copied from interface:WovenClass
Returns whether weaving is complete in this woven class. Weaving is complete after the class is defined.- Specified by:
isWeavingComplete
in interfaceWovenClass
- Returns:
true
ifstate
isWovenClass.DEFINED
,WovenClass.TRANSFORMING_FAILED
orWovenClass.DEFINE_FAILED
;false
otherwise.
-
getClassName
public java.lang.String getClassName()
Description copied from interface:WovenClass
Returns the fully qualified name of the class being woven.- Specified by:
getClassName
in interfaceWovenClass
- Returns:
- The fully qualified name of the class being woven.
-
getProtectionDomain
public java.security.ProtectionDomain getProtectionDomain()
Description copied from interface:WovenClass
Returns the protection domain to which the woven class will be assigned when it is defined.- Specified by:
getProtectionDomain
in interfaceWovenClass
- Returns:
- The protection domain to which the woven class will be assigned
when it is defined, or
null
if no protection domain will be assigned.
-
getDefinedClass
public java.lang.Class<?> getDefinedClass()
Description copied from interface:WovenClass
Returns the class defined by this woven class. During weaving, this method will returnnull
. Once weaving iscomplete
, this method will return the class object if this woven class was used to define the class.- Specified by:
getDefinedClass
in interfaceWovenClass
- Returns:
- The class associated with this woven class, or
null
if weaving is not complete, the class definition failed or this woven class was not used to define the class.
-
getBundleWiring
public BundleWiring getBundleWiring()
Description copied from interface:WovenClass
Returns the bundle wiring whose class loader will define the woven class.- Specified by:
getBundleWiring
in interfaceWovenClass
- Returns:
- The bundle wiring whose class loader will define the woven class.
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<java.lang.String>
- Specified by:
size
in interfacejava.util.List<java.lang.String>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<java.lang.String>
- Specified by:
isEmpty
in interfacejava.util.List<java.lang.String>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<java.lang.String>
- Specified by:
contains
in interfacejava.util.List<java.lang.String>
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<java.lang.String>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
- Specified by:
iterator
in interfacejava.util.List<java.lang.String>
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interfacejava.util.Collection<java.lang.String>
- Specified by:
toArray
in interfacejava.util.List<java.lang.String>
-
toArray
public <T> T[] toArray(T[] ts)
- Specified by:
toArray
in interfacejava.util.Collection<java.lang.String>
- Specified by:
toArray
in interfacejava.util.List<java.lang.String>
-
add
public boolean add(java.lang.String s)
- Specified by:
add
in interfacejava.util.Collection<java.lang.String>
- Specified by:
add
in interfacejava.util.List<java.lang.String>
-
checkImport
private void checkImport(java.lang.String s)
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<java.lang.String>
- Specified by:
remove
in interfacejava.util.List<java.lang.String>
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
- Specified by:
containsAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
containsAll
in interfacejava.util.List<java.lang.String>
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.String> collection)
- Specified by:
addAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
addAll
in interfacejava.util.List<java.lang.String>
-
addAll
public boolean addAll(int i, java.util.Collection<? extends java.lang.String> collection)
- Specified by:
addAll
in interfacejava.util.List<java.lang.String>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
removeAll
in interfacejava.util.List<java.lang.String>
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
retainAll
in interfacejava.util.List<java.lang.String>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<java.lang.String>
- Specified by:
clear
in interfacejava.util.List<java.lang.String>
-
get
public java.lang.String get(int i)
- Specified by:
get
in interfacejava.util.List<java.lang.String>
-
set
public java.lang.String set(int i, java.lang.String s)
- Specified by:
set
in interfacejava.util.List<java.lang.String>
-
add
public void add(int i, java.lang.String s)
- Specified by:
add
in interfacejava.util.List<java.lang.String>
-
remove
public java.lang.String remove(int i)
- Specified by:
remove
in interfacejava.util.List<java.lang.String>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List<java.lang.String>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<java.lang.String>
-
listIterator
public java.util.ListIterator<java.lang.String> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<java.lang.String>
-
listIterator
public java.util.ListIterator<java.lang.String> listIterator(int i)
- Specified by:
listIterator
in interfacejava.util.List<java.lang.String>
-
subList
public java.util.List<java.lang.String> subList(int i, int i1)
- Specified by:
subList
in interfacejava.util.List<java.lang.String>
-
_getBytes
byte[] _getBytes()
-
getState
public int getState()
Description copied from interface:WovenClass
Returns the current state of this woven class.A woven class can be in only one state at any time.
- Specified by:
getState
in interfaceWovenClass
- Returns:
- Either
WovenClass.TRANSFORMING
,WovenClass.TRANSFORMED
,WovenClass.DEFINED
,WovenClass.TRANSFORMING_FAILED
orWovenClass.DEFINE_FAILED
.
-
setState
public void setState(int state)
-
-