001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     matic
018 */
019package org.nuxeo.runtime.management;
020
021import org.apache.commons.logging.Log;
022import org.apache.commons.logging.LogFactory;
023import org.nuxeo.common.xmap.annotation.XNode;
024import org.nuxeo.common.xmap.annotation.XObject;
025import org.nuxeo.runtime.api.Framework;
026
027/**
028 * @author matic
029 */
030@XObject("locator")
031public class ServerLocatorDescriptor {
032
033    private static final Log log = LogFactory.getLog(ServerLocatorDescriptor.class);
034
035    @XNode("@default")
036    protected boolean isDefault = true;
037
038    protected boolean isExisting = true;
039
040    protected int rmiPort = 1099;
041
042    @XNode("@domain")
043    protected String domainName;
044
045    @XNode("@remote")
046    protected boolean remote = true;
047
048    public ServerLocatorDescriptor() {
049        domainName = "";
050    }
051
052    public ServerLocatorDescriptor(String domainName, boolean isDefaultServer) {
053        this.domainName = domainName;
054        isDefault = isDefaultServer;
055    }
056
057    @XNode("@exist")
058    public void setExisting(String value) {
059        String expandedValue = Framework.expandVars(value);
060        if (expandedValue.startsWith("$")) {
061            log.warn("Cannot expand " + value + " for existing server");
062            return;
063        }
064        isExisting = Boolean.parseBoolean(expandedValue);
065    }
066
067    @XNode("@rmiPort")
068    public void setRmiPort(String value) {
069        String expandedValue = Framework.expandVars(value);
070        if (expandedValue.startsWith("$")) {
071            log.warn("Cannot expand " + value + " for server locator");
072            return;
073        }
074        rmiPort = Integer.parseInt(expandedValue);
075    }
076}