niclas 2004/03/01 15:04:25
Modified: merlin/platform/tutorials/composition README.txt
merlin/platform/tutorials/meta README.TXT
merlin/platform/tutorials/mixed README.TXT
Added: merlin/platform/tutorials/security README.txt
merlin/platform/tutorials/security/application/impl
maven.xml project.xml
merlin/platform/tutorials/security/application/impl/conf
block.xml kernel.xml targets.xml
merlin/platform/tutorials/security/application/impl/src/java/tutorial/application
Application.java
merlin/platform/tutorials/security/location/api maven.xml
merlin/platform/tutorials/security/location/impl project.xml
merlin/platform/tutorials/security/location/impl/src/java/tutorial/location
LocationComponent.java LocationComponent.xprofile
merlin/platform/tutorials/security/publisher/api maven.xml
project.xml
merlin/platform/tutorials/security/publisher/api/src/java/tutorial/publisher
PublisherService.java
merlin/platform/tutorials/security/publisher/impl maven.xml
project.xml
merlin/platform/tutorials/security/publisher/impl/conf
block.xml
merlin/platform/tutorials/security/publisher/impl/src/java/tutorial/publisher
PublisherComponent.java
Log:
Beginning of a Tutorial to show the power of code security in Merlin. More work is
needed though.
Revision Changes Path
1.3 +8 -2 avalon/merlin/platform/tutorials/composition/README.txt
Index: README.txt
===================================================================
RCS file: /home/cvs/avalon/merlin/platform/tutorials/composition/README.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- README.txt 13 Nov 2003 01:56:42 -0000 1.2
+++ README.txt 1 Mar 2004 23:04:24 -0000 1.3
@@ -36,13 +36,19 @@
[INFO ] (application.application): done
-Use the following command to include container debug level log entries for the
demanding developer.
+Use the following command to include container debug level log entries for the
+demanding developer.
$ merlin -execute -repository %MAVEN_HOME% target\*.jar -config conf\debug.xml
Summary
-------
-The purpose of this demonstration is to show how the container can be viewed as an
implementation strategy for the creation of a virtual service, and how these service
can be composed within a higher level containers, enabling new implementation
solutions. The key to achiving this is related to the <service> directives inside the
<container> directive. Each service directive describes a service that is exported by
the container in its role as a virtual component.
+The purpose of this demonstration is to show how the container can be viewed as
+an implementation strategy for the creation of a virtual service, and how these
+service can be composed within a higher level containers, enabling new
+implementation solutions. The key to achiving this is related to the <service>
+directives inside the <container> directive. Each service directive describes
+a service that is exported by the container in its role as a virtual component.
1.2 +3 -2 avalon/merlin/platform/tutorials/meta/README.TXT
Index: README.TXT
===================================================================
RCS file: /home/cvs/avalon/merlin/platform/tutorials/meta/README.TXT,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- README.TXT 24 Sep 2003 09:34:04 -0000 1.1
+++ README.TXT 1 Mar 2004 23:04:24 -0000 1.2
@@ -2,7 +2,8 @@
Meta Generation
---------------
-This tutorial demonstrates the creation of meta-info tags and subsequent deployment
of a container using the component types declared with the meta.
+This tutorial demonstrates the creation of meta-info tags and subsequent
+deployment of a container using the component types declared with the meta.
$ maven clean
$ maven
@@ -14,4 +15,4 @@
[INFO ] (secondary): logging established
[INFO ] (secondary.system): primary service resolved
-Steve.
+
1.2 +3 -1 avalon/merlin/platform/tutorials/mixed/README.TXT
Index: README.TXT
===================================================================
RCS file: /home/cvs/avalon/merlin/platform/tutorials/mixed/README.TXT,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- README.TXT 24 Sep 2003 09:34:05 -0000 1.1
+++ README.TXT 1 Mar 2004 23:04:24 -0000 1.2
@@ -2,4 +2,6 @@
Putting it together
-------------------
-This tutorial is an agregation of the content presented in earlier tutorials. It
demonstrates a more complex component case in which component configuration,
contextualization and services are demonstrated together.
+This tutorial is an agregation of the content presented in earlier tutorials.
+It demonstrates a more complex component case in which component configuration,
+contextualization and services are demonstrated together.
1.1 avalon/merlin/platform/tutorials/security/README.txt
Index: README.txt
===================================================================
Security enabled Composition Management
=======================================
Overview
--------
This is an extension of the tutorial/composition, in that here
we use security profiles to GRANT access for one component, but
not the other, to the Location, which is configured to
"Europe.France.Paris" in the Application.xprofile defaults.
One application component has the security enabled for Spain
and the other has the security enabled for France.
This tutorial is interesting as it shows that it is possible
to grant different security access to the same codebase, which
is not possible in standard Java security policies.
For more information about the other aspects of this example,
please check the tutorial/composition, which is practically
identical.
Build and execution instructions:
---------------------------------
$ cd application/impl
$ maven build
$ merlin -execute target\*.jar -repository %MAVEN_HOME%
[INFO ] (application.publisher.publisher): created
[INFO ] (application.location.info): location: Paris
[INFO ] (application.application): servicing application
[INFO ] (application.location.info): location: Paris
[INFO ] (application.publisher.publisher): created
[INFO ] (application.publisher.publisher):
******************
* Paris
******************
[INFO ] (application.application): done
Use the following command to include container debug level log entries for the
demanding developer.
$ merlin -execute -repository %MAVEN_HOME% target\*.jar -config conf\debug.xml
Summary
-------
The purpose of this demonstration is to show how the container can be viewed as
an implementation strategy for the creation of a virtual service, and how these
service can be composed within a higher level containers, enabling new
implementation solutions. The key to achiving this is related to the <service>
directives inside the <container> directive. Each service directive describes
a service that is exported by the container in its role as a virtual component.
1.1
avalon/merlin/platform/tutorials/security/application/impl/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<preGoal name="java:compile">
<attainGoal name="avalon:meta"/>
</preGoal>
<preGoal name="merlin:simulate">
<attainGoal name="jar:install"/>
</preGoal>
<goal name="build">
<maven:reactor
basedir="${basedir}/../.."
includes="${basedir}/**/project.xml"
goals="jar:install"
banner="Installing:"
ignoreFailures="false" />
</goal>
</project>
1.1
avalon/merlin/platform/tutorials/security/application/impl/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../../project.xml</extend>
<id>application-impl</id>
<name>Composition Application Tutorial</name>
<currentVersion>1.0</currentVersion>
<dependencies>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>locator-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>locator-impl</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>publisher-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>publisher-impl</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
1.1
avalon/merlin/platform/tutorials/security/application/impl/conf/block.xml
Index: block.xml
===================================================================
<container name="application">
<classloader>
<classpath>
<repository>
<resource id="avalon-framework:avalon-framework-api" version="4.1.5"/>
<resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
<resource id="merlin-tutorial:locator-api" version="1.0"/>
<resource id="merlin-tutorial:publisher-api" version="1.0"/>
<resource id="merlin-tutorial:application-impl" version="1.0"/>
</repository>
</classpath>
</classloader>
<include name="location" id="merlin-tutorial:locator-impl" version="1.0"/>
<include name="publisher" id="merlin-tutorial:publisher-impl" version="1.0"/>
<component name="spain"
class="tutorial.application.Application">
</component>
<component name="france"
class="tutorial.application.Application">
</component>
</container>
1.1
avalon/merlin/platform/tutorials/security/application/impl/conf/kernel.xml
Index: kernel.xml
===================================================================
<!--
Configuration used by the DefaultInitialContextFactoryTest to validate the
populatation of registered artifacts with the initial context.
-->
<kernel>
<system>
<artifact spec="avalon-logging/avalon-logkit-impl#1.0-SNAPSHOT"/>
</system>
<security>
<!-- Default Grant is nothing -->
<profile name="default">
</profile>
<!-- Allow access to Locations in France -->
<profile name="FranceGranted">
<permissions>
<permission class="tutorial.location.LocationPermission"
name="Europe.France" />
</permissions>
</profile>
<!-- Allow access to Locations in Spain -->
<profile name="SpainGranted">
<permissions>
<permission class="tutorial.location.LocationPermission"
name="Europe.Spain" />
</permissions>
</profile>
</security>
</kernel>
1.1
avalon/merlin/platform/tutorials/security/application/impl/conf/targets.xml
Index: targets.xml
===================================================================
<targets>
<target path="/application/spain">
<security profile="name="SpainGranted"/>
</target>
<target path="/application/france">
<security profile="name="FranceGranted"/>
</target>
</targets>
1.1
avalon/merlin/platform/tutorials/security/application/impl/src/java/tutorial/application/Application.java
Index: Application.java
===================================================================
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tutorial.application;
import java.io.File;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.activity.Disposable;
import tutorial.location.LocationService;
import tutorial.publisher.PublisherService;
/**
* Application Component from Merlin's Composition Tutorial
*
* @avalon.component version="1.0" name="granted-application"
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class Application extends AbstractLogEnabled
implements Serviceable, Disposable
{
/**
* Servicing of the component by the container during
* which service dependencies declared under the component
* can be resolved using the supplied service manager. In this
* example the component uses a LocatorService service to log a
* message exposing a location.
*
* @param manager the service manager
* @avalon.dependency key="locator" type="tutorial.location.LocationService"
* @avalon.dependency key="publisher" type="tutorial.publisher.PublisherService"
*/
public void service( ServiceManager manager ) throws ServiceException
{
getLogger().info( "servicing application" );
LocationService locator = null;
Object object = manager.lookup( "locator" );
if( object instanceof LocationService )
{
locator = (LocationService) object;
}
else
{
final String error =
"Object " + object.getClass().getName()
+ " does not implement the LocatorService class.";
throw new ServiceException( "locator", error );
}
PublisherService publisher = null;
object = manager.lookup( "publisher" );
if( object instanceof PublisherService )
{
publisher = (PublisherService) object;
}
else
{
final String error =
"Object " + object.getClass().getName()
+ " does not implement the PublisherService class.";
throw new ServiceException( "publisher", error );
}
//
// get the location from the locator and publish
// it using the publisher
//
publisher.publish(
"\n******************"
+ "\n* " + locator.getLocation()
+ "\n******************");
getLogger().info( "done" );
}
public void dispose()
{
getLogger().info( "disposal" );
}
}
1.1 avalon/merlin/platform/tutorials/security/location/api/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<preGoal name="demo">
<attainGoal name="jar:install"/>
</preGoal>
</project>
1.1
avalon/merlin/platform/tutorials/security/location/impl/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../../project.xml</extend>
<id>locator-impl</id>
<name>Composition Locator Impl Tutorial</name>
<currentVersion>1.0</currentVersion>
<dependencies>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>locator-api</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
1.1
avalon/merlin/platform/tutorials/security/location/impl/src/java/tutorial/location/LocationComponent.java
Index: LocationComponent.java
===================================================================
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tutorial.location.impl;
import java.io.File;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.activity.Disposable;
import tutorial.location.LocationService;
import tutorial.location.LocationPermission;
/**
* HelloComponent from Merlin's Tutorial
*
* @avalon.component version="1.0" name="location-provider"
* @avalon.service type="tutorial.location.LocationService"
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class LocationComponent extends AbstractLogEnabled implements
Configurable, Disposable, LocationService
{
private String m_location = "unknown";
/**
* Configuration of the component by the container. The
* implementation gets a child element named 'source' and
* assigns log the value.
*
* @param config the component configuration
* @exception ConfigurationException if a configuration error occurs
*/
public void configure( Configuration config ) throws
ConfigurationException
{
m_location = config.getChild( "place" ).getValue( "unknown" );
getLogger().info( "location: " + m_location );
}
/**
* Return a location.
* @return a location
* @avalon.security.permission class="tutorial.location.LocationPermission"
*/
public String getLocation()
{
LocationPermission perm = new LocationPermission( location );
AccessController.checkPermission( perm );
return m_location;
}
public void dispose()
{
getLogger().info( "disposal" );
}
}
1.1
avalon/merlin/platform/tutorials/security/location/impl/src/java/tutorial/location/LocationComponent.xprofile
Index: LocationComponent.xprofile
===================================================================
<?xml version="1.0"?>
<profiles>
<profile name="locator">
<configuration>
<place>Europe.France.Paris</place>
</configuration>
</profile>
</profiles>
1.1
avalon/merlin/platform/tutorials/security/publisher/api/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<preGoal name="demo">
<attainGoal name="jar:install"/>
</preGoal>
</project>
1.1
avalon/merlin/platform/tutorials/security/publisher/api/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../../project.xml</extend>
<id>publisher-api</id>
<name>Composition Publisher API Tutorial</name>
<currentVersion>1.0</currentVersion>
<dependencies>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
</dependencies>
</project>
1.1
avalon/merlin/platform/tutorials/security/publisher/api/src/java/tutorial/publisher/PublisherService.java
Index: PublisherService.java
===================================================================
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tutorial.publisher;
/**
* HelloComponent from Merlin's Tutorial
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public interface PublisherService
{
/**
* Publish a message.
* @param message the message to publish
*/
public void publish( String message );
}
1.1
avalon/merlin/platform/tutorials/security/publisher/impl/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<preGoal name="demo">
<attainGoal name="jar:install"/>
</preGoal>
</project>
1.1
avalon/merlin/platform/tutorials/security/publisher/impl/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../../project.xml</extend>
<id>publisher-impl</id>
<name>Composition Publisher Impl Tutorial</name>
<currentVersion>1.0</currentVersion>
<dependencies>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>merlin-tutorial</groupId>
<artifactId>publisher-api</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
1.1
avalon/merlin/platform/tutorials/security/publisher/impl/conf/block.xml
Index: block.xml
===================================================================
<container name="publisher-block">
<services>
<service type="tutorial.publisher.PublisherService">
<source>publisher</source>
</service>
</services>
<classloader>
<classpath>
<repository>
<resource id="avalon-framework:avalon-framework-api" version="4.1.5"/>
<resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
<resource id="merlin-tutorial:publisher-api" version="1.0"/>
<resource id="merlin-tutorial:publisher-impl" version="1.0"/>
</repository>
</classpath>
</classloader>
<component name="publisher"
class="tutorial.publisher.PublisherComponent"/>
</container>
1.1
avalon/merlin/platform/tutorials/security/publisher/impl/src/java/tutorial/publisher/PublisherComponent.java
Index: PublisherComponent.java
===================================================================
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tutorial.publisher;
import java.io.File;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.activity.Disposable;
/**
* PublisherComponent from Merlin's Composition Tutorial
*
* @avalon.component version="1.0" name="publisher"
* @avalon.service type="tutorial.publisher.PublisherService"
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class PublisherComponent extends AbstractLogEnabled
implements PublisherService, Disposable
{
/**
* Supply of the logging channel by the container.
* @param logger the logging channel
*/
public void enableLogging( Logger logger )
{
logger.info( "created" );
super.enableLogging( logger );
}
/**
* Publish a message.
* @param message the message to publish
*/
public void publish( String message )
{
getLogger().info( message );
}
public void dispose()
{
getLogger().info( "disposal" );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]