Beta
Nuxeo Answers
ask a question

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:

asked May 31 '12 at 14:33 murkein 105152340 murkein's gravatar image
edited May 31 '12 at 14:50

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

link
answered May 31 '12 at 15:01 Laurent Doguin ♦♦ 1.0k2512 Laurent%20Doguin's gravatar image

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);
(May 31 '12 at 17:08) murkein

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

(May 31 '12 at 17:12) Laurent Doguin ♦♦

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 :)

(May 31 '12 at 20:24) murkein
Your answer
toggle preview

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×555

Asked: May 31 '12 at 14:33

Seen: 596 times

Last updated: May 31 '12 at 21:01