Package com.sun.enterprise.admin.target

Examples of com.sun.enterprise.admin.target.Target


        throws InstanceException
    {
        final ConfigContext configContext = getConfigContext();
        final StringManager stringMgr = StringManager.getManager(EEInstancesManager.class);       
        try {                              
            final Target target = TargetBuilder.INSTANCE.createTarget(
                DOMAIN_TARGET, VALID_LIST_TYPES, targetName, configContext);                   
            final Server[] servers = target.getServers();                         
            return getRuntimeStatus(servers);                           
        } catch (Exception ex) {
            throw getExceptionHandler().handleInstanceException(
                ex, "eeadmin.listInstances.Exception", targetName);
        }        
View Full Code Here


        String targetName, boolean andStatus) throws InstanceException
   {
        final ConfigContext configContext = getConfigContext();
        final StringManager stringMgr = StringManager.getManager(EEInstancesManager.class);       
        try {                              
            final Target target = TargetBuilder.INSTANCE.createTarget(
                DOMAIN_TARGET, VALID_LIST_TYPES, targetName, configContext);                   
            final Server[] servers = target.getServers();         
            final int numServers = servers.length;           
            ArrayList result = new ArrayList();
            String serverName = null;
            int status;           
            RuntimeStatusList statusList = null;
View Full Code Here

        String serverName, Properties props) throws InstanceException
    {
        try {
            final ConfigContext configContext = getConfigContext();
            //validate that the server exists and return its node agent
            Target target = null;
            try {
                target = TargetBuilder.INSTANCE.createTarget(
                    VALID_TYPES, serverName, configContext);  
            } catch (Exception e) {
                throw new InstanceException(
                    _strMgr.getString("noSuchInstance", serverName));
            }
            NodeAgent controller = target.getNodeAgents()[0];
            String agentName = controller.getName();
                                   
            // Call the Node Agent to start the server instance remotely
            NodeAgentsConfigBean ncb = getNodeAgentsConfigBean();
            if (ncb.isRunning(agentName)) {
View Full Code Here

        String serverName, boolean forcekill, int timeout) throws InstanceException
    {
        try {
            final ConfigContext configContext = getConfigContext();
            //validate that the server exists and return its node agent
            final Target target = TargetBuilder.INSTANCE.createTarget(
                VALID_TYPES, serverName, configContext);  
            NodeAgent controller = target.getNodeAgents()[0];
            String agentName = controller.getName();
                      
            // Call the Node Agent to stop the server instance remotely
            NodeAgentsConfigBean ncb = getNodeAgentsConfigBean();
            if (ncb.isRunning(agentName)) {
View Full Code Here

    {
        try {
            final ConfigContext configContext = getConfigContext();
            ConfigContextImpl.lock();
            //validate that the server exists and return its node agent
            final Target target = TargetBuilder.INSTANCE.createTarget(
                VALID_TYPES, serverName, configContext);  
            final NodeAgent controller = target.getNodeAgents()[0];
           
            //Remove the server instance
            final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);           
            final Servers servers = domain.getServers();
            final Server server = target.getServers()[0];
            boolean isReachable = true;

            try {               
                ServerRuntimeMBean serverMBean = InstanceProxy.getInstanceProxy(serverName);
                Status status = serverMBean.getRuntimeStatus().getStatus();
View Full Code Here

    private static final TargetType[] VALID_LIST_REFS_TARGETS = new TargetType[] {
        TargetType.CLUSTER, TargetType.SERVER, TargetType.DAS};

    Target getListRefsTarget(String targetName) throws ConfigException
    {
        final Target target = TargetBuilder.INSTANCE.createTarget(
                VALID_LIST_REFS_TARGETS, targetName, getConfigContext());
        return target;
    }
View Full Code Here

    }           
          
    Properties getTargetedProperties(String targetName, boolean inherit) throws ConfigException
    {               
        final ConfigContext configContext = getConfigContext();
        final Target target = TargetBuilder.INSTANCE.createTarget(VALID_TYPES, targetName,
            configContext);           
       
        final Properties result = new Properties();
        if (target.getType() == TargetType.DOMAIN) {
            //list domain properties
            final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
            addProperties(result, domain.getSystemProperty());
        } else if (target.getType() == TargetType.CONFIG) {
            //list config properties
            if (inherit) {
                final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
                addProperties(result, domain.getSystemProperty());
            }
            final Config config = ConfigAPIHelper.getConfigByName(configContext,
                target.getName());
            addProperties(result, config.getSystemProperty());           
        } else if (target.getType() == TargetType.CLUSTER) {           
            //list cluster properties
            if (inherit) {
                final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);         
                addProperties(result, domain.getSystemProperty());
                final Config config = ClusterHelper.getConfigForCluster(configContext,
                    target.getName());
                addProperties(result, config.getSystemProperty());
            }
            final Cluster cluster = ClusterHelper.getClusterByName(configContext,
                target.getName());
            addProperties(result, cluster.getSystemProperty());
        } else if (target.getType() == TargetType.SERVER ||
            target.getType() == TargetType.DAS) {           
            //list server properties
            final Server server = ServerHelper.getServerByName(configContext,
                target.getName());
            if (inherit) {
                final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);           
                addProperties(result, domain.getSystemProperty());

                final Config config = ConfigAPIHelper.getConfigByName(configContext, server.getConfigRef());
                addProperties(result, config.getSystemProperty());
                if (ServerHelper.isServerClustered(configContext, target.getName()))  {
                    final Cluster cluster = ClusterHelper.getClusterForInstance(configContext,
                        target.getName());
                    addProperties(result, cluster.getSystemProperty());
                }       
            }
            addProperties(result, server.getSystemProperty());
        } else {
            //list node agent properties. Shouldnt happen.
            throw new ConfigException(_strMgr.getString("invalidPropertyTarget",
                target.getName()));
        }    
        return result;
    }
View Full Code Here

    public void createSystemProperties(Properties props, String targetName)
        throws ConfigException
    {
        try {           
            final ConfigContext configContext = getConfigContext();
            final Target target = TargetBuilder.INSTANCE.createTarget(VALID_TYPES, targetName,
                configContext);                          
            if (target.getType() == TargetType.DOMAIN) {
                //create domain property
                final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);                  
                //Add the properties
                for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
                    final String name = (String)e.nextElement();
                    //If the property exists, remove it
                    final SystemProperty sysProp = domain.getSystemPropertyByName(name);
                    if (sysProp != null) {
                        domain.removeSystemProperty(sysProp, OVERWRITE);
                    }
                    domain.addSystemProperty(getSystemProperty(props, name),
                        OVERWRITE);
                }     
            } else if (target.getType() == TargetType.CONFIG) {
                final Config config = ConfigAPIHelper.getConfigByName(configContext, 
                    target.getName());                  
                //Add the properties
                for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
                    final String name = (String)e.nextElement();
                    //If the property exists, remove it
                    final SystemProperty sysProp = config.getSystemPropertyByName(name);
                    if (sysProp != null) {
                        config.removeSystemProperty(sysProp, OVERWRITE);
                    }
                    config.addSystemProperty(getSystemProperty(props, name),
                        OVERWRITE);
                }                     
            } else if (target.getType() == TargetType.CLUSTER) {
                final Cluster cluster = ClusterHelper.getClusterByName(configContext,
                    target.getName());
                //Add the properties
                for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
                    final String name = (String)e.nextElement();
                    //If the property exists, remove it
                    final SystemProperty sysProp = cluster.getSystemPropertyByName(name);
                    if (sysProp != null) {
                        cluster.removeSystemProperty(sysProp, OVERWRITE);
                    }                                    
                    cluster.addSystemProperty(getSystemProperty(props, name),
                        OVERWRITE);
                }                
            } else if (target.getType() == TargetType.SERVER ||
                target.getType() == TargetType.DAS) {
                    createServerProperties(target, props);               
            } else {
                //create node agent property. Shouldnt happen
                throw new ConfigException(_strMgr.getString("invalidPropertyTarget",
                    target.getName()));
           
            //FIXTHIS: Not sure why we have to intentionally flush here. The changes get written to
            //disk, but the runtime config context does not get updated!!! This is probably due to
            //the fact that the config change was not handled and the server thinks it needs to
            //restart
View Full Code Here

    public void deleteSystemProperty(String propertyName, String targetName)
        throws ConfigException
    {
        try {
            final ConfigContext configContext = getConfigContext();
            final Target target = TargetBuilder.INSTANCE.createTarget(VALID_TYPES, targetName,
                configContext);                          
            if (target.getType().equals(TargetType.DOMAIN)) {
                //create domain property
                final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
                final SystemProperty sysProp = domain.getSystemPropertyByName(propertyName);
                //Ensure that the property specified exists
                if (sysProp == null) {
                    throw new ConfigException(_strMgr.getString("propertyDoesNotExist",
                        propertyName, target.getName()));
                }
                //Remove the property
                domain.removeSystemProperty(sysProp, OVERWRITE);
            } else if (target.getType().equals(TargetType.CONFIG)){
                //create configuration property           
                final Config config = ConfigAPIHelper.getConfigByName(configContext, 
                    target.getName());  
                final SystemProperty sysProp = config.getSystemPropertyByName(propertyName);
                //Ensure that the property specified exists
                if (sysProp == null) {
                    throw new ConfigException(_strMgr.getString("propertyDoesNotExist",
                        propertyName, target.getName()));
                }
                //Remove the property
                config.removeSystemProperty(sysProp, OVERWRITE);
            } else if (target.getType().equals(TargetType.CLUSTER)) {
                //create instance property                      
                final Cluster cluster = ClusterHelper.getClusterByName(configContext,
                    target.getName());
                final SystemProperty sysProp = cluster.getSystemPropertyByName(propertyName);
                //Ensure that the property specified exists
                if (sysProp == null) {
                    throw new ConfigException(_strMgr.getString("propertyDoesNotExist",
                        propertyName, target.getName()));
                }
                //Remove the property
                cluster.removeSystemProperty(sysProp, OVERWRITE);
            } else if (target.getType().equals(TargetType.SERVER) ||
                target.getType().equals(TargetType.DAS)) {
                //create instance property                      
                final Server server = ServerHelper.getServerByName(configContext, target.getName());
                final SystemProperty sysProp = server.getSystemPropertyByName(propertyName);
                //Ensure that the property specified exists
                if (sysProp == null) {
                    throw new ConfigException(_strMgr.getString("propertyDoesNotExist",
                        propertyName, target.getName()));
                }
                SystemProperty removedProp = new SystemProperty();
                removedProp.setName(sysProp.getName());
                removedProp.setValue(sysProp.getValue());
                //Remove the property
                server.removeSystemProperty(sysProp, OVERWRITE);
                /*
                 *Fix for bug 6303353
                 *We do not have to check if the system-property being deleted in this server-instance
                 *is also being defined in another instance (on same machine).
                 *Ideally we want to check if this system-property is being referenced in any of
                 *the attributes in the associated config, and this is the only system-property that exists
                 *to specify that value (not even in the parent config). But this would be an extensive search
                 *to go through the whole config and the attributes of all elements in there, which isn't really
                 *worth, when you have to just delete a system property.
                //Check for a port conflict after modifying server. If a port conflict occurs,
                //we "rollback" the addition of the system properties.
                try {
                    PortConflictCheckerConfigBean portChecker = getPortConflictCheckerConfigBean();  
                    ServersConfigBean scb = getServersConfigBean();                   
                    portChecker.checkForPortConflicts(server, null,
                        scb.isRunning(server.getName()));
                } catch (Exception ex2) {                        
                    server.addSystemProperty(removedProp, OVERWRITE);
                    //We do not want to propagate the PortInUseException up. It is a protected
                    //class used for internal use only
                    if (ex2 instanceof PortInUseException) {
                        throw new ConfigException(ex2.getMessage());
                    } else {
                        throw (ex2);
                    }
                }
                */
            } else {
                //create node agent property. Shouldnt happen.
                throw new ConfigException(_strMgr.getString("invalidPropertyTarget",
                    target.getName()));
            }  
            //FIXTHIS: Not sure why we have to intentionally flush here. The changes get written to
            //disk, but the runtime config context does not get updated!!! This is probably due to
            //the fact that the config change was not handled and the server thinks it needs to
            //restart
View Full Code Here

    {       
        try {
            TargetType[] validTypes = new TargetType[] {TargetType.DOMAIN, TargetType.CLUSTER,
                TargetType.SERVER, TargetType.DAS, TargetType.CONFIG};
            ConfigContext configContext = getConfigContext();       
            Target target = TargetBuilder.INSTANCE.createTarget(
                DOMAIN_TARGET, validTypes, targetName,
                configContext);           
            final Config[] configs = target.getConfigs();
            int numConfigs = configs.length;
            String[] result = new String[numConfigs];
            for (int i = 0; i < numConfigs; i++) {
                result[i] = configs[i].getName();
            }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.admin.target.Target

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.