Package org.jboss.as.naming

Examples of org.jboss.as.naming.NamingStore


                    ObjectFactoryBuilder.INSTANCE.setServiceRegistry(context.getServiceRegistry());

                    NamingContext.initializeNamingManager();

                    final NamingStore namingStore = new InMemoryNamingStore(new NamingEventCoordinator());

                    // Create the Naming Service
                    final ServiceTarget target = context.getServiceTarget();
                        target.addService(NamingService.SERVICE_NAME, new NamingService(namingStore))
                            .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME)
View Full Code Here


     *
     * @param context The start context
     * @throws StartException If the entity can not be bound
     */
    public synchronized void start(StartContext context) throws StartException {
        final NamingStore namingStore = namingStoreValue.getValue();
        try {
            final Reference reference = ManagedReferenceObjectFactory.createReference(context.getController().getName());
            final Name name = NameParser.INSTANCE.parse(this.name);
            namingStore.bindCreatingParents(null, name, reference, Reference.class.getName());
        } catch (NamingException e) {
            throw new StartException("Failed to bind resource into naming store [" + namingStore + "] at location [" + name + "]", e);
        }
    }
View Full Code Here

     * Unbind the entry from the injected context.
     *
     * @param context The stop context
     */
    public synchronized void stop(StopContext context) {
        final NamingStore namingStore = namingStoreValue.getValue();
        try {
            namingStore.unbind(null, NameParser.INSTANCE.parse(name));
        } catch (NamingException e) {
            throw new IllegalStateException("Failed to unbind resource from naming store [" + namingStore + "] at location [" + name + "]", e);
        }
    }
View Full Code Here

                .addListener(verificationHandler)
                .install());

        NamespaceContextSelector.setDefault(new NamespaceContextSelector() {
            public Context getContext(String identifier) {
                final NamingStore namingStore;
                if (identifier.equals("global")) {
                    namingStore = globalNamingStore;
                } else if (identifier.equals("jboss")) {
                    namingStore = jbossNamingStore;
                } else {
                    namingStore = null;
                }
                if (namingStore != null) {
                    try {
                        return (Context) namingStore.lookup(EMPTY_NAME);
                    } catch (NamingException e) {
                        throw new IllegalStateException(e);
                    }
                } else {
                    return null;
View Full Code Here

                    final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);

                    final ModelNode contextsNode = resultNode.get("java: contexts");

                    final ServiceController<?> javaContextService = serviceRegistry.getService(ContextNames.JAVA_CONTEXT_SERVICE_NAME);
                    final NamingStore javaContextNamingStore = NamingStore.class.cast(javaContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:"), new NamingContext(javaContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set(MESSAGES.failedToReadContextEntries("java:")));
                    }

                    final ServiceController<?> jbossContextService = serviceRegistry.getService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
                    final NamingStore jbossContextNamingStore = NamingStore.class.cast(jbossContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:jboss"), new NamingContext(jbossContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set(MESSAGES.failedToReadContextEntries("java:jboss")));
                    }

                    final ServiceController<?> globalContextService = serviceRegistry.getService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
                    final NamingStore globalContextNamingStore = NamingStore.class.cast(globalContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:global"), new NamingContext(globalContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set(MESSAGES.failedToReadContextEntries("java:global")));
                    }
View Full Code Here

     *
     * @param context The start context
     * @throws StartException If the entity can not be bound
     */
    public synchronized void start(StartContext context) throws StartException {
        final NamingStore namingStore = namingStoreValue.getValue();
        try {
            ServiceController<?> controller = context.getController();
            this.controller = controller;
            final Reference reference = ManagedReferenceObjectFactory.createReference(controller.getName());
            final Name name = NameParser.INSTANCE.parse(this.name);
            namingStore.bind(name, reference);
            logger.tracef("Bound resource %s into naming store %s", name, namingStore);
        } catch (NamingException e) {
            throw new StartException("Failed to bind resource into naming store [" + namingStore + "] at location [" + name + "]", e);
        }
    }
View Full Code Here

     * Unbind the entry from the injected context.
     *
     * @param context The stop context
     */
    public synchronized void stop(StopContext context) {
        final NamingStore namingStore = namingStoreValue.getValue();
        try {
            namingStore.unbind(NameParser.INSTANCE.parse(name));
        } catch (NamingException e) {
            throw new IllegalStateException("Failed to unbind resource from naming store [" + namingStore + "] at location [" + name + "]", e);
        }
    }
View Full Code Here

        log.info("Activating Naming Subsystem");

        NamingContext.initializeNamingManager();

        final NamingStore namingStore = new InMemoryNamingStore(new NamingEventCoordinator());

        // Create the Naming Service
        final ServiceTarget target = context.getServiceTarget();
        newControllers.add(target.addService(NamingService.SERVICE_NAME, new NamingService(namingStore))
                .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME)
                .setInitialMode(ServiceController.Mode.ACTIVE)
                .addListener(verificationHandler)
                .install());

        // Create the java:global namespace
        final NamingStore globalNamingStore = new InMemoryNamingStore();
        newControllers.add(target.addService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, new NamingStoreService(globalNamingStore))
                .setInitialMode(ServiceController.Mode.ACTIVE)
                .addListener(verificationHandler)
                .install());

        // Create the java:jboss vendor namespace
        final NamingStore jbossNamingStore = new InMemoryNamingStore();
        newControllers.add(target.addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, new NamingStoreService(jbossNamingStore))
                .setInitialMode(ServiceController.Mode.ACTIVE)
                .addListener(verificationHandler)
                .install());

        NamespaceContextSelector.setDefault(new NamespaceContextSelector() {
            public Context getContext(String identifier) {
                final NamingStore namingStore;
                if(identifier.equals("global")){
                    namingStore = globalNamingStore;
                } else if(identifier.equals("jboss")) {
                    namingStore = jbossNamingStore;
                } else {
                    namingStore = null;
                }
                if (namingStore != null) {
                    try {
                        return (Context) namingStore.lookup(EMPTY_NAME);
                    } catch (NamingException e) {
                        throw new IllegalStateException(e);
                    }
                } else {
                    return null;
View Full Code Here

                    final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);

                    final ModelNode contextsNode = resultNode.get("java: contexts");

                    final ServiceController<?> javaContextService = serviceRegistry.getService(ContextNames.JAVA_CONTEXT_SERVICE_NAME);
                    final NamingStore javaContextNamingStore = NamingStore.class.cast(javaContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:"), new NamingContext(javaContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set("Failed to read java: context entries."));
                    }

                    final ServiceController<?> jbossContextService = serviceRegistry.getService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
                    final NamingStore jbossContextNamingStore = NamingStore.class.cast(jbossContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:jboss"), new NamingContext(jbossContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set("Failed to read java:jboss context entries."));
                    }

                    final ServiceController<?> globalContextService = serviceRegistry.getService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
                    final NamingStore globalContextNamingStore = NamingStore.class.cast(globalContextService.getValue());
                    try {
                        addEntries(contextsNode.get("java:global"), new NamingContext(globalContextNamingStore, null));
                    } catch (NamingException e) {
                        throw new OperationFailedException(e, new ModelNode().set("Failed to read java:global context entries."));
                    }
View Full Code Here

            return null;
        }
    }

    public Context getContext(final String identifier) {
        NamingStore namingStore = getNamingStore(identifier);
        if (namingStore != null) {
            try {
                return (Context) namingStore.lookup(EMPTY_NAME);
            } catch (NamingException e) {
                throw new IllegalStateException(e);
            }
        } else {
            return null;
View Full Code Here

TOP

Related Classes of org.jboss.as.naming.NamingStore

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.