org.eclipse.osgi.internal.baseadaptor.weaving
Class WovenClassImpl

java.lang.Object
  extended by org.eclipse.osgi.internal.baseadaptor.weaving.WovenClassImpl
All Implemented Interfaces:
HookContext, WovenClass

public final class WovenClassImpl
extends Object
implements WovenClass, HookContext


Constructor Summary
WovenClassImpl(String className, byte[] bytes, BundleEntry entry, ProtectionDomain domain, BundleLoader loader, ServiceRegistry registry, Map<ServiceRegistration<?>,Boolean> blacklist)
           
 
Method Summary
 void call(Object hook, ServiceRegistration<?> hookRegistration)
          Call the specified hook.
 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 the named class.
 String getClassName()
          Returns the fully qualified name of the class being woven.
 Class<?> getDefinedClass()
          Returns the class associated with this woven class.
 List<String> getDynamicImports()
          Returns the list of dynamic import package descriptions to add to the bundle wiring for this woven class.
 ServiceRegistration<?> getErrorHook()
           
 String getHookClassName()
          Return the class name of the hook type supported by this hook context.
 String getHookMethodName()
          Return the hook method name called by this hook context.
 ProtectionDomain getProtectionDomain()
          Returns the protection domain to which the woven class will be assigned when it is defined.
 boolean isWeavingComplete()
          Returns whether weaving is complete in this woven class.
 void setBytes(byte[] newBytes)
          Set the class file bytes to be used to define the named class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WovenClassImpl

public WovenClassImpl(String className,
                      byte[] bytes,
                      BundleEntry entry,
                      ProtectionDomain domain,
                      BundleLoader loader,
                      ServiceRegistry registry,
                      Map<ServiceRegistration<?>,Boolean> blacklist)
Method Detail

getBytes

public byte[] getBytes()
Description copied from interface: WovenClass
Returns the class file bytes to be used to define the named class.

While weaving is not complete, this method returns a reference to the class files byte array contained in this object. After weaving is complete, this object becomes effectively immutable and a copy of the class file byte array is returned.

Specified by:
getBytes in interface WovenClass
Returns:
The bytes to be used to define the named class.

setBytes

public void setBytes(byte[] newBytes)
Description copied from interface: WovenClass
Set the class file bytes to be used to define the named class. This method must not be called outside invocations of the weave method by the framework.

While weaving is not complete, this method replaces the reference to the array contained in this object with the specified array. After weaving is complete, this object becomes effectively immutable and this method will throw an IllegalStateException.

Specified by:
setBytes in interface WovenClass
Parameters:
newBytes - The new classfile that will be used to define the named class. The specified array is retained by this object and the caller must not modify the specified array.

getDynamicImports

public List<String> getDynamicImports()
Description copied from interface: WovenClass
Returns the list of dynamic import package descriptions to add to the bundle wiring for this woven class. Changes made to the returned list will be visible to later weaving hooks called with this object. The returned list must not be modified outside invocations of the weave method by the framework.

After weaving is complete, this object becomes effectively immutable and the returned list will be unmodifiable.

If the Java runtime environment supports permissions, the caller must have AdminPermission[bundle,WEAVE] to modify the returned list.

Specified by:
getDynamicImports in interface WovenClass
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 last weaving hook is called and the class is defined.

After weaving is complete, this object becomes effectively immutable.

Specified by:
isWeavingComplete in interface WovenClass
Returns:
true weaving is complete, false otherwise.

getClassName

public String getClassName()
Description copied from interface: WovenClass
Returns the fully qualified name of the class being woven.

Specified by:
getClassName in interface WovenClass
Returns:
The fully qualified name of the class being woven.

getProtectionDomain

public 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 interface WovenClass
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 Class<?> getDefinedClass()
Description copied from interface: WovenClass
Returns the class associated with this woven class. When loading a class for the first time this method will return null until weaving is complete. Once weaving is complete, this method will return the class object.

Specified by:
getDefinedClass in interface WovenClass
Returns:
The class associated with this woven class, or null if weaving is not complete or the class definition failed.

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 interface WovenClass
Returns:
The bundle wiring whose class loader will define the woven class.

call

public void call(Object hook,
                 ServiceRegistration<?> hookRegistration)
          throws Exception
Description copied from interface: HookContext
Call the specified hook.

Specified by:
call in interface HookContext
Parameters:
hook - The hook object to call. The hook object must be of the type supported by this hook context. If it is not, then this method will simply return.
hookRegistration - the registration for the hook object
Throws:
Exception - An exception thrown by the hook object.

getHookMethodName

public String getHookMethodName()
Description copied from interface: HookContext
Return the hook method name called by this hook context.

Specified by:
getHookMethodName in interface HookContext
Returns:
The hook method name called by this hook context.

getHookClassName

public String getHookClassName()
Description copied from interface: HookContext
Return the class name of the hook type supported by this hook context.

Specified by:
getHookClassName in interface HookContext
Returns:
The class name of the hook type supported by this hook context.

toString

public String toString()
Overrides:
toString in class Object

getErrorHook

public ServiceRegistration<?> getErrorHook()


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.