Package org.rioproject.opstring

Examples of org.rioproject.opstring.ServiceBeanConfig


    private ServiceElement makeServiceElement(String name) {
        ServiceElement elem = new ServiceElement();
        ClassBundle main = new ClassBundle("");
        elem.setComponentBundle(main);
        ServiceBeanConfig sbc = new ServiceBeanConfig();
        sbc.setName(name);
        elem.setServiceBeanConfig(sbc);
        return elem;
    }
View Full Code Here


        String jmxName = (String)config.getEntry(configComponent, "jmxName", String.class, null);
        if(jmxName!=null)
            configParms.put(ServiceBeanConfig.JMX_NAME, jmxName);

        ServiceBeanConfig sbConfig = new ServiceBeanConfig(configParms, configArgs);
        sbConfig.addInitParameter(BOOT_CONFIG_COMPONENT, configComponent);

        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if(cl instanceof ServiceClassLoader) {
            Properties p = new Properties();
            p.setProperty("opStringName", sbConfig.getOperationalStringName());
            p.setProperty("serviceName", sbConfig.getName());
            ((ServiceClassLoader)cl).addMetaData(p);
        }

        /* Add a boot-cookie, indicating that the JSB was booted by this utility */
        sbConfig.addInitParameter("org.rioproject.boot", BOOT_COOKIE);
        ServiceLevelAgreements sla = new ServiceLevelAgreements();
        /* Get the export codebase from the ClassLoader which loaded us. The
         * export codebase will be returned by the getURLs() method since
         * getURLs() is overridden to return configured export codebase
         */
 
View Full Code Here

                try {
                    String codebase = "http://"+HostUtil.getHostAddressFromProperty(Constants.RMI_HOST_ADDRESS)+":9010";
                    elem.setExportBundles(makeClassBundle(Dummy.class.getName(), codebase));
                    elem.setComponentBundle(makeClassBundle(DummyImpl.class.getName(), codebase));

                    ServiceBeanConfig sbc = new ServiceBeanConfig();
                    sbc.setName("Add");
                    sbc.setGroups(System.getProperty("org.rioproject.groups"));
                    sbc.setOperationalStringName("association stuff");
                    elem.setServiceBeanConfig(sbc);

                    logger.info("Wait 5 seconds to deploy another dummy...");
                    Thread.sleep(5*1000);
                    logger.info("Deploying another dummy...");
View Full Code Here

            elem = copyServiceElement(sElem);
       
        /* set the instance id */
        Map<String, Object> parms = elem.getServiceBeanConfig().getConfigurationParameters();
        parms.put(ServiceBeanConfig.INSTANCE_ID, id);
        ServiceBeanConfig sbConfig = new ServiceBeanConfig(parms, elem.getServiceBeanConfig().getConfigArgs());
        /* Get the initialization parameters and add them */
        Map<String, Object> initParms = elem.getServiceBeanConfig().getInitParameters();
        for (Map.Entry<String, Object> e : initParms.entrySet()) {
            sbConfig.addInitParameter(e.getKey(), e.getValue());
        }
        if(!elem.getServiceBeanConfig().getAdditionalEntries().isEmpty()) {
            List<Entry> entries = elem.getServiceBeanConfig().getAdditionalEntries();
            sbConfig.addAdditionalEntries(entries.toArray(new Entry[entries.size()]));
        }
        elem.setServiceBeanConfig(sbConfig);       
        return(elem);
    }
View Full Code Here

     * @param sElem The ServiceElement to copy
     *
     * @return A new ServiceElement
     */
    public static ServiceElement copyServiceElement(ServiceElement sElem) {
        ServiceBeanConfig oldSBC = sElem.getServiceBeanConfig();
        ServiceBeanConfig sbc = new ServiceBeanConfig(oldSBC.getConfigurationParameters(), oldSBC.getConfigArgs());
        for(Map.Entry<String, Object> entry : oldSBC.getInitParameters().entrySet()) {
            sbc.addInitParameter(entry.getKey(), entry.getValue());
        }
        sbc.addLoggerConfig(oldSBC.getLoggerConfigs());
        if(!oldSBC.getAdditionalEntries().isEmpty()) {
            List<Entry> entries = oldSBC.getAdditionalEntries();
            sbc.addAdditionalEntries(entries.toArray(new Entry[entries.size()]));
        }
        ServiceElement elem = new ServiceElement(sElem.getProvisionType(),
                                                 sbc,
                                                 sElem.getServiceLevelAgreements(),
                                                 sElem.getExportBundles(),
View Full Code Here

                                                       final Integer value) {
        if(sbc == null || key == null || value == null)
            throw new IllegalArgumentException("parameters cannot be null");
        Map<String, Object> configParms = sbc.getConfigurationParameters();
        configParms.put(key, value);
        ServiceBeanConfig newConfig = new ServiceBeanConfig(configParms, sbc.getConfigArgs());
        Map<String, Object> initParms = sbc.getInitParameters();

        for (Map.Entry<String, Object> e : initParms.entrySet()) {
            newConfig.addInitParameter(e.getKey(), e.getValue());
        }
        if(!sbc.getAdditionalEntries().isEmpty()) {
            List<Entry> entries = sbc.getAdditionalEntries();
            newConfig.addAdditionalEntries(entries.toArray(new Entry[entries.size()]));
        }
        return (newConfig);
    }
View Full Code Here

     * using the ServiceBeanManager
     *
     * @param groups Array of groups names to set
     */
    private void setGroups(String[] groups) {
        ServiceBeanConfig sbConfig = service.getServiceBeanContext().getServiceBeanConfig();
        sbConfig.setGroups(groups);
        try {
            service.getServiceBeanContext().getServiceBeanManager().update(sbConfig);
        } catch(Exception e) {
            logger.warn("Setting groups", e);
        }
View Full Code Here

     * ServiceBeanConfig using the ServiceBeanManager
     *
     * @param locators Array of LookupLocator names to set
     */
    private void setLocators(LookupLocator[] locators) {
        ServiceBeanConfig sbConfig =  service.getServiceBeanContext().getServiceBeanConfig();
        sbConfig.setLocators(locators);
        try {
            service.getServiceBeanContext().getServiceBeanManager().update(sbConfig);
        } catch(Exception e) {
            logger.warn("Setting LookupLocators", e);
        }
View Full Code Here

            ObjectInputStream oistream = new ObjectInputStream(in);
            if(!logDirName.equals(oistream.readUTF()))
                throw new IOException("log from wrong implementation");
            DefaultServiceBeanContext serviceBeanContext = (DefaultServiceBeanContext)oistream.readObject();
            ServiceElement sElem = serviceBeanContext.getServiceElement();
            ServiceBeanConfig sAttr = sElem.getServiceBeanConfig();
            try {
                String[] groups = (String[])oistream.readObject();
                LookupLocator[] locators = (LookupLocator[])oistream.readObject();
                sAttr.setGroups(groups);
                sAttr.setLocators(locators);
            } catch(Throwable t) {
                logger.error("Couldnt get groups or locators", t);
            }
            sElem.setServiceBeanConfig(sAttr);
            serviceBeanContext.setServiceElement(sElem);
View Full Code Here

    }

    @Test(expected = IOException.class)
    public void testAllGroupsFail() throws Exception {
        ServiceElement service = new ServiceElement();
        ServiceBeanConfig serviceBeanConfig = new ServiceBeanConfig();
        serviceBeanConfig.setGroups("all");
        service.setServiceBeanConfig(serviceBeanConfig);
        deploymentVerifier.ensureGroups(service);
    }
View Full Code Here

TOP

Related Classes of org.rioproject.opstring.ServiceBeanConfig

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.