Package org.apache.tools.ant

Examples of org.apache.tools.ant.ComponentHelper$AntTypeTable


            throw new BuildException("Name not specified");
        }

        name = ProjectHelper.genComponentName(getURI(), name);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        String componentName = ProjectHelper.genComponentName(
            nestedTask.getNamespace(), nestedTask.getTag());

        AntTypeDefinition def = helper.getDefinition(componentName);
        if (def == null) {
            throw new BuildException(
                "Unable to find typedef " + componentName);
        }

        PreSetDefinition newDef = new PreSetDefinition(def, nestedTask);

        newDef.setName(name);

        helper.addDataTypeDefinition(newDef);
    }
View Full Code Here


            antlibUrl.openConnection().connect();
        } catch (IOException ex) {
            throw new BuildException(
                "Unable to find " + antlibUrl, ex);
        }
        ComponentHelper helper =
            ComponentHelper.getComponentHelper(project);
        helper.enterAntLib(uri);
        try {
            // Should be safe to parse
            ProjectHelper2 parser = new ProjectHelper2();
            UnknownElement ue =
                parser.parseUnknownElement(project, antlibUrl);
            // Check name is "antlib"
            if (!(ue.getTag().equals(TAG))) {
                throw new BuildException(
                    "Unexpected tag " + ue.getTag() + " expecting "
                    + TAG, ue.getLocation());
            }
            Antlib antlib = new Antlib();
            antlib.setProject(project);
            antlib.setLocation(ue.getLocation());
            antlib.init();
            ue.configure(antlib);
            return antlib;
        } finally {
            helper.exitAntLib();
        }
    }
View Full Code Here

        MyAntTypeDefinition def = new MyAntTypeDefinition(this);
        def.setName(name);
        def.setClass(MacroInstance.class);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        helper.addDataTypeDefinition(def);
    }
View Full Code Here

        svcCtrl.verify();
    }
   
    public void testExecuteNoDefWithGoodReference() throws Exception {
        MockControl chCtrl = MockClassControl.createNiceControl(ComponentHelper.class);
        ComponentHelper cHelper = (ComponentHelper)chCtrl.getMock();
       
        MockControl prjCtrl = MockClassControl.createNiceControl(Project.class);
        Project project = (Project)prjCtrl.getMock();
        project.getReference("ant.ComponentHelper");
        prjCtrl.setReturnValue(cHelper);

        MockControl vfyCtrl = MockClassControl.createNiceControl(ServiceVerifyTask.class);
        ServiceVerifyTask verify = (ServiceVerifyTask)vfyCtrl.getMock();
        verify.getProject();
        vfyCtrl.setReturnValue(project, 2);
        verify.execute();
        vfyCtrl.setVoidCallable();

        MockControl svcCtrl = MockClassControl.createControl(ServiceDef.class);
        ServiceDef service = (ServiceDef)svcCtrl.getMock();
        service.getVerifyTask();
        svcCtrl.setReturnValue(verify);
        service.start();
        svcCtrl.setVoidCallable();

        ServiceInstance instance = new ServiceInstance();
        instance.setProject(project);
        instance.setReference("foo");
       
        MockControl atdCtrl = MockClassControl.createControl(AntTypeDefinition.class);
        AntTypeDefinition typeDef = (AntTypeDefinition)atdCtrl.getMock();
        typeDef.create(project);
        ServiceInstance helperInstance = new ServiceInstance();
        helperInstance.setServiceDef(service);
        atdCtrl.setReturnValue(helperInstance);
        cHelper.getDefinition("foo");
        chCtrl.setReturnValue(typeDef);

        chCtrl.replay();
        prjCtrl.replay();
        vfyCtrl.replay();
View Full Code Here

        atdCtrl.verify();
    }
   
    public void testExecuteNoDefWithBadReference() throws Exception {
        MockControl chCtrl = MockClassControl.createNiceControl(ComponentHelper.class);
        ComponentHelper cHelper = (ComponentHelper)chCtrl.getMock();
       
        MockControl prjCtrl = MockClassControl.createNiceControl(Project.class);
        Project project = (Project)prjCtrl.getMock();
        project.getReference("ant.ComponentHelper");
        prjCtrl.setReturnValue(cHelper);

        ServiceInstance instance = new ServiceInstance();
        instance.setProject(project);
        instance.setReference("foo");
       
        MockControl atdCtrl = MockClassControl.createControl(AntTypeDefinition.class);
        AntTypeDefinition typeDef = (AntTypeDefinition)atdCtrl.getMock();
        typeDef.create(project);
        atdCtrl.setReturnValue(new Object()); // bad reference!
        cHelper.getDefinition("foo");
        chCtrl.setReturnValue(typeDef);

        chCtrl.replay();
        prjCtrl.replay();
        atdCtrl.replay();
View Full Code Here

       
        if (serviceDef == null) {
            if (serviceName == null) {
                throw new BuildException("No Service Definition found!");
            } else {
                ComponentHelper helper = ComponentHelper.getComponentHelper(getProject());
                AntTypeDefinition def = helper.getDefinition(serviceName);
                Object obj = def.create(getProject());
                if (obj instanceof ServiceInstance) {
                    serviceDef = ((ServiceInstance)obj).getServiceDef();
                } else {
                    throw new BuildException("No Service Definition found!");
View Full Code Here

        MyAntTypeDefinition def = new MyAntTypeDefinition(this);
        def.setName(serviceName);
        def.setClass(ServiceInstance.class);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        helper.addDataTypeDefinition(def);
    }
View Full Code Here

            conn.connect();
        } catch (IOException ex) {
            throw new BuildException(
                "Unable to find " + antlibUrl, ex);
        }
        ComponentHelper helper =
            ComponentHelper.getComponentHelper(project);
        helper.enterAntLib(uri);
        URLResource antlibResource = new URLResource(antlibUrl);
        try {
            // Should be safe to parse
            ProjectHelper parser = null;
            Object p =
                project.getReference(ProjectHelper.PROJECTHELPER_REFERENCE);
            if (p instanceof ProjectHelper) {
                parser = (ProjectHelper) p;
                if (!parser.canParseAntlibDescriptor(antlibResource)) {
                    parser = null;
                }
            }
            if (parser == null) {
                ProjectHelperRepository helperRepository =
                    ProjectHelperRepository.getInstance();
                parser = helperRepository.getProjectHelperForAntlib(antlibResource);
            }
            UnknownElement ue =
                parser.parseAntlibDescriptor(project, antlibResource);
            // Check name is "antlib"
            if (!(ue.getTag().equals(TAG))) {
                throw new BuildException(
                    "Unexpected tag " + ue.getTag() + " expecting "
                    + TAG, ue.getLocation());
            }
            Antlib antlib = new Antlib();
            antlib.setProject(project);
            antlib.setLocation(ue.getLocation());
            antlib.setTaskName("antlib");
            antlib.init();
            ue.configure(antlib);
            return antlib;
        } finally {
            helper.exitAntLib();
        }
    }
View Full Code Here

        MyAntTypeDefinition def = new MyAntTypeDefinition(this);
        def.setName(name);
        def.setClass(MacroInstance.class);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        helper.addDataTypeDefinition(def);
        log("creating macro  " + name, Project.MSG_VERBOSE);
    }
View Full Code Here

        MyAntTypeDefinition def = new MyAntTypeDefinition(this);
        def.setName(name);
        def.setClass(MacroInstance.class);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        helper.addDataTypeDefinition(def);
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.ComponentHelper$AntTypeTable

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.