Package org.wso2.carbon.base

Examples of org.wso2.carbon.base.ServerConfiguration


        String port;
        int portNumber = -1;
        int indexOfStartingChars = -1;
        int indexOfClosingBrace;

        ServerConfiguration serverConfiguration = ServerConfiguration.getInstance();
        // The following condition deals with ports specified to be read from carbon.xml.
        // Ports are specified as templates: eg ${Ports.EmbeddedLDAP.LDAPServerPort},
        if (indexOfStartingChars < property.indexOf("${") &&
            (indexOfStartingChars = property.indexOf("${")) != -1 &&
            (indexOfClosingBrace = property.indexOf("}")) != -1) { // Is this template used?

            String portTemplate = property.substring(indexOfStartingChars + 2,
                                                     indexOfClosingBrace);

            port = serverConfiguration.getFirstProperty(portTemplate);

            if (port != null) {
                portNumber = Integer.parseInt(port);
            }

        }
        String portOffset = serverConfiguration.getFirstProperty("Ports.Offset");
        return portOffset == null? portNumber : portNumber + Integer.parseInt(portOffset);
    }
View Full Code Here


        String temp = System.getProperty(ServerRoleConstants.SERVER_ROLES_CMD_OPTION);
        if (temp != null) {
            serverRoles = temp.split(",");
        } else {
            // now try to read from carbon.xml
            ServerConfiguration serverConfig = ServerConfiguration.getInstance();
            serverRoles = serverConfig.getProperties(ServerRoleConstants.CARBON_SERVER_ROLE);
        }
        return ServerRoleUtils.arrayToList(serverRoles);
    }
View Full Code Here

    /**
     * Set-up the system properties required to access the trust-store in Carbon. This is used in
     * the atom-based Remote Registry implementation.
     */
    public static void setTrustStoreSystemProperties() {
        ServerConfiguration config = ServerConfiguration.getInstance();
        String type = config.getFirstProperty("Security.TrustStore.Type");
        String password = config.getFirstProperty("Security.TrustStore.Password");
        String storeFile = new File(
                config.getFirstProperty("Security.TrustStore.Location")).getAbsolutePath();

        System.setProperty("javax.net.ssl.trustStore", storeFile);
        System.setProperty("javax.net.ssl.trustStoreType", type);
        System.setProperty("javax.net.ssl.trustStorePassword", password);
    }
View Full Code Here

    public static boolean isRegistryReadOnly(RegistryContext registryContext) {
        String repositoryWriteModeProperty = System.getProperty(ServerConstants.REPO_WRITE_MODE);
        if (repositoryWriteModeProperty != null) {
            return !(repositoryWriteModeProperty.equals("true"));
        }
        ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();

        String isRegistryReadOnly =
                serverConfig.getFirstProperty("Registry.ReadOnly");
        if (isRegistryReadOnly == null) {
            if (registryContext != null) {
                return registryContext.isReadOnly();
            }
            return RegistryContext.getBaseInstance().isReadOnly();
View Full Code Here

     * @return webcontext name
     */
    public static String getWebContextName(BundleContext bundleContext) {
        String webContext = "carbon";

        ServerConfiguration sc = ServerConfiguration.getInstance();
        if (sc != null) {
            String value = sc.getFirstProperty("WebContext");
            if (value != null) {
                webContext = value;
            }
        }
        return webContext;
View Full Code Here

     * @param propertyName Name of the property
     * @return the property
     */
    public static String getServerConfigurationProperty(String propertyName) {
        try {
            ServerConfiguration serverConfig = CarbonUIServiceComponent.getServerConfiguration();
            return serverConfig.getFirstProperty(propertyName);
        } catch (Exception e) {
            String msg = "ServerConfiguration Service not available";
            log.error(msg, e);
        }

View Full Code Here

      private Stack<JmDNSRegistration> registrations = new Stack<JmDNSRegistration>();

    public String getServerConfigurationProperty() {
      try {
        ServerConfiguration serverConfig = ServerRegistrationComponent
            .getServerConfiguration();
        return serverConfig.getFirstProperty("Name");
      } catch (Exception e) {
        String msg = "ServerConfiguration Service not available";
        log.error(msg, e);
      }
View Full Code Here

            }
            Date stTime = new Date(startTime);
            SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
            data.setServerStartTime(dateFormatter.format(stTime));
            data.setServerUpTime(getTime((System.currentTimeMillis() - startTime) / 1000));
            ServerConfiguration serverConfig = dataHolder.getServerConfig();
            String registryType = serverConfig.getFirstProperty("Registry.Type");

            if (registryType == null) {
                registryType = "embedded";
            }
            data.setRegistryType(registryType);

            // Extract DB related data from RegistryContext
            if (registryType.equals("embedded")) {
                try {
                    DataAccessManager dataAccessManager =
                            RegistryContext.getBaseInstance().getDataAccessManager();
                    if (!(dataAccessManager instanceof JDBCDataAccessManager)) {
                        String msg = "Failed to obtain DB connection. Invalid data access manager.";
                        log.error(msg);
                        throw new AxisFault(msg);
                    }
                    DataSource dataSource = ((JDBCDataAccessManager)dataAccessManager).getDataSource();
                    Connection dbConnection = dataSource.getConnection();
                    DatabaseMetaData metaData = dbConnection.getMetaData();
                    if (metaData != null) {
                        data.setDbName(metaData.getDatabaseProductName());
                        data.setDbVersion(metaData.getDatabaseProductVersion());
                        data.setDbDriverName(metaData.getDriverName());
                        data.setDbDriverVersion(metaData.getDriverVersion());
                        data.setDbURL(metaData.getURL());
                    }
                    dbConnection.close();
                } catch (SQLException e) {
                    String msg = "Cannot create DB connection";
                    log.error(msg, e);
                    throw new AxisFault(msg, e);
                }
            } else if (registryType.equals("remote")) {
                data.setRemoteRegistryChroot(serverConfig.getFirstProperty("Registry.Chroot"));
                data.setRemoteRegistryURL(serverConfig.getFirstProperty("Registry.Url"));
            }
        }
        try {
            data.setServerIp(NetworkUtils.getLocalHostname());
        } catch (SocketException e) {
View Full Code Here

    @SuppressWarnings("deprecation")
    public RegistryService buildRegistryService() throws Exception {
        // this logic is used in check-in client
        updateRegistryConfiguration(getRegistryConfiguration());

        ServerConfiguration serverConfig = getServerConfiguration();
        setSystemTrustStore(serverConfig);

        RegistryService registryService;
        String registryRoot;
        if (org.wso2.carbon.registry.core.config.RegistryConfiguration.REMOTE_REGISTRY
View Full Code Here

        }
    }

    // Get Server Configuration instance based on the carbon.xml.
    private ServerConfiguration getServerConfiguration() throws RegistryException {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        try {
            File carbonXML = new File(CarbonUtils.getServerXml());
            InputStream inputStream = new FileInputStream(carbonXML);
            try {
                serverConfig.init(inputStream);
            } finally {
                inputStream.close();
            }
        } catch (Exception e) {
            log.error("Error initializing the Server Configuration", e);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.base.ServerConfiguration

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.