<?xml version="1.0" encoding="UTF-8"?>

<!--
   The profile service
   $Id: profile.xml 89131 2009-05-19 20:18:52Z scott.stark@jboss.org $
-->
<deployment xmlns="urn:jboss:bean-deployer:2.0">

	<classloader><inject bean="profile-classloader:0.0.0" /></classloader>

	<classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
		<root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
	</classloader>

	<!-- 
		The profile configuration
		This contains required properties:
			The uri to jboss-service.xml.
			The uri to the deployers folder.
			A list of uris to deploy folders. -->
	<bean name="BootstrapProfileFactory" class="org.jboss.system.server.profileservice.repository.StaticProfileFactory">
      <property name="bindingsURI">${jboss.server.home.url}conf/bindingservice.beans</property>
      <property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
		<property name="deployersURI">${jboss.server.home.url}deployers</property>
		<property name="applicationURIs">
			<list elementClass="java.net.URI">
				<value>${jboss.server.home.url}deploy</value>
			</list>
		</property>
		<property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
		<property name="profileFactory"><inject bean="ProfileFactory" /></property>
	</bean>
	
	<!--  The default profile key -->
	<bean name="DefaultProfileKey" class="org.jboss.profileservice.spi.ProfileKey">
		<constructor><parameter>${jboss.server.name}</parameter></constructor>
	</bean>

	<!-- The ProfileService -->
	<bean name="ProfileService" class="org.jboss.system.server.profileservice.repository.AbstractProfileService">
		<constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
		<property name="deployer"><inject bean="ProfileServiceDeployer" /></property>
		<property name="defaultProfile"><inject bean="DefaultProfileKey" /></property>
	</bean>

	<!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
	<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
		<property name="profileKey"><inject bean="DefaultProfileKey" /></property>
		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
		<property name="profileService"><inject bean="ProfileService" /></property>
		<property name="mof"><inject bean="ManagedObjectFactory" /></property>
		<property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator" /></property>
		<property name="bootstrapProfileFactory"><inject bean="BootstrapProfileFactory" /></property>
		<property name="configurator"><inject bean="jboss.kernel:service=Kernel" property="configurator"/></property>
	</bean>

	<!-- The profile factory -->
	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileFactory">
		<!-- Accept any AbstractprofileFactory -->
		<incallback method="addProfileFactory" />
		<uncallback method="removeProfileFactory" />
	</bean>

	<!-- The profile repository factory -->
	<bean name="ProfileRepositoryFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileRepository">
		<!-- Accept any DeploymentRepositoryFactory -->
		<incallback method="addRepositoryFactory" />
		<uncallback method="removeRepositoryFactory" />
	</bean>

  <!-- The structure modification cache and checker -->
  <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.DefaultStructureCache">
    <destroy method="flush"/>
  </bean>

  <!-- This just checks metadata locations -->
  <bean name="MetaDataStructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker">
    <constructor>
      <parameter><inject bean="MainDeployer" /></parameter>
    </constructor>
    <property name="cache"><inject bean="StructureModCache" /></property>
    <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
  </bean>

  <!-- Synchs modifed files -->
  <bean name="SynchAdapter" class="org.jboss.deployers.vfs.spi.structure.modified.OverrideSynchAdapter"/>

  <!-- We just visit wars, but exclude classes, lib, dev dirs -->
  <bean name="WebVisitorAttributes" class="org.jboss.system.server.profile.basic.IncludeExcludeVisitorAttributes">
    <constructor>
      <parameter>
        <set>
          <value>.war</value>
        </set>
      </parameter>
      <parameter>
        <set>
          <value>WEB-INF/classes</value>
          <value>WEB-INF/lib</value>
          <value>WEB-INF/dev</value>
        </set>
      </parameter>
    </constructor>
  </bean>

  <bean name="StructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.SynchWrapperModificationChecker">
    <constructor>
      <parameter><inject bean="MetaDataStructureModificationChecker"/></parameter>
      <parameter><inject bean="SynchAdapter"/></parameter>
    </constructor>
    <property name="originalAttributes"><inject bean="WebVisitorAttributes"/></property>
    <property name="tempAttributes"><inject bean="WebVisitorAttributes"/></property>
  </bean>

	<bean name="BasicProfileFactory" class="org.jboss.system.server.profileservice.repository.BasicProfileFactory">
		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
	</bean>
	<bean name="FilteredProfileFactory" class="org.jboss.system.server.profileservice.repository.FilteredProfileFactory"/>

	<!-- The default deployment repository factory -->
	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
		<property name="checker"><inject bean="StructureModificationChecker" /></property>
	</bean>

	<bean name="ComponentMapperRegistry"
		class="org.jboss.system.server.profileservice.persistence.component.ComponentMapperRegistry">
		<constructor factoryClass="org.jboss.system.server.profileservice.persistence.component.ComponentMapperRegistry" factoryMethod="getInstance"/>
		<!-- Accept any AbstractprofileFactory -->
		<incallback method="addMapper" />
		<uncallback method="removeComponentMapper" />
	</bean>

	<!-- A persistence factory for creating the persisted format of ManagedComponents -->
	<bean name="PersistenceFactory" class="org.jboss.system.server.profileservice.persistence.AbstractPersistenceFactory">
		<constructor><parameter><inject bean="ManagedObjectFactory" /></parameter></constructor>
		<!-- Accept any ComponentMapper -->
		<incallback method="addComponentMapper" />
		<uncallback method="removeComponentMapper" />
		<!-- Accept any ManagedObjectPersistencePlugin -->
		<incallback method="addPersistencePlugin" />
		<uncallback method="removePersistencePlugin" />
	</bean>

	<!-- The attachment store -->
	<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
		<constructor><parameter class="java.io.File"><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
		<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
	</bean>

	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
	</bean>

	<bean name="ProfileServiceDeployer" class="org.jboss.system.server.profileservice.repository.MainDeployerAdapter">
		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
	</bean>

	<bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer">
   		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
   		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
   </bean>
   
   <bean name="KernelDeploymentComponentMapper" class="org.jboss.deployers.plugins.managed.KernelDeploymentComponentMapper">
   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
   		<!-- Register under the attachment interface name as well -->
   		<install bean="ComponentMapperRegistry" method="addMapper">
   			<parameter class="java.lang.String">org.jboss.kernel.spi.deployment.KernelDeployment</parameter>
   			<parameter class="org.jboss.system.server.profileservice.persistence.component.ComponentMapper"><this/></parameter>
	   	</install>
	   	<uninstall bean="ComponentMapperRegistry" method="removeComponentMapper">
	   		<parameter class="java.lang.String">org.jboss.kernel.spi.deployment.KernelDeployment</parameter>
	   	</uninstall>
   </bean>
   <bean name="ServiceDeploymentComponentMapper" class="org.jboss.system.deployers.managed.ServiceDeploymentComponentMapper">
   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
   </bean>
   
	<!-- A filter for excluding files from the scanner -->
	<bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
		<!-- Files starting with theses strings are ignored -->
		<property name="prefixes">#,%,\,,.,_$</property>
		<!-- Files ending with theses strings are ignored -->
		<property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
		<!-- Files matching with theses strings are ignored -->
		<property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
	</bean>

</deployment>
