Examples of ExistingSingletonInhabitant


Examples of com.sun.hk2.component.ExistingSingletonInhabitant

      private final CopyOnWriteArrayList<HabitatListener> listeners =
          new CopyOnWriteArrayList<HabitatListener>();
      private volatile boolean released;

      protected ListenersByTypeInhabitant(String name) {
        super(new ExistingSingletonInhabitant(ListenersByTypeInhabitant.class, null));
        this.name = name;
      }
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

    }

    @SuppressWarnings("unchecked")
    public void initialize(T t, Inhabitant onBehalfOf) throws ComponentException {
        super.initialize(t, onBehalfOf);
        builder.onEntered(new ExistingSingletonInhabitant(t));
    }
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

        // create a habitat and initialize them
        Habitat habitat = registry.newHabitat();
        habitat.add(new ExistingSingletonInhabitant<StartupContext>(context));
        habitat.add(new ExistingSingletonInhabitant<Logger>(Logger.global));
        // the root registry must be added as other components sometimes inject it
        habitat.add(new ExistingSingletonInhabitant(ModulesRegistry.class, registry));
        final ClassLoader oldCL = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
            @Override
            public ClassLoader run() {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

        // Bootstrap a hk2 environment.
        ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader());
        habitat = registry.createHabitat("default");

        StartupContext startupContext = new StartupContext();
        habitat.add(new ExistingSingletonInhabitant(startupContext));

        habitat.addComponent(null, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other));
    }
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

                    if (name == null) {
                        // let's get a name if possible, that will only work with Spring OSGi services
                        // we may need to find a better way to get a potential name.
                        name = (String) reference.getProperty("org.springframework.osgi.bean.name");
                    }
                    habitat.addIndex(new ExistingSingletonInhabitant(object), contractName, name);
                    if (logger.isLoggable(Level.FINE)) {
                        String objectDetails = object.toString();
                        logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
                            "addingService", "registering service = {0}, contract = {1}, name = {2}", new Object[]{
                                    objectDetails, contractName, name});
                    }
                }
            } else {
                // this service does not implement a specific contract, let's register it by its type.
                habitat.add(new ExistingSingletonInhabitant(object));
                if (logger.isLoggable(Level.FINE)) {
                    String objectDetails = object.toString();
                    logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
                        "addingService", "registering service = {0}", objectDetails);
                }
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

                    if (name == null) {
                        // let's get a name if possible, that will only work with Spring OSGi services
                        // we may need to find a better way to get a potential name.
                        name = (String) reference.getProperty("org.springframework.osgi.bean.name");
                    }
                    habitat.addIndex(new ExistingSingletonInhabitant(object), contractName, name);
                    if (logger.isLoggable(Level.FINE)) {
                        String objectDetails = object.getClass().getName()+"@"+
                            Integer.toHexString(
                                System.identityHashCode(object));
                        logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
                            "addingService", "registering service = {0}, contract = {1}, name = {2}", new Object[]{
                                    objectDetails, contractName, name});
                    }
                }
            } else {
                // this service does not implement a specific contract, let's register it by its type.
                habitat.add(new ExistingSingletonInhabitant(object));
                if (logger.isLoggable(Level.FINE)) {
                    String objectDetails = object.getClass().getName()+"@"+
                        Integer.toHexString(System.identityHashCode(object));
                    logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
                        "addingService", "registering service = {0}", objectDetails);
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

             * with the ACC one.
             */
            habitat.removeAllByType(StartupContext.class);
           
            StartupContext startupContext = new ACCStartupContext();
            habitat.add(new ExistingSingletonInhabitant(StartupContext.class, startupContext));
            /*
             * Following the example from AppServerStartup, remove any
             * pre-loaded lazy inhabitant for ProcessEnvironment that exists
             * from HK2's scan for services.  Then add in
             * an ACC ProcessEnvironment.
View Full Code Here

Examples of com.sun.hk2.component.ExistingSingletonInhabitant

    }

    static private Habitat getHabitat() {
        Habitat habitat = Globals.getStaticHabitat();
        StartupContext startupContext = new StartupContext();
        habitat.add(new ExistingSingletonInhabitant(startupContext));

        habitat.addComponent(null, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other));
        return habitat;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.