1 15 package org.apache.hivemind.definition.impl; 16 17 import org.apache.hivemind.definition.ConfigurationPointDefinition; 18 import org.apache.hivemind.definition.Contribution; 19 import org.apache.hivemind.definition.ContributionDefinition; 20 import org.apache.hivemind.definition.ImplementationConstructor; 21 import org.apache.hivemind.definition.ImplementationDefinition; 22 import org.apache.hivemind.definition.ModuleDefinition; 23 import org.apache.hivemind.definition.Occurances; 24 import org.apache.hivemind.definition.ServicePointDefinition; 25 import org.apache.hivemind.definition.Visibility; 26 import org.apache.hivemind.impl.CreateClassServiceConstructor; 27 import org.apache.hivemind.internal.ServiceModel; 28 29 37 public class ModuleDefinitionHelper 38 { 39 private ModuleDefinitionImpl _module; 40 41 public ModuleDefinitionHelper(ModuleDefinitionImpl module) 42 { 43 _module = module; 44 } 45 46 public ServicePointDefinition addServicePoint(String servicePointId, String serviceInterface) 47 { 48 ServicePointDefinitionImpl result = new ServicePointDefinitionImpl(_module, servicePointId, _module 49 .getLocation(), Visibility.PUBLIC, serviceInterface); 50 51 _module.addServicePoint(result); 52 return result; 53 } 54 55 public ServicePointDefinition addServicePointWithDefaultImplementation(String servicePointId, String serviceInterface) 56 { 57 ServicePointDefinition result = addServicePoint(servicePointId, serviceInterface); 58 String defaultImplementationName = serviceInterface + "Impl"; 59 addSimpleServiceImplementation(result, defaultImplementationName, ServiceModel.SINGLETON); 60 return result; 61 } 62 63 public ImplementationDefinition addServiceImplementation( 64 ServicePointDefinition servicePoint, 65 ImplementationConstructor constructor, String serviceModel 66 ) 67 { 68 ImplementationDefinition result = new ImplementationDefinitionImpl(_module, _module 70 .getLocation(), constructor, serviceModel, true); 71 servicePoint.addImplementation(result); 72 return result; 73 } 74 75 public ImplementationDefinition addSimpleServiceImplementation( 76 ServicePointDefinition servicePoint, 77 String serviceImplementationClass, String serviceModel) 78 { 79 return addServiceImplementation(servicePoint, 80 new CreateClassServiceConstructor(_module.getLocation(), serviceImplementationClass), 81 serviceModel); 82 } 83 84 public ConfigurationPointDefinition addConfigurationPoint(String configurationPointId, String containerType) 85 { 86 ConfigurationPointDefinitionImpl result = new ConfigurationPointDefinitionImpl(_module, configurationPointId, _module 87 .getLocation(), Visibility.PUBLIC, containerType, Occurances.UNBOUNDED); 88 89 _module.addConfigurationPoint(result); 90 return result; 91 } 92 93 public ContributionDefinition addContributionDefinition(ConfigurationPointDefinition configurationPoint, 94 Contribution contributionConstructor) 95 { 96 ContributionDefinition result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor, false); 97 configurationPoint.addContribution(result); 98 return result; 99 } 100 101 public ContributionDefinition addContributionDefinition(String qualifiedConfigurationPointId, 102 Contribution contributionConstructor) 103 { 104 ContributionDefinitionImpl result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor, false); 105 _module.addContribution(qualifiedConfigurationPointId, result); 106 return result; 107 } 108 109 public ModuleDefinition getModule() 110 { 111 return _module; 112 } 113 114 } 115 | Popular Tags |