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_bytesprivate java.lang.Stringm_classNameprivate java.lang.Classm_definedClassprivate java.util.List<java.lang.String>m_importsprivate booleanm_isCompleteprivate intm_stateprivate BundleWiringm_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()voidadd(int i, java.lang.String s)booleanadd(java.lang.String s)booleanaddAll(int i, java.util.Collection<? extends java.lang.String> collection)booleanaddAll(java.util.Collection<? extends java.lang.String> collection)private voidcheckImport(java.lang.String s)voidclear()(package private) voidcomplete(java.lang.Class definedClass, byte[] bytes, java.util.List<java.lang.String> imports)(package private) voidcompleteDefine(java.lang.Class definedClass)(package private) voidcompleteImports(java.util.List<java.lang.String> imports)booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> collection)java.lang.Stringget(int i)BundleWiringgetBundleWiring()Returns the bundle wiring whose class loader will define the woven class.byte[]getBytes()Returns the class file bytes to be used to define thenamedclass.java.lang.StringgetClassName()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 wiringfor this woven class.(package private) java.util.List<java.lang.String>getDynamicImportsInternal()java.security.ProtectionDomaingetProtectionDomain()Returns the protection domain to which the woven class will be assigned when it is defined.intgetState()Returns the current state of this woven class.intindexOf(java.lang.Object o)booleanisEmpty()booleanisWeavingComplete()Returns whether weaving is complete in this woven class.java.util.Iterator<java.lang.String>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<java.lang.String>listIterator()java.util.ListIterator<java.lang.String>listIterator(int i)java.lang.Stringremove(int i)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> collection)booleanretainAll(java.util.Collection<?> collection)java.lang.Stringset(int i, java.lang.String s)voidsetBytes(byte[] bytes)Set the class file bytes to be used to define thenamedclass.voidsetState(int state)intsize()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:WovenClassReturns the class file bytes to be used to define thenamedclass.While in the
WovenClass.TRANSFORMINGstate, this method returns a reference to the class files byte array contained in this object. After leaving theWovenClass.TRANSFORMINGstate, this woven class can no longer be transformed and a copy of the class file byte array is returned.- Specified by:
getBytesin interfaceWovenClass- Returns:
- The bytes to be used to define the
namedclass.
-
setBytes
public void setBytes(byte[] bytes)
Description copied from interface:WovenClassSet the class file bytes to be used to define thenamedclass. This method must not be called outside invocations of theweavemethod by the framework.While in the
WovenClass.TRANSFORMINGstate, this method replaces the reference to the array contained in this object with the specified array. After leaving theWovenClass.TRANSFORMINGstate, this woven class can no longer be transformed and this method will throw anIllegalStateException.- Specified by:
setBytesin interfaceWovenClass- Parameters:
bytes- The new classfile that will be used to define thenamedclass. 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:WovenClassReturns the list of dynamic import package descriptions to add to thebundle wiringfor this woven class. Changes made to the returned list will be visible to laterweaving hookscalled with this object. The returned list must not be modified outside invocations of theweavemethod by the framework.After leaving the
WovenClass.TRANSFORMINGstate, 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:
getDynamicImportsin 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
IllegalArgumentExceptionif 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:WovenClassReturns whether weaving is complete in this woven class. Weaving is complete after the class is defined.- Specified by:
isWeavingCompletein interfaceWovenClass- Returns:
trueifstateisWovenClass.DEFINED,WovenClass.TRANSFORMING_FAILEDorWovenClass.DEFINE_FAILED;falseotherwise.
-
getClassName
public java.lang.String getClassName()
Description copied from interface:WovenClassReturns the fully qualified name of the class being woven.- Specified by:
getClassNamein interfaceWovenClass- Returns:
- The fully qualified name of the class being woven.
-
getProtectionDomain
public java.security.ProtectionDomain getProtectionDomain()
Description copied from interface:WovenClassReturns the protection domain to which the woven class will be assigned when it is defined.- Specified by:
getProtectionDomainin interfaceWovenClass- Returns:
- The protection domain to which the woven class will be assigned
when it is defined, or
nullif no protection domain will be assigned.
-
getDefinedClass
public java.lang.Class<?> getDefinedClass()
Description copied from interface:WovenClassReturns 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:
getDefinedClassin interfaceWovenClass- Returns:
- The class associated with this woven class, or
nullif 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:WovenClassReturns the bundle wiring whose class loader will define the woven class.- Specified by:
getBundleWiringin interfaceWovenClass- Returns:
- The bundle wiring whose class loader will define the woven class.
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.String>- Specified by:
sizein interfacejava.util.List<java.lang.String>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<java.lang.String>- Specified by:
isEmptyin interfacejava.util.List<java.lang.String>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<java.lang.String>- Specified by:
containsin interfacejava.util.List<java.lang.String>
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<java.lang.String>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>- Specified by:
iteratorin interfacejava.util.List<java.lang.String>
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<java.lang.String>- Specified by:
toArrayin interfacejava.util.List<java.lang.String>
-
toArray
public <T> T[] toArray(T[] ts)
- Specified by:
toArrayin interfacejava.util.Collection<java.lang.String>- Specified by:
toArrayin interfacejava.util.List<java.lang.String>
-
add
public boolean add(java.lang.String s)
- Specified by:
addin interfacejava.util.Collection<java.lang.String>- Specified by:
addin interfacejava.util.List<java.lang.String>
-
checkImport
private void checkImport(java.lang.String s)
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<java.lang.String>- Specified by:
removein interfacejava.util.List<java.lang.String>
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
- Specified by:
containsAllin interfacejava.util.Collection<java.lang.String>- Specified by:
containsAllin interfacejava.util.List<java.lang.String>
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.String> collection)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.String>- Specified by:
addAllin interfacejava.util.List<java.lang.String>
-
addAll
public boolean addAll(int i, java.util.Collection<? extends java.lang.String> collection)- Specified by:
addAllin interfacejava.util.List<java.lang.String>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAllin interfacejava.util.Collection<java.lang.String>- Specified by:
removeAllin interfacejava.util.List<java.lang.String>
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAllin interfacejava.util.Collection<java.lang.String>- Specified by:
retainAllin interfacejava.util.List<java.lang.String>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<java.lang.String>- Specified by:
clearin interfacejava.util.List<java.lang.String>
-
get
public java.lang.String get(int i)
- Specified by:
getin interfacejava.util.List<java.lang.String>
-
set
public java.lang.String set(int i, java.lang.String s)- Specified by:
setin interfacejava.util.List<java.lang.String>
-
add
public void add(int i, java.lang.String s)- Specified by:
addin interfacejava.util.List<java.lang.String>
-
remove
public java.lang.String remove(int i)
- Specified by:
removein interfacejava.util.List<java.lang.String>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<java.lang.String>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<java.lang.String>
-
listIterator
public java.util.ListIterator<java.lang.String> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<java.lang.String>
-
listIterator
public java.util.ListIterator<java.lang.String> listIterator(int i)
- Specified by:
listIteratorin interfacejava.util.List<java.lang.String>
-
subList
public java.util.List<java.lang.String> subList(int i, int i1)- Specified by:
subListin interfacejava.util.List<java.lang.String>
-
_getBytes
byte[] _getBytes()
-
getState
public int getState()
Description copied from interface:WovenClassReturns the current state of this woven class.A woven class can be in only one state at any time.
- Specified by:
getStatein interfaceWovenClass- Returns:
- Either
WovenClass.TRANSFORMING,WovenClass.TRANSFORMED,WovenClass.DEFINED,WovenClass.TRANSFORMING_FAILEDorWovenClass.DEFINE_FAILED.
-
setState
public void setState(int state)
-
-