Package org.jvnet.hk2.component

Examples of org.jvnet.hk2.component.Habitat


    }

    public Map<String, Object> pingJdbcConnectionPool(final String poolName)
    {
        final Map<String, Object> result = new HashMap<String, Object>();
        final Habitat habitat = getHabitat();
        ConnectorRuntime connRuntime = null;

        result.put(PING_SUCCEEDED_KEY, false);
        if (habitat == null)
        {
            result.put(REASON_FAILED_KEY, "Habitat is null");
            return result;
        }

        // check pool name
        final Resources resources = getDomainRootProxy().child(Domain.class).getResources();

        final Map<String, JdbcConnectionPool> pools = resources.childrenMap(JdbcConnectionPool.class);
        final JdbcConnectionPool cfg = pools.get(poolName);
        if (cfg == null)
        {
            result.put(REASON_FAILED_KEY, "The JdbcConnectionPool \"" + poolName + "\" does not exist");
            return result;
        }

        // get connector runtime
        try
        {
            connRuntime = habitat.getComponent(ConnectorRuntime.class, null);
        }
        catch (final ComponentException e)
        {
            result.putAll(ExceptionUtil.toMap(e));
            result.put(REASON_FAILED_KEY, ExceptionUtil.toString(e));
View Full Code Here


    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
        stream.defaultReadObject();

        //Initialize the transients that were passed at ctor.
        Habitat defaultHabitat = Globals.getDefaultHabitat();
        txManager     = defaultHabitat.getByContract(TransactionManager.class);
        invMgr        = defaultHabitat.getByContract(InvocationManager.class);
        compEnvMgr    = defaultHabitat.getByContract(ComponentEnvManager.class);
        callFlowAgent = defaultHabitat.getByContract(CallFlowAgent.class);
    }
View Full Code Here

    @Override                        
    public Habitat createHabitat(String name) throws ComponentException {

        StartupContext sc = startupContext;
        Habitat habitat = super.newHabitat();

        if (startupContext==null) {
            sc = new StartupContext(new Properties());
        }
        super.createHabitat("default", habitat);
        habitat.add(Inhabitants.create(sc));
        return habitat;
    }
View Full Code Here

    /**
     * Creates an uninitialized {@link Habitat}
     *
     */
    public Habitat newHabitat() throws ComponentException {
        Habitat habitat = new Habitat();
        initializeHabitat(habitat);
        return habitat;
    }
View Full Code Here

     *      Determines which inhabitants descriptors are loaded.
     *      (so that different parallel habitats can be
     *      created over the same modules registry.)
     */
    public Habitat createHabitat(String name) throws ComponentException {
        Habitat h = newHabitat();
        return createHabitat(name, h);
    }
View Full Code Here

        return createHabitat(name, createInhabitantsParser(h));
    }

    public Habitat createHabitat(String name, InhabitantsParser parser) throws ComponentException {
        try {
            Habitat habitat = parser.habitat;

            for (final Module module : getModules())
                parseInhabitants(module, name,parser);

            populateConfig(habitat);

            // default modules registry is the one that created the habitat
            habitat.addIndex(new ExistingSingletonInhabitant<ModulesRegistry>(this),
                    ModulesRegistry.class.getName(), null);
            habitats.put(name, habitat);

            habitat.initialized();
           
            return habitat;
        } catch (Exception e) {
            throw new ComponentException("Failed to create a habitat",e);
        }
View Full Code Here

            for( String name : spi.providerNames )
                providers.put(name,newModule);
        }
        for (Map.Entry<String, Habitat> entry : habitats.entrySet()) {
            String name = entry.getKey();
            Habitat h = entry.getValue();
            try
            {
                // TODO: should get the inhabitantsParser out of Main instead since
                // this could have been overridden
                parseInhabitants(newModule, name, createInhabitantsParser(h));
View Full Code Here

    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
        stream.defaultReadObject();

        //Initialize the transients that were passed at ctor.
        Habitat defaultHabitat = Globals.getDefaultHabitat();
        invMgr        = defaultHabitat.getByContract(InvocationManager.class);
        compEnvMgr    = defaultHabitat.getByContract(ComponentEnvManager.class);
    }
View Full Code Here

                }
            };

            // Install the all-trusting trust manager
            SSLContext sc = SSLContext.getInstance(SSL);
            Habitat habitat = Globals.getDefaultHabitat();
            SSLUtils sslUtils = habitat.getComponent(SSLUtils.class);
            sc.init(sslUtils.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());

            //---------------------------------
            url = new URL(HTTPS_PROTOCOL, _lbHost, Integer.parseInt(_lbPort), contextRoot);
            if (_lbProxyHost != null && _lbProxyPort != null) {
View Full Code Here

                }
            };

            // Install the all-trusting trust manager
            SSLContext sc = SSLContext.getInstance(TLS);
            Habitat habitat = Globals.getDefaultHabitat();
            SSLUtils sslUtils = habitat.getComponent(SSLUtils.class);
            sc.init(sslUtils.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());

            //---------------------------------
            url = new URL(HTTPS_PROTOCOL, _lbHost, Integer.parseInt(_lbPort), contextRoot);
            if (_lbProxyHost != null && _lbProxyPort != null) {
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.component.Habitat

Copyright © 2018 www.massapicom. 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.