my nuxeo component exposed as service is not injected in my action bean

Hi, I have developed my own nuxeo component exposed as service with my “nuxeo ide”, but it is not injected in the bean action where it is used. I have this files in my plugin:

component xml:

alt text

code in MyService:

public class MyService extends DefaultComponent implements MyManager {

    public static final ComponentName ID = new ComponentName(
            "my.component.MyService");

    private static final Log log = LogFactory.getLog(TypeService.class);


    protected Bundle bundle;

    public Bundle getBundle() {
        return bundle;
    }

    /**
     * Component activated notification. Called when the component is activated.
     * All component dependencies are resolved at that moment. Use this method
     * to initialize the component.
     * <p>
     * The default implementation of this method is storing the Bundle owning
     * that component in a class field. You can use the bundle object to lookup
     * for bundle resources:
     * <code>URL url = bundle.getEntry("META-INF/some.resource");</code>, load
     * classes or to interact with OSGi framework.
     * <p>
     * Note that you must always use the Bundle to lookup for resources in the
     * bundle. Do not use the classloader for this.
     * 
     * @param context
     *            the component context. Use it to get the current bundle
     *            context
     */
    @Override
    public void activate(ComponentContext context) {
        this.bundle = context.getRuntimeContext().getBundle();
    }


    /**
     * Component deactivated notification. Called before a component is
     * unregistered. Use this method to do cleanup if any and free any resources
     * held by the component.
     * 
     * @param context
     *            the component context. Use it to get the current bundle
     *            context
     */
    @Override
    public void deactivate(ComponentContext context) {
        this.bundle = null;
    }

    /**
     * Application started notification. Called after the application started.
     * You can do here any initialization that requires a working application
     * (all resolved bundles and components are active at that moment)
     * 
     * @param context
     *            the component context. Use it to get the current bundle
     *            context
     * @throws Exception
     */
    @Override
    public void applicationStarted(ComponentContext context) throws Exception {
        // do nothing by default. You can remove this method if not used.
    }

    @Override
    public String getStr() {
        // TODO Auto-generated method stub
        return "test";
    }

}

code in interface:

public interface MyManager {
    String getStr();
}

in myActionBean:

@In(create = true)
protected transient TypeManager typeManager;  //its working

@In(create = true)
protected transient MyManager myManager; //its not working when I use. Example: myManager.getStr();

this error message is showed:

@In attribute requires non-null value: myActionBean.myManager Caused by: org.jboss.seam.RequiredException: @In attribute requires non-null value:

0 votes

1 answers

1536 views

ANSWER



You need to use the Seam Service Bean wizard. It will expose your service as a seam component.

0 votes



Thanks doguin but "Seam Service Bean Wizard" is part of "seam plugin" for eclipse or it is part of Nuxeo Plugin? because I do not see it in my ide nuxeo. Anyway, I have resolved this problem developing a seam component that initializes my service using nuxeo api.

@Unwrap
public myManager getMyManager() throws ClientException {
    if (null == myManager) {
        try {
            myManager = Framework.getService(myManager.class);
05/31/2012

You did exactly what the wizard does :) I was talking about the Nuxeo IDE wizard called Service Bean under the seam category.
05/31/2012

uhmm ok, excellent. I going to review well those ide options. I have been reading this: Service Bean: This is a simple service wrapper that allow to inject a Nuxeo Runtime service as a Seam component. -> src/main/seam/packagePath/MyServiceWrapperBean.java

all what you said http://doc.nuxeo.com/display/IDEDOC/Wizard+Index :)

05/31/2012