Package org.jayasoft.woj.common.model

Examples of org.jayasoft.woj.common.model.Server


    private Server _server = null;

    public JDBCServer() {
    }
    public JDBCServer(String ip, int port, String base) {
        _server = new Server(ip, port, base);
    }
View Full Code Here


    public JDBCServer(String ip, int port, String base) {
        _server = new Server(ip, port, base);
    }

    public Object load(ResultSet rs) throws SQLException {
        _server = new Server(rs.getInt("SRV_ID"), rs.getString("SRV_IP"), rs.getInt("SRV_PORT"), rs.getString("SRV_BASE_ADDRESS"));
        return _server;
    }
View Full Code Here

                String[] sha1s = (String[])md.getSHA1s().toArray(new String[0]);
                // UAK not necessary because it's an update
                insert(null, md, md5s, sha1s);
                List servers = md.getServers();
                for (Iterator iter = servers.iterator(); iter.hasNext();) {
                    Server server = (Server)iter.next();
                    registerModule(server, md);
                }
            }
        });
    }
View Full Code Here

    public Object create() {
        return newJDBCObject();
    }
   
    protected Object[] getInsertParameters(Object o) {
        Server server = (Server) o;
        List parameters = new ArrayList();
        parameters.add(""+server.getId());
        parameters.add(server.getIp());
        parameters.add(""+server.getPort());
        parameters.add(server.getBaseAddress());
        return parameters.toArray();
    }
View Full Code Here

        parameters.add(server.getBaseAddress());
        return parameters.toArray();
    }
   
    protected Object[] getDeleteParameters(Object o) {
        Server server = (Server) o;
        List parameters = new ArrayList();
        parameters.add(""+server.getId());
        return parameters.toArray();
    }
View Full Code Here

        parameters.add(""+server.getId());
        return parameters.toArray();
    }

    protected Object[] getUpdateParameters(Object o) {
        Server server = (Server) o;
        List parameters = new ArrayList();
        parameters.add(server.getIp());
        parameters.add(""+server.getPort());
        parameters.add(server.getBaseAddress());
        parameters.add(new Long(server.getId()));
        return parameters.toArray();
    }
View Full Code Here

    private static Logger LOGGER = LoggingManager.getLogger(ModuleManagementServiceImpl.class.getName());

    public void registerModule(Server server, ModuleDescriptor md) {
        WOJServer.getInstance().getDataService().getModuleDescriptorDao().registerModule(server, md);
       
        Server master = WOJServer.getInstance().getMaster();
        try {
            ServerServicesProvider.get(master).getModuleManagementService().registerModule(server, md);
        } catch (ServiceException e) {
            LOGGER.error("problem occured while registering module "+md+" to master: "+master, e);
        }
View Full Code Here

import org.jayasoft.woj.common.model.WOJCluster;
import org.jayasoft.woj.common.services.internal.ClusterMasterTargetServerProvider;

public class ClusterTargetServerProvider extends TestCase {
    public void test() throws Exception {
        Server server1 = new Server(new URL("http://127.0.0.1:8080/woj-server"));
        Server server2 = new Server(new URL("http://127.0.0.1:8080/woj-server2"));
        Server server3 = new Server(new URL("http://127.0.0.1:8080/"));
        ClusterMasterTargetServerProvider tsp = new ClusterMasterTargetServerProvider(new WOJCluster(Arrays.asList(new Server[] {
                server1,
                server2,
                server3})));
        assertTrue(server1 == tsp.getFirstTargetServer());
View Full Code Here

    public RegisterModuleCommand() {
        super(Commands.REGISTER_MODULE.NAME);
    }

    public Object securedInvoke(UAK uak, Map m) {
        Server server = (Server)ServiceProvider.getDefault().getEncodingService().decode((String)m.get(Commands.REGISTER_MODULE.P_SERVER));
        ModuleDescriptor md = (ModuleDescriptor)ServiceProvider.getDefault().getEncodingService().decode((String)m.get(Commands.REGISTER_MODULE.P_MODULE));
       
        WOJServer.getInstance().getModuleManagementService().registerModule(server, md);
      return null;
    }
View Full Code Here

        _targetServer.reset();
        String urlSuffix = serviceName;
        Exception firstException = null;
        StringBuffer errorMessages = new StringBuffer();
        while (_targetServer.hasNext()) {
            Server target = _targetServer.getNextTargetServer();
           
            String serverUrl = target.getFullUrlString(encrypted && !WojUtil.isDevMode());
            try {
                URL url = new URL(serverUrl+ urlSuffix);
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("calling "+url+" encrypted="+encrypted+" devmode="+WojUtil.isDevMode()+" params="+params);
                }
                String urlContent = URLHelper.getContentPostMethod(url, params, false);
                _targetServer.setNewTargetServer(target);
                if (urlContent != null && decode) {
                    Object result = ServiceProvider.getDefault().getEncodingService().decode(urlContent);
                    //if object is encapsulate in an answer
                    if (result instanceof Answer) {
                        Answer a = (Answer) result;
                        if (a.getNewUak() != null) {
                            getUnifiedAuthentificationService().setUAK(a.getNewUak());
                        }
                        Object object = a.getObject();
                        switch (a.getStatus()) {
                        case Answer.STATUS_OK:
                            return object;
                        case Answer.STATUS_FAILED:
                        case Answer.STATUS_INVALID:
                        case Answer.STATUS_BAD_UAK:
                        case Answer.STATUS_NOT_AUTHORIZED:
                            throw new AnswerServiceException(serverUrl, serviceName, params, a, String.valueOf(object));
                        }
                        return null;
                    }
                    return result;
                } else {
                    return urlContent;
                }
            } catch(URLRedirectException e) {
                String url = e.getUrl();
                LOGGER.debug("redirected to url: "+url);
                String server = url;
                if (server.indexOf('?') != -1) {
                    server = server.substring(0, server.indexOf('?'));
                }
                if (server.endsWith(serviceName)) {
                    server = server.substring(0, server.length() - serviceName.length());
                }
                urlSuffix = url.substring(server.length());
                LOGGER.info("redirected to server: "+server);
                try {
                    _targetServer.setNewTargetServer(new Server(new URL(server)));
                } catch (MalformedURLException e1) {
                    throw new ServiceNotAvailableException("redirected to malformed url: "+server, e1);
                }                   
            } catch(ConnectException e) {
                LOGGER.info("Server did not respond: "+serverUrl, e);
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.common.model.Server

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.