You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "YANG, BongYeol (JIRA)" <ji...@apache.org> on 2010/07/31 11:29:15 UTC

[jira] Created: (FELIX-2497) Jython support in iPOJO API

Jython support in iPOJO API
---------------------------

                 Key: FELIX-2497
                 URL: https://issues.apache.org/jira/browse/FELIX-2497
             Project: Felix
          Issue Type: Wish
          Components: iPOJO
            Reporter: YANG, BongYeol
            Priority: Minor


I tried to build iPOJO component dynamically using jython script and iPOJO api, but I can't. Because iPOJO cannot find dynamically added python proxy classes like this:

----
>>> sys.add_package('org.apache.felix.ipojo.api')
<java package org.apache.felix.ipojo.api 0x2>

>>> from org.apache.felix.ipojo.api import PrimitiveComponentType
>>> PrimitiveComponentType
<type 'org.apache.felix.ipojo.api.PrimitiveComponentType'>

>>> from java.lang import *
>>> Runnable
<type 'java.lang.Runnable'>

>>> class Test(Runnable):
...   def run():
...     print 'Hello'
...
>>> Test().getClass().getName()
u'org.python.proxies.__main__$Test$0'

>>> c = PrimitiveComponentType().setBundleContext(bc).setClassName(u'org.python.proxies.__main__$Test$0').createInstance()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
        at org.apache.felix.ipojo.api.PrimitiveComponentType.getClassByteArray(PrimitiveComponentType.java:473)
        at org.apache.felix.ipojo.api.PrimitiveComponentType.manipulate(PrimitiveComponentType.java:455)
        at org.apache.felix.ipojo.api.PrimitiveComponentType.createFactory(PrimitiveComponentType.java:431)
        at org.apache.felix.ipojo.api.PrimitiveComponentType.initializeFactory(PrimitiveComponentType.java:198)
        at org.apache.felix.ipojo.api.PrimitiveComponentType.getFactory(PrimitiveComponentType.java:171)
        at org.apache.felix.ipojo.api.ComponentType.ensureFactory(ComponentType.java:185)
        at org.apache.felix.ipojo.api.ComponentType.ensureAndGetFactory(ComponentType.java:177)
        at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.IllegalStateException: java.lang.IllegalStateException: An exception occurs during implementation class manipulation : cannot found the class file org/python/proxies/__main__$Test$0.class

----
How about creating overloaded setClassName() method on API? for example, setClass(Class<?>) or any idea..?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2497) Jython support in iPOJO API

Posted by "Clement Escoffier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894265#action_12894265 ] 

Clement Escoffier commented on FELIX-2497:
------------------------------------------

Hi,

It's a little bit more tricky. iPOJO requires the byte array to manipulate the class. So a setClass(Class) will not help, but a setClass(byte[]) can do the job. However, do you have the possibility to get the byte array of the class ?

> Jython support in iPOJO API
> ---------------------------
>
>                 Key: FELIX-2497
>                 URL: https://issues.apache.org/jira/browse/FELIX-2497
>             Project: Felix
>          Issue Type: Wish
>          Components: iPOJO
>            Reporter: YANG, BongYeol
>            Priority: Minor
>
> I tried to build iPOJO component dynamically using jython script and iPOJO api, but I can't. Because iPOJO cannot find dynamically added python proxy classes like this:
> ----
> >>> sys.add_package('org.apache.felix.ipojo.api')
> <java package org.apache.felix.ipojo.api 0x2>
> >>> from org.apache.felix.ipojo.api import PrimitiveComponentType
> >>> PrimitiveComponentType
> <type 'org.apache.felix.ipojo.api.PrimitiveComponentType'>
> >>> from java.lang import *
> >>> Runnable
> <type 'java.lang.Runnable'>
> >>> class Test(Runnable):
> ...   def run():
> ...     print 'Hello'
> ...
> >>> Test().getClass().getName()
> u'org.python.proxies.__main__$Test$0'
> >>> c = PrimitiveComponentType().setBundleContext(bc).setClassName(u'org.python.proxies.__main__$Test$0').createInstance()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.getClassByteArray(PrimitiveComponentType.java:473)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.manipulate(PrimitiveComponentType.java:455)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.createFactory(PrimitiveComponentType.java:431)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.initializeFactory(PrimitiveComponentType.java:198)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.getFactory(PrimitiveComponentType.java:171)
>         at org.apache.felix.ipojo.api.ComponentType.ensureFactory(ComponentType.java:185)
>         at org.apache.felix.ipojo.api.ComponentType.ensureAndGetFactory(ComponentType.java:177)
>         at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
> java.lang.IllegalStateException: java.lang.IllegalStateException: An exception occurs during implementation class manipulation : cannot found the class file org/python/proxies/__main__$Test$0.class
> ----
> How about creating overloaded setClassName() method on API? for example, setClass(Class<?>) or any idea..?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-2497) Jython support in iPOJO API

Posted by "YANG, BongYeol (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2497?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

YANG, BongYeol closed FELIX-2497.
---------------------------------

    Resolution: Fixed

i couldn't find how to get jython-generated bytecode. I will try it later.

> Jython support in iPOJO API
> ---------------------------
>
>                 Key: FELIX-2497
>                 URL: https://issues.apache.org/jira/browse/FELIX-2497
>             Project: Felix
>          Issue Type: Wish
>          Components: iPOJO
>            Reporter: YANG, BongYeol
>            Priority: Minor
>
> I tried to build iPOJO component dynamically using jython script and iPOJO api, but I can't. Because iPOJO cannot find dynamically added python proxy classes like this:
> ----
> >>> sys.add_package('org.apache.felix.ipojo.api')
> <java package org.apache.felix.ipojo.api 0x2>
> >>> from org.apache.felix.ipojo.api import PrimitiveComponentType
> >>> PrimitiveComponentType
> <type 'org.apache.felix.ipojo.api.PrimitiveComponentType'>
> >>> from java.lang import *
> >>> Runnable
> <type 'java.lang.Runnable'>
> >>> class Test(Runnable):
> ...   def run():
> ...     print 'Hello'
> ...
> >>> Test().getClass().getName()
> u'org.python.proxies.__main__$Test$0'
> >>> c = PrimitiveComponentType().setBundleContext(bc).setClassName(u'org.python.proxies.__main__$Test$0').createInstance()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.getClassByteArray(PrimitiveComponentType.java:473)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.manipulate(PrimitiveComponentType.java:455)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.createFactory(PrimitiveComponentType.java:431)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.initializeFactory(PrimitiveComponentType.java:198)
>         at org.apache.felix.ipojo.api.PrimitiveComponentType.getFactory(PrimitiveComponentType.java:171)
>         at org.apache.felix.ipojo.api.ComponentType.ensureFactory(ComponentType.java:185)
>         at org.apache.felix.ipojo.api.ComponentType.ensureAndGetFactory(ComponentType.java:177)
>         at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
> java.lang.IllegalStateException: java.lang.IllegalStateException: An exception occurs during implementation class manipulation : cannot found the class file org/python/proxies/__main__$Test$0.class
> ----
> How about creating overloaded setClassName() method on API? for example, setClass(Class<?>) or any idea..?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.