Package com.sun.enterprise.admin.target

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


        String[] ctxRoots = getAppContextRoots(appBean);
        if(ctxRoots==null || ctxRoots.length<=0)
          return null;

        //create target by name
        final Target target = TargetBuilder.INSTANCE.createTarget(
            new TargetType[]{TargetType.CLUSTER, TargetType.SERVER, TargetType.DAS}, targetName, ctx);           
       
        //get apprefs for target
        ApplicationRef[] refs = null;
        if (target.getType() == TargetType.CLUSTER ||
            target.getType() == TargetType.STANDALONE_CLUSTER)
        {
            refs = ClusterHelper.getApplicationReferences(ctx, targetName);
        }
        else
        {
View Full Code Here


    public DeploymentTarget getTarget(ConfigContext configContext, String domainName, String targetName) throws IASDeploymentException
    {
        try{
            //parse the given target and ensure that it is a valid server instance. Server instance
            //is the only valid target type for PE.           
            final Target target = TargetBuilder.INSTANCE.createTarget(VALID_DEPLOYMENT_TYPES,
                targetName, configContext);   
            if (targetName == null) {
                targetName = target.getName();           
            }
            return new ServerDeploymentTarget(configContext , domainName, targetName);
        } catch(Throwable t){           
            throw new IASDeploymentException("Error:" + t.getMessage(), t);
        }
View Full Code Here

        String virtualServers, String referenceName) throws ConfigException
    {                        
        final ConfigContext configContext = getConfigContext();
        //Validate that there is indeed a resource with the specified name. 
        final String type = getApplicationType(referenceName);
        final Target target = TargetBuilder.INSTANCE.createTarget(
            validTypes, targetName, configContext);           
        if (target.getType() == TargetType.CLUSTER) {
            final Cluster cluster = ClusterHelper.getClusterByName(configContext, target.getName());
            addApplicationReferenceToCluster(cluster, enabled, virtualServers, referenceName);
            final Server[] servers = ServerHelper.getServersInCluster(configContext, target.getName());
            addApplicationReferenceToClusteredServers(cluster, servers, enabled,
                virtualServers, referenceName);           
        } else if (target.getType() == TargetType.SERVER ||
            target.getType() == TargetType.DAS) {
            final Server server = ServerHelper.getServerByName(configContext, target.getName());
            addApplicationReferenceToServer(server, enabled, virtualServers, referenceName);
        } else {
            throw new ConfigException(_strMgr.getString("invalidClusterOrServerTarget",
                target.getName()));
        }             
    }
View Full Code Here

        throws ConfigException
    {       
        final ConfigContext configContext = getConfigContext();
        //Validate that there is indeed a resource with the specified name. 
        final String type = getApplicationType(referenceName);                            
        final Target target = TargetBuilder.INSTANCE.createTarget(
            validTypes, targetName, configContext);           
        if (target.getType() == TargetType.SERVER ||
            target.getType() == TargetType.DAS) {
            final Server server = ServerHelper.getServerByName(configContext, targetName);
            deleteApplicationReferenceFromServer(server, referenceName);
        } else if (target.getType() == TargetType.CLUSTER) {
            final Cluster cluster = ClusterHelper.getClusterByName(configContext, targetName);
            deleteApplicationReferenceFromCluster(cluster, referenceName);
            final Server[] servers = ServerHelper.getServersInCluster(configContext, targetName);
            deleteApplicationReferenceFromClusteredServers(cluster, servers, referenceName);           
        } else {
View Full Code Here

            String targetName,
            String appName) throws ConfigException {
        ApplicationRef appRef = null;
        final ConfigContext configContext = deploymentCtx.getConfigContext();

        final Target target = TargetBuilder.INSTANCE.createTarget(
            targetTypes, targetName, configContext);

        if (target.getType() == TargetType.CLUSTER ||
            target.getType() == TargetType.STANDALONE_CLUSTER)
        {
            Cluster cluster = ClusterHelper.getClusterByName(
                configContext, target.getName());
            if (cluster != null) {
                appRef = cluster.getApplicationRefByRef(appName);
            }
        }
        else
        {
            Server server =  ServerHelper.getServerByName(
                configContext, target.getName());
            if (server != null) {
                appRef = server.getApplicationRefByRef(appName);
            }
        }
                                                                               
View Full Code Here

     */
    public static Target getTarget(String targetName, TargetType[] targetTypes,
            ConfigContext configContext) throws MBeanException {       
               
        try {              
            Target target = TargetBuilder.INSTANCE.createTarget(
                    targetTypes, targetName, configContext);
            if (target.getType() == TargetType.SERVER ||
                target.getType() == TargetType.DAS) {
                //If we are operating on a server, ensure that the server is the only entity
                //referencing its config
                String configName = ServerHelper.getConfigForServer(configContext,
                    target.getName()).getName();
                if (!ConfigAPIHelper.isConfigurationReferencedByServerOnly(configContext,
                    configName, target.getName())) {
                        throw new ConfigException(localStrings.getString(
                            "configurationHasMultipleRefs", target.getName(), configName,
                            ConfigAPIHelper.getConfigurationReferenceesAsString(
                                configContext, configName)));  
                }                                             
            } else if (target.getType() == TargetType.CLUSTER) {
                //If we are operating on a cluster, ensure that the cluster is the only entity
                //referencing its config
                String configName = ClusterHelper.getConfigForCluster(configContext,
                    target.getName()).getName();
                if (!ConfigAPIHelper.isConfigurationReferencedByClusterOnly(configContext,
                    configName, target.getName())) {
                        throw new ConfigException(localStrings.getString(
                            "configurationHasMultipleRefs", target.getName(), configName,
                            ConfigAPIHelper.getConfigurationReferenceesAsString(
                                configContext, configName)));
                }    
            }
            return target;
View Full Code Here

    {
        sLogger.info("createJmsResource -------------------" );
        ObjectName mbean = null;
        Properties properties = new Properties();

        Target target = getResourceTarget(tgtName);

//        try {
            JmsRaMapping ramap = ConnectorRuntime.getRuntime().getJmsRaMapping();

            /* Map MQ properties to Resource adapter properties */
 
View Full Code Here

    {
        // fix for bug# 6531767
        TargetType[] VALID_CREATE_DELETE_TYPES_JDBCRES = new TargetType[] {
                TargetType.CLUSTER, TargetType.UNCLUSTERED_SERVER,
                TargetType.DAS, TargetType.DOMAIN};
        Target target = TargetBuilder.INSTANCE.createTarget(
            VALID_CREATE_DELETE_TYPES_JDBCRES, 
            tgtName, getConfigContext());

        return createResource( JDBC_RESOURCE, attrList, props, tgtName );
    }
View Full Code Here

             validateCnctorConnPoolAttrList(attrList);

       
        ObjectName mbean = null;     

        final Target target = TargetBuilder.INSTANCE.createTarget(
            VALID_CREATE_DELETE_TYPES, 
            tgtName, getConfigContext()); // This method call fails as getConfigContext is returning null.         
        boolean hasReferences = isResourceReferenceValid(resourceType, target.getType());

        boolean enabled = true;
        String resName = getResourceName(resourceType, attrList);
        int  idxEnabled = -1;
        if (attrList != null)
        {
            for(int i=0; i<attrList.size(); i++)
            {
                Attribute attr = (Attribute)attrList.get(i);
                if (attr.getName().equals("enabled"))
                {
                    enabled = Boolean.valueOf(attr.getValue().toString()).booleanValue();
                    idxEnabled = i;
                }
            }
        }
       

        Attribute saveEnabledAtttr = null;
        if(!enabled && hasReferences)
        { //change original "enabled" value to true
            saveEnabledAtttr  = (Attribute)attrList.get(idxEnabled);
            attrList.set(idxEnabled, new Attribute("enabled", "true"));
        }
        mbean = (ObjectName)super.invoke( "create" + ConfigMBeanHelper.convertTagName(resourceType),
                    new Object[] {attrList},
                    new String[] {AttributeList.class.getName()});

        if(!enabled && hasReferences)
        { //restore original enabled value
            attrList.set(idxEnabled, saveEnabledAtttr);
        }
                   
        // Add properties
        if (props != null)
        {
            setProperties(mbean, props);
        }

        /*
            No need to create resource-ref if
            - resource is a jdbc-connection-pool or connector-connection-pool
              or resource-adapter-config
            - target is domain
         */
        if (!hasReferences)
        {
            return mbean;
        }

        // If target is server or cluster, resource-ref should also be
        // created inside server or group/cluster element
        if (target.getType() == TargetType.SERVER ||
            target.getType() == TargetType.CLUSTER ||
            target.getType() == TargetType.DAS)               
        {               
            if ( (resName != null) && !(resName.equals("")) && createResourceRefs )
            {
                //System.out.println("ResourcesMBean - default creation of resource refs "+ target.getName() + " " + resName);
                getResourceReferenceHelper().createResourceReference(
                    target.getName(), enabled, resName);
            }                        
        }
        return mbean;
    }
View Full Code Here

     * @param resource <code>Resource</code> object for which the resource-ref
     * needs to be deleted.
     * @throws Exception
     */
    public void deleteResourceReference(String targetName, Resource resource) throws Exception {
        Target target = getResourceTarget(targetName);
        this.deleteResourceRef(getResourceName(resource.getType(), resource.getAttributes()), target, targetName);
    }
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.