0

I am building a component for use in XWiki. The Interface is available and straightforward. But I need this Singleton component to execute some straightforward tasks. It seems however that the @Postcontsruct is not executed in the following code: (I left out the rest of the code since it is of no concern):

package wiki.kennisfabriek.core.pagenamegenerator;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;

import org.hashids.Hashids;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.model.reference.LocalDocumentReference;
import org.xwiki.model.reference.WikiReference;
import org.xwiki.query.QueryManager;

import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.objects.BaseObject;

@Component
@Singleton
public class DefaultPageNameGenerator implements PageNameGenerator
{

    @Inject
    private Logger LOGGER;

    @Inject
    private QueryManager queryManager;

    @Inject
    private Reporter reporter;

    @Inject
    private Provider<XWikiContext> xwikiContextProvider;

    private static Random randomGenerator = new Random();

    private static Hashids hashIds = new Hashids(GEGEVENSHASHSALT, GEGEVENSHASCOUNTER, HASHSTRING);

    private static Date date1 = new Date(1435701600000L);

    @PostConstruct
    private void initialize()
    {
        this.LOGGER.error("PAGENAMEGENERATOR geinitialiseerd");
    }

......

I have no clue why it doesn't work. Can anyone help me with this?

XiMM
  • 13
  • 3
  • How to you know it doesn't work, what is your DI provider? –  Feb 26 '16 at 15:52
  • 1
    Do you use/access `DefaultPageNameGenerator` anywhere? If not the instance might just not be constructed. – Thomas Feb 26 '16 at 15:56
  • I know because I tested it. I inject the PageNameGenerator and I am sure it is working :-) – XiMM Feb 26 '16 at 18:33

0 Answers0