Examples of Habitat


Examples of org.jvnet.hk2.component.Habitat

        if (ServletContext.class.isAssignableFrom( spiType)) {
            return (T)servletContext;
        }
       
        if (ServerPipelineHook.class.isAssignableFrom(spiType)){
            Habitat h = Globals.getDefaultHabitat();
            ServerPipeCreator s = h.getByContract(ServerPipeCreator.class);
            s.init(endpoint);
            return((T)s);
        }

        if (ResourceInjector.class.isAssignableFrom(spiType)) {
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

                GlassFish server = runtime.newGlassFish(glassFishProperties);
                if (l.instance_root != null && !l.reuse_instance_location) {
                    // XXX Start the server to get the services
                    server.start();
                    EmbeddedSecurity es = server.getService(EmbeddedSecurity.class);
                    Habitat habitat = server.getService(Habitat.class);

                    // XXX Wait a little before stopping to avoid a deadlock
                    Thread.sleep(1000);
                    server.stop();
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

        }
        tldListenerMap.putAll(appLibTldMap);
        servletContext.setAttribute(
            "com.sun.appserv.tldlistener.map", tldListenerMap);

        Habitat defaultHabitat =
                webContainer.getServerContext().getDefaultHabitat();

        // set habitat for jsf injection
        servletContext.setAttribute(
                Constants.HABITAT_ATTRIBUTE, defaultHabitat);

        SunWebApp bean = webModule.getIasWebAppConfigBean();

        // Find the default jsp servlet
        Wrapper wrapper = (Wrapper) webModule.findChild(
            org.apache.catalina.core.Constants.JSP_SERVLET_NAME);
        if (wrapper == null) {
            return;
        }

        if (webModule.getTldValidation()) {
            wrapper.addInitParameter("enableTldValidation", "true");
        }
        if (bean != null && bean.getJspConfig()  != null) {
            WebProperty[]  props = bean.getJspConfig().getWebProperty();
            for (int i = 0; i < props.length; i++) {
                String pname = props[i].getAttributeValue("name");
                String pvalue = props[i].getAttributeValue("value");
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("jsp-config property for [" +
                                 webModule.getID() + "] is [" + pname +
                                 "] = [" + pvalue + "]");
                }
                wrapper.addInitParameter(pname, pvalue);
            }
        }
          
        // Override any log setting with the container wide logging level
        wrapper.addInitParameter("logVerbosityLevel",getJasperLogLevel());

        ResourceInjectorImpl resourceInjector = new ResourceInjectorImpl(
            webModule);
        servletContext.setAttribute(
                "com.sun.appserv.jsp.resource.injector",
                resourceInjector);

        // START SJSAS 6311155
        String sysClassPath = ASClassLoaderUtil.getModuleClassPath(
            defaultHabitat,
            webModule.getID(), null
        );
        // If the configuration flag usMyFaces is set, remove javax.faces.jar
        // and from the system class path
        Boolean useMyFaces = (Boolean)
            servletContext.getAttribute("com.sun.faces.useMyFaces");
        if (useMyFaces != null && useMyFaces) {
            sysClassPath =
                sysClassPath.replace("javax.faces.jar", "$disabled$.raj");
            // jsf-connector.jar manifest has a Class-Path to javax.faces.jar
            sysClassPath =
                sysClassPath.replace("jsf-connector.jar", "$disabled$.raj");
        }
        // TODO: combine with classpath from
        // servletContext.getAttribute(("org.apache.catalina.jsp_classpath")
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine(" sysClasspath for " + webModule.getID() + " is \n"  +
                sysClassPath + "\n");
        }
        if (sysClassPath.equals("")) {
            // In embedded mode, habitat returns SingleModulesRegistry and
            // it has no modules.
            // Try "java.class.path" system property instead.
            sysClassPath = System.getProperty("java.class.path");
        }
        sysClassPath = trimSysClassPath(sysClassPath);
        wrapper.addInitParameter("com.sun.appserv.jsp.classpath",
            sysClassPath);
        // END SJSAS 6311155

        // Configure JSP monitoring
        servletContext.setAttribute(
            "org.glassfish.jsp.monitor.probeEmitter",
            new JspProbeEmitterImpl(webModule));

        // Pass BeanManager's ELResolver as ServletContext attribute
        // (see IT 11168)
        InvocationManager invocationMgr =
            webContainer.getInvocationManager();
        WebComponentInvocation inv = new WebComponentInvocation(webModule);
        try {
            invocationMgr.preInvoke(inv);
            JCDIService jcdiService = defaultHabitat.getByContract(JCDIService.class);
            // JCDIService can be absent if weld integration is missing in the runtime, so check for null is needed.
            if (jcdiService != null && jcdiService.isCurrentModuleJCDIEnabled()) {
                jcdiService.setELResolver(servletContext);
            }
        } catch (NamingException e) {
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

        if (habitats.containsKey(fileName))  {
           return habitats.get(fileName);
        }

        Habitat habitat = getNewHabitat(test);
        habitats.put(fileName, habitat);
        return habitat;
    }
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

        return habitat;
    }

    public static synchronized Habitat getNewHabitat(final ConfigApiTest test) {

        final Habitat habitat = getNewHabitat();

        final String fileName = test.getFileName();


        ConfigParser configParser = new ConfigParser(habitat);

        (new Populator() {

            public void run(ConfigParser parser) {
                long now = System.currentTimeMillis();
                URL url = getClass().getClassLoader().getResource(fileName + ".xml");
                if (url != null) {
                    try {
                        DomDocument document = parser.parse(url,  test.getDocument(habitat));
                        habitat.addComponent("document", document);
                    } catch(Exception e) {
                        e.printStackTrace();
                    }
                    Logger.getAnonymousLogger().fine("time to parse domain.xml : " + String.valueOf(System.currentTimeMillis() - now));
                }
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

     public static void initialize(Client client){
        if (client == null){
            client = JERSEY_CLIENT;
        }
        try{
            Habitat habitat = SecurityServicesUtil.getInstance().getHabitat();
            SecureAdmin secureAdmin = habitat.getComponent(SecureAdmin.class);
            HTTPSProperties httpsProperties = new HTTPSProperties(new BasicHostnameVerifier(),
                habitat.getComponent(SSLUtils.class).getAdminSSLContext(SecureAdmin.Util.DASAlias(secureAdmin), null ));
            client.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
            client.addFilter(new CsrfProtectionFilter());
        }catch(Exception ex){
            GuiUtil.getLogger().warning("RestUtil.initialize() failed");
            if (GuiUtil.getLogger().isLoggable(Level.FINE)){
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

    /**
     * Return instance with all injected values from deserialization if possible
     */
    Object readResolve() throws ObjectStreamException {
        Habitat h = Globals.getDefaultHabitat();
        if (h != null) {
            return h.getComponent(UserTransactionImpl.class);
        }

        return this;
    }
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

//        Issue 13108 (Cycle in our component chain involving GlassFishNamingManager
//        and TransactionNamingProxy).  Comment out the publishing of "UserTransaction"
//        and related field injections to break the circular dependency.

        if( processEnv.getProcessType().isServer()) {
            final Habitat h = habitat;
            // made the lookup of the naming manager asynchronous to avoid getting
            // in an infinite cyclic dependency (see IT 13108). By making the lookup
            // asynchronous, we ensure the NamingManager implementation has finished
            // initializing in *this* thread before getting returned by the
            // getComponent() call below.
            es.submit(new Runnable() {
                @Override
                public void run() {
                    GlassfishNamingManager namingMgr = h.getComponent(GlassfishNamingManager.class);
                    try {
                        namingMgr.publishObject(USER_TX_NO_JAVA_COMP,
                            new UserTransactionProxy(), true);
                    } catch (NamingException e) {
                       logger.warning("Can't bind \"UserTransaction\" in JNDI");
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

    private static final String SERVICES_FACES_CONFIG = "META-INF/services/faces-config.xml";

    public Collection<URI> getResources(ServletContext context) {

        Habitat defaultHabitat = (Habitat)context.getAttribute(
                HABITAT_ATTRIBUTE);
        invokeMgr = defaultHabitat.getByContract(InvocationManager.class);
        ComponentInvocation inv = invokeMgr.getCurrentInvocation();
        WebModule webModule = (WebModule)inv.getContainer();
        WebBundleDescriptor wdesc = webModule.getWebBundleDescriptor();

        List<URI> list = new ArrayList<URI>(1);
View Full Code Here

Examples of org.jvnet.hk2.component.Habitat

    public <T> void aroundInject(InjectionContext<T> injectionContext) {

        try {


            Habitat h = Globals.getDefaultHabitat();
            ComponentEnvManager compEnvManager = (ComponentEnvManager) h.getByContract(ComponentEnvManager.class);

            EjbContainerServices containerServices = h.getByContract(EjbContainerServices.class);

            JndiNameEnvironment componentEnv = compEnvManager.getCurrentJndiNameEnvironment();

            ManagedBeanDescriptor mbDesc = null;
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.