ServiceAnalyzerPlugin implements AnalyzerPlugin { @Override public boolean analyzeJar(Analyzer analyzer) throws Exception { boolean liferayService = Boolean.parseBoolean( analyzer.getProperty("Liferay-Service")); if (!liferayService) { return false; } processProvideCapability(analyzer); Jar jar = getClasspathJar( analyzer, "com.liferay.portal.spring.extender.api"); if (jar == null) { jar = getClasspathJar( analyzer, "com.liferay.portal.spring.extender"); } if (jar == null) { return false; } processRequireCapability( analyzer, Version.parseVersion(jar.getVersion())); processSpringContext(analyzer); processSpringDependency(analyzer); return false; }  @Override boolean analyzeJar(Analyzer analyzer);  }
@Test public void testReadCustomServiceXmlLocation() throws Exception { InputStream inputStream = ServiceAnalyzerPluginTest.class.getResourceAsStream( "dependencies/com.liferay.contacts.service2.jar"); try (Jar jar = new Jar("dot", inputStream); Analyzer analyzer = new Analyzer()) { analyzer.setJar(jar); analyzer.setProperty("Liferay-Service", "true"); analyzer.setProperty("-liferay-service-xml", "entities.xml"); ServiceAnalyzerPlugin serviceAnalyzerPlugin = new ServiceAnalyzerPlugin(); serviceAnalyzerPlugin.analyzeJar(analyzer); Parameters provideCapabilityHeaders = analyzer.getProvideCapability(); Assert.assertNotNull(provideCapabilityHeaders); Assert.assertEquals( provideCapabilityHeaders.toString(), 1, provideCapabilityHeaders.size()); } }
@Test public void testReadServiceXmlToProvideServiceCapabilities() throws Exception { InputStream inputStream = ServiceAnalyzerPluginTest.class.getResourceAsStream( "dependencies/com.liferay.contacts.service1.jar"); try (Jar jar = new Jar("dot", inputStream); Analyzer analyzer = new Analyzer()) { analyzer.setJar(jar); analyzer.setProperty("Liferay-Service", "true"); analyzer.setProperty( "-liferay-service-xml", "service.xml,**/service.xml"); Parameters parameters = new Parameters( "existing.parameter;saveme=true"); analyzer.setProperty( Constants.PROVIDE_CAPABILITY, parameters.toString()); ServiceAnalyzerPlugin serviceAnalyzerPlugin = new ServiceAnalyzerPlugin(); serviceAnalyzerPlugin.analyzeJar(analyzer); Parameters provideCapabilityHeaders = analyzer.getProvideCapability(); Assert.assertNotNull(provideCapabilityHeaders); Assert.assertEquals( provideCapabilityHeaders.toString(), 2, provideCapabilityHeaders.size()); } }