Package org.apache.openejb.server

Examples of org.apache.openejb.server.ServiceException


            String value = (String) p.get(property);

            if (property.startsWith(ServerConstants.SC_KEY_DBNAME + ".") ||
                    property.startsWith(ServerConstants.SC_KEY_DATABASE + ".")) {

                throw new ServiceException("Databases cannot be declared in the hsql.properties.  " +
                        "Instead declare a database connection in the openejb.conf file");
            }

            if ("port".equals(property)) {
                properties.setProperty(ServerConstants.SC_KEY_PORT, value);
            } else if ("bind".equals(property)) {
                properties.setProperty(ServerConstants.SC_KEY_ADDRESS, value);
            } else {
                properties.setProperty(property, value);
            }
        }
        properties.setProperty(ServerConstants.SC_KEY_NO_SYSTEM_EXIT, "true");

        boolean disabled = Boolean.parseBoolean(properties.getProperty("disabled"));
        if (!disabled) {
            NamingEnumeration<Binding> bindings = null;
            try {
                bindings = new InitialContext().listBindings("java:openejb/Resource/");
                int dbIndex = 0;
                for (Binding binding : Collections.list(bindings)) {
                    Object value = binding.getObject();
                    if (value instanceof ConnectorReference) {
                        Object connectionFactory = ((ConnectorReference)value).getObject();
                        if (connectionFactory instanceof JdbcConnectionFactory) {
                            JdbcConnectionFactory jdbc = (JdbcConnectionFactory) connectionFactory;
                            String path = getPath(jdbc);
                            if (path != null) {
                                if (dbIndex > 9) {
                                    throw new ServiceException("Hsql Server can only host 10 database connections");
                                }
                                String dbname = path.substring(path.lastIndexOf('/') + 1);
                                properties.put(ServerConstants.SC_KEY_DBNAME + "." + dbIndex, dbname);
                                properties.put(ServerConstants.SC_KEY_DATABASE + "." + dbIndex, path);
                                dbIndex++;
View Full Code Here


    public void start() throws ServiceException {
        if (disabled) return;
        try {
            broker.start();
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

            return;
        }
        try {
            broker.stop();
        } catch (Exception e) {
            throw new ServiceException(e);
        } finally {
            broker = null;
        }
    }
View Full Code Here

    public void start() throws ServiceException {
        if (disabled) return;
        try {
            broker.start();
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

            return;
        }
        try {
            broker.stop();
        } catch (Exception e) {
            throw new ServiceException(e);
        } finally {
            broker = null;
        }
    }
View Full Code Here

            String value = (String) entry.getValue();

            if (property.startsWith(ServerConstants.SC_KEY_DBNAME + ".") ||
                    property.startsWith(ServerConstants.SC_KEY_DATABASE + ".")) {

                throw new ServiceException("Databases cannot be declared in the hsql.properties.  " +
                        "Instead declare a database connection in the openejb.conf file");
            }

            if ("port".equals(property)) {
                properties.setProperty(ServerConstants.SC_KEY_PORT, value);
            } else if ("bind".equals(property)) {
                properties.setProperty(ServerConstants.SC_KEY_ADDRESS, value);
            } else {
                properties.setProperty(property, value);
            }
        }
        properties.setProperty(ServerConstants.SC_KEY_NO_SYSTEM_EXIT, "true");

        boolean disabled = Boolean.parseBoolean(properties.getProperty("disabled"));
        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
        if (!disabled && containerSystem != null) {
            NamingEnumeration<Binding> bindings = null;
            try {
                bindings = containerSystem.getJNDIContext().listBindings("java:openejb/Resource/");
                Set<String> dbnames = new TreeSet<String>();
                for (Binding binding : Collections.list(bindings)) {
                    Object value = binding.getObject();
                    if (value instanceof BasicDataSource) {
                        BasicDataSource jdbc = (BasicDataSource) value;
                        String path = getPath(jdbc);
                        if (path != null) {
                            if (dbnames.size() > 9) {
                                throw new ServiceException("Hsql Server can only host 10 database instances");
                            }
                            String dbname = path.substring(path.lastIndexOf(':') + 1);
                            dbname = dbname.substring(dbname.lastIndexOf('/') + 1);
                            if (!dbnames.contains(dbname)) {
                                properties.put(ServerConstants.SC_KEY_DBNAME + "." + dbnames.size(), dbname);
View Full Code Here

                Timer timer = new Timer("MulticastDiscovery: Broadcaster", true);
                timer.scheduleAtFixedRate(broadcaster, 0, heartRate);
            }
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

            serverControl = new NetworkServerControl(host, port);
            //serverControl.setMaxThreads(threads);

            serverControl.start(new Log4jPrintWriter("Derby", Priority.INFO));
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

            return;
        }
        try {
            serverControl.shutdown();
        } catch (Exception e) {
            throw new ServiceException(e);
        } finally {
            serverControl = null;
        }
    }
View Full Code Here

    public void start() throws ServiceException {
        try {
            server.start();
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.server.ServiceException

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.