001// Copyright 2004, 2005 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.hivemind.parse; 016 017import org.apache.hivemind.impl.BaseLocatable; 018import org.apache.hivemind.impl.CreateClassServiceConstructor; 019import org.apache.hivemind.internal.Module; 020import org.apache.hivemind.internal.ServicePoint; 021import org.apache.hivemind.internal.ServiceImplementationConstructor; 022import org.apache.hivemind.util.ToStringBuilder; 023 024/** 025 * Descriptor for the <create-instance< element, used to create 026 * a core service implementation from a class name. 027 * 028 * @author Howard Lewis Ship 029 */ 030public final class CreateInstanceDescriptor extends BaseLocatable implements InstanceBuilder 031{ 032 private String _serviceModel = "singleton"; 033 private String _instanceClassName; 034 035 public String getInstanceClassName() 036 { 037 return _instanceClassName; 038 } 039 040 public void setInstanceClassName(String string) 041 { 042 _instanceClassName = string; 043 } 044 045 public ServiceImplementationConstructor createConstructor( 046 ServicePoint point, 047 Module contributingModule) 048 { 049 CreateClassServiceConstructor result = new CreateClassServiceConstructor(); 050 051 result.setLocation(getLocation()); 052 result.setContributingModule(contributingModule); 053 result.setInstanceClassName(_instanceClassName); 054 055 return result; 056 } 057 058 public String toString() 059 { 060 ToStringBuilder builder = new ToStringBuilder(this); 061 062 builder.append("instanceClassName", _instanceClassName); 063 builder.append("serviceModel", _serviceModel); 064 065 return builder.toString(); 066 } 067 068 public String getServiceModel() 069 { 070 return _serviceModel; 071 } 072 073 public void setServiceModel(String serviceModel) 074 { 075 _serviceModel = serviceModel; 076 } 077 078}