Package org.apache.geronimo.gbean

Examples of org.apache.geronimo.gbean.GBeanData


        }

        FileInputStream fis = new FileInputStream(file);
        try {
            ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(fis));
            GBeanData config = new GBeanData();
            try {
                config.readExternal(ois);
            } catch (ClassNotFoundException e) {
                //TODO more informative exceptions
                throw new InvalidConfigException("Unable to read attribute ", e);
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to set attribute ", e);
            }
            config.setReferencePattern("ConfigurationStore", objectName);
            return config;
        } finally {
            fis.close();
        }
    }
View Full Code Here


    public void register(GBeanData gbean) {
        registry.put(gbean.getName(), gbean);
    }

    public synchronized GBeanData getGBeanInstance(ObjectName name) throws GBeanNotFoundException {
        GBeanData gbeanData = (GBeanData) registry.get(name);
        if (gbeanData == null) {
            throw new GBeanNotFoundException(name);
        }
        return gbeanData;
    }
View Full Code Here

    }

    public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream out) throws IOException, InvalidConfigException {

        // convert the configuration data to a gbeandata object
        GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);

        // save the persisted form in the source directory
        out.putNextEntry(new ZipEntry("META-INF/config.ser"));
        ObjectOutputStream objectOutputStream = null;
        try {
            objectOutputStream = new ObjectOutputStream(out);
            configurationGBeanData.writeExternal(objectOutputStream);
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw new InvalidConfigException("Unable to save configuration state", e);
        } finally {
View Full Code Here

        }
    }

    public static void writeConfiguration(ConfigurationData configurationData, File source) throws InvalidConfigException, IOException {
        // convert the configuration data to a gbeandata object
        GBeanData configurationGBeanData = getConfigurationGBeanData(configurationData);

        // save the persisted form in the source directory
        File metaInf = new File(source, "META-INF");
        metaInf.mkdirs();
        File configSer = new File(metaInf, "config.ser");
        ObjectOutputStream out = null;
        try {
            out = new ObjectOutputStream(new FileOutputStream(configSer));
            try {
                configurationGBeanData.writeExternal(out);
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to save configuration state", e);
            }
View Full Code Here

    }

    public static GBeanData getConfigurationGBeanData(ConfigurationData configurationData) throws InvalidConfigException {
        try {
            URI id = configurationData.getId();
            GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
            config.setAttribute("id", id);
            config.setAttribute("type", configurationData.getModuleType());
            config.setAttribute("domain", configurationData.getDomain());
            config.setAttribute("server", configurationData.getServer());

            List parentId = configurationData.getParentId();
            if (parentId.size() > 0) {
                config.setAttribute("parentId", parentId.toArray(new URI[parentId.size()]));
            }

            config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
            config.setReferencePatterns("Repositories", Collections.singleton(new ObjectName("*:name=Repository,*")));
            config.setAttribute("dependencies", configurationData.getDependencies());
            config.setAttribute("classPath", configurationData.getClassPath());

            return config;
        } catch (MalformedObjectNameException e) {
            throw new InvalidConfigException(e);
        }
View Full Code Here

        try {
            Properties props = new Properties();
            props.put("jbiType", "Deployment");
            props.put("name", configID.toString());
            ObjectName name = ObjectName.getInstance(context.getDomain(), props);
            GBeanData gbeanData = new GBeanData(name, ServiceMixDeployment.GBEAN_INFO);

            context.addGBean(gbeanData);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException("Invalid gbean name: " + e, e);
        }
View Full Code Here

     * @return a copy of the configurations GBeanData
     * @deprecated Currently used only in some tests, and may not be appropriate as a public method.
     */
    public GBeanData getConfigurationGBeanData() throws MalformedObjectNameException, InvalidConfigException {
        URI id = configurationData.getId();
        GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
        config.setAttribute("id", id);
        config.setAttribute("type", configurationData.getModuleType());
        config.setAttribute("domain", configurationData.getDomain());
        config.setAttribute("server", configurationData.getServer());

        List parentId = configurationData.getParentId();
        if (parentId != null) {
            config.setAttribute("parentId", parentId.toArray(new URI[parentId.size()]));
        }

        config.setAttribute("gBeanState", Configuration.storeGBeans(gbeans.getGBeans()));
        config.setReferencePatterns("Repositories", Collections.singleton(new ObjectName("*:name=Repository,*")));
        config.setAttribute("dependencies", configurationData.getDependencies());
        config.setAttribute("classPath", configurationData.getClassPath());

        return config;
    }
View Full Code Here

        return principal;
    }

    public static GBeanData configureApplicationPolicyManager(ObjectName name, Map contextIDToPermissionsMap, SecurityConfiguration securityConfiguration) {
        GBeanData jaccBeanData = new GBeanData(name, ApplicationPolicyConfigurationManager.GBEAN_INFO);
        jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap);
        jaccBeanData.setAttribute("principalRoleMap", securityConfiguration.getPrincipalRoleMap());
        jaccBeanData.setAttribute("roleDesignates", securityConfiguration.getRoleDesignates());
        return jaccBeanData;
    }
View Full Code Here

    throws BeansException
  {
    // create a GBean peer...
    try
    {
      GBeanData gd=createPOJOGBeanData(bean, name);
      if (gd==null)
        _log.warn("No GBean available for name: " + name + " bean: " + bean);
      else
      {
  _log.info("proxying: "+bean);
  _log.info("loading: "+gd.getName());
  //        _kernel.loadGBeanProxy(bean, gd, _appClassLoader);
        _kernel.loadGBean(gd, _appClassLoader);
  _log.info("starting: "+gd.getName());
  _kernel.startGBean(gd.getName());
      }
    }
    catch (Exception e)
    {
      throw new BeanDefinitionValidationException("Could not load the GBean for name: " + name + " bean: " + bean + ". Reason: " + e, e);
View Full Code Here

            AddToSystemProperty(extensionDirs, extensionDirsFromManifest, geronimoInstallDirectory);


            // load this configuration
            ClassLoader classLoader = Daemon.class.getClassLoader();
            GBeanData configuration = new GBeanData();
            ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
            try {
                configuration.readExternal(ois);
            } finally {
                ois.close();
            }
            URI configurationId = (URI) configuration.getAttribute("id");
            ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
            configuration.setName(configName);

            // todo: JNB for now we clear out the dependency list but we really need a way to resolve them
            configuration.setAttribute("dependencies", Collections.EMPTY_LIST);

            // create a mbean server
            MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
            String mbeanServerId = (String) mbeanServer.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId");

            // create the kernel
            final Kernel kernel = KernelFactory.newInstance().createKernel("geronimo");

            // boot the kernel
            try {
                kernel.boot();
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(2);
                throw new AssertionError();
            }

            // load this configuration into the kernel
            kernel.loadGBean(configuration, classLoader);
            kernel.setAttribute(configName, "baseURL", classLoader.getResource("/"));

            // add our shutdown hook
            Runtime.getRuntime().addShutdownHook(new Thread("Shutdown Thread") {
                public void run() {
                    log.info("Server shutdown begun");
                    System.out.println("\rServer shutdown begun              ");
                    kernel.shutdown();
                    log.info("Server shutdown completed");
                    System.out.println("Server shutdown completed");
                }
            });

            // add the jmx bridge
            ObjectName mbeanServerKernelBridgeName = new ObjectName("geronimo.boot:role=MBeanServerKernelBridge");
            GBeanData mbeanServerKernelBridge = new GBeanData(mbeanServerKernelBridgeName, MBeanServerKernelBridge.GBEAN_INFO);
            mbeanServerKernelBridge.setAttribute("mbeanServerId", mbeanServerId);
            kernel.loadGBean(mbeanServerKernelBridge, classLoader);
            kernel.startGBean(mbeanServerKernelBridgeName);

            // start this configuration
            kernel.startRecursiveGBean(configuration.getName());
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gbean.GBeanData

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.