Package org.apache.openejb.server

Examples of org.apache.openejb.server.ServiceException


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

            if (property.startsWith(sc_key_dbname + ".") ||
                property.startsWith(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(sc_key_port, value);
            } else if ("bind".equals(property)) {
                properties.setProperty(sc_key_address, value);
            } else {
                properties.setProperty(property, value);
            }
        }
        properties.setProperty(sc_key_no_system_exit, "true");

        final boolean disabled = Boolean.parseBoolean(properties.getProperty("disabled"));
        final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
        if (!disabled && containerSystem != null) {
            final NamingEnumeration<Binding> bindings;
            try {
                bindings = containerSystem.getJNDIContext().listBindings("openejb/Resource/");
                final Set<String> dbnames = new TreeSet<String>();
                for (final Binding binding : Collections.list(bindings)) {
                    final Object value = binding.getObject();
                    if (value instanceof DataSource) {
                        final DataSource jdbc = (DataSource) value;
                        Connection connection = null;
                        String path = null;
                        try {
                            connection = jdbc.getConnection();
                            final DatabaseMetaData meta = connection.getMetaData();
                            path = getPath(meta.getDriverName(), meta.getURL());
                        } catch (Throwable t) {
                            continue;
                        } finally {
                            if (connection != null) {
                                try {
                                    connection.close();
                                } catch (SQLException sqlEx) {
                                    // no-op
                                }
                            }
                        }

                        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(sc_key_dbname + "." + dbnames.size(), dbname);
View Full Code Here


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

            serverControl.start(new LoggingPrintWriter("Derby"));
        } 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

        if (!this.running.getAndSet(true)) {

            try {
                this.sockets = getSockets(this.multicast, this.port);
            } catch (Exception e) {
                throw new ServiceException("Failed to get Multicast sockets", e);
            }

            final CountDownLatch latch = new CountDownLatch(this.sockets.length);
            final String mpg = MulticastPulseAgent.this.group;
            final boolean isLoopBackOnly = MulticastPulseAgent.this.loopbackOnly;
View Full Code Here

        final InetAddress ia;

        try {
            ia = InetAddress.getByName(multicastAddress);
        } catch (UnknownHostException e) {
            throw new ServiceException(multicastAddress + " is not a valid address", e);
        }

        if (null == ia || !ia.isMulticastAddress()) {
            throw new ServiceException(multicastAddress + " is not a valid multicast address");
        }

        return getSockets(ia, port);
    }
View Full Code Here

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

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

    public synchronized void start(final boolean block) throws ServiceException {

        //This implementaion ignores block

        if (started == null) {
            throw new ServiceException("ServiceManager not initialized");
        }
        if (stopped) {
            throw new ServiceException("ServiceManager has already been stopped");
        }

        started = Boolean.TRUE;
        for (final Map.Entry<Bundle, List<Service>> entry : serverMap.entrySet()) {
            for (final Service service : entry.getValue()) {
View Full Code Here

                this.port = multipointServer.getPort();

            }
        } catch (Exception e) {
            throw new ServiceException(port + "", e);
        }
    }
View Full Code Here

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

            serverControl.start(new LoggingPrintWriter("Derby"));
        } 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.